]> arthur.barton.de Git - backup-script.git/commitdiff
Autodetect "localhost" and 127.0.0.1 as being "local"
authorAlexander Barton <alex@barton.de>
Thu, 26 Sep 2013 16:03:02 +0000 (18:03 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 26 Sep 2013 16:03:02 +0000 (18:03 +0200)
bin/backup-script
bin/backup-status

index e57673a0461b112a71d237af030056f3a5ee0f68..89abead0610b6c11cfd63c5effe25cf1d7a649d0 100755 (executable)
@@ -160,6 +160,9 @@ for f in $sys; do
        # Read in system configuration file
        source "$f"
 
+       # Validate configuration
+       [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1
+
        [ "$system" = "$fname" ] \
                && systxt="\"$system\"" \
                || systxt="\"$fname\" [\"$system\"]"
index 16d3af1eb0d36231c6c719bcf7eeae7f0c855a14..bbb6b056265baa6e2e68fc9005d69cee10915c4b 100755 (executable)
@@ -18,8 +18,8 @@ export LC_ALL=C
 
 declare -i count=0
 
+# Default settings, can be overwritten in backup-script.conf:
 default_target=""
-default_user="root"
 
 if [ "$1" == "-q" ]; then
        QUICK=1
@@ -50,29 +50,39 @@ fi
 for f in $sys; do
        [ -r "$f" -a -f "$f" ] || continue
 
-       system=`basename $f`
-       target="$default_target"
-
-       case "$system" in
+       fname=`basename $f`
+       case "$fname" in
                "backup-script.conf"|*.sh)
                        continue
                        ;;
        esac
 
-       # Read in configuration file
+       # Set global defaults
+       system="$fname"
+       target="$default_target"
+
+       # Read in system configuration file
        source "$f"
 
+       # Validate configuration
+       [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1
+
        destdir="$target"
        target="$target/$system"
 
        [ -d "$target" ] || continue
 
-       echo "$system"
+       # System name
+       [ "$system" = "$fname" ] && echo "$system" || echo "$system [$fname]"
+
+       # System target directory
        echo "- Target: $target"
        if [ "$QUICK" = "0" ]; then
                size=`du -sh "$target" | cut -f1`
                echo "- Size:" $size
        fi
+
+       # Timestamp and result code
        if [ -f "$target/.stamp" ]; then
                last=`stat "$target/.stamp" | grep "^Modify: " | cut -d':' -f2- | cut -d. -f1`
                [ -n "$last" ] && echo "- Date:" $last