diff --git a/music-sync.sh b/music-sync.sh index cc494b2..0e26cab 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -52,7 +52,7 @@ script_name=$(basename "${0}") script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) CheckDeps() { - if [[ $1 == 0 ]]; then + if [[ $1 == 2 ]]; then # Check getopt ! getopt --test > /dev/null if [[ ${PIPESTATUS[0]} -ne 4 ]]; then @@ -67,48 +67,56 @@ CheckDeps() { if [[ $1 == 1 ]]; then # Check ffmpeg - if [[ $convert == true && ! $(ffmpeg -h 2>/dev/null) ]]; then - VerboseOutput 5 "\`ffmpeg -h\` failed" - VerboseOutput 5 "Sorry, It seems that ffmpeg is not installed on your system" - VerboseOutput 5 "Please install ffmpeg from your repositories and make sure it is available in your \$PATH" - VerboseOutput 5 "Otherwise disable conversion" - ExecTime - exit 1 + if [[ $convert == true ]]; then + if [[ ! $(ffmpeg -h 2>/dev/null) ]]; then + VerboseOutput 5 "\`ffmpeg -h\` failed" + VerboseOutput 5 "Sorry, It seems that ffmpeg is not installed on your system" + VerboseOutput 5 "Please install ffmpeg from your repositories and make sure it is available in your \$PATH" + VerboseOutput 5 "Otherwise disable conversion" + ExecTime + exit 1 + fi + VerboseOutput 0 "\`ffmpeg -h\` succeeded" fi - VerboseOutput 0 "\`ffmpeg -h\` succeeded" # Check EyeD3 - if [[ $convertart == true && ! $(eyeD3 --version 2>/dev/null) ]]; then - VerboseOutput 5 "\`eyeD3 --version\` failed" - VerboseOutput 5 "Sorry, It seems that eyeD3 is not installed on your system" - VerboseOutput 5 "Please install eyeD3 from your repositories and make sure it is available in your \$PATH" - VerboseOutput 5 "Otherwise disable albumart conversion" - ExecTime - exit 1 + if [[ $convertart == true ]]; then + if [[ ! $(eyeD3 --version 2>/dev/null) ]]; then + VerboseOutput 5 "\`eyeD3 --version\` failed" + VerboseOutput 5 "Sorry, It seems that eyeD3 is not installed on your system" + VerboseOutput 5 "Please install eyeD3 from your repositories and make sure it is available in your \$PATH" + VerboseOutput 5 "Otherwise disable albumart conversion" + ExecTime + exit 1 + fi + VerboseOutput 0 "\`eyeD3 --version\` succeeded" fi - VerboseOutput 0 "\`eyeD3 --version\` succeeded" # Check ImageMagick - if [[ $convertart == true && ! $(convert --version 2>/dev/null) ]]; then - VerboseOutput 5 "\`convert --version\` failed" - VerboseOutput 5 "Sorry, It seems that ImageMagick is not installed on your system" - VerboseOutput 5 "Please install ImageMagick from your repositories and make sure it is available in your \$PATH" - VerboseOutput 5 "Otherwise disable albumart conversion" - ExecTime - exit 1 + if [[ $convertart == true ]]; then + if [[ ! $(convert --version 2>/dev/null) ]]; then + VerboseOutput 5 "\`convert --version\` failed" + VerboseOutput 5 "Sorry, It seems that ImageMagick is not installed on your system" + VerboseOutput 5 "Please install ImageMagick from your repositories and make sure it is available in your \$PATH" + VerboseOutput 5 "Otherwise disable albumart conversion" + ExecTime + exit 1 + fi + VerboseOutput 0 "\`convert --version\` succeeded" fi - VerboseOutput 0 "\`convert --version\` succeeded" # Check Gnu parallel - if [[ $multithread == true && ! $(parallel -h 2>/dev/null) ]]; then - VerboseOutput 5 "\`parallel -h\` failed" - VerboseOutput 5 "Sorry, It seems that parallel is not installed on your system" - VerboseOutput 5 "Please install gnu-parallel and env_parallel from your repositories and make sure it is available in your \$PATH" - VerboseOutput 5 "Otherwise disable multithreading" - ExecTime - exit 1 + if [[ $multithread == true ]]; then + if [[ ! $(parallel -h 2>/dev/null) ]]; then + VerboseOutput 5 "\`parallel -h\` failed" + VerboseOutput 5 "Sorry, It seems that parallel is not installed on your system" + VerboseOutput 5 "Please install gnu-parallel and env_parallel from your repositories and make sure it is available in your \$PATH" + VerboseOutput 5 "Otherwise disable multithreading" + ExecTime + exit 1 + fi + VerboseOutput 0 "\`parallel -h \` succeeded" fi - VerboseOutput 0 "\`parallel -h \` succeeded" fi VerboseOutput 1 "Dependency test OK" } @@ -442,7 +450,7 @@ ExitHandler() { trap 'ExitHandler' SIGINT trap 'ErrorHandler $BASH_COMMAND' ERR -CheckDeps 0 +CheckDeps 2 GetOptions $@ CheckDeps 1 if [[ $help == true ]]; then