diff options
author | Karel Kočí <karel.koci@nic.cz> | 2018-08-29 10:11:33 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2018-08-29 10:11:33 +0200 |
commit | 7f64f19870c7df471e5373db77bedb2046f14324 (patch) | |
tree | b92885f0340524945cfd63c7d2951766fb95cc98 /scripts | |
parent | a17f6845bac4bcc0e2b81e71e2782d63b6a82a44 (diff) | |
download | laminar-cnf-7f64f19870c7df471e5373db77bedb2046f14324.tar.gz laminar-cnf-7f64f19870c7df471e5373db77bedb2046f14324.tar.bz2 laminar-cnf-7f64f19870c7df471e5373db77bedb2046f14324.zip |
utils: instead of plain base name use jobid in locks
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/utils | 11 |
1 files changed, 8 insertions, 3 deletions
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" } |