diff options
Diffstat (limited to 'templates/interfaces')
-rw-r--r-- | templates/interfaces/ethernet/node.def | 17 | ||||
-rw-r--r-- | templates/interfaces/loopback/node.def | 17 |
2 files changed, 20 insertions, 14 deletions
diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index ba15828..3023a70 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -1,19 +1,20 @@ tag: type: txt help: Set ethernet interface +syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \ + ; "interface must be (eth0 - eth999)" syntax:expression: exec " \ - if [ -z \"`ip link | grep eth | egrep -v 'eth[0-9]+[.]' | grep $VAR(@)`\" ]; then \ - echo Invalid ethernet interface [$VAR(@)]; \ - exit 1 ; \ - fi ; " + if [ -f /sys/class/net/$VAR(@) ]; then \ + echo \"Ethernet interface does not exist: $VAR(@)\"; \ + exit 1; \ + fi" + update: sudo ip link set "$VAR(@)" up vyatta-vtysh -c "configure terminal" \ -c "interface $VAR(@)" -c "link-detect" delete: sudo ip link set "$VAR(@)" down -allowed: for dev in /sys/class/net/*; +allowed: for dev in /sys/class/net/eth*; do if [[ -d $dev && -L $dev/device ]] - then if [[ $(cat $dev/type) -eq 1 ]] - then echo -n ${dev##*/} " " - fi + then echo -n ${dev##*/} " " fi done diff --git a/templates/interfaces/loopback/node.def b/templates/interfaces/loopback/node.def index 7b7a304..e57f4b1 100644 --- a/templates/interfaces/loopback/node.def +++ b/templates/interfaces/loopback/node.def @@ -1,9 +1,14 @@ tag: type: txt help: Set loopback interface -syntax:expression: exec " \ - if [ -z \"`ip addr | grep $VAR(@) `\" ]; then \ - echo loopback interface $VAR(@) doesn\\'t exist on this system ; \ - exit 1 ; \ - fi ; " -update:expression: "sudo ip link set $VAR(@) up" +allowed: echo "lo" +syntax:expression: exec "\ + if [ ! -d /sys/class/net/$VAR(@) ]; then \ + echo \"loopback interface $VAR(@) does not exist\"; \ + exit 1; \ + elif [ $(cat /sys/class/net/$VAR(@)/type) -ne 772 ]; then \ + echo \"interface $VAR(@) is not a loopback interface\"; \ + exit 1; \ + fi" + +update: sudo ip link set $VAR(@) up |