]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
change: Config Function
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Jul 2017 15:59:57 +0000 (17:59 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Jul 2017 15:59:57 +0000 (17:59 +0200)
albentohandy

index 0cae5e03ef6d02ccc486c40b5ae274d006e95074..2cc832e9b82783ccd35d774574d3f761706ea0f1 100755 (executable)
@@ -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