Commit 68320826 authored by Franco Fichtner's avatar Franco Fichtner

firewall: fix cron handling, retry 5 times, then abort, no fork

PR: https://forum.opnsense.org/index.php?topic=5099.0

(cherry picked from commit 1417414b)
(cherry picked from commit ef1dc387)
(cherry picked from commit ecace09a)
parent 55c13f16
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
DESTDIR="/usr/local/etc" DESTDIR="/usr/local/etc"
WORKDIR="/tmp/bogons" WORKDIR="/tmp/bogons"
FETCH="fetch -aqT 30" FETCH="fetch -aqT 30"
PROC_ERROR= RETRIES=5
COMMAND=${1} COMMAND=${1}
...@@ -17,37 +17,43 @@ if [ -n "${CORE_ABI}" -a -n "${SYS_ABI}" ]; then ...@@ -17,37 +17,43 @@ if [ -n "${CORE_ABI}" -a -n "${SYS_ABI}" ]; then
fi fi
URL="${URL}/sets/bogons.txz" URL="${URL}/sets/bogons.txz"
echo "rc.update_bogons is starting up." | logger echo "rc.update_bogons is starting up" | logger
if [ "${COMMAND}" = "cron" ]; then while [ ${RETRIES} -gt 0 ]; do
VALUE=$(jot -r 1 1 900) if [ "${COMMAND}" = "cron" ]; then
echo "rc.update_bogons is sleeping for ${VALUE} seconds" | logger VALUE=$(jot -r 1 1 900)
sleep ${VALUE} echo "rc.update_bogons is sleeping for ${VALUE} seconds" | logger
fi sleep ${VALUE}
fi
echo "rc.update_bogons is beginning the update cycle." | logger echo "rc.update_bogons is beginning the update cycle" | logger
rm -rf ${WORKDIR} rm -rf ${WORKDIR}
mkdir -p ${WORKDIR} mkdir -p ${WORKDIR}
${FETCH} -o ${WORKDIR}/bogons.txz.sig "${URL}.sig" ${FETCH} -o ${WORKDIR}/bogons.txz.sig "${URL}.sig"
${FETCH} -o ${WORKDIR}/bogons.txz "${URL}" ${FETCH} -o ${WORKDIR}/bogons.txz "${URL}"
if [ ! -f ${WORKDIR}/bogons.txz ]; then if [ ! -f ${WORKDIR}/bogons.txz ]; then
echo "Could not download ${URL}" | logger echo "Could not download ${URL}" | logger
PROC_ERROR=1 elif ! opnsense-verify -q ${WORKDIR}/bogons.txz; then
elif ! opnsense-verify -q ${WORKDIR}/bogons.txz; then echo "Could not verify ${URL}" | logger
echo "Could not verify ${URL}" | logger elif ! tar -C ${WORKDIR} -xJf ${WORKDIR}/bogons.txz; then
PROC_ERROR=1 echo "Could not extract ${URL}" | logger
elif ! tar -C ${WORKDIR} -xJf ${WORKDIR}/bogons.txz; then else
echo "Could not extract ${URL}" | logger break
PROC_ERROR=1 fi
fi
if [ "${COMMAND}" = "cron" ]; then
RETRIES=$((RETRIES - 1))
else
RETRIES=0
fi
done
if [ -n "${PROC_ERROR}" ]; then if [ ${RETRIES} -eq 0 ]; then
# Relaunch and sleep echo "rc.update_bogons is aborting the update cycle" | logger
sh /usr/local/etc/rc.update_bogons & exit 1
exit
fi fi
ENTRIES_MAX=`pfctl -s memory | awk '/table-entries/ { print $4 }'` ENTRIES_MAX=`pfctl -s memory | awk '/table-entries/ { print $4 }'`
...@@ -88,4 +94,4 @@ else ...@@ -88,4 +94,4 @@ else
fi fi
fi fi
echo "rc.update_bogons is ending the update cycle." | logger echo "rc.update_bogons is ending the update cycle" | logger
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment