#!/bin/bash repos="core extra testing" 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" #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null #Get our destination dir . "$(dirname $0)/../db-functions" for repo in $repos; do $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo $CLEANUP_DESTDIR done cleanup