firmware: restructure upgrade code

Goes over the previous change by calling the reboot only once
instead of three times:

Here we are told there are upgrades pending and the upgrade hooks
were returning successfully.  Apply the kernel immediately if
necessary to save a reboot.  Contrary to popular belief the kernel
can still apply during a reboot if something went wrong, but this
way we save a reboot.  After that don't question that a reboot is
necessary to avoid ever falling into the error case for no reason.
This commit is contained in:
Franco Fichtner 2026-02-13 09:52:32 +01:00
parent 0e31c27ef7
commit 22b36dcc4b

View file

@ -31,14 +31,10 @@ REQUEST="UPGRADE"
if output_cmd opnsense-update -u; then
if output_cmd /usr/local/etc/rc.syshook upgrade; then
# no pending kernels but still need a reboot
if ! output_cmd opnsense-update -K -c; then
output_reboot keep-log
# pending kernel applies before reboot
elif output_cmd opnsense-update -K; then
output_reboot keep-log
if output_cmd opnsense-update -K -c; then
output_cmd opnsense-update -K
fi
# kernel is already applied so continue
output_reboot keep-log
fi