summaryrefslogtreecommitdiffstats
path: root/cron-jobs
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-08-08 15:03:27 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-08-08 15:03:27 +0200
commit9eb1cd7b9403533c4b60ecfbbbf00a08c211059a (patch)
tree024459abc4017b4c574bf6e5cd9d2f4df2b95f26 /cron-jobs
parent388d629327d97e8d15a7a67cc87ae36edfe2f385 (diff)
downloaddbscripts-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 'cron-jobs')
-rwxr-xr-xcron-jobs/ftpdir-cleanup26
1 files changed, 3 insertions, 23 deletions
diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 546afd9..f5e401a 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -5,34 +5,14 @@
repos="$(get_repos_for_host)"
-LOCKFILE="/tmp/.ftpdircleanup.lock"
-
-cleanup () {
- rm -f "$LOCKFILE"
- exit 0
-}
-
-ctrl_c() {
- cleanup
-}
-
-if [ -f "$LOCKFILE" ]; then
- owner="$(/usr/bin/stat -c %U $LOCKFILE)"
- echo "error: ftp cleanup is already in progress (started by $owner)"
- exit 1
-fi
-
-trap cleanup 0
-trap ctrl_c 2
-
-/bin/touch "$LOCKFILE"
+script_lock
#adjust the nice level to run at a lower priority
/usr/bin/renice +10 -p $$ > /dev/null
repopaths=''
for repo in $repos; do
- $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo
+ $(dirname $0)/../misc-scripts/ftpdir-cleanup-repo $repo
repopaths="${repopaths} ${FTP_BASE}/${repo}/os/"
done
@@ -60,4 +40,4 @@ if [ -n "$to_cleanup" ]; then
mv $to_cleanup "$CLEANUP_DESTDIR"
fi
-cleanup
+script_unlock