Compare commits
2 Commits
0dd962fb8c
...
0fd1fae6dc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fd1fae6dc | ||
|
|
dd72a6b0ba |
158
atom
158
atom
@ -183,163 +183,7 @@ set +H
|
|||||||
(( cfgdump )) && exit
|
(( cfgdump )) && exit
|
||||||
|
|
||||||
# check sanity
|
# check sanity
|
||||||
if [ ! -d "$tempdir" ] && ! mkdir -p "$tempdir"
|
sanityCheck
|
||||||
then
|
|
||||||
echo "[FATAL] Could not create temp directory $tempdir" >&2
|
|
||||||
(( sanityfail++ ))
|
|
||||||
fi
|
|
||||||
if [ ! -f "$database" ] && [ ! -d "${database%/*}" ] && ! mkdir -p "${database%/*}"
|
|
||||||
then
|
|
||||||
echo "[FATAL] Directory holding database file does not exist and could" \
|
|
||||||
"not be created" >&2
|
|
||||||
(( sanityfail++ ))
|
|
||||||
fi
|
|
||||||
if [ ! -d "$sourcepath" ]
|
|
||||||
then
|
|
||||||
echo "[FATAL] Source path $sourcepath does not exist or is not a directory" >&2
|
|
||||||
(( sanityfail++ ))
|
|
||||||
fi
|
|
||||||
if ! which sed >/dev/null
|
|
||||||
then
|
|
||||||
echo "[FATAL] Required tool sed is not installed or not in PATH
|
|
||||||
I never thought this would actually hit someone..." >&2
|
|
||||||
(( sanityfail++ ))
|
|
||||||
fi
|
|
||||||
if ! which sox >/dev/null
|
|
||||||
then
|
|
||||||
echo "[FATAL] Required tool sox is not installed or not in PATH" >&2
|
|
||||||
(( sanityfail++ ))
|
|
||||||
fi
|
|
||||||
if ! which ogginfo >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool ogginfo (from vorbis-tools) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
WebM metadata disabled" >&2
|
|
||||||
disableogginfo=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which soxi >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool soxi (from sox) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Vorbis metadata disabled" >&2
|
|
||||||
disablesoxi=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if (( oggencneeded )) && ! which oggenc >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool oggenc (from vorbis-tools) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Vorbis targets disabled" >&2
|
|
||||||
disableoggenc=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which opusinfo >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool opusinfo (from opus-tools) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Opus metadata disabled" >&2
|
|
||||||
disableopusinfo=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if (( opusencneeded )) && ! which opusenc >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool opusenc (from opus-tools) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Opus targets disabled" >&2
|
|
||||||
disableopusenc=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which opusdec >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool opusdec (from opus-tools) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Opus support disabled" >&2
|
|
||||||
disableopusdec=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if (( lameneeded )) && ! which lame >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool lame is not installed or not in PATH
|
|
||||||
MP3 targets disabled" >&2
|
|
||||||
disablelame=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which metaflac >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool metaflac (from FLAC) is not installed" \
|
|
||||||
"or not in PATH
|
|
||||||
FLAC metadata disabled" >&2
|
|
||||||
disableflac=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which mpcdec >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool mpcdec (from Musepack) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
Musepack support disabled" >&2
|
|
||||||
disablempcdec=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which mkvextract >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool mkvextract (from MKVToolNix) is not" \
|
|
||||||
"installed or not in PATH
|
|
||||||
WebM metadata disabled
|
|
||||||
WebM support disabled" >&2
|
|
||||||
disablemkvextract=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which ffprobe >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool ffprobe (from FFmpeg) is not installed or not in PATH
|
|
||||||
Video metadata disabled
|
|
||||||
MPEG metadata disabled
|
|
||||||
MusePack metadata disabled
|
|
||||||
Unknown format metadata disabled" >&2
|
|
||||||
disableffprobe=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if ! which ffmpeg >/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Tool ffmpeg is not installed or not in PATH
|
|
||||||
Video support disabled" >&2
|
|
||||||
disablevideo=1
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if (( textunidecodeneeded )) && ! perl -MText::Unidecode -e 'exit;' 2>/dev/null
|
|
||||||
then
|
|
||||||
echo "[WARNING] Perl module Text::Unidecode is not available
|
|
||||||
Renaming to ASCII-only disabled" >&2
|
|
||||||
unset destinationascii
|
|
||||||
destinationascii=0
|
|
||||||
textunidecodeneeded=0
|
|
||||||
(( sanitywarn++ ))
|
|
||||||
fi
|
|
||||||
if (( sanityfail ))
|
|
||||||
then
|
|
||||||
echo "
|
|
||||||
Sanity checks raised ${sanitywarn:-0} warnings, $sanityfail failures. Dying now." >&2
|
|
||||||
exit $ESANITY
|
|
||||||
elif (( sanitywarn ))
|
|
||||||
then
|
|
||||||
echo "
|
|
||||||
Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
|
||||||
if ! (( cron ))
|
|
||||||
then
|
|
||||||
timeout=$(( sanitywarn * 10 ))
|
|
||||||
echo -n "Starting in $(printf %3i $timeout)" \
|
|
||||||
$'seconds...\b\b\b\b\b\b\b\b\b\b\b' >&2
|
|
||||||
while (( timeout ))
|
|
||||||
do
|
|
||||||
echo -n $'\b\b\b'"$(printf %3i $timeout)" >&2
|
|
||||||
sleep 1
|
|
||||||
(( timeout-- ))
|
|
||||||
done
|
|
||||||
echo -en "\r\033[K"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
for destination in "${destinations[@]}"
|
for destination in "${destinations[@]}"
|
||||||
|
|||||||
164
lib/tools/sanityChecks
Normal file
164
lib/tools/sanityChecks
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sanityCheck() {
|
||||||
|
if [ ! -d "$tempdir" ] && ! mkdir -p "$tempdir"
|
||||||
|
then
|
||||||
|
echo "[FATAL] Could not create temp directory $tempdir" >&2
|
||||||
|
(( sanityfail++ ))
|
||||||
|
fi
|
||||||
|
if [ ! -f "$database" ] && [ ! -d "${database%/*}" ] \
|
||||||
|
&& ! mkdir -p "${database%/*}"
|
||||||
|
then
|
||||||
|
echo "[FATAL] Directory holding database file does not exist"\
|
||||||
|
"and could not be created" >&2
|
||||||
|
(( sanityfail++ ))
|
||||||
|
fi
|
||||||
|
if [ ! -d "$sourcepath" ]
|
||||||
|
then
|
||||||
|
echo "[FATAL] Source path $sourcepath does not exist or is"\
|
||||||
|
"not a directory" >&2
|
||||||
|
(( sanityfail++ ))
|
||||||
|
fi
|
||||||
|
if ! which sed >/dev/null
|
||||||
|
then
|
||||||
|
echo "[FATAL] Required tool sed is not installed or not in PATH
|
||||||
|
I never thought this would actually hit someone..." >&2
|
||||||
|
(( sanityfail++ ))
|
||||||
|
fi
|
||||||
|
if ! which sox >/dev/null
|
||||||
|
then
|
||||||
|
echo "[FATAL] Required tool sox is not installed or not in"\
|
||||||
|
"PATH" >&2
|
||||||
|
(( sanityfail++ ))
|
||||||
|
fi
|
||||||
|
if ! which ogginfo >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool ogginfo (from vorbis-tools) is not"\
|
||||||
|
"installed or not in PATH
|
||||||
|
WebM metadata disabled" >&2
|
||||||
|
disableogginfo=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which soxi >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool soxi (from sox) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Vorbis metadata disabled" >&2
|
||||||
|
disablesoxi=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if (( oggencneeded )) && ! which oggenc >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool oggenc (from vorbis-tools) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Vorbis targets disabled" >&2
|
||||||
|
disableoggenc=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which opusinfo >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool opusinfo (from opus-tools) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Opus metadata disabled" >&2
|
||||||
|
disableopusinfo=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if (( opusencneeded )) && ! which opusenc >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool opusenc (from opus-tools) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Opus targets disabled" >&2
|
||||||
|
disableopusenc=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which opusdec >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool opusdec (from opus-tools) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Opus support disabled" >&2
|
||||||
|
disableopusdec=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if (( lameneeded )) && ! which lame >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool lame is not installed or not in PATH
|
||||||
|
MP3 targets disabled" >&2
|
||||||
|
disablelame=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which metaflac >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool metaflac (from FLAC) is not installed"\
|
||||||
|
"or not in PATH
|
||||||
|
FLAC metadata disabled" >&2
|
||||||
|
disableflac=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which mpcdec >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool mpcdec (from Musepack) is not" \
|
||||||
|
"installed or not in PATH
|
||||||
|
Musepack support disabled" >&2
|
||||||
|
disablempcdec=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which mkvextract >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool mkvextract (from MKVToolNix) is not"\
|
||||||
|
"installed or not in PATH
|
||||||
|
WebM metadata disabled
|
||||||
|
WebM support disabled" >&2
|
||||||
|
disablemkvextract=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which ffprobe >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool ffprobe (from FFmpeg) is not installed"\
|
||||||
|
"or not in PATH
|
||||||
|
Video metadata disabled
|
||||||
|
MPEG metadata disabled
|
||||||
|
MusePack metadata disabled
|
||||||
|
Unknown format metadata disabled" >&2
|
||||||
|
disableffprobe=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if ! which ffmpeg >/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Tool ffmpeg is not installed or not in PATH
|
||||||
|
Video support disabled" >&2
|
||||||
|
disablevideo=1
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if (( textunidecodeneeded )) && ! perl -MText::Unidecode -e 'exit;' 2>/dev/null
|
||||||
|
then
|
||||||
|
echo "[WARNING] Perl module Text::Unidecode is not available
|
||||||
|
Renaming to ASCII-only disabled" >&2
|
||||||
|
unset destinationascii
|
||||||
|
destinationascii=0
|
||||||
|
textunidecodeneeded=0
|
||||||
|
(( sanitywarn++ ))
|
||||||
|
fi
|
||||||
|
if (( sanityfail ))
|
||||||
|
then
|
||||||
|
echo "
|
||||||
|
Sanity checks raised ${sanitywarn:-0} warnings, $sanityfail failures. Dying now." >&2
|
||||||
|
exit $ESANITY
|
||||||
|
elif (( sanitywarn ))
|
||||||
|
then
|
||||||
|
echo "
|
||||||
|
Sanity checks raised $sanitywarn warnings... Hit Control-C to abort." >&2
|
||||||
|
if ! (( cron ))
|
||||||
|
then
|
||||||
|
timeout=$(( sanitywarn * 10 ))
|
||||||
|
echo -n "Starting in $(printf %3i $timeout)" \
|
||||||
|
$'seconds...\b\b\b\b\b\b\b\b\b\b\b' >&2
|
||||||
|
while (( timeout ))
|
||||||
|
do
|
||||||
|
echo -n $'\b\b\b'"$(printf %3i $timeout)" >&2
|
||||||
|
sleep 1
|
||||||
|
(( timeout-- ))
|
||||||
|
done
|
||||||
|
echo -en "\r\033[K"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
@ -62,6 +62,7 @@ done
|
|||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
(( update )) && getFiles
|
(( update )) && getFiles
|
||||||
|
|||||||
@ -58,7 +58,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
sourcepath=''
|
sourcepath=''
|
||||||
|
|||||||
@ -59,7 +59,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
echo 'SELECT id,filename FROM destination_files WHERE filename IS NOT NULL;' >&3
|
echo 'SELECT id,filename FROM destination_files WHERE filename IS NOT NULL;' >&3
|
||||||
|
|||||||
@ -59,7 +59,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
checkwanted() {
|
checkwanted() {
|
||||||
|
|||||||
@ -139,7 +139,7 @@ done
|
|||||||
}
|
}
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
columns="${show[@]//*/-}"
|
columns="${show[@]//*/-}"
|
||||||
|
|||||||
@ -75,7 +75,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
if (( update ))
|
if (( update ))
|
||||||
|
|||||||
@ -94,7 +94,7 @@ done
|
|||||||
}
|
}
|
||||||
|
|
||||||
getConfig
|
getConfig
|
||||||
|
sanityCheck
|
||||||
openDatabase
|
openDatabase
|
||||||
|
|
||||||
if (( update ))
|
if (( update ))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user