diff options
author | Aaron Griffin <aaronmgriffin@gmail.com> | 2010-05-02 17:52:59 +0200 |
---|---|---|
committer | Aaron Griffin <aaronmgriffin@gmail.com> | 2010-05-02 17:52:59 +0200 |
commit | 1e13a032ac0bef748150c60f3b670e57dad2aee5 (patch) | |
tree | 34a5ccbe960d35722206a3855ac1d0c8428e0476 /misc-scripts/ftpdir-cleanup | |
parent | 22c5f235fa25ea3327d95a28c6dc8ae399d6cb9a (diff) | |
download | dbscripts-1e13a032ac0bef748150c60f3b670e57dad2aee5.tar.gz dbscripts-1e13a032ac0bef748150c60f3b670e57dad2aee5.tar.xz |
ftpdir-cleanup: Add clean_pkgs function
This should remove files if they are symlinks (pooled packages)
and move them to the cleanup dir if not
Diffstat (limited to 'misc-scripts/ftpdir-cleanup')
-rwxr-xr-x | misc-scripts/ftpdir-cleanup | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index 97f46b2..c9a232d 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -20,6 +20,16 @@ cleanup() { exit 1 } +clean_pkgs () { + for pkg in "$@"; do + if [ -h "$pkg" ]; then + rm -f "$pkg" + else + mv "$pkg" "$CLEANUP_DESTDIR" + fi + done +} + trap cleanup 2 trap cleanup 15 @@ -155,17 +165,17 @@ for arch in ${ARCHES[@]}; do fi if [ -n "${DELETEFILES}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${DELETEFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETEFILES} echo "" fi if [ -n "${DELETESYMLINKS}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${DELETESYMLINKS} + ${CLEANUP_DRYRUN} || clean_pkgs ${DELETESYMLINKS} echo "" fi if [ -n "${EXTRAFILES}" ]; then - ${CLEANUP_DRYRUN} || rm -f ${EXTRAFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${EXTRAFILES} echo "" fi @@ -202,6 +212,6 @@ fi if [ -d "$ftppath_base/any" -a -n "${ARCHINDEPFILES}" ]; then cd "$ftppath_base/any" - ${CLEANUP_DRYRUN} || rm -f ${ARCHINDEPFILES} + ${CLEANUP_DRYRUN} || clean_pkgs ${ARCHINDEPFILES} echo "" fi |