diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-02-27 00:46:25 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-02-27 00:46:25 -0300 |
commit | 4bd5435cab38818318818906c5f864a599990e26 (patch) | |
tree | 72e774d79b963e20f44ad4309a2e8fbb0f69298f /templates | |
parent | 4440a1c7d9eb14326217d4dce5904b2b9bcdc437 (diff) | |
download | puppet-puppet-4bd5435cab38818318818906c5f864a599990e26.tar.gz puppet-puppet-4bd5435cab38818318818906c5f864a599990e26.tar.bz2 |
Lockfile enhancement at check-puppetd
Diffstat (limited to 'templates')
-rw-r--r-- | templates/check-puppetd.sh.erb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/templates/check-puppetd.sh.erb b/templates/check-puppetd.sh.erb index 1340315..d467ad6 100644 --- a/templates/check-puppetd.sh.erb +++ b/templates/check-puppetd.sh.erb @@ -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 |