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