summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-17 22:53:26 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-06-17 22:53:26 -0400
commit56e6bf0c9a2dac9e34b4ce12af1e614308a38319 (patch)
treeb348e3088f78d6e108a432e497e8976809637436
parentfb93f14b724c82427ab2531502ed3b79e6ccfe7f (diff)
db-cleanup: cleanup
-rwxr-xr-xdb-cleanup60
1 files changed, 30 insertions, 30 deletions
diff --git a/db-cleanup b/db-cleanup
index f6580b6..2051130 100755
--- a/db-cleanup
+++ b/db-cleanup
@@ -10,9 +10,9 @@
# * Instant cleanup!
trap_exit() {
- echo
- error "$@"
- exit 1
+ echo
+ error "$@"
+ exit 1
}
source "$(dirname "$(readlink -e "$0")")/config"
@@ -25,42 +25,42 @@ 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
-${CLEANUP_DRYRUN} && EXTRAFLAGS+=" --dry-run"
+EXTRAFLAGS=()
+"${CLEANUP_DRYRUN}" && EXTRAFLAGS+=(--dry-run)
-for _repo in ${PKGREPOS[@]}; do
- for _arch in ${ARCHES[@]}; do
- msg "Getting ${_repo}-${_arch} database"
+for _repo in "${PKGREPOS[@]}"; do
+ for _arch in "${ARCHES[@]}"; do
+ msg "Getting ${_repo}-${_arch} database"
- dbfile="${FTP_BASE}/${_repo}/os/${_arch}/${_repo}${DBEXT}"
+ dbfile="${FTP_BASE}/${_repo}/os/${_arch}/${_repo}${DBEXT}"
- if [ ! -r "${dbfile}" ]; then
- warning "Not found"
- continue
- fi
+ if [ ! -r "${dbfile}" ]; then
+ warning "Not found"
+ continue
+ fi
-# Echo the contents into a filter file
- bsdtar tf "${dbfile}" | \
- cut -d'/' -f1 | \
- sort -u | \
- sed "s|$|*|" >> /tmp/${0##*/}.$$.filter
+ # Echo the contents into a filter file
+ bsdtar tf "${dbfile}" | \
+ cut -d'/' -f1 | \
+ sort -u | \
+ sed "s|$|*|" >> "/tmp/${0##*/}.$$.filter"
- done
+ done
done
msg "Removing old files:"
-for POOL in ${PKGPOOLS[@]} ${SRCPOOLS[@]}; do
- msg2 "${POOL}"
+for POOL in "${PKGPOOLS[@]}" "${SRCPOOLS[@]}"; do
+ msg2 "${POOL}"
- rsync ${EXTRAFLAGS} -va --delete-excluded \
- --include-from="/tmp/${0##*/}.$$.filter" \
- --exclude="*" \
- ${FTP_BASE}/${POOL}/ \
- ${FTP_BASE}/${POOL}/
+ rsync "${EXTRAFLAGS[@]}" -va --delete-excluded \
+ --include-from="/tmp/${0##*/}.$$.filter" \
+ --exclude="*" \
+ "${FTP_BASE}/${POOL}/" \
+ "${FTP_BASE}/${POOL}/"
done
-msg "Removing symlinks:"
-find -L ${FTP_BASE}/ -type l
-${CLEANUP_DRYRUN} || find -L ${FTP_BASE}/ -type l -delete
-
-exit $?
+msg "Removing dead symlinks:"
+actions=(-print)
+"${CLEANUP_DRYRUN}" || actions+=(-delete)
+find -L "${FTP_BASE}/" -type l -print -delete