packages/olsrd: use new service functions (again)
authorNicolas Thill <nico@openwrt.org>
Wed, 16 Nov 2011 09:44:11 +0000 (09:44 +0000)
committerNicolas Thill <nico@openwrt.org>
Wed, 16 Nov 2011 09:44:11 +0000 (09:44 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/packages/net/olsrd@29172 3c298f89-4303-0410-b956-a3cf2f4a3e73

Makefile
files/olsrd.init

index 8cdc58176a9a277d30720d92dde1ab71c5f3e20b..0dbf32ce84930f080cf6506a1c386f7445fb8e9a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=olsrd
 PKG_VERSION:=0.6.2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://www.olsr.org/releases/0.6
index ff4f8c1d827dce20aee38776260f617c70cfffeb..ed6455da42241d78dc88f7dbee5ad1e8aba8da3e 100644 (file)
@@ -2,7 +2,10 @@
 # Copyright (C) 2008-2011 OpenWrt.org 
 
 START=65
-BIN=/usr/sbin/olsrd
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
 CONF=/var/etc/olsrd.conf
 PID=/var/run/olsrd.pid
 PID6=/var/run/olsrd.ipv6.pid
@@ -637,6 +640,10 @@ olsrd_setup_smartgw_rules() {
        fi
 }
 
+error() {
+       echo "${initscript}:" "$@" 1>&2
+}
+
 start() {
        SYSTEM_HOSTNAME=
        SYSTEM_LAT=
@@ -684,16 +691,18 @@ start() {
                        sed -i "s/$f/$f.ipv6/g" /var/etc/olsrd.conf.ipv6
                done
 
-               if ([ -s $PID6 ] && kill -0 $(cat $PID6) 2>&-); then
-                       echo "Error: There already is a IPv6 instance of olsrd running ($(cat $PID6)), not starting."
+               SERVICE_PID_FILE="$PID6"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv6 instance of olsrd running ($(cat $PID6)), not starting."
                else
-                       start-stop-daemon -q -b -m -p $PID6 -x $BIN -S -- -f /var/etc/olsrd.conf.ipv6 -nofork
+                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv6 -nofork
                fi
 
-                if ([ -s $PID ] && kill -0 $(cat $PID) 2>&-); then
-                               echo "Error: There already is a IPv4 instance of olsrd running ($(cat $PID)), not starting."
+               SERVICE_PID_FILE="$PID"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
                else
-                       start-stop-daemon -q -b -m -p $PID -x $BIN -S -- -f /var/etc/olsrd.conf.ipv4 -nofork
+                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv4 -nofork
                fi
 
                sleep 3
@@ -705,20 +714,21 @@ start() {
                        sed -i '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' "$OLSRD_CONFIG_FILE"
                fi
 
-               ### check for running instance
-               if ([ -s $PID ] && kill -0 $(cat $PID) 2>&-); then
-                       echo "Error: There already is a instance of olsrd running ($(cat $PID)), exiting now."
+               SERVICE_PID_FILE="$PID"
+               if service_check /usr/sbin/olsrd; then
+                       error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
                        return 1
                else
-                       start-stop-daemon -q -b -m -p $PID -x $BIN -S -- -f "$OLSRD_CONFIG_FILE" -nofork
+                       service_start /usr/sbin/olsrd -f "$OLSRD_CONFIG_FILE" -nofork
                fi
        fi
        olsrd_setup_smartgw_rules
 }
 
 stop() {
-       start-stop-daemon -q -p $PID -x $BIN -K
-       start-stop-daemon -q -p $PID6 -x $BIN -K
-       test -s $PID && rm $PID
-       test -s $PID6 && rm $PID6
+       SERVICE_PID_FILE="$PID"
+       service_stop /usr/sbin/olsrd
+
+       SERVICE_PID_FILE="$PID6"
+       service_stop /usr/sbin/olsrd
 }