Commit bcd89930 authored by Ad Schellevis's avatar Ad Schellevis

(firmware) add upgrade action

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