mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
firmware: simplify upgrade procedure #4500
This commit is contained in:
parent
14416172b1
commit
52594df3e3
@ -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';
|
||||
|
||||
@ -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');
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user