summaryrefslogtreecommitdiff
path: root/get-repos
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-31 17:09:29 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-01 22:04:41 -0500
commitbaf990333197d42fc25e3220b2bbc97ea03d88a4 (patch)
tree39142520293d1d2e7f3586029812946af6c3317d /get-repos
parent877eaef7357c5ca171e15de16ffce055da68af2f (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-xget-repos12
1 files changed, 5 insertions, 7 deletions
diff --git a/get-repos b/get-repos
index 2921dd0..5096433 100755
--- a/get-repos
+++ b/get-repos
@@ -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 $?