aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-06-22 07:57:50 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-06-22 07:57:50 +0300
commit92eb9c4f77daad2b0614d6b985ad4740e8996b29 (patch)
tree084fa8998db5ca5ebe5cfd85e4abff5ddd8051c9
parentc37d312f0398cac0a2eecc348bfd359e8be21ec5 (diff)
downloadoffsync-92eb9c4f77daad2b0614d6b985ad4740e8996b29.tar.gz
offsync-92eb9c4f77daad2b0614d6b985ad4740e8996b29.tar.bz2
offsync-92eb9c4f77daad2b0614d6b985ad4740e8996b29.zip
pidfile check in start.shHEADmaster
-rwxr-xr-xstart.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/start.sh b/start.sh
index 351474b..e6abfa3 100755
--- a/start.sh
+++ b/start.sh
@@ -10,6 +10,11 @@ if -z "${RSYNC_TARGET}"; then
exit 1
fi
+if [[ -e "$PIDFILE" ]]; then
+ echo "Offsync already running, exiting" 2>&1
+ exit 1
+fi
+
date >> "${LOGFILE}"
/usr/local/bin/rsync -auvhNHXxrz\
--stats --protect-args --fileflags --force-change --delete\
@@ -20,6 +25,10 @@ echo $! > "$PIDFILE"
# wait for rsync to finish
wait $(cat "$PIDFILE")
-rm "$PIDFILE"
+
+# stop may have already deleted it
+if [[ -e "$PIDFILE" ]]; then
+ rm "$PIDFILE"
+fi
tail "$LOGFILE" | mail -E -s "Offsite backup of $(hostname) completed" $MAILTO