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 a6dbae136..23574592e 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php @@ -116,6 +116,34 @@ class FirmwareController extends ApiControllerBase return $response; } + /** + * reinstall package + * @param string $pkg_name package name to reinstall + * @return array status + * @throws \Exception + */ + public function reinstallAction($pkg_name) + { + $backend = new Backend(); + $response =array(); + + if ($this->request->isPost()) { + $response['status'] = 'ok'; + // sanitize package name + $filter = new \Phalcon\Filter(); + $filter->add('pkgname', function($value) { + return preg_replace('/[^0-9a-zA-Z-_]/', '', $value); + }); + $pkg_name = $filter->sanitize($pkg_name, "pkgname"); + // execute action + $response['msg_uuid'] = trim($backend->configdpRun("firmware reinstall", array($pkg_name), true)); + } else { + $response['status'] = 'failure'; + } + + return $response; + } + /** * retrieve upgrade status (and log file of current process) */ diff --git a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt index 003e7c78d..7f829cf1a 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Core/firmware.volt @@ -91,6 +91,20 @@ POSSIBILITY OF SUCH DAMAGE. }); } + /** + * perform package reinstall, install poller to update status + */ + function reinstall(pkg_name) + { + $('#progresstab > a').tab('show'); + $('#updatestatus').html("{{ lang._('Reinstalling... (do not leave this page while reinstall is in progress)') }}"); + + ajaxCall('/api/core/firmware/reinstall/'+pkg_name,{},function() { + $('#updatelist').empty(); + setTimeout(trackStatus, 500); + }); + } + /** * check if a reboot is required, warn user or just upgrade */ @@ -190,7 +204,10 @@ POSSIBILITY OF SUCH DAMAGE. '