summaryrefslogtreecommitdiff
path: root/global/overlay/usr/local/bin/run-cosmos
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2014-05-05 12:53:51 +0200
committerFredrik Thulin <fredrik@thulin.net>2014-05-05 12:53:51 +0200
commitd000b1adea71cc89f31d4509c135768ecc796ba3 (patch)
treeca607a5066b5696ef6a13bb3b13e64f1b38e04f3 /global/overlay/usr/local/bin/run-cosmos
parent0e9331718dba878570505faa0e28fa57f1e6f762 (diff)
Diffstat (limited to 'global/overlay/usr/local/bin/run-cosmos')
-rwxr-xr-xglobal/overlay/usr/local/bin/run-cosmos20
1 files changed, 20 insertions, 0 deletions
diff --git a/global/overlay/usr/local/bin/run-cosmos b/global/overlay/usr/local/bin/run-cosmos
new file mode 100755
index 0000000..df104b8
--- /dev/null
+++ b/global/overlay/usr/local/bin/run-cosmos
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Simplify running cosmos, with serialization if flock is available.
+#
+
+set -e
+
+FLOCK=`which flock`
+
+if [ -x "$FLOCK" ]; then
+ ($FLOCK --exclusive --wait 60 9 || exit 1
+ cosmos $* update
+ cosmos $* apply
+ )9>/var/lock/run-cosmos
+else
+ cosmos $* update
+ cosmos $* apply
+fi
+
+touch /var/run/last-cosmos-ok.stamp