summaryrefslogtreecommitdiff
path: root/templates/interfaces/ethernet/node.def
blob: 2af57e0af2dcab7d4b246b64c6070e9f1a6761e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
tag:
priority: 318
type: txt
help: Ethernet interface name
allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet
val_help: <ethN>; Ethernet interface name
syntax:expression: pattern $VAR(@) "^(eth|lan)[0-9]+$" \
		   ; "interface ethernet $VAR(@): not a valid name"

syntax:expression: exec \
    "if [ ! -d /sys/class/net/$VAR(@) ]; then \
        echo \"interface ethernet $VAR(@): does not exist\";
	exit 1; \
    fi

    if ip link show | awk '{print $2 }' | grep -ao \"lan[0-9]@$VAR(@)\" > /dev/null 2>&1 ; then \
       echo \"interface ethernet $VAR(@): is a switch master interface and not configurable, please use 'lan' interfaces\";
       exit 1; \
    fi"

begin: rm -f /tmp/speed-duplex.$VAR(@)
        if [ -d "/sys/class/net/$VAR(@)" ]; then
           if [ -n "$VAR(mac/@)" ]; then
                /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(@) \
                 --set-mac "$VAR(mac/@)"
           else 
                /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(@) \
                --set-mac "$VAR(hw-id/@)"
           fi
       fi


create: if ! cli-shell-api exists interfaces ethernet $VAR(@) disable;
	then
           case "$VAR(@)" in 
             *lan*)
               masterint=$(ip link show $VAR(@) | awk 'NR==1{print $2 }' | grep -ao "eth[0-9]")
               ip link set $masterint up
             ;;
           esac
           ip link set $VAR(@) up
	fi
	/opt/vyatta/sbin/vyatta-link-detect $VAR(@) on

delete: [ -d /sys/class/net/$VAR(@) ] || exit 0
        ip link set $VAR(@) down

end: rm -f /tmp/speed-duplex.$VAR(@)