From 3120c7bd8ce158f5dd482deef3b69441cf5a117d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Sep 2018 02:36:21 -0400 Subject: db-cleanup: Tidy - Use libremessages:setup_traps() instead of doing it ourselves - Use $(dirname ... $0)/../ instead of calling dirname twice - Don't use `&&` or `||` instead of an `if` block - Compare $CLEANUP_DRYRUN against the string 'true', rather than executing it --- cron-jobs/db-cleanup | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cron-jobs/db-cleanup b/cron-jobs/db-cleanup index 2a2769e..de92e21 100755 --- a/cron-jobs/db-cleanup +++ b/cron-jobs/db-cleanup @@ -9,25 +9,15 @@ # * Rsync pools against themselves removing excluded files # * Instant cleanup! -trap_exit() { - echo - error "$@" - exit 1 -} - -source "$(dirname $(dirname "$(readlink -e "$0")"))/config" -source "$(dirname $(dirname "$(readlink -e "$0")"))/db-cleanup.conf" +source "$(dirname "$(readlink -e "$0")")/../config" +source "$(dirname "$(readlink -e "$0")")/../db-cleanup.conf" source "$(librelib messages)" - -# From makepkg -set -E - -trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT -trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT -trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR +setup_traps EXTRAFLAGS=() -"${CLEANUP_DRYRUN}" && EXTRAFLAGS+=(--dry-run) +if [[ $CLEANUP_DRYRUN = true ]]; then + EXTRAFLAGS+=(--dry-run) +fi filter=$(mktemp -t "${0##*/}.XXXXXXXXXX") trap "rm -f -- ${filter@Q}" EXIT @@ -62,5 +52,7 @@ done msg "Removing dead symlinks:" actions=(-print) -"${CLEANUP_DRYRUN}" || actions+=(-delete) +if [[ $CLEANUP_DRYRUN != true ]]; then + actions+=(-delete) +fi find -L "${FTP_BASE}/" -type l "${actions[@]}" -- cgit v1.2.2