base-files: move network related scripts to a separate package to make the transition...
[openwrt.git] / package / base-files-network / files / etc / hotplug.d / net / 10-net
1 # Copyright (C) 2006 OpenWrt.org
2
3 include /lib/network
4
5 addif() {
6 # Ensure that ipv6 is loaded, autoloading happens later but ipv6 might be
7 # required now for interface setup.
8 [ -d /proc/sys/net/ipv6 ] || {
9 grep -q '^ipv6' /etc/modules.d/* && insmod ipv6
10 }
11
12 # PPP devices are configured by pppd, no need to run setup_interface here
13 case "$INTERFACE" in
14 3g-*|ppp-*|pppoa-*|pppoe-*|pptp-*) return 0;;
15 esac
16
17 scan_interfaces
18 local cfg="$(find_config "$INTERFACE")"
19
20 case "$INTERFACE" in
21 # Skip wireless parent interfaces
22 ath[0-9]|wlan[0-9]) ;;
23 *)
24 # check the autoload setting
25 config_get auto "$cfg" auto
26 case "$auto" in
27 1|on|enabled) setup_interface "$INTERFACE";;
28 esac
29 ;;
30 esac
31
32 # find all vlan configurations for this interface and set them up as well
33 for ifc in $interfaces; do
34 config_get iftype "$ifc" type
35 config_get ifs "$ifc" device
36 for dev in $ifs; do
37 [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
38 add_vlan "$dev"
39 }
40 done
41 done
42 }
43
44
45 delif() {
46 scan_interfaces
47
48 # find all vlan configurations for this interface and nuke 'em
49 for ifc in $interfaces; do
50 config_get iftype "$ifc" type
51 config_get ifs "$ifc" device
52 confdevs="$(uci_get network.$ifc.ifname)"
53 for dev in $ifs; do
54 [ "${dev%%\.*}" = "$INTERFACE" ] && {
55 list_contains confdevs "$dev" || list_remove ifs "$dev"
56 }
57 done
58 uci_set_state "network" "$ifc" device "$ifs"
59 done
60 }
61
62 case "$ACTION" in
63 add|register)
64 case "$PHYSDEVDRIVER" in
65 natsemi) sleep 1;;
66 esac
67 addif
68 ;;
69 remove|unregister)
70 delif
71 ;;
72 esac
This page took 0.045465 seconds and 5 git commands to generate.