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 | |
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')
-rwxr-xr-x | misc-scripts/ftpdir-cleanup-repo (renamed from misc-scripts/ftpdir-cleanup) | 13 | ||||
-rwxr-xr-x | misc-scripts/make-sourceball | 21 | ||||
-rwxr-xr-x | misc-scripts/sourceballs-cleanup | 27 |
3 files changed, 6 insertions, 55 deletions
diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup-repo index ac17a8d..12f726c 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup-repo @@ -12,14 +12,6 @@ reponame=$1 . "$(dirname $0)/../db-functions" . "$(dirname $0)/../config" -cleanup() { - trap '' 2 15 - for arch in ${ARCHES[@]}; do - repo_unlock $reponame $arch - done - exit 1 -} - clean_pkgs () { for pkg in "$@"; do if [ -h "$pkg" ]; then @@ -30,9 +22,6 @@ clean_pkgs () { done } -trap cleanup 2 -trap cleanup 15 - ${CLEANUP_DRYRUN} && echo 'dry run mode is active' ftppath_base="$FTP_BASE/$reponame/os" @@ -41,7 +30,7 @@ for arch in ${ARCHES[@]}; do repo_lock $reponame $arch $LOCK_TIMEOUT || continue - CLEANUP_TMPDIR=$(mktemp -d ${TMPDIR}/cleanup-XXXXXX) || exit 1 + CLEANUP_TMPDIR=$(mktemp -d ${WORKDIR}/cleanup-XXXXXX) || exit 1 ftppath="$ftppath_base/$arch" MISSINGFILES="" DELETEFILES="" diff --git a/misc-scripts/make-sourceball b/misc-scripts/make-sourceball index e216356..6e57385 100755 --- a/misc-scripts/make-sourceball +++ b/misc-scripts/make-sourceball @@ -22,21 +22,7 @@ _arch="$3" srcpath="$FTP_BASE/sources/" logpath="/var/log/sourceballs/" -cleanup() { - restore_umask - rm -rf "$WORKDIR" - [ "$1" ] && exit $1 -} - -ctrl_c() { - echo "Interrupted" >&2 - cleanup 0 -} - -die() { - echo -e "$*" >&2 - cleanup 1 -} +script_lock create_srcpackage() { if [ -d "$1" ]; then @@ -71,9 +57,6 @@ create_srcpackage() { fi } -trap ctrl_c 2 -trap cleanup 0 1 - set_umask /bin/mkdir -p "$logpath" cd "$WORKDIR" @@ -91,3 +74,5 @@ else die "\tPackage '$packagename' does not exist in repo '$reponame-$_arch'" fi fi + +script_unlock 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 |