firmware: handle script errors by aborting the upgrade #6594

The individual scripts should return an error and clean up
their state in case they aborted (which isn't too easy but
in most cases moving the relevant files to the final location
is a good way of dealing with this problem).
This commit is contained in:
Franco Fichtner 2023-06-05 13:31:51 +02:00
parent cea3afd44c
commit 5f60391b63

View File

@ -38,11 +38,15 @@ echo "Currently running $(opnsense-version) at $(date)" >> ${LOCKFILE}
${TEE} ${LOCKFILE} < ${PIPEFILE} &
if opnsense-update -u > ${PIPEFILE} 2>&1; then
/usr/local/etc/rc.syshook upgrade
echo '***REBOOT***' >> ${LOCKFILE}
sleep 5
/usr/local/etc/rc.reboot
${TEE} ${LOCKFILE} < ${PIPEFILE} &
if ! /usr/local/etc/rc.syshook upgrade > ${PIPEFILE} 2>&1; then
# aboort pending upgrades
opnsense-update -e >> ${LOCKFILE} 2>&1
else
echo '***REBOOT***' >> ${LOCKFILE}
sleep 5
/usr/local/etc/rc.reboot
fi
fi
echo '***DONE***' >> ${LOCKFILE}