06e5244447ec669f2194dc6c59e9a22b2859ed4c
[openwrt/svn-archive/archive.git] / package / base-files / files / etc / hotplug.d / net / 10-net
1 # Copyright (C) 2006 OpenWrt.org
2
3 include /lib/network
4
5 addif() {
6 # PPP devices are configured by pppd, no need to run setup_interface here
7 case "$INTERFACE" in
8 ppp*) return 0;;
9 esac
10
11 scan_interfaces
12 local cfg="$(find_config "$INTERFACE")"
13
14 # check the autoload setting
15 config_get auto "$cfg" auto
16 case "$auto" in
17 1|on|enabled) setup_interface "$INTERFACE";;
18 esac
19
20
21 # find all vlan configurations for this interface and set them up as well
22 for ifc in $interfaces; do
23 config_get iftype "$ifc" type
24 config_get ifs "$ifc" device
25 for dev in $ifs; do
26 [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
27 add_vlan "$dev"
28 }
29 done
30 done
31 }
32
33
34 delif() {
35 scan_interfaces
36
37 # find all vlan configurations for this interface and nuke 'em
38 for ifc in $interfaces; do
39 config_get iftype "$ifc" type
40 config_get ifs "$ifc" device
41 confdevs="$(uci get network.$ifc.ifname)"
42 for dev in $ifs; do
43 [ "${dev%%\.*}" = "$INTERFACE" ] && {
44 list_contains confdevs "$dev" || list_remove ifs "$dev"
45 }
46 done
47 uci_set_state "network" "$ifc" device "$ifs"
48 done
49 }
50
51 case "$ACTION" in
52 add|register)
53 case "$PHYSDEVDRIVER" in
54 natsemi) sleep 1;;
55 esac
56 addif
57 ;;
58 remove|unregister)
59 delif
60 ;;
61 esac