diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/interfaces/ethernet/node.tag/duplex/node.def | 32 | ||||
-rw-r--r-- | templates/interfaces/ethernet/node.tag/speed/node.def | 30 |
2 files changed, 32 insertions, 30 deletions
diff --git a/templates/interfaces/ethernet/node.tag/duplex/node.def b/templates/interfaces/ethernet/node.tag/duplex/node.def index a44efd1..ba81cca 100644 --- a/templates/interfaces/ethernet/node.tag/duplex/node.def +++ b/templates/interfaces/ethernet/node.tag/duplex/node.def @@ -2,21 +2,23 @@ type: txt help: Set the duplex mode for this interface default: "auto" syntax:expression: $VAR(@) in "auto", "half", "full"; "duplex must be auto, half or full" -commit:expression: exec "if [ x$VAR(@) != xauto ]; then \ - if [ x$VAR(../speed/@) == xauto ]; then \ - exit 1; \ - fi; \ - else \ - if [ x$VAR(../speed/@) != xauto ]; then \ - exit 1; \ - fi; \ - fi; " ; "if duplex is hardcoded, speed must also be hardcoded" -update:expression: "if [ x$VAR(@) != xauto ]; then \ - sudo ethtool -s $VAR(../@) speed $VAR(../speed/@) duplex $VAR(@) autoneg off; \ - else \ - sudo ethtool -s $VAR(../@) autoneg on; \ - fi; " -delete:expression: "sudo ethtool -s $VAR(../@) autoneg on" +commit:expression: ( $VAR(@) == "auto" && $VAR(../speed/@) == "auto" ) || \ + ( $VAR(@) != "auto" && $VAR(../speed/@) != "auto" ) ; \ + "if duplex is hardcoded, speed must also be hardcoded" + +update: if [ "$VAR(@)" = "auto" ] + then + if ! sudo ethtool $VAR(../@) | grep -q 'Auto-negotiation: on' + then sudo ethtool -s $VAR(../@) autoneg on + fi + else + sudo ethtool -s $VAR(../@) \ + speed $VAR(../speed/@) duplex $VAR(@) autoneg off + fi + +delete: if [ -d /sys/class/net/$VAR(../@) ]; then + sudo ethtool -s $VAR(../@) autoneg on + fi comp_help:Possible completions: auto\t\tAuto negotiation half\t\tHalf duplex diff --git a/templates/interfaces/ethernet/node.tag/speed/node.def b/templates/interfaces/ethernet/node.tag/speed/node.def index d042074..b22e93c 100644 --- a/templates/interfaces/ethernet/node.tag/speed/node.def +++ b/templates/interfaces/ethernet/node.tag/speed/node.def @@ -2,18 +2,18 @@ type: txt help: Set the speed for this interface default: "auto" syntax:expression: $VAR(@) in "auto", "10", "100", "1000", "2500", "10000"; "Speed must be auto, 10, 100, 1000, 2500, or 10000" -commit:expression: exec "if [ x$VAR(@) != xauto ]; then \ - if [ x$VAR(../duplex/@) == xauto ]; then \ - exit 1; \ - fi; \ - else \ - if [ x$VAR(../duplex/@) != xauto ]; then \ - exit 1; \ - fi; \ - fi;"; "if speed is hardcoded, duplex must also be hardcoded" -update:expression: "if [ x$VAR(@) != xauto ]; then \ - sudo ethtool -s $VAR(../@) speed $VAR(@) duplex $VAR(../duplex/@) autoneg off; \ - else \ - sudo ethtool -s $VAR(../@) autoneg on; \ - fi; " -delete:expression: "sudo ethtool -s $VAR(../@) autoneg on" +commit:expression: ( $VAR(@) == "auto" && $VAR(../speed/@) == "auto" ) || \ + ( $VAR(@) != "auto" && $VAR(../speed/@) != "auto" ) ; \ + "if speed is hardcoded, duplex must also be hardcoded" +update: if [ "$VAR(@)" = "auto" ] + then + if ! sudo ethtool $VAR(../@) | grep -q 'Auto-negotiation: on' + then sudo ethtool -s $VAR(../@) autoneg on + fi + else + sudo ethtool -s $VAR(../@) \ + speed $VAR(../speed/@) duplex $VAR(@) autoneg off + fi +delete: if [ -d /sys/class/net/$VAR(../@) ]; then + sudo ethtool -s $VAR(../@) autoneg on + fi |