]> arthur.barton.de Git - backup-script.git/commitdiff
Read in configuration before showing usage information
authorAlexander Barton <alex@barton.de>
Thu, 20 Aug 2015 14:55:05 +0000 (16:55 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 20 Aug 2015 14:55:05 +0000 (16:55 +0200)
And show more configuration details on regular runs, too.

bin/backup-script

index 2c6fd823704adf916c7837c673e6ff971a742e71..d28a4d8fc3b570ddf37a8c536c2c73326ec7da8d 100755 (executable)
@@ -52,8 +52,7 @@ Usage() {
        echo
        echo "When no <system> is given, all defined systems are used."
        echo
-       echo "Configuration file is \"$conf\","
-       echo "using \"$conf_d\" as configuration directory."
+       echo -e $config_info
        echo
        exit 2
 }
@@ -273,6 +272,15 @@ for conf in \
        [ -r "$conf" ] && break
 done
 
+# Read in configuration file
+config_info="Configuration file is \"$conf\""
+if [ -r "$conf" ]; then
+       source "$conf"
+else
+       config_info="${config_info} (not readable, using defaults)"
+fi
+config_info="${config_info},\nusing \"$conf_d\" as configuration directory."
+
 while [ $# -gt 0 ]; do
        case "$1" in
          "-n"|"--dry-run")
@@ -292,14 +300,7 @@ done
 trap GotSignal SIGINT
 
 echo -n "Started: "; date
-
-# Read in configuration file
-if [ -r "$conf" ]; then
-       echo "Reading configuration: \"$conf\" ..."
-       source "$conf"
-else
-       echo "No configuration file found, using defaults."
-fi
+echo -e $config_info
 echo
 
 if [ $# -ge 1 ]; then