From 5c203b6d519c545f491375848e1722d727b09dae Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 8 Jun 2016 00:24:03 +0200 Subject: [PATCH 1/3] Added possibility to bring secondary interfaces up/down --- plugins/dynamix/Eth0.page | 4 ++++ plugins/dynamix/EthX.page | 12 +++++++++--- plugins/dynamix/include/PortToggle.php | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 plugins/dynamix/include/PortToggle.php diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index 7ad7ad10a..4d293dd45 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -52,6 +52,7 @@ if (isset($eth0)) foreach ($eth0 as $key => $val) if (substr($key,0,6)=='VLANID' span.pin i{font-size:16px;cursor:pointer;} span.unset{color:#E68A00;} span.member{color:#00529B;} +span.shut{color:#4F8A10;} div.shade-white{background-color:#F8F8F8;} div.shade-black{background-color:#0C0C0C;} @@ -220,6 +221,9 @@ function portcheck_eth0() { setTimeout(portcheck_eth0,10000); }); } +function portToggle(port,cmd) { + $.post('/webGui/include/PortToggle.php',{port:port,cmd:cmd},function(){refresh();}); +} $(function() { var ctrl = ""; var form = document.eth0_settings; diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index 82d75a0b9..0a5f7f58b 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -27,7 +27,13 @@ $locked = $bond_ethX || $bridge_ethX ; $vlan_ethX = [0]; if (!$locked && isset($ethX)) foreach ($ethX as $key => $val) if (substr($key,0,6)=='VLANID') $vlan_ethX[] = substr($key,7); -if ($bond_ethX) { +$cmd = 'Down'; +if (strlen(exec("ip link show ethX|grep -om1 ',UP[,>]'"))==0) { + $more = true; + $reason = "Interface is shutdown (inactive)"; + $class = 'shut'; + $cmd = 'Up'; +} elseif ($bond_ethX) { $more = true; $reason = "Interface is member of ".$eth0['BONDNAME']." (see interface eth0)"; $class = 'member'; @@ -35,7 +41,7 @@ if ($bond_ethX) { $more = true; $reason = "Interface is member of ".$eth0['BRNAME']." (see interface eth0)"; $class = 'member'; -} elseif (empty($ethX) || strlen(exec("ip link show ethX|grep -om1 ',UP[,>]'"))==0) { +} elseif (empty($ethX)) { $more = true; $reason = "Interface is not configured"; $class = 'unset'; @@ -254,5 +260,5 @@ Network mask:   -: STOPPED to change"?> +: STOPPED to change"?> diff --git a/plugins/dynamix/include/PortToggle.php b/plugins/dynamix/include/PortToggle.php new file mode 100644 index 000000000..782dafbaf --- /dev/null +++ b/plugins/dynamix/include/PortToggle.php @@ -0,0 +1,17 @@ + + From f81be4baecfbd88a5a5111238d90bfb3ba745dca Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 8 Jun 2016 00:28:55 +0200 Subject: [PATCH 2/3] Make color coding more logical --- plugins/dynamix/Eth0.page | 6 +++--- plugins/dynamix/EthX.page | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index 4d293dd45..742f1850c 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -50,9 +50,9 @@ if (isset($eth0)) foreach ($eth0 as $key => $val) if (substr($key,0,6)=='VLANID' ?> diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index 0a5f7f58b..aa50ec73c 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -31,20 +31,20 @@ $cmd = 'Down'; if (strlen(exec("ip link show ethX|grep -om1 ',UP[,>]'"))==0) { $more = true; $reason = "Interface is shutdown (inactive)"; - $class = 'shut'; + $class = 'blue'; $cmd = 'Up'; } elseif ($bond_ethX) { $more = true; $reason = "Interface is member of ".$eth0['BONDNAME']." (see interface eth0)"; - $class = 'member'; + $class = 'green'; } elseif ($bridge_ethX) { $more = true; $reason = "Interface is member of ".$eth0['BRNAME']." (see interface eth0)"; - $class = 'member'; + $class = 'green'; } elseif (empty($ethX)) { $more = true; $reason = "Interface is not configured"; - $class = 'unset'; + $class = 'red'; } else { $more = false; } From e0867fc901d98b3a0ccbd3036967768f7c7d7fef Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 8 Jun 2016 00:39:27 +0200 Subject: [PATCH 3/3] Added a safety measure that eth0 must be UP before other interface can be shut --- plugins/dynamix/EthX.page | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index aa50ec73c..63f047701 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -73,6 +73,9 @@ $(function() { disableForm(form,true); + +]'"))==0):?> + $('input[name="#shut"]').prop('disabled',true); setTimeout(portcheck_ethX,Number('ethX'.substr(3))*1000); });