#!/bin/sh # # $Id$ # # squeezecenter initscript for slimserver.pl # This file should be placed in /etc/init.d. # # Original Author: Mattias Holmlund # # Updated By: Dan Sully set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="SqueezeCenter Audio Server" NAME=squeezecenter DAEMON=/usr/sbin/$NAME-server DAEMON_SAFE=/usr/sbin/${NAME}_safe PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME SLIMUSER=root PREFSDIR=/var/lib/$NAME/prefs LOGDIR=/var/log/$NAME/ CACHEDIR=/var/lib/$NAME/cache SLIMOPTIONS= # Read config file if it is present. if [ -r /etc/default/$NAME ] then . /etc/default/$NAME fi # # Function that starts the daemon/service. # d_start() { # Use squeezecenter_safe to restart the daemon when # it dies. This must be done to handle mysql restarts. start-stop-daemon --start --quiet \ --chuid $SLIMUSER \ --pidfile $PIDFILE \ --exec /bin/bash \ --background \ --make-pidfile \ --name squeezecenter_s \ --startas $DAEMON_SAFE \ -- \ $DAEMON \ --prefsdir $PREFSDIR \ --logdir $LOGDIR \ --cachedir $CACHEDIR \ $SLIMOPTIONS } d_start_direct() { start-stop-daemon --start --quiet \ --chuid $SLIMUSER \ --pidfile $PIDFILE \ --exec $DAEMON \ -- \ --pidfile $PIDFILE \ --daemon \ --prefsdir $PREFSDIR \ --logdir $LOGDIR \ --cachedir $CACHEDIR \ $SLIMOPTIONS } # Function that stops the daemon/service. # d_stop() { ## This is a bug in the start-stop-daemon that checks the PID name from the /proc/PID/stat filesystem... ## Unfortunately this cuts-off the name of the daemon because its longer now, and then it doesnt get ## caught by the start-stop-daemon. The daemon actually reports it as squeezecenter_s instead of ## squeezecenter_safe. start-stop-daemon -o --stop --pidfile $PIDFILE --name squeezecenter_s } # # Function that sends a SIGHUP to the daemon/service. # d_reload() { start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --name $NAME --signal 1 } case "$1" in start) echo -n "Starting $DESC" d_start echo "." ;; stop) echo -n "Stopping $DESC" d_stop echo "." ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo -n "Restarting $NAME" d_stop sleep 15 d_start echo "." ;; *) # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0