X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;ds=sidebyside;f=package%2F6in4%2Ffiles%2F6in4.hotplug;fp=package%2F6in4%2Ffiles%2F6in4.hotplug;h=96b046d14d39d107a4388e2c82271068d10d16fb;hb=7c6904ccee74536ddf813ba3e6b15ee6790d5ea4;hp=0000000000000000000000000000000000000000;hpb=b1c533c4a51dc464c889a5471d86051a94962aed;p=openwrt-10.03%2F.git diff --git a/package/6in4/files/6in4.hotplug b/package/6in4/files/6in4.hotplug new file mode 100644 index 000000000..96b046d14 --- /dev/null +++ b/package/6in4/files/6in4.hotplug @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ "$ACTION" = ifup ]; then + . /etc/functions.sh + + include /lib/network + scan_interfaces + + update_tunnel() { + local cfg="$1" + + local proto + config_get proto "$cfg" proto + [ "$proto" = 6in4 ] || return 0 + + local wandev + config_get wandev "$cfg" wan_device "$(find_6in4_wanif)" + [ "$wandev" = "$DEVICE" ] || return 0 + + local oldip + local wanip=$(find_6in4_wanip "$wandev") + config_get oldip "$cfg" ipaddr + + [ -n "$wanip" ] && [ "$oldip" != "$wanip" ] && { + local tunnelid + config_get tunnelid "$cfg" tunnelid + + local username + config_get username "$cfg" username + + local password + config_get password "$cfg" password + + [ -n "$tunnelid" ] && [ -n "$username" ] && [ -n "$password" ] && { + password="$(echo -n "$password" | md5sum)"; password="${password%% *}" + uci_set_state network "$cfg" ipaddr "$wanip" + + ( wget -qO/dev/null "http://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=AUTO&user_id=$username&pass=$password&tunnel_id=$tunnelid" && ifup "$cfg" )& + } + } + } + + config_foreach update_tunnel interface +fi