diff --git a/update-list.sh b/update-list.sh index f6b1600..40b929d 100755 --- a/update-list.sh +++ b/update-list.sh @@ -4,18 +4,24 @@ CONFDIR="/etc/unbound" CONFFILE="always-deny.conf" CONF="${CONFDIR}/${CONFFILE}" SOURCES="${CONFDIR}/sources" -BUILDDIR="/tmp/$(openssl rand -hex 42)" +BUILDDIR="$(openssl rand -hex 42)" + +cleanup() +{ + cd /tmp || cd || true + rm -r "${BUILDDIR}" +} update_sources() { - mkdir -p "${BUILDDIR}" && cd "${BUILDDIR}" || exit 1 + mkdir -p "/tmp/${BUILDDIR}" && cd "/tmp/${BUILDDIR}" || exit 1 cat "${SOURCES}" | while read -r src do curl -#LO "$src" done find . -type f | while read -r file do - cat "$file" | tee -a domains + cat "${file}" | tee -a domains done } @@ -31,5 +37,7 @@ format_sources() done | tee "${CONF}" } +trap cleanup QUIT INT TERM EXIT + update_sources format_sources