firmware: simplify repo file flush

This commit is contained in:
Franco Fichtner 2021-08-17 09:37:39 +02:00
parent 07d6658492
commit 588fbfbbc9

View File

@ -770,35 +770,26 @@ function get_memory()
function system_firmware_configure($verbose = false)
{
global $config, $g;
global $config;
if ($verbose) {
echo 'Writing firmware setting...';
flush();
}
/* rewrite the config via the defaults */
$origin_conf = '/usr/local/etc/pkg/repos/OPNsense.conf';
copy("{$origin_conf}.sample", $origin_conf);
$args = [];
if (!empty($config['system']['firmware']['mirror'])) {
mwexecf(
'/usr/local/sbin/opnsense-update %s %s',
array('-sm', str_replace('/', '\/', $config['system']['firmware']['mirror']))
);
$args[] = exec_safe('-m %s', str_replace('/', '\/', $config['system']['firmware']['mirror']));
}
if (!empty($config['system']['firmware']['flavour'])) {
mwexecf(
'/usr/local/sbin/opnsense-update -sn %s',
str_replace('/', '\/', sprintf(
"%s{$config['system']['firmware']['flavour']}",
/* if there is no directory slash we always treat it with default ABI prefix */
strpos($config['system']['firmware']['flavour'], '/') === false ? "${g['product_abi']}/" : ''
))
);
$args[] = exec_safe('-n %s', str_replace('/', '\/', $config['system']['firmware']['flavour']));
}
/* rewrite the config via the defaults and possible arguments */
mwexec('/usr/local/sbin/opnsense-update -sd ' . join(' ', $args));
if ($verbose) {
echo "done.\n";
}