firmware: provide upgrade log "audit" for #5855

This commit is contained in:
Franco Fichtner 2022-07-14 15:18:06 +02:00
parent aaaf842462
commit 8d56b78153
4 changed files with 43 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (c) 2015-2021 Franco Fichtner <franco@opnsense.org>
* Copyright (c) 2015-2022 Franco Fichtner <franco@opnsense.org>
* Copyright (c) 2015-2018 Deciso B.V.
* All rights reserved.
*
@ -369,6 +369,27 @@ class FirmwareController extends ApiControllerBase
return $response;
}
/**
* Retrieve upgrade log hidden in system
* @return string with upgrade log
* @throws \Exception
*/
public function logAction()
{
$this->sessionClose(); // long running action, close session
$backend = new Backend();
$response = [];
if ($this->request->isPost()) {
$text = trim($backend->configdRun('firmware log'));
if (!empty($text)) {
$response['log'] = $text;
}
}
return $response;
}
/**
* Retrieve specific license for package in text format
* @param string $package package to retrieve

View File

@ -447,6 +447,11 @@
);
}
if (data['product']['product_log']) {
$('#audit_upgrade').parent().show();
} else {
$('#audit_upgrade').parent().hide();
}
$('#audit_actions').show();
$("#plugin_search").keyup();
$("#package_search").keyup();
@ -598,6 +603,13 @@
$('#audit_security').click(function () { backend('audit'); });
$('#audit_connection').click(function () { backend('connection'); });
$('#audit_health').click(function () { backend('health'); });
$('#audit_upgrade').click(function () {
ajaxCall('/api/core/firmware/log', {}, function (data, status) {
if (data['log'] != undefined) {
stdDialogInform("{{ lang._('Upgrade log') }}", data['log'], "{{ lang._('Close') }}");
}
});
});
// populate package information
packagesInfo(true);
@ -872,6 +884,7 @@
<li><a id="audit_connection" href="#">{{ lang._('Connectivity') }}</a></li>
<li><a id="audit_health" href="#">{{ lang._('Health') }}</a></li>
<li><a id="audit_security" href="#">{{ lang._('Security') }}</a></li>
<li><a id="audit_upgrade" href="#">{{ lang._('Upgrade') }}</a></li>
</ul>
</div>
<div class="btn-group" id="plugin_actions" style="display:none;">

View File

@ -2,7 +2,7 @@
<?php
/*
* Copyright (c) 2021 Franco Fichtner <franco@opnsense.org>
* Copyright (c) 2021-2022 Franco Fichtner <franco@opnsense.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,6 +37,7 @@ if ($ret != null) {
$ret['product_time'] = date('D M j H:i:s T Y', filemtime('/usr/local/opnsense/www/index.php'));
$repos = explode("\n", trim(shell_exec('opnsense-verify -l')));
sort($repos);
$ret['product_log'] = empty(trim(shell_exec('opnsense-update -G'))) ? 0 : 1;
$ret['product_repos'] = implode(', ', $repos);
$ret['product_check'] = json_decode(@file_get_contents('/tmp/pkg_upgrade.json'), true);
ksort($ret);

View File

@ -23,6 +23,12 @@ parameters:
type:script
message:Flush firmware update status
[log]
command:/usr/local/sbin/opnsense-update -G
parameters:
type:script_output
message:Requesting firmware upgrade log
[changelog.latest]
command:/usr/local/opnsense/scripts/firmware/latest.php
parameters: