From 9eb1cd7b9403533c4b60ecfbbbf00a08c211059a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 15:03:27 +0200 Subject: 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. --- misc-scripts/sourceballs-cleanup | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'misc-scripts/sourceballs-cleanup') 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 -- cgit v1.2.3-24-g4f1b