]> arthur.barton.de Git - trigger-rcmd.git/commitdiff
Fix $NAME handling
authorAlexander Barton <alex@barton.de>
Sun, 22 Oct 2017 16:55:26 +0000 (18:55 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 22 Oct 2017 16:55:26 +0000 (18:55 +0200)
scripts/trigger-rcmd

index cfd4d790df7c531e9fca9d6482f3cda984a9fa4e..a2bf18f04dd5d06ab85db1d39df861d5d2f746c5 100755 (executable)
@@ -10,7 +10,8 @@
 # Please read the file COPYING, README and AUTHORS for more information.
 #
 
-NAME=$(basename "$0")
+BASENAME=$(basename "$0")
+NAME="$BASENAME"
 RCMD_D="/usr/local/etc/rcmd.d"
 
 PATH="$PATH:/usr/local/sbin:/usr/sbin"
@@ -39,8 +40,6 @@ do_rcmd() {
                return 2
        fi
 
-       NAME="$NAME($1)"
-
        echo "$NAME: Checking system \"$SYSTEM\" ..."
        fping -c1 -q "$SYSTEM" 2>/dev/null
        if [ $? -ne 0 ]; then
@@ -153,6 +152,7 @@ while [ $# -gt 0 ]; do
                r=1
        else
                echo "$NAME: Working on \"$1\" - $(date "+%Y-%m-%d %H:%M:%S")"
+               NAME="$BASENAME($1)"
                lck="/run/lock/$NAME-$1.lock"
                if lockfile-create --quiet --use-pid --retry 2 --lock-name "$lck"; then
                        do_rcmd "$1" ; r=$?
@@ -162,6 +162,7 @@ while [ $# -gt 0 ]; do
                        echo "$NAME: Failed to acquire lock file, skipping job! ($lck)"
                        r=1
                fi
+               NAME=$BASENAME
        fi
        [ $r -ne 0 ] && result=1
        shift