mirror of
https://github.com/unraid/webgui.git
synced 2026-01-12 12:40:08 -06:00
Fixed eth0 port status detection and port up/down execution
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
<?if ($locked || $service):?>
|
||||
disableForm(form,true);
|
||||
<?endif;?>
|
||||
<?if (strlen(exec("ip link show eth0|grep -om1 ',UP[,>]'"))==0):?>
|
||||
$('input[name="#shut"]').prop('disabled',true);
|
||||
<?if ($no_eth0):?>
|
||||
$('input[name="#shut_ethX"]').prop('disabled',true);
|
||||
<?endif;?>
|
||||
setTimeout(portcheck_ethX,Number('ethX'.substr(3))*1000);
|
||||
});
|
||||
@@ -263,5 +263,5 @@ Network mask:
|
||||
</script>
|
||||
|
||||
|
||||
: <input type="submit" value="Apply" onclick="$(waitid).show()"><input type="button" value="Done" onclick="done()"><input type="button" name="#shut" value="Port <?=$cmd?>" onclick="portToggle('ethX','<?=$cmd?>')"><?if ($service) echo "$service must be <b>STOPPED</b> to change"?>
|
||||
: <input type="submit" value="Apply" onclick="$(waitid).show()"><input type="button" value="Done" onclick="done()"><input type="button" name="#shut_ethX" value="Port <?=$cmd?>" onclick="portToggle('ethX','<?=$cmd?>')"><?if ($service) echo "$service must be <b>STOPPED</b> to change"?>
|
||||
</form>
|
||||
|
||||
@@ -13,5 +13,12 @@
|
||||
<?
|
||||
$port = $_POST['port'];
|
||||
$cmd = strtolower($_POST['cmd']);
|
||||
if ($port) exec("ip link set $port $cmd");
|
||||
exec("ip link set $port $cmd");
|
||||
$pass = $cmd=='up' ? 'UP>' : '';
|
||||
$wait = 5;
|
||||
while ($wait > 0) {
|
||||
if (exec("ip link show $port|grep -om1 'UP>'")==$pass) break;
|
||||
sleep(1);
|
||||
$wait--;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user