[packages_10.03.2] n2n: merge r29071, r29199
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 15:29:48 +0000 (15:29 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Feb 2012 15:29:48 +0000 (15:29 +0000)
SVN-Revision: 30222

net/n2n/Makefile
net/n2n/files/n2n.init

index 338ccb62cef3f36358804492d6b296f027339cac..d65a6f70c3cf4a854bc4494c30d57ce340825310 100644 (file)
@@ -1,9 +1,9 @@
 #
-## Copyright (C) 2007-2008 OpenWrt.org
+# Copyright (C) 2007-2011 OpenWrt.org
 #
-## This is free software, licensed under the GNU General Public License v2.
+# This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
-
+#
 
 include $(TOPDIR)/rules.mk
 
@@ -13,7 +13,7 @@ PKG_REV:=3875
 
 PKG_NAME:=n2n
 PKG_VERSION:=$(PKG_REV)
-PKG_RELEASE:=1
+PKG_RELEASE:=3
 
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
@@ -39,13 +39,17 @@ define Build/Compile
 endef
 
 define Package/n2n/install
-       $(INSTALL_DIR) $(1)/sbin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/sbin/
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/sbin/
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/etc/config
        $(INSTALL_DATA) ./files/n2n.config $(1)/etc/config/n2n
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/n2n.init $(1)/etc/init.d/n2n
 endef
 
+define Package/n2n/conffiles
+/etc/config/n2n
+endef
+
 $(eval $(call BuildPackage,n2n))
index 4730112d48de84ad8ca557a2d8a1bf721c7725cb..791b805430082a8eb6097b17f9093bcdab51bb93 100644 (file)
@@ -1,37 +1,56 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2008 OpenWrt.org
+# Copyright (C) 2008-2011 OpenWrt.org
+
 START=90
 
-config_cb() {
-       local cfg="$CONFIG_SECTION"
-       config_get configname "$cfg" TYPE
-
-       case "$configname" in
-               edge)
-                       config_get ipaddr "$cfg" ipaddr
-                       config_get supernode "$cfg" supernode
-                       config_get port "$cfg" port
-                       config_get community "$cfg" community
-                       config_get key "$cfg" key
-                       config_get_bool route "$cfg" route 0
-                       [ "$route" = "1" ] && args='-r'
-                       if [ "$ipaddr" != "" ]; then
-                               edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port}
-                       fi
+start_instance() {
+       local cfg="$1"
+
+       config_get type "$cfg" TYPE
+
+       case "$type" in
+         edge)
+               config_get ipaddr "$cfg" 'ipaddr'
+               [ -n "$ipaddr" ] || return 1
+               config_get supernode "$cfg" 'supernode'
+               config_get port "$cfg" 'port'
+               config_get community "$cfg" 'community'
+               config_get key "$cfg" 'key'
+               config_get_bool route "$cfg" 'route' '0'
+               [ "$route" = "1" ] && args='-r'
+               service_start /usr/sbin/edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port}
                ;;
-               supernode)
-                       config_get port "$cfg" port
-                       if [ "$port" != "" ]; then
-                               supernode -l $port &
-                       fi
+         supernode)
+               config_get port "$cfg" port
+               [ -n "$port" ] || return 1
+               service_start /usr/sbin/supernode -l $port
+               ;;
+       esac
+}
+
+stop_instance() {
+       local cfg="$1"
+
+       config_get type "$cfg" TYPE
+
+       case "$type" in
+         edge)
+               service_stop /usr/sbin/edge
+               ;;
+         supernode)
+               service_stop /usr/sbin/supernode
                ;;
        esac
 }
 
 start() {
-       config_load n2n
+       config_load 'n2n'
+       config_foreach start_instance 'edge'
+       config_foreach start_instance 'superndoe'
 }
+
 stop() {
-       killall edge
-       killall supernode
+       config_load 'n2n'
+       config_foreach stop_instance 'edge'
+       config_foreach stop_instance 'supernode'
 }