From 7f64f19870c7df471e5373db77bedb2046f14324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 29 Aug 2018 10:11:33 +0200 Subject: utils: instead of plain base name use jobid in locks --- scripts/utils | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/utils b/scripts/utils index 713d8f4..1c364a0 100644 --- a/scripts/utils +++ b/scripts/utils @@ -1,5 +1,10 @@ # vim: ft=sh +# Returns current job's id +jobid() { + basename "$0" | sed 's/\.run$//' +} + ## Simple echo wrappers ######################################################### echo_stage() { echo -e "\033[1;34m========== $@ ==========\033[0m ($(date))" >&2 @@ -20,7 +25,7 @@ _LAMINAR_LOCKS="" _handle_exit() { # Release all locks for LOCK in $_LAMINAR_LOCKS; do - laminarc release "$(basename "$0")-$LOCK" + laminarc release "$(jobid)-$LOCK" done } trap _handle_exit EXIT @@ -61,7 +66,7 @@ git_fetch() { laminar_self_lock() { _check_trap _LAMINAR_LOCKS="$_LAMINAR_LOCKS $1" - laminarc lock "$(basename "$0")-$1" + laminarc lock "$(jobid)-$1" echo_debug "Locking $1" } @@ -69,7 +74,7 @@ laminar_self_lock() { # Extension appended to lock name has to be provided as first argument laminar_self_release() { _check_trap - laminarc release "$(basename "$0")-$1" + laminarc release "$(jobid)-$1" _LAMINAR_LOCKS="$(echo "$_LAMINAR_LOCKS" | sed "s/ $1//")" echo_debug "Releasing $1" } -- cgit v1.2.3