Commit eb7a9a31 authored by Ad Schellevis's avatar Ad Schellevis

move firmware mirror/flavour settings to firmware page, closes...

move firmware mirror/flavour settings to firmware page, closes https://github.com/opnsense/core/issues/834
parent 419d6d72
......@@ -243,39 +243,6 @@ function get_country_codes()
return $dn_cc;
}
function get_firmware_mirrors()
{
$mirrors = array();
$mirrors['default'] = '(default)';
$mirrors['https://opnsense.aivian.org'] = 'Aivian (Shaoxing, CN)';
$mirrors['https://mirror.auf-feindgebiet.de/opnsense'] = 'auf-feindgebiet.de (Karlsruhe, DE)';
$mirrors['https://opnsense.c0urier.net'] = 'c0urier.net (Lund, SE)';
$mirrors['https://fleximus.org/mirror/opnsense'] = 'Fleximus (Roubaix, FR)';
$mirrors['http://mirror.ams1.nl.leaseweb.net/opnsense'] = 'LeaseWeb (Amsterdam, NL)';
$mirrors['http://mirror.fra10.de.leaseweb.net/opnsense'] = 'LeaseWeb (Frankfurt, DE)';
$mirrors['http://mirror.sfo12.us.leaseweb.net/opnsense'] = 'LeaseWeb (San Francisco, US)';
$mirrors['http://mirror.wdc1.us.leaseweb.net/opnsense'] = 'LeaseWeb (Washington, D.C., US)';
$mirrors['http://mirrors.nycbug.org/pub/opnsense'] = 'NYC*BUG (New York, US)';
$mirrors['http://pkg.opnsense.org'] = 'OPNsense (Amsterdam, NL)';
$mirrors['http://mirror.ragenetwork.de/opnsense'] = 'RageNetwork (Munich, DE)';
$mirrors['http://mirrors.supranet.net/pub/opnsense'] = 'Supranet Communications (Middleton, US)';
$mirrors['http://mirror.wjcomms.co.uk/opnsense'] = 'WJComms (London, GB)';
return $mirrors;
}
function get_firmware_flavours()
{
$flavours = array();
$flavours['default'] = '(default)';
$flavours['libressl'] = 'LibreSSL';
$flavours['latest'] = 'OpenSSL';
return $flavours;
}
function get_zoneinfo()
{
$zones = timezone_identifiers_list(DateTimeZone::ALL ^ DateTimeZone::UTC);
......@@ -1420,16 +1387,16 @@ function system_firmware_configure()
$origin_conf = '/usr/local/etc/pkg/repos/origin.conf';
copy("${origin_conf}.sample", $origin_conf);
if (isset($config['system']['firmware']['mirror'])) {
configd_run('firmware mirror ' . escapeshellarg(
str_replace('/', '\/', $config['system']['firmware']['mirror'])
));
if (!empty($config['system']['firmware']['mirror'])) {
mwexecf("/usr/local/sbin/opnsense-update %s %s",
array("-sm", str_replace('/', '\/', $config['system']['firmware']['mirror']))
);
}
if (isset($config['system']['firmware']['flavour'])) {
configd_run('firmware flavour ' . escapeshellarg(
str_replace('/', '\/', $osabi . '/' . $config['system']['firmware']['flavour'])
));
if (!empty($config['system']['firmware']['flavour'])) {
mwexecf("/usr/local/sbin/opnsense-update %s %s",
array("-sn", str_replace('/', '\/', $osabi . '/' . $config['system']['firmware']['flavour']))
);
}
}
......
......@@ -466,6 +466,9 @@ class FirmwareController extends ApiControllerBase
Config::getInstance()->object()->system->firmware->flavour = $selectedFlavour;
Config::getInstance()->save();
$backend = new Backend();
$backend->configdRun("firmware configure");
}
return $response;
......
......@@ -329,10 +329,13 @@ POSSIBILITY OF SUCH DAMAGE.
});
$("#change_mirror").click(function(){
$("#change_mirror_progress").addClass("fa fa-spinner fa-pulse");
var confopt = {};
confopt.mirror = $("#firmware_mirror").val()
confopt.flavour = $("#firmware_flavour").val()
ajaxCall(url='/api/core/firmware/setFirmwareConfig',sendData=confopt);
ajaxCall(url='/api/core/firmware/setFirmwareConfig',sendData=confopt, callback=function(data,status) {
$("#change_mirror_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
......@@ -389,7 +392,7 @@ POSSIBILITY OF SUCH DAMAGE.
<tr>
<td></td>
<td>
<button class="btn btn-primary" id="change_mirror" type="button"><b>{{ lang._('Change') }}</b></button>
<button class="btn btn-primary" id="change_mirror" type="button"><b>{{ lang._('Change') }}</b><i id="change_mirror_progress" class=""></i></button>
</td>
<td></td>
</tr>
......
......@@ -70,17 +70,11 @@ parameters:
type:script_output
message:view remote packages
[mirror]
command:/usr/local/sbin/opnsense-update -sm
parameters:%s
type:script
message:switching firmware mirror to %s
[flavour]
command:/usr/local/sbin/opnsense-update -sn
parameters:%s
[configure]
command:/usr/local/etc/rc.configure_firmware
parameters:
type:script
message:switching firmware flavour to %s
message:update firmware configuration
[reboot]
command:/usr/local/etc/rc.reboot
......
......@@ -65,8 +65,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['theme'] = null;
$pconfig['language'] = null;
$pconfig['timezone'] = "Etc/UTC";
$pconfig['mirror'] = 'default';
$pconfig['flavour'] = 'default';
$pconfig['prefer_ipv4'] = isset($config['system']['prefer_ipv4']);
$pconfig['gw_switch_default'] = isset($config['system']['gw_switch_default']);
$pconfig['hostname'] = $config['system']['hostname'];
......@@ -94,14 +92,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['language'] = $config['system']['language'];
}
$pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']);
if (isset($config['system']['firmware']['mirror'])) {
$pconfig['mirror'] = $config['system']['firmware']['mirror'];
}
if (isset($config['system']['firmware']['flavour'])) {
$pconfig['flavour'] = $config['system']['firmware']['flavour'];
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['timezone']) && $pconfig['timezone'] <> $_POST['timezone']) {
filter_pflog_start();
......@@ -172,26 +162,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
set_language();
}
if (!isset($config['system']['firmware'])) {
$config['system']['firmware'] = array();
}
if ($pconfig['mirror'] == 'default') {
if (isset($config['system']['firmware']['mirror'])) {
/* default does not set anything for backwards compat */
unset($config['system']['firmware']['mirror']);
}
} else {
$config['system']['firmware']['mirror'] = $pconfig['mirror'];
}
if ($pconfig['flavour'] == 'default') {
if (isset($config['system']['firmware']['flavour'])) {
/* default does not set anything for backwards compat */
unset($config['system']['firmware']['flavour']);
}
} else {
$config['system']['firmware']['flavour'] = $pconfig['flavour'];
}
if (!empty($pconfig['prefer_ipv4'])) {
$config['system']['prefer_ipv4'] = true;
} elseif (isset($config['system']['prefer_ipv4'])) {
......@@ -278,7 +248,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
services_dnsmasq_configure();
services_unbound_configure();
system_timezone_configure();
system_firmware_configure();
if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {
configd_run("dns reload");
......@@ -405,44 +374,6 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_mirror" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Firmware Mirror"); ?></td>
<td>
<select name="mirror" class="selectpicker" data-size="10" data-width="auto">
<?php
foreach (get_firmware_mirrors() as $mcode => $mdesc):?>
<option value="<?=$mcode;?>" <?=$mcode == $pconfig['mirror'] ? "selected=\"selected\"":"";?>>
<?=$mdesc;?>
</option>
<?php
endforeach;?>
</select>
<div class="hidden" for="help_for_mirror">
<strong>
<?=gettext("Select an alternate firmware mirror."); ?>
</strong>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_flavour" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Firmware Flavour"); ?></td>
<td width="78%" class="vtable">
<select name="flavour" class="selectpicker" data-size="10" data-style="btn-default" data-width="auto">
<?php
foreach (get_firmware_flavours() as $fcode => $fdesc):?>
<option value="<?=$fcode;?>" <?=$fcode == $pconfig['flavour'] ? "selected=\"selected\"" : "" ;?>>
<?=$fdesc;?>
</option>
<?php
endforeach;?>
</select>
<div class="hidden" for="help_for_flavour">
<strong>
<?=gettext("Select the firmware cryptography flavour."); ?>
</strong>
</div>
</td>
</tr>
<tr>
<th colspan="2" valign="top" class="listtopic"><?=gettext("Name resolution"); ?></th>
</tr>
......
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