f37 -> f39
[infrastructure.git] / scripts / manage-git-mirror.sh
index 6a18543..78489ec 100755 (executable)
@@ -6,8 +6,8 @@ COMMAND=$(basename $0)
 function stop () {
     while true; do 
        echo -n . 
-       ls /git-mirror/RUNNING_MIRROR >& /dev/null || { 
-           touch /git-mirror/RUNNING_MIRROR 
+       ls /git-mirror/LOCK >& /dev/null || { 
+           touch /git-mirror/LOCK 
            echo "OK, git-mirror stopped for an hour"
            break 
        } 
@@ -16,13 +16,44 @@ function stop () {
 }
 
 function start () {
-    rm /git-mirror/RUNNING_MIRROR
+    if pgrep git-mirror >& /dev/null; then
+       echo "git-mirror instance is running"
+    else
+       echo "Cleaned LOCK"
+       rm /git-mirror/LOCK
+    fi
+}
+
+function status () {
+    pids=$(pgrep git-mirror)
+    if [ -n "$pids" ] ; then
+       echo "Active processes"
+       ps $pids
+    else
+       echo "No running instance of git-mirror"
+    fi
+    echo "Lock file status"
+    ls -l /git-mirror/LOCK
+}
+
+function clean () {
+    totrash=$(ls /git-mirror/*/NOTIFIED 2> /dev/null)
+    if [ -z "$totrash" ] ; then
+       echo "No NOTIFIED file found"
+    else
+       echo "Trashing the following files"
+       ls -l $totrash
+       rm -f $totrash
+       echo Done
+    fi
 }
 
 function main () {
     case $1 in
        start) start;;
        stop) stop;;
+       status) status;;
+       clean) clean;;
        *) echo "Usage: $COMMAND start|stop";;
     esac
 }