Commit 23530144 authored by Franco Fichtner's avatar Franco Fichtner

rc: last minor tweaks for big effect

o > 16 hours of randomisation is too much, let cron jobs
  run within 15 minutes.
o Move to `jot' utility for better visibility/portability.
o switch the default bogons invoke to right now, only
  defer the run if `cron' argument was given.
parent b0daaef4
...@@ -2307,14 +2307,14 @@ function configure_cron() ...@@ -2307,14 +2307,14 @@ function configure_cron()
/* bogons fetch always set in default config.xml */ /* bogons fetch always set in default config.xml */
switch ($config['system']['bogons']['interval']) { switch ($config['system']['bogons']['interval']) {
case 'daily': case 'daily':
$autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons', '1', '3', '*', '*', '*'); $autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons cron', '1', '3', '*', '*', '*');
break; break;
case 'weekly': case 'weekly':
$autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons', '1', '3', '*', '*', '0'); $autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons cron', '1', '3', '*', '*', '0');
break; break;
case 'monthly': case 'monthly':
default: default:
$autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons', '1', '3', '1', '*', '*'); $autocron[] = generate_cron_job('/usr/local/etc/rc.update_bogons cron', '1', '3', '1', '*', '*');
break; break;
} }
......
#!/bin/sh #!/bin/sh
DESTDIR="/usr/local/etc"
WORKDIR="/tmp/bogons"
FETCH="fetch -aqT 30"
PROC_ERROR=
COMMAND=${1}
CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null) CORE_ABI=$(cat /usr/local/opnsense/version/opnsense.abi 2> /dev/null)
SYS_ABI=$(opnsense-verify -a 2> /dev/null) SYS_ABI=$(opnsense-verify -a 2> /dev/null)
...@@ -10,20 +17,12 @@ if [ -n "${CORE_ABI}" -a -n "${SYS_ABI}" ]; then ...@@ -10,20 +17,12 @@ if [ -n "${CORE_ABI}" -a -n "${SYS_ABI}" ]; then
fi fi
URL="${URL}/sets/bogons.txz" URL="${URL}/sets/bogons.txz"
DESTDIR="/usr/local/etc"
WORKDIR="/tmp/bogons"
FETCH="fetch -aqT 30"
proc_error=
echo "rc.update_bogons is starting up." | logger echo "rc.update_bogons is starting up." | logger
# Sleep for some time, unless an argument is specified. if [ "${COMMAND}" = "cron" ]; then
if [ -z "$1" ]; then VALUE=$(jot -r 1 1 900)
# Grab a random value echo "rc.update_bogons is sleeping for ${VALUE} seconds" | logger
value=`od -A n -d -N2 /dev/random | awk '{ print $1 }'` sleep ${VALUE}
echo "rc.update_bogons is sleeping for $value" | logger
sleep $value
fi fi
echo "rc.update_bogons is beginning the update cycle." | logger echo "rc.update_bogons is beginning the update cycle." | logger
...@@ -36,16 +35,16 @@ ${FETCH} -o ${WORKDIR}/bogons.txz "${URL}" ...@@ -36,16 +35,16 @@ ${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="true" 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
proc_error="true" PROC_ERROR=1
elif ! tar -C ${WORKDIR} -xJf ${WORKDIR}/bogons.txz; then elif ! tar -C ${WORKDIR} -xJf ${WORKDIR}/bogons.txz; then
echo "Could not extract ${URL}" | logger echo "Could not extract ${URL}" | logger
proc_error="true" PROC_ERROR=1
fi fi
if [ -n "${proc_error}" ]; then if [ -n "${PROC_ERROR}" ]; then
# Relaunch and sleep # Relaunch and sleep
sh /usr/local/etc/rc.update_bogons & sh /usr/local/etc/rc.update_bogons &
exit exit
......
...@@ -54,7 +54,7 @@ type:script ...@@ -54,7 +54,7 @@ type:script
message:delete entry from pf table ( %s / %s ) message:delete entry from pf table ( %s / %s )
[update.bogons] [update.bogons]
command:/usr/local/etc/rc.update_bogons now command:/usr/local/etc/rc.update_bogons
parameters: parameters:
type:script type:script
message:update bogons database message:update bogons database
......
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