diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php index f156457cd..5eff730de 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php @@ -239,10 +239,8 @@ class FirmwareController extends ApiControllerBase $response['status_msg'], gettext('All available updates will be installed in the background as well.') ); - $response['status_upgrade_action'] = 'rel'; $response['status'] = 'ok'; } else { - $response['status_upgrade_action'] = 'all'; $response['status'] = 'ok'; if ($response['updates'] == 1) { /* keep this dynamic for template translation even though %s is always '1' */ @@ -403,24 +401,16 @@ class FirmwareController extends ApiControllerBase } /** - * perform actual upgrade + * perform (major) upgrade * @return array status * @throws \Exception */ public function upgradeAction() { - $this->sessionClose(); // long running action, close session $backend = new Backend(); $response = array(); - if ($this->request->hasPost('upgrade')) { - if ($this->request->getPost('upgrade') == 'maj') { - $action = 'firmware upgrade maj'; - } elseif ($this->request->getPost('upgrade') == 'rel') { - $action = 'firmware upgrade rel'; - } else { - $action = 'firmware upgrade all'; - } - $response['msg_uuid'] = trim($backend->configdRun($action, true)); + if ($this->request->isPost()) { + $response['msg_uuid'] = trim($backend->configdRun('firmware upgrade', true)); $response['status'] = 'ok'; } else { $response['status'] = 'failure'; diff --git a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt index 7909d4bc4..1ec11bb31 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt @@ -73,7 +73,6 @@ $('.updatestatus').html(data['status_msg']); if (data['status'] == "ok") { - $.upgrade_action = data['status_upgrade_action']; $.upgrade_needs_reboot = data['upgrade_needs_reboot']; $.upgrade_show_log = ''; @@ -246,7 +245,7 @@ action: function(dialogRef){ dialogRef.close(); if ($.upgrade_action == 'maj') { - backend('upgrade', {upgrade:$.upgrade_action}); + backend('upgrade'); } else { backend('update'); } @@ -260,7 +259,7 @@ }); } else { if ($.upgrade_action == 'maj') { - backend('upgrade', {upgrade:$.upgrade_action}); + backend('upgrade'); } else { backend('update'); } diff --git a/src/opnsense/scripts/firmware/check.sh b/src/opnsense/scripts/firmware/check.sh index 23f22c12e..4c94e97f6 100755 --- a/src/opnsense/scripts/firmware/check.sh +++ b/src/opnsense/scripts/firmware/check.sh @@ -335,9 +335,11 @@ fi fi fi - # XXX use opnsense-update -SRp to check for download size before advertising - upgrade_major_message=$(cat /usr/local/opnsense/firmware-message 2> /dev/null | sed 's/"/\\&/g' | tr '\n' ' ') - upgrade_major_version=$(cat /usr/local/opnsense/firmware-upgrade 2> /dev/null) + packages_is_size="$(opnsense-update -SRp)" + if [ -n "${packages_is_size}" ]; then + upgrade_major_message=$(cat /usr/local/opnsense/firmware-message 2> /dev/null | sed 's/"/\\&/g' | tr '\n' ' ') + upgrade_major_version=$(cat /usr/local/opnsense/firmware-upgrade 2> /dev/null) + fi # write our json structure cat > ${JSONFILE} << EOF diff --git a/src/opnsense/scripts/firmware/upgrade.sh b/src/opnsense/scripts/firmware/upgrade.sh index d8bec14e5..306c50f9f 100755 --- a/src/opnsense/scripts/firmware/upgrade.sh +++ b/src/opnsense/scripts/firmware/upgrade.sh @@ -26,55 +26,14 @@ # POSSIBILITY OF SUCH DAMAGE. PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress -PACKAGE=${1} -REBOOT= # Truncate upgrade progress file : > ${PKG_PROGRESS_FILE} -echo "***GOT REQUEST TO UPGRADE: ${PACKAGE}***" >> ${PKG_PROGRESS_FILE} +echo "***GOT REQUEST TO UPGRADE***" >> ${PKG_PROGRESS_FILE} -if [ "${PACKAGE}" == "all" ]; then - # update all installed packages - opnsense-update -p >> ${PKG_PROGRESS_FILE} 2>&1 - # restart the web server - /usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE} 2>&1 - # if we can update base, we'll do that as well - if opnsense-update -c >> ${PKG_PROGRESS_FILE} 2>&1; then - if opnsense-update -bk >> ${PKG_PROGRESS_FILE} 2>&1; then - REBOOT=1 - fi - fi -elif [ "${PACKAGE}" == "maj" ]; then - # extract info for major upgrade - UPGRADE="/usr/local/opnsense/firmware-upgrade" - NAME=unknown - if [ -f ${UPGRADE} ]; then - NAME=$(cat ${UPGRADE}) - fi - # perform first half of major upgrade - # (download all + kernel install) - # XXX use opnsense-update -uR at least unless we can imply -R later - if opnsense-update -ur "${NAME}" >> ${PKG_PROGRESS_FILE} 2>&1; then - REBOOT=1 - fi - # second half reboots multiple times, - # but will snap the GUI back when done -elif [ "${PACKAGE}" == "rel" ]; then - # figure out the release type from config - SUFFIX="-$(pluginctl -g system.firmware.type)" - if [ "${SUFFIX}" = "-" ]; then - SUFFIX= - fi - # change the release type - opnsense-update -t "opnsense${SUFFIX}" >> ${PKG_PROGRESS_FILE} 2>&1 - # restart the web server - /usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE} 2>&1 -else - echo "Cannot update ${PACKAGE}" >> ${PKG_PROGRESS_FILE} -fi - -if [ -n "${REBOOT}" ]; then +# perform first half of major upgrade (download all + kernel install) +if opnsense-update -uR >> ${PKG_PROGRESS_FILE} 2>&1; then echo '***REBOOT***' >> ${PKG_PROGRESS_FILE} # give the frontend some time to figure out that a reboot is coming sleep 5 diff --git a/src/opnsense/service/conf/actions.d/actions_firmware.conf b/src/opnsense/service/conf/actions.d/actions_firmware.conf index 6f2fd7814..14ac771b4 100644 --- a/src/opnsense/service/conf/actions.d/actions_firmware.conf +++ b/src/opnsense/service/conf/actions.d/actions_firmware.conf @@ -74,9 +74,9 @@ message:Running firmware update [upgrade] command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh upgrade -parameters:%s +parameters: type:script -message:Upgrading %s +message:Running firmware upgrade [reinstall] command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/firmware/launcher.sh reinstall