diff --git a/src/etc/rc.firmware b/src/etc/rc.firmware index c933b9cbb..fc54fa95d 100755 --- a/src/etc/rc.firmware +++ b/src/etc/rc.firmware @@ -27,6 +27,6 @@ SUBR=/usr/local/etc/rc.firmware.subr -if ! /usr/local/opnsense/scripts/firmware/launcher.sh ${SUBR} "${@}"; then +if ! /usr/local/opnsense/scripts/firmware/launcher.sh -s ${SUBR} "${@}"; then echo "A firmware action is currently in progress." fi diff --git a/src/opnsense/scripts/firmware/launcher.sh b/src/opnsense/scripts/firmware/launcher.sh index d8f617c75..c696f5fe0 100755 --- a/src/opnsense/scripts/firmware/launcher.sh +++ b/src/opnsense/scripts/firmware/launcher.sh @@ -43,8 +43,39 @@ update upgrade " -SELECTED=${1} -shift +DO_RANDOM= +DO_SCRIPT= + +while getopts r:s: OPT; do + case ${OPT} in + r) + DO_RANDOM="-r $(jot -r 1 1 ${OPTARG})" + ;; + s) + # make sure the script exists + if [ ! -f "${OPTARG}" ]; then + exit 1 + fi + DO_SCRIPT="-s ${OPTARG}" + ;; + *) + # ignore unknown + ;; + esac +done + +shift $((${OPTIND} - 1)) + +if [ -n "${DO_SCRIPT}" ]; then + SELECTED=${DO_SCRIPT#"-s "} +else + SELECTED=${1} + shift +fi + +if [ -n "${DO_RANDOM}" ]; then + sleep ${DO_RANDOM#"-r "} +fi if [ -f "${SELECTED}" ]; then ${FLOCK} ${LOCKFILE} ${SELECTED} "${@}" diff --git a/src/opnsense/service/conf/actions.d/actions_firmware.conf b/src/opnsense/service/conf/actions.d/actions_firmware.conf index 8a4d19947..cdf0c01fe 100644 --- a/src/opnsense/service/conf/actions.d/actions_firmware.conf +++ b/src/opnsense/service/conf/actions.d/actions_firmware.conf @@ -9,6 +9,12 @@ command:/usr/local/opnsense/scripts/firmware/launcher.sh check parameters:%s type:script message:Running firmware update status + +[poll] +command:/usr/local/opnsense/scripts/firmware/launcher.sh -r 1500 check +parameters:%s +type:script +message:Running firmware update status via cron description:Firmware update check [flush] @@ -200,8 +206,8 @@ type:script message:issued firmware power off [auto-update] -command:/usr/local/etc/rc.firmware +command:/usr/local/etc/rc.firmware -r 1500 description:Automatic firmware update parameters:%s type:script -message:attempting automatic firmware update +message:Attempting automatic firmware update via cron