utility to manage git-mirror
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 13 Oct 2011 07:46:57 +0000 (09:46 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 13 Oct 2011 07:46:57 +0000 (09:46 +0200)
scripts/manage-git-mirror.sh [new file with mode: 0755]

diff --git a/scripts/manage-git-mirror.sh b/scripts/manage-git-mirror.sh
new file mode 100755 (executable)
index 0000000..6a18543
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+COMMAND=$(basename $0)
+
+# avoid the crontab job for an hour 
+# wait until the running instance is done and create a void stamp 
+function stop () {
+    while true; do 
+       echo -n . 
+       ls /git-mirror/RUNNING_MIRROR >& /dev/null || { 
+           touch /git-mirror/RUNNING_MIRROR 
+           echo "OK, git-mirror stopped for an hour"
+           break 
+       } 
+       sleep 5
+    done
+}
+
+function start () {
+    rm /git-mirror/RUNNING_MIRROR
+}
+
+function main () {
+    case $1 in
+       start) start;;
+       stop) stop;;
+       *) echo "Usage: $COMMAND start|stop";;
+    esac
+}
+
+main "$@"