[package] ipv6: add tayga
[openwrt/svn-archive/archive.git] / ipv6 / tayga / files / tayga.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" = tayga ] || return 0
15
16 local wandev4
17 config_get wandev4 "$cfg" wan4_device "$(find_tayga_wanif4)"
18
19 local wandev6
20 config_get wandev6 "$cfg" wan6_device "$(find_tayga_wanif6)"
21
22 [ "$wandev4" = "$DEVICE" ] || [ "$wandev6" = "$DEVICE" ] || return 0
23
24 local wanip4=$(find_tayga_wanip4 "$wandev4")
25 local wanip6=$(find_tayga_wanip6 "$wandev6")
26
27 [ -n "$wanip4" ] && [ -n "$wanip6" ] && {
28 uci_set_state network "$cfg" ipv4addr "$wanip4"
29 uci_set_state network "$cfg" ipv6addr "$wanip6"
30
31 logger -t tayga-update "Re-establishing tayga NAT64 due to change on $INTERFACE ($DEVICE)"
32 ifup "$cfg" &
33 }
34 }
35
36 config_foreach update_tunnel interface
37 fi