Last active
January 29, 2022 19:35
-
-
Save nfekete/d2c4c40b3f5347c9e514ffdf8c622c42 to your computer and use it in GitHub Desktop.
Shairplay init script and default config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#which nologin >> /etc/shells | |
useradd -s /usr/sbin/nologin -r -M -d /etc/shairplay --groups audio,pulse,pulse-access shairplay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shairplay Daemon options | |
# Uncomment and modify lines to change defaults | |
# User and group under which shairplay should be run | |
# user should have permission to output sound | |
# Check the audio output documentation for details. | |
USER=shairplay | |
# Specify where the airport.key is located | |
KEYLOCATION=/etc/shairplay | |
# File where log messages should be redirected. | |
# If a non-default log or error file is used, and logrotate is configured with | |
# the provided configuration file, then the paths of the log files should be | |
# updated in /etc/logrotate.d/shairplay to reflect the value of $LOGFILE and $ERRFILE | |
LOGFILE=/var/log/shairplay.log | |
# If empty, errors are redirected to LOGFILE | |
#ERRFILE=/var/log/shairplay.err | |
PIDFILE=/var/run/shairplay.pid | |
# Set the AirPlay advertised name. | |
# Defaults to computer's hostname | |
APNAME=`hostname` | |
# Set output driver and options | |
# Defaults to the first available, depends on the build options | |
# Check 'shairplay -h' for details | |
#OUTPUT=ao | |
#OUTPUT_OPTS= | |
#RUN_ONSTART= | |
#RUN_ONSTOP= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This starts and stops shairplay | |
# | |
### BEGIN INIT INFO | |
# Provides: shairplay | |
# Required-Start: $network | |
# Required-Stop: | |
# Short-Description: shairplay - Airtunes emulator! | |
# Description: Airtunes emulator! | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
### END INIT INFO | |
# Check for existance of defaults file | |
# and utilze if available | |
if [ -f /etc/default/shairplay ]; then | |
. /etc/default/shairplay | |
else | |
echo "/etc/default/shairplay not found using default settings."; | |
fi | |
# Source function library. | |
. /lib/lsb/init-functions | |
NAME=shairplay | |
USER=${USER} | |
DAEMON=/usr/bin/shairplay | |
KEYLOCATION=${KEYLOCATION-/etc/shairplay} | |
PIDFILE=${PIDFILE-/var/run/$NAME.pid} | |
APNAME=${APNAME-shairplay} | |
LOGFILE=${LOGFILE-/var/log/shairport.log} | |
DAEMON_ARGS="-a $APNAME" | |
[ -x $DAEMON ] || exit 0 | |
RETVAL=0 | |
start() { | |
echo -n "Starting shairplay: " | |
start-stop-daemon --start --make-pidfile --pidfile "$PIDFILE" \ | |
--chuid $USER \ | |
--chdir "$KEYLOCATION" \ | |
--exec "$DAEMON" -b --oknodo -- $DAEMON_ARGS | |
log_end_msg $? | |
} | |
stop() { | |
echo -n "Shutting down shairplay: " | |
start-stop-daemon --stop --quiet --remove-pidfile --pidfile "$PIDFILE" \ | |
--retry 1 --oknodo | |
log_end_msg $? | |
} | |
restart() { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status shairplay | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
log file output doesn't work currently