[package] add ip-up script to update ipv4 address for Hurricane Electric tunnels...
authorFlorian Fainelli <florian@openwrt.org>
Tue, 10 Mar 2009 10:29:44 +0000 (10:29 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Tue, 10 Mar 2009 10:29:44 +0000 (10:29 +0000)
SVN-Revision: 14836

ipv6/6scripts/Makefile
ipv6/6scripts/files/he-tun.ppp [new file with mode: 0644]

index 6a7f249..74a8da4 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=6scripts
 PKG_VERSION:=0.1
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -44,6 +44,8 @@ define Package/6scripts/install
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/6tunnel.init $(1)/etc/init.d/6tunnel
        $(INSTALL_BIN) ./files/6bridge.init $(1)/etc/init.d/6bridge
+       $(INSTALL_DIR) $(1)/etc/ppp/ip-up.d/ 
+       $(INSTALL_DATA) ./files/he-tun.ppp $(1)/etc/ppp/ip-up.d/ 
 endef
 
 $(eval $(call BuildPackage,6scripts))
diff --git a/ipv6/6scripts/files/he-tun.ppp b/ipv6/6scripts/files/he-tun.ppp
new file mode 100644 (file)
index 0000000..4cc7385
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+. /etc/functions.sh
+
+ipaddr="$PPP_LOCAL"
+
+update_tun() {
+       local cfg="$1"
+       
+       config_get tunnelid "$cfg" tunnelid
+       config_get username "$cfg" username
+       config_get password "$cfg" password
+       config_get tunnel "$cfg" tunnel
+       
+       password=`echo -n $password | md5sum | cut -d ' ' -f 1`
+       wget -q -O /dev/null "http://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=$ipaddr&pass=$password&user_id=$username&tunnel_id=$tunnelid"
+       
+       uci set "6tunnel.@$tunnel[0].localip4=$ipaddr"
+       uci commit 6tunnel
+       /etc/init.d/6tunnel restart
+}
+
+config_load "hetun"
+config_foreach update_tun