Improved init script for Debian systems

Sat, 21 Dec 2019 12:40:18 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 21 Dec 2019 12:40:18 +0100
changeset 575
fd9e4838648f
parent 574
b436e3d8d83a
child 576
8853fd62ac6f

Improved init script for Debian systems

tools/bmsd.init file | annotate | diff | comparison | revisions
--- a/tools/bmsd.init	Wed Dec 18 13:22:19 2019 +0100
+++ b/tools/bmsd.init	Sat Dec 21 12:40:18 2019 +0100
@@ -45,7 +45,11 @@
 #
 do_start()
 {
-	su - brewery -c "$DAEMON" >/dev/null 2>/dev/null
+	# Return
+        #   0 if daemon has been started
+        #   1 if daemon was already running
+        #   other if daemon could not be started or a failure occured
+	start-stop-daemon --start --chuid brewery --exec $DAEMON
 }
 
 #
@@ -53,9 +57,11 @@
 #
 do_stop()
 {
-	[ -f $PIDFILE ] && kill $(cat $PIDFILE)
-	RETVAL="$?"
-	return "$RETVAL"
+	# Return
+        #   0 if daemon has been stopped
+        #   1 if daemon was already stopped
+        #   other if daemon could not be stopped or a failure occurred
+	start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
 }
 
 #

mercurial