mirror of
https://github.com/unraid/webgui.git
synced 2026-04-24 02:58:57 -05:00
network settings: fix when updating description only
This commit is contained in:
@@ -92,9 +92,31 @@ refresh(); // automatically include new ethernet ports
|
||||
Array.prototype.same = function(){return this.sort().filter(function(v,i,o){return i&&v===o[i-1]?v:0;}).length;}
|
||||
|
||||
function prepareSettings(form) {
|
||||
var metrics = [];
|
||||
var metrics6 = [];
|
||||
var bondnics = [], brnics = [];
|
||||
for (var i=0,nic; nic=form.BONDNICS.options[i]; i++) {
|
||||
if (nic.selected) {
|
||||
bondnics.push(nic.value);
|
||||
nic.selected = false;
|
||||
}
|
||||
}
|
||||
nic = form.BONDNICS.options[0];
|
||||
nic.value = bondnics.join(',');
|
||||
nic.selected = true;
|
||||
nic.disabled = false;
|
||||
for (var i=0,nic; nic=form.BRNICS.options[i]; i++) {
|
||||
if (nic.selected) {
|
||||
brnics.push(nic.value);
|
||||
nic.selected = false;
|
||||
}
|
||||
}
|
||||
nic = form.BRNICS.options[0];
|
||||
nic.value = form.BONDING.value=='yes' ? form.BONDNAME.value : brnics.join(',');
|
||||
nic.selected = true;
|
||||
nic.disabled = false;
|
||||
if (brnics.length>1) form.BRSTP.value = 'yes';
|
||||
if ($(form).find('input[name="#arg[1]"]').val()=='none') return true;
|
||||
|
||||
var metrics = [], metrics6 = [];
|
||||
$(form).find('input[name^="METRIC:"]').each(function(){if($(this).val()>0) metrics.push($(this).val());});
|
||||
$(form).find('input[name^="METRIC6:"]').each(function(){if($(this).val()>0) metrics6.push($(this).val());});
|
||||
if (metrics.same() || metrics6.same()) {
|
||||
@@ -123,31 +145,6 @@ function prepareSettings(form) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var member = '';
|
||||
for (var i=0,item; item=form.BONDNICS.options[i]; i++) {
|
||||
if (item.selected) {
|
||||
if (member.length) member += ',';
|
||||
member += item.value;
|
||||
item.selected = false;
|
||||
}
|
||||
}
|
||||
item = form.BONDNICS.options[0];
|
||||
item.value = member;
|
||||
item.selected = true;
|
||||
item.disabled = false;
|
||||
var member = '';
|
||||
for (var i=0,item; item=form.BRNICS.options[i]; i++) {
|
||||
if (item.selected) {
|
||||
if (member.length) member += ',';
|
||||
member += item.value;
|
||||
item.selected = false;
|
||||
}
|
||||
}
|
||||
item = form.BRNICS.options[0];
|
||||
item.value = form.BONDING.value=='yes' ? form.BONDNAME.value : member;
|
||||
item.selected = true;
|
||||
item.disabled = false;
|
||||
if (member.indexOf(',')>0) form.BRSTP.value = 'yes';
|
||||
$(form).find('select[name^="PROTOCOL:"]').each(function() {
|
||||
var protocol = $(this).val() || 'ipv4';
|
||||
var i = $(this).attr('name').split(':')[1];
|
||||
|
||||
@@ -17,6 +17,8 @@ $run = $set != 'none';
|
||||
$ini = parse_ini_file('/var/local/emhttp/network.ini',true); ksort($ini,SORT_NATURAL);
|
||||
$cfg = '/boot/config/network.cfg';
|
||||
|
||||
file_put_contents('/tmp/ini',print_r($ini,true));
|
||||
|
||||
function update_wireguard($ifname) {
|
||||
if (!in_array($ifname,['br0','bond0','eth0'])) return;
|
||||
$nic = file_exists('/sys/class/net/br0') ? 'br0' : (file_exists('/sys/class/net/bond0') ? 'bond0' : 'eth0');
|
||||
@@ -81,7 +83,7 @@ if ($run) {
|
||||
}
|
||||
|
||||
// create configuration file for all available interfaces
|
||||
$i = 0; $new = []; $new[] = "# Generated settings:";
|
||||
$i = 0; $new = ["# Generated settings:"];
|
||||
foreach ($ini as $name => $port) {
|
||||
$bonding = $port['BONDING']=='yes';
|
||||
$bridging = $port['BRIDGING']=='yes';
|
||||
@@ -126,8 +128,8 @@ file_put_contents($cfg,implode("\r\n",$new)."\r\n");
|
||||
// start interface with updated (new) configuration
|
||||
// don't execute when only interface description has changed
|
||||
if ($run) {
|
||||
exec("/etc/rc.d/rc.inet1 {$ifname}_start >/dev/null 2>&1");
|
||||
exec("/usr/local/sbin/create_network_ini $ifname >/dev/null 2>&1 &");
|
||||
exec("/etc/rc.d/rc.inet1 {$ifname}_start &>/dev/null");
|
||||
exec("/usr/local/sbin/create_network_ini $ifname &>/dev/null &");
|
||||
update_wireguard($ifname);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user