packages/n2n: use new service functions

git-svn-id: svn://svn.openwrt.org/openwrt/packages@29071 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nico 2011-11-13 22:16:11 +00:00
parent 20e3c05181
commit ab643c10bd
2 changed files with 48 additions and 29 deletions

View File

@ -1,5 +1,5 @@
# #
## 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. # See /LICENSE for more information.
@ -13,7 +13,7 @@ PKG_REV:=3875
PKG_NAME:=n2n PKG_NAME:=n2n
PKG_VERSION:=$(PKG_REV) PKG_VERSION:=$(PKG_REV)
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
@ -39,9 +39,9 @@ define Build/Compile
endef endef
define Package/n2n/install define Package/n2n/install
$(INSTALL_DIR) $(1)/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/edge $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/supernode $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/n2n.config $(1)/etc/config/n2n $(INSTALL_DATA) ./files/n2n.config $(1)/etc/config/n2n
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d

View File

@ -1,37 +1,56 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org # Copyright (C) 2008-2011 OpenWrt.org
START=90 START=90
config_cb() { start_instance() {
local cfg="$CONFIG_SECTION" local cfg="$1"
config_get configname "$cfg" TYPE
case "$configname" in config_get type "$cfg" TYPE
case "$type" in
edge) edge)
config_get ipaddr "$cfg" ipaddr config_get ipaddr "$cfg" 'ipaddr'
config_get supernode "$cfg" supernode [ -n "$ipaddr" ] || return 1
config_get port "$cfg" port config_get supernode "$cfg" 'supernode'
config_get community "$cfg" community config_get port "$cfg" 'port'
config_get key "$cfg" key config_get community "$cfg" 'community'
config_get_bool route "$cfg" route 0 config_get key "$cfg" 'key'
config_get_bool route "$cfg" 'route' '0'
[ "$route" = "1" ] && args='-r' [ "$route" = "1" ] && args='-r'
if [ "$ipaddr" != "" ]; then service_start /usr/sbin/edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port}
edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port}
fi
;; ;;
supernode) supernode)
config_get port "$cfg" port config_get port "$cfg" port
if [ "$port" != "" ]; then [ -n "$port" ] || return 1
supernode -l $port & service_start /usr/sbin/supernode -l $port
fi ;;
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 esac
} }
start() { start() {
config_load n2n config_load 'n2n'
config_foreach start_instance 'edge'
config_foreach start_instance 'superndoe'
} }
stop() { stop() {
killall edge config_load 'n2n'
killall supernode config_foreach stop_instance 'edge'
config_foreach stop_instance 'supernode'
} }