From d3e5719e2724a38d02213a4ac24b324905e27da3 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 16 Sep 2020 22:09:00 -0700 Subject: [PATCH] updategc-util-functions.sh: parametize "still running" message Instead of always using "gc already running" make the "gc" part replaceable defaulting to something sane based on the lock file name. Signed-off-by: Kyle J. McKay --- jobd/updategc-util-functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jobd/updategc-util-functions.sh b/jobd/updategc-util-functions.sh index d76db90..14a8be7 100755 --- a/jobd/updategc-util-functions.sh +++ b/jobd/updategc-util-functions.sh @@ -46,6 +46,7 @@ createlock() { # Create a new lockfile # $1 => name of variable to store result in # $2 => name of the new lockfile (default is "lockfile.pid") +# $3 => "type" name to use in error message (default is ${2%%.*}) # On success: # variable named by $1 will contain the name of the newly create lockfile (i.e. "$2") # On failure: @@ -53,6 +54,7 @@ createlock() { v_lock_file() { # be compatibile with gc.pid file from newer Git releases _lockf="${2:-lockfile.pid}" + _locktype="${3:-${2%%.*}}" _hn="$(hostname)" _active= if [ "$(createlock "$_lockf")" ]; then @@ -77,7 +79,7 @@ v_lock_file() { fi if [ -n "$_active" ]; then rm -f "$_lockf.lock" - eval "$1="'"gc already running on machine '\''$_ahost'\'' pid '\''$_apid'\''"' + eval "$1="'"$_locktype already running on machine '\''$_ahost'\'' pid '\''$_apid'\''"' return 1 fi printf "%s %s" "$$" "$_hn" >"$_lockf.lock" -- 2.11.4.GIT