stun: fix init script (#9528)
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jun 2011 00:34:46 +0000 (00:34 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jun 2011 00:34:46 +0000 (00:34 +0000)
SVN-Revision: 27141

net/stun/Makefile
net/stun/files/stund.init

index 34f7df5ffd4b8d3f63d9480b7b9cb2b97cebc805..b0ac419df2c62034e690a5e2cb7225e124998a2d 100644 (file)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2008-2009 OpenWrt.org
+# Copyright (C) 2008-2011 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=stund
 PKG_VERSION:=0.96
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION)_Aug13.tgz
 PKG_SOURCE_URL:=@SF/stun
@@ -68,7 +68,7 @@ define Package/stund/install
        $(INSTALL_DIR) $(1)/usr/sbin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/server $(1)/usr/sbin/stund
        $(INSTALL_DIR) $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/stund.init $(1)/etc/init.d/
+       $(INSTALL_BIN) ./files/stund.init $(1)/etc/init.d/stund
        $(INSTALL_DIR) $(1)/etc/config
        $(INSTALL_DATA) ./files/stund.config $(1)/etc/config/stund
 endef
index 296056745657b3d7e3fc70580cbf69c38b88ec02..177ae58f5270a54119df371e778d3cfd952ab587 100644 (file)
@@ -1,18 +1,28 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2009 OpenWrt.org
+# Copyright (C) 2009-2011 OpenWrt.org
+
 START=70
 
 start() {
-       config_load "6stund"
+       local pri_ip sec_ip pri_port sec_port
+       parse_opts() {
+               local cfg="$1"
+               config_get pri_ip   "$cfg" primaryip
+               config_get sec_ip   "$cfg" secondaryip
+               config_get pri_port "$cfg" primaryport
+               config_get sec_port "$cfg" secondaryport
+       }
 
-       config_get PRIMIP primaryip
-       config_get SECIP secondaryip
-       config_get PRIMPORT primaryport
-       config_get SECPORT secondaryport
+       config_load "stund"
+       config_foreach parse_opts
 
-       /usr/sbin/stund -b -h $PRIMIP -a $SECIP -p $PRIMPORT -o $SECPORT
+       start-stop-daemon -S -p /var/run/stund.pid -m -b \
+               -x /usr/sbin/stund -- \
+               ${pri_ip:+-h $pri_ip} ${sec_ip:+-a $sec_ip} \
+               ${pri_port:+-p $pri_port} ${sec_port:+-o $sec_port}
 }
 
 stop() {
-       killall -9 stund
+       service_kill stund /var/run/stund.pid
+       rm -f /var/run/stund.pid
 }