From ffbeb594a0ee1f435bb6b232ff1dbb8d4766dc52 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 11 Jun 2016 08:38:29 +0200 Subject: [PATCH] Fixed eth0 port status detection and port up/down execution --- plugins/dynamix/Eth0.page | 3 +++ plugins/dynamix/EthX.page | 8 ++++---- plugins/dynamix/include/PortToggle.php | 9 ++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index f63ac23b8..f45c6f45a 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -44,6 +44,9 @@ foreach ($ports as $port) { $service = exec("pgrep libvirt") ? 'VMs' : ''; $service .= exec("pgrep docker") ? ($service ? ' and ' : '').'Docker' : ''; +// eth0 port status +$no_eth0 = exec("ip link show eth0|grep -Pom1 '(NO-CARRIER|state DOWN)'"); + // get VLAN interfaces $vlan_eth0 = [0]; if (isset($eth0)) foreach ($eth0 as $key => $val) if (substr($key,0,6)=='VLANID') $vlan_eth0[] = substr($key,7); diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index 8b81f5ea0..d7b2d077f 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -28,7 +28,7 @@ $vlan_ethX = [0]; if (!$locked && isset($ethX)) foreach ($ethX as $key => $val) if (substr($key,0,6)=='VLANID') $vlan_ethX[] = substr($key,7); $cmd = 'Down'; -if (strlen(exec("ip link show ethX|grep -om1 ',UP[,>]'"))==0) { +if (!exec("ip link show ethX|grep -om1 'UP>'")) { $more = true; $reason = "Interface is shutdown (inactive)"; $class = 'blue'; @@ -74,8 +74,8 @@ $(function() { disableForm(form,true); -]'"))==0):?> - $('input[name="#shut"]').prop('disabled',true); + + $('input[name="#shut_ethX"]').prop('disabled',true); setTimeout(portcheck_ethX,Number('ethX'.substr(3))*1000); }); @@ -263,5 +263,5 @@ Network mask:   -: STOPPED to change"?> +: STOPPED to change"?> diff --git a/plugins/dynamix/include/PortToggle.php b/plugins/dynamix/include/PortToggle.php index 782dafbaf..3f8e36df4 100644 --- a/plugins/dynamix/include/PortToggle.php +++ b/plugins/dynamix/include/PortToggle.php @@ -13,5 +13,12 @@ ' : ''; +$wait = 5; +while ($wait > 0) { + if (exec("ip link show $port|grep -om1 'UP>'")==$pass) break; + sleep(1); + $wait--; +} ?>