Commit | Line | Data |
---|---|---|
460b9539 | 1 | #! /bin/sh |
2 | # | |
3 | # This file is part of DisOrder. | |
07184dd3 | 4 | # Copyright (C) 2004, 2005, 2007 Richard Kettlewell |
460b9539 | 5 | # |
e7eb3a27 | 6 | # This program is free software: you can redistribute it and/or modify |
460b9539 | 7 | # it under the terms of the GNU General Public License as published by |
e7eb3a27 | 8 | # the Free Software Foundation, either version 3 of the License, or |
460b9539 | 9 | # (at your option) any later version. |
e7eb3a27 RK |
10 | # |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
460b9539 | 16 | # You should have received a copy of the GNU General Public License |
e7eb3a27 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 18 | # |
19 | ||
20 | set -e | |
21 | ||
22 | DAEMON=sbindir/disorderd | |
af66d051 | 23 | CLIENT="bindir/disorder --local" |
460b9539 | 24 | |
25 | PATH="$PATH:sbindir" | |
26 | ||
5ec96a13 RK |
27 | start_debian() { |
28 | printf "Starting DisOrder server: disorderd" | |
29 | start-stop-daemon -S -q -x ${DAEMON} | |
30 | echo . | |
31 | } | |
32 | ||
33 | start_generic() { | |
fdf98378 | 34 | if ${CLIENT} version >/dev/null 2>&1; then |
460b9539 | 35 | : already running |
36 | else | |
07184dd3 | 37 | printf "Starting DisOrder server: disorderd" |
460b9539 | 38 | ${DAEMON} |
07184dd3 | 39 | echo . |
460b9539 | 40 | fi |
41 | } | |
42 | ||
5ec96a13 RK |
43 | start() { |
44 | if test -e /sbin/start-stop-daemon; then | |
45 | start_debian | |
46 | else | |
47 | start_generic | |
48 | fi | |
49 | } | |
50 | ||
51 | stop_debian() { | |
52 | printf "Stopping DisOrder server: disorderd" | |
53 | start-stop-daemon -K -o -q -x ${DAEMON} | |
54 | echo . | |
55 | } | |
56 | ||
57 | stop_generic() { | |
58 | if ${CLIENT} version >/dev/null 2>&1; then | |
59 | printf "Stopping DisOrder server: disorderd" | |
60 | ${CLIENT} shutdown | |
61 | echo . | |
62 | else | |
63 | : not running | |
64 | fi | |
65 | } | |
66 | ||
460b9539 | 67 | stop() { |
5ec96a13 RK |
68 | if test -e /sbin/start-stop-daemon; then |
69 | stop_debian | |
460b9539 | 70 | else |
5ec96a13 | 71 | stop_generic |
460b9539 | 72 | fi |
73 | } | |
74 | ||
75 | reload() { | |
07184dd3 | 76 | printf "Reloading DisOrder server configuration..." |
460b9539 | 77 | ${CLIENT} reconfigure |
07184dd3 | 78 | echo done. |
460b9539 | 79 | } |
80 | ||
81 | restart() { | |
82 | stop | |
83 | sleep 2 | |
84 | start | |
85 | } | |
86 | ||
87 | case "$1" in | |
88 | start | stop | reload | restart ) "$1" ;; | |
89 | force-reload ) reload ;; | |
90 | * ) | |
91 | echo "usage: $0 start|stop|restart|reload" 1>&2 | |
92 | exit 1 | |
93 | esac |