[package] support pre-md5summed passwords in 6in4 scripts
[openwrt.git] / package / 6in4 / files / 6in4.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" = 6in4 ] || return 0
15
16 local wandev
17 config_get wandev "$cfg" wan_device "$(find_6in4_wanif)"
18 [ "$wandev" = "$DEVICE" ] || return 0
19
20 local oldip
21 local wanip=$(find_6in4_wanip "$wandev")
22 config_get oldip "$cfg" ipaddr
23
24 [ -n "$wanip" ] && [ "$oldip" != "$wanip" ] && {
25 local tunnelid
26 config_get tunnelid "$cfg" tunnelid
27
28 local username
29 config_get username "$cfg" username
30
31 local password
32 config_get password "$cfg" password
33
34 [ -n "$tunnelid" ] && [ -n "$username" ] && [ -n "$password" ] && {
35 [ "${#password}" != 32 ] || [ -n "$(echo "$password" | sed 's/[a-z0-9]//g')" ] && {
36 password="$(echo -n "$password" | md5sum)"; password="${password%% *}"
37 }
38 uci_set_state network "$cfg" ipaddr "$wanip"
39
40 ( wget -qO/dev/null "http://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=AUTO&user_id=$username&pass=$password&tunnel_id=$tunnelid" && ifup "$cfg" )&
41 }
42 }
43 }
44
45 config_foreach update_tunnel interface
46 fi
This page took 0.045201 seconds and 5 git commands to generate.