chiark / gitweb /
init script now uses start-stop-daemon if available (i.e. on Debian
[disorder] / examples / disorder.init.in
index 9c912e4..905fc2e 100644 (file)
@@ -26,8 +26,14 @@ CLIENT="bindir/disorder --local"
 
 PATH="$PATH:sbindir"
 
-start() {
-  if ${CLIENT} >/dev/null 2>&1; then
+start_debian() {
+  printf "Starting DisOrder server: disorderd"
+  start-stop-daemon -S -q -x ${DAEMON}
+  echo .
+}
+
+start_generic() {
+  if ${CLIENT} version >/dev/null 2>&1; then
     : already running
   else
     printf "Starting DisOrder server: disorderd"
@@ -36,13 +42,35 @@ start() {
   fi
 }
 
+start() {
+  if test -e /sbin/start-stop-daemon; then
+    start_debian
+  else
+    start_generic
+  fi
+}
+
+stop_debian() {
+  printf "Stopping DisOrder server: disorderd"
+  start-stop-daemon -K -o -q -x ${DAEMON}
+  echo .
+}
+
+stop_generic() {
+ if ${CLIENT} version >/dev/null 2>&1; then
+   printf "Stopping DisOrder server: disorderd"
+   ${CLIENT} shutdown
+   echo .
+ else
+   : not running
+ fi
+}
+
 stop() {
-  if ${CLIENT} >/dev/null 2>&1; then
-    printf "Stopping DisOrder server: disorderd"
-    ${CLIENT} shutdown
-    echo .
+  if test -e /sbin/start-stop-daemon; then
+    stop_debian
   else
-    : not running
+    stop_generic
   fi
 }