mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] dibbler: Use start-stop-daemon to start the services
@ 2012-05-28 12:42 Bart vdr. Meulen
  2012-05-30  7:20 ` Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Bart vdr. Meulen @ 2012-05-28 12:42 UTC (permalink / raw)
  To: ptxdist

From: "Bart vdr. Meulen" <bartvdrmeulen@gmail.com>

Use start-stop-daemon to start (and stop) the various daemons of
dibbler

Signed-off-by: Bart vdr. Meulen <bartvdrmeulen@gmail.com>
---
 generic/etc/init.d/dibbler-client |   37 ++++++++++++++++++++++-------------
 generic/etc/init.d/dibbler-relay  |   37 ++++++++++++++++++++++-------------
 generic/etc/init.d/dibbler-server |   39 +++++++++++++++++++++++--------------
 rules/dibbler.in                  |    3 +++
 4 files changed, 73 insertions(+), 43 deletions(-)

diff --git a/generic/etc/init.d/dibbler-client b/generic/etc/init.d/dibbler-client
index 11d2b17..b4f219f 100644
--- a/generic/etc/init.d/dibbler-client
+++ b/generic/etc/init.d/dibbler-client
@@ -8,6 +8,7 @@ DAEMON=/usr/sbin/dibbler-client
 NAME=dibbler-client
 DESC="DHCPv6 client"
 DAEMON_OPTS=run
+PIDFILE=/var/lib/dibbler/client.pid
 
 test -x $DAEMON || exit 0
 
@@ -18,31 +19,39 @@ fi
 
 set -e
 
-case "$1" in
-  start)
+start_daemon()
+{
 	echo -n "Starting $DESC: "
-	$DAEMON start 2>&1 > /dev/null
+	start-stop-daemon -S -x "$DAEMON" -o -q -b -- "$DAEMON_OPTS"
 	echo "$NAME."
-	;;
-  stop)
+}
+
+stop_daemon()
+{
 	echo -n "Stopping $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	start-stop-daemon -K -x "$DAEMON" -q -o -p "$PIDFILE"
 	echo "$NAME."
+}
+
+case "$1" in
+  start)
+	start_daemon
 	;;
-  status)
-	echo "Status $DESC: $NAME"
-	$DAEMON status
+  stop)
+	stop_daemon
 	;;
   restart|force-reload)
-	echo -n "Restarting $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	stop_daemon
 	sleep 1
-	$DAEMON start 2>&1 > /dev/null
-	echo "$NAME."
+	start_daemon
+	;;
+  status)
+	echo "Status $DESC: $NAME"
+	$DAEMON status
 	;;
   *)
 	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 	exit 1
 	;;
 esac
diff --git a/generic/etc/init.d/dibbler-relay b/generic/etc/init.d/dibbler-relay
index 2925358..6fc029e 100644
--- a/generic/etc/init.d/dibbler-relay
+++ b/generic/etc/init.d/dibbler-relay
@@ -8,6 +8,7 @@ DAEMON=/usr/sbin/dibbler-relay
 NAME=dibbler-relay
 DESC="DHCPv6 relay"
 DAEMON_OPTS=run
+PIDFILE=/var/lib/dibbler/relay.pid
 
 test -x $DAEMON || exit 0
 
@@ -18,31 +19,39 @@ fi
 
 set -e
 
-case "$1" in
-  start)
+start_daemon()
+{
 	echo -n "Starting $DESC: "
-	$DAEMON start 2>&1 > /dev/null
+	start-stop-daemon -S -x "$DAEMON" -o -q -b -- "$DAEMON_OPTS"
 	echo "$NAME."
-	;;
-  stop)
+}
+
+stop_daemon()
+{
 	echo -n "Stopping $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	start-stop-daemon -K -x "$DAEMON" -q -o -p "$PIDFILE"
 	echo "$NAME."
+}
+
+case "$1" in
+  start)
+	start_daemon
 	;;
-  status)
-	echo "Status $DESC: $NAME"
-	$DAEMON status
+  stop)
+	stop_daemon
 	;;
   restart|force-reload)
-	echo -n "Restarting $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	stop_daemon
 	sleep 1
-	$DAEMON start 2>&1 > /dev/null
-	echo "$NAME."
+	start_daemon
+	;;
+  status)
+	echo "Status $DESC: $NAME"
+	$DAEMON status
 	;;
   *)
 	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 	exit 1
 	;;
 esac
diff --git a/generic/etc/init.d/dibbler-server b/generic/etc/init.d/dibbler-server
index d03c0c0..acbe241 100644
--- a/generic/etc/init.d/dibbler-server
+++ b/generic/etc/init.d/dibbler-server
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Starts/stops dibbler-client
+# Starts/stops dibbler-server
 #
 
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@@ -8,6 +8,7 @@ DAEMON=/usr/sbin/dibbler-server
 NAME=dibbler-server
 DESC="DHCPv6 server"
 DAEMON_OPTS=run
+PIDFILE=/var/lib/dibbler/server.pid
 
 test -x $DAEMON || exit 0
 
@@ -18,31 +19,39 @@ fi
 
 set -e
 
-case "$1" in
-  start)
+start_daemon()
+{
 	echo -n "Starting $DESC: "
-	$DAEMON start 2>&1 > /dev/null
+	start-stop-daemon -S -x "$DAEMON" -o -q -b -- "$DAEMON_OPTS"
 	echo "$NAME."
-	;;
-  stop)
+}
+
+stop_daemon()
+{
 	echo -n "Stopping $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	start-stop-daemon -K -x "$DAEMON" -q -o -p "$PIDFILE"
 	echo "$NAME."
+}
+
+case "$1" in
+  start)
+	start_daemon
 	;;
-  status)
-	echo "Status $DESC: $NAME"
-	$DAEMON status
+  stop)
+	stop_daemon
 	;;
   restart|force-reload)
-	echo -n "Restarting $DESC: "
-	($DAEMON stop 2>&1 > /dev/null; true)
+	stop_daemon
 	sleep 1
-	$DAEMON start 2>&1 > /dev/null
-	echo "$NAME."
+	start_daemon
+	;;
+  status)
+	echo "Status $DESC: $NAME"
+	$DAEMON status
 	;;
   *)
 	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 	exit 1
 	;;
 esac
diff --git a/rules/dibbler.in b/rules/dibbler.in
index 6c98080..cdf1cca 100644
--- a/rules/dibbler.in
+++ b/rules/dibbler.in
@@ -6,6 +6,9 @@ menuconfig DIBBLER
 	select LIBC_M
 	select GCCLIBS_CXX
 	select GCCLIBS_GCC_S
+	select BUSYBOX_START_STOP_DAEMON if DIBBLER_SERVER_STARTSCRIPT
+	select BUSYBOX_START_STOP_DAEMON if DIBBLER_CLIENT_STARTSCRIPT
+	select BUSYBOX_START_STOP_DAEMON if DIBBLER_RELAY_STARTSCRIPT
 	help
 	  Dibbler is a portable DHCPv6 implementation.
 	  It supports stateful (i.e. IPv6 address granting) as well as
-- 
1.7.9.5


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-30  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-28 12:42 [ptxdist] [PATCH] dibbler: Use start-stop-daemon to start the services Bart vdr. Meulen
2012-05-30  7:20 ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox