chiark / gitweb /
Make tests/play.py more reliable.
[disorder] / examples / disorder.init.in
index f09cbca98b146ee3b038da07c0d194a308cca3c3..905fc2ecb7fc6eb302af154dd9abb58fb3f121dc 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 #
 # This file is part of DisOrder.
-# Copyright (C) 2004, 2005 Richard Kettlewell
+# Copyright (C) 2004, 2005, 2007 Richard Kettlewell
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 set -e
 
 DAEMON=sbindir/disorderd
-CLIENT=bindir/disorder
+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 disorderd... "
+    printf "Starting DisOrder server: disorderd"
     ${DAEMON}
-    echo done
+    echo .
+  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 disorderd... "
-    ${CLIENT} shutdown
-    echo done
+  if test -e /sbin/start-stop-daemon; then
+    stop_debian
   else
-    : not running
+    stop_generic
   fi
 }
 
 reload() {
-  printf "Reconfiguring disorderd... "
+  printf "Reloading DisOrder server configuration..."
   ${CLIENT} reconfigure
-  echo done
+  echo done.
 }
 
 restart() {