From d49add1dea1e6009b89c1df2979090d4f758468c Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Jul 2017 17:59:57 +0200 Subject: [PATCH] change: Config Function --- albentohandy | 57 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/albentohandy b/albentohandy index 0cae5e0..2cc832e 100755 --- a/albentohandy +++ b/albentohandy @@ -76,12 +76,25 @@ MakeSha256CheckSum() { >> $workdir/sha256sum } -main() { - WORK="$(pwd)/work.$$" # temporary working directory - SCRIPTPATH="/usr/bin" # path to flactomp3v2 and notify.sh script - MUSICPATH="/tmp/musikpath" # flac collection directory +ExistsScripts() { + local readonly scriptdir="$1" - # check exist config and scripts + # flactomp3v2: convert flac's to mp3 + if [ ! -f $scriptdir/flactomp3v2 ]; then + printf "\nERROR\nflactomp3v2 do not found in %s\n" $scriptdir + exit 1 + fi + + # notify.sh: functions send email + if [ ! -f $scriptdir/notify.sh ]; then + printf "\nERROR\nnotify.sh do not found in %s\n" $scriptdir + exit 1 + else + source $scriptdir/notify.sh + fi +} + +LoadConfig() { # .albentohandy.conf: set SCRIPTPATH and MUSICPATH if [ -f $HOME/.albentohandy.conf ]; then source $HOME/.albentohandy.conf @@ -89,18 +102,23 @@ main() { printf "\nERROR\n%s/.albentohandy.conf does not exists\n" $HOME exit 1 fi - # flactomp3v2: convert flac's to mp3 - if [ ! -f $SCRIPTPATH/flactomp3v2 ]; then - printf "\nERROR\nflactomp3v2 do not found in %s\n" $SCRIPTPATH - exit 1 - fi - # notify.sh: functions send email - if [ ! -f $SCRIPTPATH/notify.sh ]; then - printf "\nERROR\nnotify.sh do not found in %s\n" $SCRIPTPATH - exit 1 - else - source $SCRIPTPATH/notify.sh + + # in cluster you have to same bitrate and + # stereo mode of mp3's on every pc. + # read more about basefile in man parallel + if [ -f $HOME/.flactomp3v2.conf ]; then + BASEFILE="--basefile $HOME/.flactomp3v2.conf --cleanup" fi +} + +main() { + WORK="$(pwd)/work.$$" # temporary working directory + SCRIPTPATH="/usr/bin" # path to flactomp3v2 and notify.sh script + MUSICPATH="/tmp/musikpath" # flac collection directory + + LoadConfig + + ExistsScripts "$SCRIPTPATH" # set defaults albumlist="albumlist" @@ -112,13 +130,6 @@ main() { removework=false cptodest=false - # in cluster you have to same bitrate and - # stereo mode of mp3's on every pc. - # read more about basefile in man parallel - if [ -f $HOME/.flactomp3v2.conf ]; then - BASEFILE="--basefile $HOME/.flactomp3v2.conf --cleanup" - fi - # read parameters while getopts ":ci:m:S::rw:z:" optname; do case "$optname" in -- 2.47.3