chiark / gitweb /
examples/disorder.init.in: Collect default environment settings.
[disorder] / examples / disorder.init.in
CommitLineData
460b9539 1#! /bin/sh
2#
3# This file is part of DisOrder.
b6a84ef2 4# Copyright (C) 2004, 2005, 2007, 2009 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
c210dedc
RK
20### BEGIN INIT INFO
21# Provides: disorder
22# Required-Start: $local_fs $network $named $remote_fs $syslog $time
23# Required-Stop: $local_fs $network $named $remote_fs $syslog $time
24# Default-Start: 2 3 4 5
25# Default-Stop: 0 1 6
26# Short-Description: Start and stop DisOrder
27# Description: DisOrder is a multi-user software jukebox.
28### END INIT INFO
29
460b9539 30set -e
31
8ed6a527
RK
32. /lib/lsb/init-functions
33
460b9539 34DAEMON=sbindir/disorderd
af66d051 35CLIENT="bindir/disorder --local"
460b9539 36
37PATH="$PATH:sbindir"
38
d9bb6bef
MW
39if [ -r /etc/default/locale ]; then
40 . /etc/default/locale
41 for var in \
42 LANG LANGUAGE LC_ALL \
43 LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT \
44 LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME
45 do
46 eval p=\${$var+t}
47 case ${p+t} in t) export $var ;; esac
48 done
49fi
50
141b3865
MW
51if [ -r /etc/default/disorder ]; then
52 . sysconfdir/default/disorder
53fi
54
5ec96a13
RK
55start_debian() {
56 printf "Starting DisOrder server: disorderd"
57 start-stop-daemon -S -q -x ${DAEMON}
58 echo .
59}
60
61start_generic() {
fdf98378 62 if ${CLIENT} version >/dev/null 2>&1; then
460b9539 63 : already running
64 else
07184dd3 65 printf "Starting DisOrder server: disorderd"
460b9539 66 ${DAEMON}
07184dd3 67 echo .
460b9539 68 fi
69}
70
5ec96a13
RK
71start() {
72 if test -e /sbin/start-stop-daemon; then
73 start_debian
74 else
75 start_generic
76 fi
77}
78
79stop_debian() {
80 printf "Stopping DisOrder server: disorderd"
81 start-stop-daemon -K -o -q -x ${DAEMON}
82 echo .
83}
84
85stop_generic() {
86 if ${CLIENT} version >/dev/null 2>&1; then
87 printf "Stopping DisOrder server: disorderd"
88 ${CLIENT} shutdown
89 echo .
90 else
91 : not running
92 fi
93}
94
460b9539 95stop() {
5ec96a13
RK
96 if test -e /sbin/start-stop-daemon; then
97 stop_debian
460b9539 98 else
5ec96a13 99 stop_generic
460b9539 100 fi
101}
102
103reload() {
07184dd3 104 printf "Reloading DisOrder server configuration..."
460b9539 105 ${CLIENT} reconfigure
07184dd3 106 echo done.
460b9539 107}
108
109restart() {
110 stop
111 sleep 2
112 start
113}
114
115case "$1" in
116start | stop | reload | restart ) "$1" ;;
117force-reload ) reload ;;
118* )
119 echo "usage: $0 start|stop|restart|reload" 1>&2
120 exit 1
121esac