aboutsummaryrefslogtreecommitdiff
path: root/files/handlers/rsync
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-08-21 19:27:32 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-08-21 19:27:32 -0300
commit0ce4fa1a25d032457d8e7fc777e2356651c2cf40 (patch)
tree4adbdf6c255f64d23f804de30b1672f62918c6f4 /files/handlers/rsync
parent1f77a77fefea93be7380eb4735837d02f2bdafc8 (diff)
downloadpuppet-backup-0ce4fa1a25d032457d8e7fc777e2356651c2cf40.tar.gz
puppet-backup-0ce4fa1a25d032457d8e7fc777e2356651c2cf40.tar.bz2
Making sure that the pid on lockfile reffers to an rsync backup process
Diffstat (limited to 'files/handlers/rsync')
-rw-r--r--files/handlers/rsync9
1 files changed, 5 insertions, 4 deletions
diff --git a/files/handlers/rsync b/files/handlers/rsync
index ba7dd89..14f607d 100644
--- a/files/handlers/rsync
+++ b/files/handlers/rsync
@@ -849,7 +849,7 @@ function set_lockfile {
if [ ! -z "$lockfile" ]; then
mkdir -p `dirname $lockfile`
if ( set -o noclobber; echo "$$" > "$lockfile" ) &> /dev/null; then
- trap 'rm -f "$lockfile"' INT TERM EXIT
+ trap 'unset_lockfile' INT TERM EXIT
else
info "Could not create lockfile $lockfile, exiting"
exit
@@ -861,18 +861,19 @@ function set_lockfile {
function unset_lockfile {
if [ ! -z "$lockfile" ]; then
- $rm $lockfile || warning "Could not remove lockfile $lockfile"
+ $rm -f $lockfile || warning "Could not remove lockfile $lockfile"
fi
}
function check_lockfile {
- local pid
+ local pid process
if [ ! -z "$lockfile" ] && [ -f "$lockfile" ]; then
pid="`cat $lockfile`"
- if ps $pid &> /dev/null; then
+ process="`ps --no-headers -o comm $pid`"
+ if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
info "Another backup is running for $lockfile, skipping run"
exit
else