From 8d95eec3a92ebe56ec478dec081790734f056591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Kwa=C5=9Bny?= Date: Thu, 14 Apr 2011 21:14:40 +0200 Subject: [PATCH] - add install target to Makefile - add sample init script (shairport.init.sample) --- Makefile | 6 ++++ shairport.init.sample | 67 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 shairport.init.sample diff --git a/Makefile b/Makefile index c1ae84a5..546bd900 100644 --- a/Makefile +++ b/Makefile @@ -13,5 +13,11 @@ clean: .PTHONY: all clean +prefix=/usr/local +install: hairtunes + install -m 0755 hairtunes $(prefix)/bin + install -m 0755 shairport.pl $(prefix)/bin +.PHONY: install + .SILENT: clean diff --git a/shairport.init.sample b/shairport.init.sample new file mode 100755 index 00000000..4cd73826 --- /dev/null +++ b/shairport.init.sample @@ -0,0 +1,67 @@ +#!/bin/bash +# +# This starts and stops shairport +# +### BEGIN INIT INFO +# Provides: shairport +# Required-Start: $network +# Required-Stop: +# Short-Description: shairport - Airtunes emulator! +# Description: Airtunes emulator! +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +### END INIT INFO + + +# Source function library. +. /lib/lsb/init-functions + +NAME=shairport +DAEMON="/usr/local/bin/shairport.pl" +DAEMON_ARGS="" +PIDFILE=/var/run/$NAME.pid + +[ -x $binary ] || exit 0 + +RETVAL=0 + +start() { + echo -n "Starting shairport: " + start-stop-daemon --start --quiet --pidfile "$PIDFILE" \ + --exec "$DAEMON" -b --oknodo -- $DAEMON_ARGS + log_end_msg $? +} + +stop() { + echo -n "Shutting down shairport: " + start-stop-daemon --stop --quiet --pidfile "$PIDFILE" \ + --retry 1 --oknodo + log_end_msg $? +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status shairport + ;; + restart) + restart + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + ;; +esac + +exit 0 +