Commit bcd89930 authored by Ad Schellevis's avatar Ad Schellevis

(firmware) add upgrade action

parent ee863f0b
......@@ -59,10 +59,12 @@ class FirmwareController extends ApiControllerBase
$response["status_msg"] = "no updates found";
} elseif (array_key_exists("updates", $response) && $response["upgrade_packages"][0]["name"] == "pkg") {
$response["status"] = "ok";
$response["status_upgrade_action"] = "pkg";
$response["status_msg"] = "There is a mandatory update for the package manager. ".
"Please install and check for updates again.";
} elseif (array_key_exists("updates", $response)) {
$response["status"] = "ok";
$response["status_upgrade_action"] = "all";
$response["status_msg"] = sprintf("A total of %s update(s) are available.", $response["updates"]);
}
} else {
......@@ -81,9 +83,14 @@ class FirmwareController extends ApiControllerBase
{
$backend = new Backend();
$response =array();
if ($this->request->isPost()) {
if ($this->request->hasPost("upgrade")) {
$response['status'] = 'ok';
$response['uuid'] = trim($backend->configdRun("firmware upgrade", true));
if ($this->request->getPost("upgrade") == "pkg") {
$action = "firmware upgrade pkg";
} else {
$action = "firmware upgrade all";
}
$response['msg_uuid'] = trim($backend->configdRun($action, true));
} else {
$response['status'] = 'failure';
}
......
......@@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
$("#checkupdate_progress").removeClass("fa fa-spinner fa-pulse");
if (data['status'] == "ok") {
$.upgrade_action = data['status_upgrade_action'];
// unhide upgrade button
$("#upgrade").attr("style","");
// show upgrade list
......@@ -80,7 +81,8 @@ POSSIBILITY OF SUCH DAMAGE.
$('#maintabs li:eq(1) a').tab('show');
$('#updatestatus').html("{{ lang._('Starting Upgrade.. Please do not leave this page while upgrade is in progress.') }}");
$("#upgrade_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall('/api/core/firmware/upgrade',{},function() {
ajaxCall('/api/core/firmware/upgrade',{upgrade:$.upgrade_action},function() {
$("#upgrade_progress").removeClass("fa fa-spinner fa-pulse");
setTimeout(trackStatus, 1000) ;
});
......@@ -106,6 +108,7 @@ POSSIBILITY OF SUCH DAMAGE.
type:BootstrapDialog.TYPE_INFO,
title: "{{ lang._('Upgrade') }}",
message: "{{ lang._('The upgrade is finished and your device is being rebooted at the moment, please wait.') }}",
closable: false,
buttons: [{
label: "{{ lang._('Close') }}",
cssClass: 'btn-success',
......
......@@ -6,9 +6,10 @@ message:retrieve package status
[upgrade]
command: /usr/sbin/daemon -f /usr/local/opnsense/scripts/pkg_upgrade.sh
parameters:
parameters:%s
type:script
message:perform upgrade
message:perform upgrade %s
[upgrade_status]
command:cat /tmp/pkg_upgrade.progress 2>&1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment