From 54402ce08906df0e7675766a84b788986f2bfd92 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Sun, 6 Jul 2014 20:07:49 +0200 Subject: [PATCH] mkmap.sh: Add locking around script call --- mkmap.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mkmap.sh b/mkmap.sh index 1c6453f..28195be 100755 --- a/mkmap.sh +++ b/mkmap.sh @@ -3,10 +3,30 @@ set -e DEST=$1 - +LOCKFILE="/run/lock/ffmap" [ "$DEST" ] || exit 1 cd "$(dirname "$0")"/ +if lockfile-check "$LOCKFILE"; then + exit +fi +lockfile-create "$LOCKFILE" +lockfile-touch "$LOCKFILE" & +LOCKPID="$!" + ./bat2nodes.py -A -a aliases.json -d $DEST + +kill "$LOCKPID" +lockfile-remove "$LOCKFILE" + +if lockfile-check "$LOCKFILE-sync"; then + exit +fi +lockfile-create "$LOCKFILE-sync" +lockfile-touch "$LOCKFILE-sync" & +LOCKPID="$!" + +kill "$LOCKPID" +lockfile-remove "$LOCKFILE-sync"