From 820f40488a485bbb78eb3edf497d68f183edb756 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 27 Oct 2007 07:12:13 +0000 Subject: [PATCH] [packages] 6tunnel: move init/config files to the right place git-svn-id: svn://svn.openwrt.org/openwrt/packages@9453 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ipv6/6tunnel/Makefile | 16 ++++++++--- ipv6/6tunnel/files/6tunnel.conf | 6 ++++ ipv6/6tunnel/files/6tunnel.init | 64 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 ipv6/6tunnel/files/6tunnel.conf create mode 100755 ipv6/6tunnel/files/6tunnel.init diff --git a/ipv6/6tunnel/Makefile b/ipv6/6tunnel/Makefile index 8c985be40..be164585e 100644 --- a/ipv6/6tunnel/Makefile +++ b/ipv6/6tunnel/Makefile @@ -1,5 +1,5 @@ -# -# Copyright (C) 2006 OpenWrt.org +# +# Copyright (C) 2007 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=6tunnel PKG_VERSION:=0.11rc1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_MD5SUM:=b325fa9d238e32195fbb3fc3646b0d28 PKG_SOURCE_URL:=http://toxygen.net/6tunnel/ @@ -44,9 +44,17 @@ define Build/Compile default endef +define Package/6tunnel/conffiles +/etc/config/6tunnel +endef + define Package/6tunnel/install $(INSTALL_DIR) $(1)/usr/sbin - $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/6tunnel $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/6tunnel.config $(1)/etc/config/6tunnel + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/6tunnel.init $(1)/etc/init.d/6tunnel endef $(eval $(call BuildPackage,6tunnel)) diff --git a/ipv6/6tunnel/files/6tunnel.conf b/ipv6/6tunnel/files/6tunnel.conf new file mode 100644 index 000000000..efd8f817c --- /dev/null +++ b/ipv6/6tunnel/files/6tunnel.conf @@ -0,0 +1,6 @@ +config 6tunnel + option tnlifname 'sixbone' + option remoteip4 '' + option localip4 '' + option localip6 '' + option prefix '/64' diff --git a/ipv6/6tunnel/files/6tunnel.init b/ipv6/6tunnel/files/6tunnel.init new file mode 100755 index 000000000..cd4e1fc02 --- /dev/null +++ b/ipv6/6tunnel/files/6tunnel.init @@ -0,0 +1,64 @@ +#!/bin/sh /etc/rc.common +START=46 +STOP=46 + +start_service() { + local section="$1" + + include /lib/network + scan_interfaces + config_load /var/state/network + + config_get LAN lan ifname + config_get tnlifname "$section" tnlifname + config_get remoteip4 "$section" remoteip4 + config_get localip4 "$section" localip4 + config_get localip6 "$section" localip6 + config_get prefix "$section" prefix + + ip tunnel add $tnlifname mode sit remote $remoteip4 local $localip4 ttl 255 + ifconfig $tnlifname up + ip addr add $localip6 dev $tnlifname + ip route add ::/0 dev $tnlifname + ip route add 2000::/3 dev $tnlifname + ip -6 addr add $prefix dev $LAN +} + +stop_service() { + local section="$1" + + include /lib/network + scan_interfaces + config_load /var/state/network + + config_get LAN lan ifname + config_get tnlifname "$section" tnlifname + config_get remoteip4 "$section" remoteip4 + config_get localip4 "$section" localip4 + config_get localip6 "$section" localip6 + config_get prefix "$section" prefix + + ip -6 addr del $prefix dev $LAN + ip -6 ro del 2000::/3 dev $tnlifname + ip -6 ro del ::/0 dev $tnlifname + ip addr del $localip6 dev $tnlifname + ifconfig $tnlifname down + ip tunnel del $tnlifname +} +start() { + if ! [ -f /proc/net/if_inet6 ]; then + echo "IPv6 not enabled, install kmod-ipv6"; + exit 1; + fi + if ! [ -x /sbin/ip ]; then + echo "ip is required to setup the tunnel"; + exit 1; + fi + config_load "6tunnel" + config_foreach start_service 6tunnel +} + +stop () { + config_load "6tunnel" + config_foreach stop_service 6tunnel +} -- 2.11.0