]> gitweb.fluxo.info Git - puppet-puppet.git/commitdiff
Lockfile enhancement at check-puppetd
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 27 Feb 2011 03:46:25 +0000 (00:46 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 27 Feb 2011 03:46:25 +0000 (00:46 -0300)
templates/check-puppetd.sh.erb

index 134031595728426c62a62d003745862659f7ebe4..d467ad6e93c1fe9e5b450590d6cac6b3fba2bc35 100644 (file)
@@ -49,14 +49,18 @@ function check_lockfile {
   local pid process
 
   if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then
-    pid="`cat $LOCKFILE`"
+    pid="`cat $LOCKFILE 2> /dev/null`"
     process="`ps --no-headers -o comm $pid`"
-    if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
-      echo "Another backup is running for $LOCKFILE, skipping run"
-      exit
-    else
-      echo "Found old lockfile $LOCKFILE, removing it"
-      unset_lockfile  
+
+    # Check lockfile again
+    if [ -f "$LOCKFILE" ]; then
+      if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
+        echo "Another backup is running for $LOCKFILE, skipping run"
+        exit
+      else
+        echo "Found old lockfile $LOCKFILE, removing it"
+        unset_lockfile  
+      fi
     fi
   fi