X-Git-Url: https://git.treefish.org/~alex/backmeupscotty.git/blobdiff_plain/aad0734411ecf750bf2233dba6cffb333da50d68..69c4602aca9da2729e48a0027b7f18be9fd1abdd:/backmeupscotty diff --git a/backmeupscotty b/backmeupscotty index 44e9c54..68afaf6 100644 --- a/backmeupscotty +++ b/backmeupscotty @@ -125,8 +125,10 @@ function scottysync { done } -function prepare { - scottyinfo "Preparing for sync." +function deleteLock { + if ! rmdir /var/run/$(basename $0).lock; then + scottyerror "Could not delete lockfile /tmp/$(basename $0).lock!" + fi } function cleanup_abort { @@ -139,6 +141,8 @@ function cleanup_abort { kill $(jobs -p) fi + deleteLock + exit } @@ -150,6 +154,11 @@ function prepare { scottyinfo "No prepare function was defined." } +function cleanup_normal { + cleanup + deleteLock +} + function printhelp { cat </var/run/$(basename $0).pid -if ! flock -n 200; then +if ! mkdir /var/run/$(basename $0).lock; then scottyerror "Another instance of $(basename $0) is still running!" exit 1 +else + trap deleteLock EXIT fi -echo $$ 1>&200