diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-12-31 17:09:29 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-01 22:04:41 -0500 |
commit | baf990333197d42fc25e3220b2bbc97ea03d88a4 (patch) | |
tree | 39142520293d1d2e7f3586029812946af6c3317d /get-repos | |
parent | 877eaef7357c5ca171e15de16ffce055da68af2f (diff) |
get-repos: clean up temp directory handling
- rename $TMPDIR to $WORKDIR
- respect environmental $TMPDIR
- use a trap to clean up,instead of a command at the end
Diffstat (limited to 'get-repos')
-rwxr-xr-x | get-repos | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -19,7 +19,9 @@ 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 -TMPDIR="$(mktemp -d /tmp/$(basename $0).XXXX)" +WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX") +trap "rm -rf -- $(printf '%q' "${WORKDIR}")" EXIT + DBLIST=() # Repos @@ -31,7 +33,7 @@ done # Get them all msg "Retrieving ${#DBLIST[@]} databases" -wget --directory-prefix=${TMPDIR} \ +wget --directory-prefix=${WORKDIR} \ --no-verbose \ --force-directories \ --no-host-directories \ @@ -42,7 +44,7 @@ wget --directory-prefix=${TMPDIR} \ arch_re="$(echo "(${ARCHES[@]} i586)" | tr ' ' '|')" msg "Adding to parabolaweb" -find "${TMPDIR}" -iname "*${FILESEXT}" | while read _db; do +find "${WORKDIR}" -iname "*${FILESEXT}" | while read _db; do _arch=$(echo "${_db}" | egrep -o "${arch_re}") if [ -z "${_arch}" ]; then @@ -52,7 +54,3 @@ find "${TMPDIR}" -iname "*${FILESEXT}" | while read _db; do "${WEB_DIR}"/manage.py reporead "${_arch}" "${_db}" || true done - -rm -r ${TMPDIR} - -exit $? |