diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-08-08 15:03:27 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-08-08 15:03:27 +0200 |
commit | 9eb1cd7b9403533c4b60ecfbbbf00a08c211059a (patch) | |
tree | 024459abc4017b4c574bf6e5cd9d2f4df2b95f26 /misc-scripts/sourceballs-cleanup | |
parent | 388d629327d97e8d15a7a67cc87ae36edfe2f385 (diff) | |
download | dbscripts-9eb1cd7b9403533c4b60ecfbbbf00a08c211059a.tar.gz dbscripts-9eb1cd7b9403533c4b60ecfbbbf00a08c211059a.tar.xz |
Move common function to db-functions
db-functions now sets an individual $WORKDIR and implements trap functinos that
remove locks on exit or error. There are new functions to lock and unlock the running script.
misc-scripts/ftpdir-cleanup was renamed to ftpdir-cleanup-repo as the cron-job had the same name.
Script names have to be unique when using db-functions.
Diffstat (limited to 'misc-scripts/sourceballs-cleanup')
-rwxr-xr-x | misc-scripts/sourceballs-cleanup | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/misc-scripts/sourceballs-cleanup b/misc-scripts/sourceballs-cleanup index c87a888..e058c38 100755 --- a/misc-scripts/sourceballs-cleanup +++ b/misc-scripts/sourceballs-cleanup @@ -6,19 +6,7 @@ srcpath="$FTP_BASE/sources/" logfile="$srcpath/cleanup.txt" -LOCKFILE="/tmp/.sourceball-cleanup.lock" - -cleanup () { - restore_umask - rm -rf "$WORKDIR" - rm -f "$LOCKFILE" - exit 0 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} +script_lock remove_old() { if [ -d "$1" ]; then @@ -52,17 +40,6 @@ remove_old() { fi } -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: source tarball generation is already in progress (started by $owner)" - exit 1 -fi - -trap cleanup 0 -trap ctrl_c 2 - -/bin/touch "$LOCKFILE" - #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null @@ -91,4 +68,4 @@ for sourceball in "$srcpath"/*$SRCEXT; do fi done -cleanup 0 +script_unlock |