]> git.treefish.org Git - backmeupscotty.git/blobdiff - backmeupscotty
Deleted zombie prepare function.
[backmeupscotty.git] / backmeupscotty
index be1ce209a4de43dba7ad413ce52cc98a3d9f0fc9..e0689a042a60240b16f3d0cfac77a6e0e5c52c4b 100644 (file)
@@ -125,16 +125,6 @@ function scottysync {
     done
 }
 
-function deleteLock {
-    if ! rmdir /tmp/$(basename $0).lock; then
-       scottyerror "Could not delete lockfile /tmp/$(basename $0).lock!"
-    fi
-}
-
-function prepare {
-    scottyinfo "Preparing for sync."
-}
-
 function cleanup_abort {
     scottyerror "Caught exit signal! Cleaning up."
 
@@ -145,8 +135,6 @@ function cleanup_abort {
        kill $(jobs -p)
     fi
 
-    deleteLock
-
     exit
 }
 
@@ -158,11 +146,6 @@ function prepare {
     scottyinfo "No prepare function was defined."
 }
 
-function cleanup_normal {
-    cleanup
-    deleteLock
-}
-
 function printhelp {
     cat <<EOF
 Usage: $(basename $0) [OPTION]...
@@ -208,14 +191,14 @@ function backmeupscotty {
     prepare
     scottysync
 
-    trap cleanup_normal EXIT
+    trap cleanup EXIT
 
     exit 0
 }
 
-if ! mkdir /tmp/$(basename $0).lock; then
+exec 200>/var/run/$(basename $0).pid
+if ! flock -n 200; then
     scottyerror "Another instance of $(basename $0) is still running!"
     exit 1
-else
-    trap deleteLock EXIT
 fi
+echo $$ 1>&200