firmware: hook up 'latest' script, use it in dashboard widget as well

Paired with a nightly cron job this can hint at updates on a daily basis
automatically now.
This commit is contained in:
Franco Fichtner 2021-11-16 11:00:40 +01:00
parent cd77cec93a
commit 82d21d0775
5 changed files with 23 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2018 Deciso B.V.
* Copyright (C) 2018-2021 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -168,8 +168,8 @@ function core_cron()
$jobs[]['autocron'] = array('/usr/local/sbin/expiretable -v -t 3600 virusprot', '2');
$jobs[]['autocron'] = array('/usr/local/etc/rc.expireaccounts', '3');
$jobs[]['autocron'] = array('/usr/local/opnsense/scripts/syslog/log_archive ', '4');
$jobs[]['autocron'] = array('/usr/local/sbin/ping_hosts.sh', '*/4');
$jobs[]['autocron'] = array('configctl firmware changelog cron', '0', '22');
if (!empty($config['system']['rrdbackup']) && $config['system']['rrdbackup'] > 0) {
$jobs[]['autocron'] = array(

View File

@ -35,10 +35,10 @@ $ret = json_decode(@file_get_contents($changelogfile), true);
if ($ret != null) {
foreach ($ret as $entry) {
if ($entry['series'] == $series) {
if (version_compare($entry['version'], $version, '>')) {
$version = $entry['version'];
}
}
if (version_compare($entry['version'], $version, '>')) {
$version = $entry['version'];
}
}
}
}

View File

@ -32,6 +32,7 @@ $metafile = '/usr/local/opnsense/version/core';
$ret = json_decode(@file_get_contents($metafile), true);
if ($ret != null) {
$ret['product_crypto'] = trim(shell_exec('opnsense-version -f'));
$ret['product_latest'] = trim(shell_exec('/usr/local/opnsense/scripts/firmware/latest.php'));
$ret['product_mirror'] = preg_replace('/\/[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}\//i', '/${SUBSCRIPTION}/', trim(shell_exec('opnsense-update -M')));
$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')));

View File

@ -17,6 +17,12 @@ parameters:
type:script
message:Flush firmware update status
[changelog.latest]
command: /usr/local/opnsense/scripts/firmware/latest.php
parameters:
type:script_output
message:Checking for latest version in changelog
[changelog.fetch]
command: /usr/local/opnsense/scripts/firmware/changelog.sh fetch
parameters:

View File

@ -167,14 +167,20 @@ function system_api_firmware()
$ret = gettext('Click to check for updates.');
$product = json_decode(configd_run('firmware product'), true);
if (
!empty($product['product_check']['upgrade_sets']) ||
/* information from changelog, more accurate for production release */
$from_changelog = !empty($product['product_latest']) &&
$product['product_latest'] != $product['product_version'];
/* update status from last check, also includes major releases */
$from_check = !empty($product['product_check']['upgrade_sets']) ||
!empty($product['product_check']['downgrade_packages']) ||
!empty($product['product_check']['new_packages']) ||
!empty($product['product_check']['reinstall_packages']) ||
!empty($product['product_check']['remove_packages']) ||
!empty($product['product_check']['upgrade_packages'])
) {
!empty($product['product_check']['upgrade_packages']);
if ($from_changelog || $from_check) {
$ret = gettext('Click to view pending updates.');
}