Add "cron" mode (suppress most progress info)
This commit is contained in:
parent
178f6a82af
commit
5e006ae7cc
40
atom
40
atom
@ -68,6 +68,7 @@ help() {
|
|||||||
-S Run setup
|
-S Run setup
|
||||||
-h Show this text
|
-h Show this text
|
||||||
-D Increase debug
|
-D Increase debug
|
||||||
|
-q Cron mode
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +102,9 @@ do
|
|||||||
D)
|
D)
|
||||||
(( debug++ ))
|
(( debug++ ))
|
||||||
;;
|
;;
|
||||||
|
q)
|
||||||
|
cron=1
|
||||||
|
;;
|
||||||
:)
|
:)
|
||||||
echo "-$OPTARG requires an argument"
|
echo "-$OPTARG requires an argument"
|
||||||
help
|
help
|
||||||
@ -115,7 +119,13 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
askconf() {
|
askconf() {
|
||||||
|
if (( cron ))
|
||||||
|
then
|
||||||
|
echo 'Non-interactive, not running setup. Please run atom -S.' >&2
|
||||||
|
createconf=n
|
||||||
|
else
|
||||||
read -p"Create one now? [Y/n/q] " createconf
|
read -p"Create one now? [Y/n/q] " createconf
|
||||||
|
fi
|
||||||
case $createconf in
|
case $createconf in
|
||||||
''|[yY])
|
''|[yY])
|
||||||
setup
|
setup
|
||||||
@ -282,6 +292,8 @@ elif (( sanitywarn ))
|
|||||||
then
|
then
|
||||||
echo "
|
echo "
|
||||||
Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
||||||
|
if ! (( cron ))
|
||||||
|
then
|
||||||
timeout=$(( sanitywarn * 10 ))
|
timeout=$(( sanitywarn * 10 ))
|
||||||
echo -n "Starting in $(printf %3i $timeout)" \
|
echo -n "Starting in $(printf %3i $timeout)" \
|
||||||
$'seconds...\b\b\b\b\b\b\b\b\b\b\b' >&2
|
$'seconds...\b\b\b\b\b\b\b\b\b\b\b' >&2
|
||||||
@ -293,6 +305,7 @@ Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
|||||||
done
|
done
|
||||||
echo -en "\r\033[K"
|
echo -en "\r\033[K"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
@ -457,9 +470,9 @@ read -u4 line
|
|||||||
while ! [[ $line = AtOM:NoMoreFiles ]]
|
while ! [[ $line = AtOM:NoMoreFiles ]]
|
||||||
do
|
do
|
||||||
decodefiles+=("$line::AtOM:SQL:Sep::")
|
decodefiles+=("$line::AtOM:SQL:Sep::")
|
||||||
|
(( cron )) || echo -n 'Creating tasks... '
|
||||||
read -u4 line
|
read -u4 line
|
||||||
done
|
done
|
||||||
echo -n 'Creating tasks... '
|
|
||||||
|
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for line in "${decodefiles[@]}"
|
for line in "${decodefiles[@]}"
|
||||||
@ -634,7 +647,7 @@ do
|
|||||||
${seconds:-0} seconds" \
|
${seconds:-0} seconds" \
|
||||||
+'%d/%m %H:%M:%S'
|
+'%d/%m %H:%M:%S'
|
||||||
)"
|
)"
|
||||||
printf \
|
(( cron )) || printf \
|
||||||
"\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\
|
"\r$fmtload $fmtworkers $fmtprogress $fmttime $eta\033[K"\
|
||||||
$humanload \
|
$humanload \
|
||||||
$maxload \
|
$maxload \
|
||||||
@ -676,8 +689,11 @@ endtime=$(date +%s)
|
|||||||
( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 )
|
( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 )
|
||||||
)) || true
|
)) || true
|
||||||
|
|
||||||
echo -e "\rRan ${ran:=0} tasks, $failed of which failed, in $days" \
|
(( cron )) || echo -n $'\r'
|
||||||
"days, $hours hours, $minutes minutes and $seconds seconds.\033[K"
|
echo -n "Ran ${ran:=0} tasks, $failed of which failed, in $days" \
|
||||||
|
"days, $hours hours, $minutes minutes and $seconds seconds."
|
||||||
|
(( cron )) || echo -en "\033[K"
|
||||||
|
echo
|
||||||
|
|
||||||
if [ -n "$quit" ]
|
if [ -n "$quit" ]
|
||||||
then
|
then
|
||||||
@ -737,7 +753,7 @@ do
|
|||||||
'opus') extension=opus ;;
|
'opus') extension=opus ;;
|
||||||
'vorbis') extension=ogg ;;
|
'vorbis') extension=ogg ;;
|
||||||
esac
|
esac
|
||||||
echo -n "$destination: rename pattern changed, renaming files... "
|
(( cron )) || echo -n "$destination: rename pattern changed, renaming files... "
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
for line in "${renamefiles[@]}"
|
for line in "${renamefiles[@]}"
|
||||||
do
|
do
|
||||||
@ -793,7 +809,10 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e $'\r'"$destination: Renamed ${changedcount:-0} files\033[K"
|
(( cron )) || echo -n $'\r'
|
||||||
|
echo -n "$destination: Renamed ${changedcount:-0} files"
|
||||||
|
(( cron )) || echo -en "\033[K"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
unset count changedcount renamefiles
|
unset count changedcount renamefiles
|
||||||
done
|
done
|
||||||
@ -810,7 +829,7 @@ echo '
|
|||||||
SELECT "AtOM:NoMoreFiles";
|
SELECT "AtOM:NoMoreFiles";
|
||||||
' >&3
|
' >&3
|
||||||
|
|
||||||
echo -n 'Removing obsolete files... '
|
(( cron )) || echo -n 'Removing obsolete files... '
|
||||||
lines=()
|
lines=()
|
||||||
read -u4 line
|
read -u4 line
|
||||||
while [[ $line != AtOM:NoMoreFiles ]]
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
@ -831,10 +850,13 @@ do
|
|||||||
fi
|
fi
|
||||||
Update destination_files old_filename NULL <<<"id = $id"
|
Update destination_files old_filename NULL <<<"id = $id"
|
||||||
(( count++ ))
|
(( count++ ))
|
||||||
printf '\b\b\b\b%3i%%' $(( (100 * count) / ${#lines[@]} ))
|
(( cron )) || printf '\b\b\b\b%3i%%' $(( (100 * count) / ${#lines[@]} ))
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e "\rRemoved ${count:-0} obsolete files.\033[K"
|
(( cron )) || echo -n $'\r'
|
||||||
|
echo -n "Removed ${count:-0} obsolete files."
|
||||||
|
(( cron )) || echo -en "\033[K"
|
||||||
|
echo
|
||||||
|
|
||||||
echo "Purging empty directories."
|
echo "Purging empty directories."
|
||||||
for path in "${destinationpath[@]}"
|
for path in "${destinationpath[@]}"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
copyFiles_action() {
|
copyFiles_action() {
|
||||||
echo -n "Copying files... "
|
(( cron )) || echo -n "Copying files... "
|
||||||
echo '
|
echo '
|
||||||
SELECT
|
SELECT
|
||||||
source_files.filename,
|
source_files.filename,
|
||||||
@ -85,9 +85,12 @@ copyFiles_action() {
|
|||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
if (( count ))
|
if (( count ))
|
||||||
then
|
then
|
||||||
echo -e "\rCopied ${done:-0} of $count files.\033[K"
|
(( cron )) || echo -n $'\r'
|
||||||
|
echo -n "Copied ${done:-0} of $count files."
|
||||||
|
(( cron )) || echo -en "\033[K"
|
||||||
|
echo
|
||||||
else
|
else
|
||||||
echo -e "\rNothing to copy.\033[K"
|
(( cron )) || echo -e "\rNothing to copy.\033[K"
|
||||||
fi
|
fi
|
||||||
unset count done
|
unset count done
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ getFiles() {
|
|||||||
do
|
do
|
||||||
prunes+="-path $sourcepath$prune_expression -prune -o "
|
prunes+="-path $sourcepath$prune_expression -prune -o "
|
||||||
done
|
done
|
||||||
echo -n "Scanning $sourcepath... "
|
(( cron )) || echo -n "Scanning $sourcepath... "
|
||||||
# We probably have thousands of files, don't waste time on disk writes
|
# We probably have thousands of files, don't waste time on disk writes
|
||||||
echo 'BEGIN TRANSACTION;' >&3
|
echo 'BEGIN TRANSACTION;' >&3
|
||||||
while read time size filename
|
while read time size filename
|
||||||
@ -59,6 +59,7 @@ getFiles() {
|
|||||||
find "$sourcepath" $prunes -type f -printf "%T@ %s %P\n"
|
find "$sourcepath" $prunes -type f -printf "%T@ %s %P\n"
|
||||||
)
|
)
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e "\r${count:-0} files found, ${new:=0} new or changed."
|
(( cron )) || echo $'\r'
|
||||||
|
echo "${count:-0} files found, ${new:=0} new or changed."
|
||||||
unset count
|
unset count
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,8 @@ updateTags() {
|
|||||||
oldchannels=${rest%%::AtOM:SQL:Sep::*}
|
oldchannels=${rest%%::AtOM:SQL:Sep::*}
|
||||||
rest=${rest#*::AtOM:SQL:Sep::}
|
rest=${rest#*::AtOM:SQL:Sep::}
|
||||||
oldbitrate=${rest%%::AtOM:SQL:Sep::*}
|
oldbitrate=${rest%%::AtOM:SQL:Sep::*}
|
||||||
echo -en "\rTags: $((++count*100/filecount))%"
|
((++count))
|
||||||
|
(( cron )) || echo -en "\rTags: $((count*100/filecount))%"
|
||||||
if (( count % 1000 == 0 ))
|
if (( count % 1000 == 0 ))
|
||||||
then
|
then
|
||||||
echo 'COMMIT;BEGIN TRANSACTION;' >&3
|
echo 'COMMIT;BEGIN TRANSACTION;' >&3
|
||||||
@ -153,6 +154,9 @@ updateTags() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo 'COMMIT;' >&3
|
echo 'COMMIT;' >&3
|
||||||
echo -e "\rRead tags from ${count:-0} files.\033[K"
|
(( cron )) || echo -n $'\r'
|
||||||
|
echo -n "Read tags from ${count:-0} files."
|
||||||
|
(( cron )) || echo -ne "\033[K"
|
||||||
|
echo
|
||||||
unset count tagfiles
|
unset count tagfiles
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
progressSpin() {
|
progressSpin() {
|
||||||
|
if (( cron ))
|
||||||
|
then
|
||||||
|
(( ++count ))
|
||||||
|
else
|
||||||
case $(( ++count % 40 )) in
|
case $(( ++count % 40 )) in
|
||||||
0) echo -ne '\b|' ;;
|
0) echo -ne '\b|' ;;
|
||||||
10) echo -ne '\b/' ;;
|
10) echo -ne '\b/' ;;
|
||||||
@ -7,4 +11,5 @@ progressSpin() {
|
|||||||
30) echo -ne '\b\\' ;;
|
30) echo -ne '\b\\' ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user