3
# RoarAudio PlayList Daemon initscript
5
# Copyright (c) 2008-2010 Philipp 'ph3-der-loewe' Schafft <lion@lion.leolix.org>
6
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
8
# This is free software; you may redistribute it and/or modify
9
# it under the terms of the GNU General Public License as
10
# published by the Free Software Foundation; either version 3,
11
# or (at your option) any later version.
13
# This is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License with
19
# the Debian operating system, in /usr/share/common-licenses/GPL; if
20
# not, write to the Free Software Foundation, Inc., 59 Temple Place,
21
# Suite 330, Boston, MA 02111-1307 USA
24
# Provides: roarplaylistd
25
# Required-Start: $network $local_fs $remote_fs
26
# Required-Stop: $network $local_fs $remote_fs
27
# Should-Start: roaraudio-server
28
# Should-Stop: roaraudio-server
29
# Default-Start: 2 3 4 5
31
# Short-Description: PlayList mangement daemon for RoarAudio
32
# Description: RoarAudio PlayList Daemon is a daemon managing playlist
33
# for the user and playback of those.
34
# It uses a RoarAudio server as audio backend.
39
. /lib/lsb/init-functions
41
PATH=/sbin:/bin:/usr/sbin:/usr/bin
42
DAEMON=/usr/bin/roarplaylistd
44
DESC="RoarAudio PlayList Daemon"
46
PIDFILEDIR=/var/run/$NAME
47
PIDFILE=$PIDFILEDIR/`basename $DAEMON`.pid
48
SCRIPTNAME=/etc/init.d/$NAME
52
# Gracefully exit if the package has been removed.
53
test -x $DAEMON || exit 0;
55
# Read config file if it is present.
56
if [ -r /etc/default/$NAME ]
61
[ "$RPLD" = 'YES' ] || exit 0;
63
RPLD_OPTS="--daemon $RPLD_OPTS"
65
[ "$PIDFILE" = '' ] || RPLD_OPTS="--pidfile $PIDFILE $RPLD_OPTS"
66
[ "$ROARAUDIO_SERVER" = '' ] || RPLD_OPTS="--server $ROARAUDIO_SERVER $RPLD_OPTS"
68
[ "$RPLD_STORE_LOCATION" = '' ] || RPLD_OPTS="--store-path $RPLD_STORE_LOCATION $RPLD_OPTS"
70
[ "$RPLD_PLAY" = '' ] || RPLD_OPTS="--play $RPLD_OPTS"
72
[ "$RPLD_USER" = '' ] || RPLD_OPTS="--user $RPLD_USER $RPLD_OPTS"
73
[ "$RPLD_GROUP" = '' ] || RPLD_OPTS="--group $RPLD_GROUP $RPLD_OPTS"
77
RPLD_OPTS="$RPLD_OPTS --auto-restore"
79
RPLD_OPTS="$RPLD_OPTS --no-restore"
84
RPLD_OPTS="$RPLD_OPTS --store"
86
RPLD_OPTS="$RPLD_OPTS --no-store"
91
RPLD_OPTS="--unix $RPLD_OPTS"
92
[ "$RPLD_SOCKET" = '' ] || RPLD_OPTS="--bind $RPLD_SOCKET $RPLD_OPTS"
95
RPLD_OPTS="--tcp $RPLD_OPTS"
96
[ "$RPLD_PORT" = '' ] || RPLD_OPTS="--port $RPLD_PORT $RPLD_OPTS"
97
[ "$RPLD_HOST" = '' ] || RPLD_OPTS="--bind $RPLD_HOST $RPLD_OPTS"
100
RPLD_OPTS="--decnet $RPLD_OPTS"
101
[ "$RPLD_PORT" = '' ] || RPLD_OPTS="--port $RPLD_PORT $RPLD_OPTS"
102
[ "$RPLD_HOST" = '' ] || RPLD_OPTS="--bind $RPLD_HOST $RPLD_OPTS"
108
echo -n "Starting $DESC: $NAME"
109
# Set up dir to use for pidfile
110
mkdir -p "$PIDFILEDIR"
111
chown $RPLD_USER:$RPLD_GROUP "$PIDFILEDIR"
112
# Set up dir for store
113
mkdir -p "$RPLD_STORE_LOCATION"
114
chown $RPLD_SOCK_USER:$RPLD_SOCK_GROUP "$RPLD_STORE_LOCATION"
115
# Check if daemon is already running:
117
if [ "$PIDFILE" != '' ]
119
_pid=`cat $PIDFILE 2> /dev/null`
122
if kill -0 $_pid 2> /dev/null
135
echo -n "Stopping $DESC: $NAME"
137
if [ "$PIDFILE" = '' ]
141
_pid=`cat $PIDFILE 2> /dev/null`
142
[ "$_pid" != '' ] && kill -TERM $_pid
148
echo -n "Status of $DESC: "
150
if [ "$PIDFILE" != '' ]
152
_pid=`cat $PIDFILE 2> /dev/null`
155
kill -0 $_pid 2> /dev/null
161
echo "dead (stale pid file)."
170
echo "unknown (no pid file configured)."
173
restart|force-reload)
179
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2