summaryrefslogtreecommitdiff
path: root/scripts/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/utils')
-rw-r--r--scripts/utils11
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"
}