forked from tryphon/rivendell2-debian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rivendell-suse.in
executable file
·252 lines (237 loc) · 6.15 KB
/
rivendell-suse.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#! /bin/bash
##
## Rivendell init script for LSB and chkconfig(8) compliant Linux systems.
##
## (C) Copyright 2002-2006 Fred Gleason <[email protected]>
##
## $Id: rivendell-suse.in,v 1.16.4.1 2013/11/13 18:30:57 cvs Exp $
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of version 2 of the GNU General Public License as
## published by the Free Software Foundation;
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330,
## Boston, MA 02111-1307 USA
##
# chkconfig: 35 65 35
# description: Rivendell system daemons
# config: /etc/rc.conf
### BEGIN INIT INFO
# Provides: rivendell
# Required-Start: $remote_fs alsasound
# Required-Stop: $remote_fs alsasound
# Should-Start: @MYSQL_PKG@
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start the Rivendell system daemons
### END INIT INFO
function StartDaemons {
if test $GPIO_START = yes ; then
if test -x /etc/init.d/gpio ; then
/etc/init.d/gpio status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/gpio start
fi
fi
fi
if test $HPI_START = yes ; then
if test -x /etc/init.d/asihpi ; then
/etc/init.d/asihpi status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/asihpi start
sleep 2
fi
fi
fi
if test $LIVEWIRE_START = yes ; then
if test -x /etc/init.d/axiad ; then
/etc/init.d/axiad status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/axiad start
fi
fi
fi
$JACK_COMMAND > /dev/null 2> /dev/null &
echo -n $! > /var/run/rivendell/jackd.pid
ipcrm -M 0x5005 2> /dev/null
@LOCAL_PREFIX@/bin/caed 2> /dev/null
sleep 1
if test -x @LOCAL_PREFIX@/bin/ripcd ; then
@LOCAL_PREFIX@/bin/ripcd 2> /dev/null
sleep 1
fi
if test -x @LOCAL_PREFIX@/bin/rdcatchd ; then
@LOCAL_PREFIX@/bin/rdcatchd 2> /dev/null
fi
}
function StopDaemons {
killall rdimport > /dev/null 2> /dev/null
if [ -f /var/run/rivendell/rdcatchd.pid ] ; then
kill `cat /var/run/rivendell/rdcatchd.pid` > /dev/null 2> /dev/null
fi
if [ -f /var/run/rivendell/ripcd.pid ] ; then
kill `cat /var/run/rivendell/ripcd.pid` > /dev/null 2> /dev/null
fi
if [ -f /var/run/rivendell/caed.pid ] ; then
kill `cat /var/run/rivendell/caed.pid` > /dev/null 2> /dev/null
fi
if [ -n "$JACK_COMMAND" ] ; then
#
# FIXME
# Why are three kill(1) invocations necessary to stop jackd(1)?
#
if [ -f /var/run/rivendell/jackd.pid ] ; then
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
rm -f /var/run/rivendell/jackd.pid
fi
fi
sleep 2
}
# Set path for script functions
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
#
# If the LSB Init functions exist, use them, otherwise roll our own
#
if test -f /lib/lsb/init-functions ; then
. /lib/lsb/init-functions
else
function log_success_msg() {
echo "$1 ... done."
}
function log_failure_msg() {
echo "$1 ... done."
}
fi
# Default sysconfig values
GPIO_START="no"
HPI_START="no"
LIVEWIRE_START="no"
JACK_START="no"
JACK_SAMPLE_RATE="48000"
JACK_ALSA_DEVICE="hw:0"
JACK_USE_REALTIME="no"
# Override defaults, if we have the sysconfig file
test -f /etc/sysconfig/rivendell && . /etc/sysconfig/rivendell
# Build a jackd command line
if [ $JACK_START = yes ] ; then
if [ $JACK_USE_REALTIME = yes ] ; then
JACK_COMMAND="jackd -R"
else
JACK_COMMAND="jackd"
fi
JACK_COMMAND="$JACK_COMMAND -d alsa -d $JACK_ALSA_DEVICE -r $JACK_SAMPLE_RATE"
fi
# Check for missing binaries
if [ ! -x @LOCAL_PREFIX@/bin/caed ] ; then
echo "caed not installed"
exit 5
fi
#if [ ! -x @LOCAL_PREFIX@/bin/ripcd ] ; then
# echo "ripcd not installed"
# exit 5
#fi
#if [ ! -x @LOCAL_PREFIX@/bin/rdcatchd ] ; then
# echo "rdcatchd not installed"
# exit 5
#fi
# Check for existence of needed config file and read it
if [ ! -r /etc/rd.conf ] ; then
echo "Missing /etc/rd.conf"
exit 6
fi
# Check for existence of PID file directory and create it if necessary.
if [ ! -d /var/run/rivendell ] ; then
mkdir -p /var/run/rivendell
fi
if [ ! -d /var/run/rivendell ] ; then
echo "Missing /var/run/rivendell directory"
exit 6
fi
case "$1" in
start)
$0 silent-status
if test $? -eq 3 ; then
StartDaemons
fi
$0 silent-status
if test $? -eq 0 ; then
log_success_msg "Starting Rivendell system daemons"
exit 0
else
log_failure_msg "Starting Rivendell system daemons"
exit 1
fi
;;
stop)
StopDaemons
$0 silent-status
if test $? -eq 0 ; then
log_failure_msg "Stopping Rivendell system daemons"
exit 1
else
log_success_msg "Stopping Rivendell system daemons"
exit 0
fi
;;
restart)
$0 silent-status
if test $? -eq 0 ; then
$0 stop
fi
$0 silent-status
if test $? -eq 0 ; then
exit 1
fi
$0 start
$0 silent-status
if test $? -eq 0 ; then
exit 0
fi
exit 1
;;
force-reload)
$0 restart
;;
status)
$0 silent-status
EXIT_CODE=$?
if test $EXIT_CODE -eq 0 ; then
echo "Rivendell system daemons running."
else
echo "Rivendell system daemons stopped."
fi
exit $EXIT_CODE
;;
silent-status)
if test -f /var/run/rivendell/caed.pid ; then
if test -d /proc/`cat /var/run/rivendell/caed.pid` ; then
if test ! -x @LOCAL_PREFIX@/bin/ripcd ; then
exit 0
fi
if test -f /var/run/rivendell/ripcd.pid ; then
if test -d /proc/`cat /var/run/rivendell/ripcd.pid` ; then
if test -f /var/run/rivendell/rdcatchd.pid ; then
if test -d /proc/`cat /var/run/rivendell/rdcatchd.pid` ; then
exit 0
fi
fi
fi
fi
fi
fi
exit 3
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac