Add and init script for debian.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# Shairport Daemon options
|
||||
# Uncomment and modify lines to change defaults
|
||||
#
|
||||
|
||||
# User and group under whihc shairport should be run
|
||||
# user should have permission to output sound
|
||||
# Check the audio output documentation for details.
|
||||
#USER=shairport
|
||||
#GROUP=nobody
|
||||
|
||||
# Process' nice on start
|
||||
#NICE=0
|
||||
|
||||
#LOGFILE=/var/log/shairport.log
|
||||
|
||||
# If empty, errors are redirected to LOGFILE
|
||||
#ERRFILE=/var/log/shairport.err
|
||||
|
||||
#PIDFILE=/var/run/shairport.pid
|
||||
|
||||
# Set the AirPlay advertised name.
|
||||
# Defaults to computer's hostname
|
||||
#AP_NAME=
|
||||
|
||||
# Set output driver and options
|
||||
# Defaults to the first available, depends on the build options
|
||||
# Check 'shairport -h' for details
|
||||
#OUTPUT=ao
|
||||
#OUTPUT_OPTS=
|
||||
|
||||
# Change how many frames re required to start playing
|
||||
#BUFFER_FILL=220
|
||||
|
||||
#RUN_ONSTART=
|
||||
#RUN_ONSTOP=
|
||||
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: skeleton
|
||||
# Required-Start: $remote_fs $networking
|
||||
# Required-Stop: $remote_fs $networking
|
||||
# Should-Start: pulseaudio alsa-utils hostname
|
||||
# Should-Stop: pulseaudio alsa-utils hostname
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
### END INIT INFO
|
||||
|
||||
# Do not configure this file. Edit /etc/default/shairport instead!
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Shairport Airtunes emulator"
|
||||
NAME=shairport
|
||||
DAEMON=/usr/bin/shairport
|
||||
|
||||
# Configuration defaults
|
||||
USER=shairport
|
||||
GROUP=nogroup
|
||||
LOGFILE=/var/log/$NAME.log
|
||||
ERRFILE=/var/log/$NAME.err
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
AP_NAME=$(hostname)
|
||||
NICE=0
|
||||
|
||||
test -f /etc/default/shairport && . /etc/default/shairport
|
||||
|
||||
DAEMON_ARGS="--daemon --pidfile $PIDFILE --log $LOGFILE"
|
||||
|
||||
[ -z "$ERRFILE" ] || DAEMON_ARGS="$DAEMON_ARGS --error $ERRFILE"
|
||||
[ -z "$AP_NAME" ] || DAEMON_ARGS="$DAEMON_ARGS --name $AP_NAME"
|
||||
[ -z "$BUFFER_FILL" ] || DAEMON_ARGS="$DAEMON_ARGS -b $BUFFER_FILL"
|
||||
[ -z "$ON_START" ] || DAEMON_ARGS="$DAEMON_ARGS --on-start \"$ON_START\""
|
||||
[ -z "$ON_STOP" ] || DAEMON_ARGS="$DAEMON_ARGS --on-stop \"$ON_STOP\""
|
||||
[ -z "$OUTPUT" ] || DAEMON_ARGS="$DAEMON_ARGS --output $OUTPUT"
|
||||
[ -z "$OUTPUT_OPTS" ] || DAEMON_ARGS="$DAEMON_ARGS -- $OUTPUT_OPTS"
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || { echo "$NAME is not installed" >&2 ; exit 1; }
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
do_start()
|
||||
{
|
||||
# Let the daemon write to the pid/log/error files
|
||||
touch $PIDFILE $LOGFILE $ERRFILE
|
||||
chown root:$GROUP $PIDFILE $LOGFILE $ERRFILE
|
||||
chmod 660 $PIDFILE $LOGFILE $ERRFILE
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--pidfile $PIDFILE \
|
||||
--exec $DAEMON \
|
||||
--chuid $USER:$GROUP \
|
||||
--nicelevel $NICE \
|
||||
-- $DAEMON_ARGS
|
||||
}
|
||||
|
||||
do_stop()
|
||||
{
|
||||
start-stop-daemon --stop --quiet \
|
||||
--pidfile $PIDFILE \
|
||||
--exec $DAEMON \
|
||||
--name $NAME \
|
||||
--retry=TERM/10/KILL/5
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
log_end_msg $?
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
log_end_msg $?
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
Reference in New Issue
Block a user