diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-25 02:36:21 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-25 02:36:21 -0400 |
commit | 3120c7bd8ce158f5dd482deef3b69441cf5a117d (patch) | |
tree | 36203af2da1c4c9c34e224030986a9e256ebb55c | |
parent | 19732f071794d73a5598a41de3e6caa4c77acd81 (diff) |
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
-rwxr-xr-x | cron-jobs/db-cleanup | 26 |
1 files 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[@]}" |