utility to manage git-mirror
[infrastructure.git] / scripts / manage-git-mirror.sh
1 #!/bin/bash
2 COMMAND=$(basename $0)
3
4 # avoid the crontab job for an hour 
5 # wait until the running instance is done and create a void stamp 
6 function stop () {
7     while true; do 
8         echo -n . 
9         ls /git-mirror/RUNNING_MIRROR >& /dev/null || { 
10             touch /git-mirror/RUNNING_MIRROR 
11             echo "OK, git-mirror stopped for an hour"
12             break 
13         } 
14         sleep 5
15     done
16 }
17
18 function start () {
19     rm /git-mirror/RUNNING_MIRROR
20 }
21
22 function main () {
23     case $1 in
24         start) start;;
25         stop) stop;;
26         *) echo "Usage: $COMMAND start|stop";;
27     esac
28 }
29
30 main "$@"