[package] /etc/functions.sh => /lib/functions.sh
[openwrt.git] / package / 6in4 / files / 6in4.hotplug
1 #!/bin/sh
2
3 if [ "$ACTION" = ifup ]; then
4         . /lib/functions.sh
5
6         INCLUDE_ONLY=1
7         . /lib/netifd/proto/6in4.sh
8
9         include /lib/network
10         scan_interfaces
11
12         update_tunnel() {
13                 local cfg="$1"
14
15                 local proto
16                 config_get proto "$cfg" proto
17                 [ "$proto" = 6in4 ] || return 0
18
19                 local wandev
20                 config_get wandev "$cfg" wan_device "$(find_6in4_wanif)"
21                 [ "$wandev" = "$DEVICE" ] || return 0
22
23                 local wanip=$(find_6in4_wanip "$wandev")
24
25                 [ -n "$wanip" ] && ifup "$cfg"
26         }
27
28         config_foreach update_tunnel interface
29 fi