From 76df8018fe0f0648abc58bd7a988ffaf61e75106 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Mar 2009 08:42:36 -0800 Subject: Use check option to vyatta-interfaces.pl Eliminate checks in template in favor of doing it in one place in vyatta-interfaces.pl code. --- templates/interfaces/ethernet/node.def | 11 +++-------- templates/interfaces/loopback/node.def | 13 +++---------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index 55d0a85..c231b74 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -1,14 +1,9 @@ tag: type: txt help: Set ethernet interface -syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \ - ; "interface must be (eth0 - eth999)" -syntax:expression: exec " \ - if [ -f /sys/class/net/$VAR(@) ]; then \ - echo \"Ethernet interface does not exist: $VAR(@)\"; \ - exit 1; \ - fi" -allowed: /opt/vyatt/sbin/vyatta-interfaces.pl --show=ethernet +syntax:expression: exec \ + "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=ethernet" +allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet update: sudo ip link set "$VAR(@)" up /opt/vyatta/sbin/vyatta-link-detect $VAR(@) on delete: sudo ip link set "$VAR(@)" down diff --git a/templates/interfaces/loopback/node.def b/templates/interfaces/loopback/node.def index e57f4b1..690dc39 100644 --- a/templates/interfaces/loopback/node.def +++ b/templates/interfaces/loopback/node.def @@ -1,14 +1,7 @@ tag: type: txt help: Set loopback interface -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" - +syntax:expression: exec \ + "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=loopback" +allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=loopback update: sudo ip link set $VAR(@) up -- cgit v1.2.3