[SCM] forked-daapd/master: Update init script
rbalint at users.alioth.debian.org
rbalint at users.alioth.debian.org
Thu Jun 12 00:02:11 UTC 2014
The following commit has been merged in the master branch:
commit 9635299ca68c9eaa6a5d83c3e9171976dc4a4248
Author: Espen Jürgensen <espenjurgensen at gmail.com>
Date: Tue Jun 3 09:00:08 2014 +0700
Update init script
diff --git a/debian/control b/debian/control
index 28d31a4..95307bd 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: sound
Priority: optional
Maintainer: Debian Multimedia Maintainers <pkg-multimedia-maintainers at lists.alioth.debian.org>
Uploaders: Balint Reczey <balint at balintreczey.hu>
-Build-Depends: debhelper (>= 9~), libflac-dev, libtagc0-dev, libavcodec-dev (>= 3:0.svn20090204), libavformat-dev (>= 3:0.svn20090204), libswscale-dev, libavutil-dev, libavresample-dev, libavahi-client-dev, libsqlite3-dev (>= 3.6.23.1-2), libconfuse-dev, libavl-dev, libmxml-dev, libplist-dev (>= 0.16), libgcrypt11-dev, libgpg-error-dev, libasound2-dev [linux-any], oss4-dev [kfreebsd-any], zlib1g-dev, libunistring-dev (>= 0.9.3), libtre-dev (>= 0.8.0), libevent-dev (>= 2.0), libantlr3c-dev (>= 3.2), antlr3 (>= 3.2-3), gperf, autotools-dev, dh-autoreconf
+Build-Depends: debhelper (>= 9~), libflac-dev, libtagc0-dev, libavcodec-dev (>= 3:0.svn20090204), libavformat-dev (>= 3:0.svn20090204), libswscale-dev, libavutil-dev, libavresample-dev, libavahi-client-dev, libsqlite3-dev (>= 3.6.23.1-2), libconfuse-dev, libavl-dev, libmxml-dev, libplist-dev (>= 0.16), libgcrypt11-dev, libgpg-error-dev, libasound2-dev [linux-any], oss4-dev [kfreebsd-any], zlib1g-dev, libunistring-dev (>= 0.9.3), libtre-dev (>= 0.8.0), libevent-dev (>= 2.0), libantlr3c-dev (>= 3.2), antlr3 (>= 3.2-3), gperf, autotools-dev, dh-autoreconf, lsb-base (>= 3.0-6)
Homepage: http://github.com/ejurgensen/forked-daapd
Vcs-Git: git://git.debian.org/pkg-multimedia/forked-daapd.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-multimedia/forked-daapd.git
diff --git a/debian/forked-daapd.init b/debian/forked-daapd.init
index 61b1aba..744eb29 100755
--- a/debian/forked-daapd.init
+++ b/debian/forked-daapd.init
@@ -1,127 +1,158 @@
-#! /bin/sh
+#!/bin/sh
### BEGIN INIT INFO
# Provides: forked-daapd
-# Required-Start: $local_fs $remote_fs $network $time avahi-daemon
+# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
+# Should-Start: avahi-daemon
+# Should-Stop: avahi-daemon
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: media server with support for RSP, DAAP, DACP and AirTunes
-# Description: forked-daapd is an iTunes-compatible media server for
-# sharing your music library over the local network with RSP
-# clients like the SoundBridge from Roku and DAAP clients like
-# iTunes. It can also stream music to AirTunes devices.
+# Short-Description: Media server with support for RSP, DAAP, DACP and AirPlay
+# Description: It supports a wide range of audio formats, can stream
+# video to iTunes, FrontRow and other compatible clients,
+# has support for Apple's Remote iPhone/iPod application
+# and can stream music to AirPlay devices like the AirPort
+# Express.
### END INIT INFO
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/sbin/forked-daapd
-NAME=forked-daapd
-DESC="RSP and DAAP media server"
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC=forked-daapd # Introduce a short description here
+NAME=forked-daapd # Introduce the short server's name here
+DAEMON=/usr/sbin/forked-daapd # Introduce the server's location here
+DAEMON_ARGS="" # Arguments to run the daemon with
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
-test -x $DAEMON || exit 0
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
-PIDFILE=/var/run/$NAME.pid
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-set -e
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
-running_pid()
+#
+# Function that starts the daemon/service
+#
+do_start()
{
- # Check if a given process pid's cmdline matches a given name
- pid=$1
- name=$2
- [ -z "$pid" ] && return 1
- [ ! -d /proc/$pid ] && return 1
- cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
- # Is this the expected child?
- [ "$cmd" != "$name" ] && return 1
- return 0
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
}
-running()
+#
+# Function that stops the daemon/service
+#
+do_stop()
{
-# Check if the process is running looking at /proc
-# (works for all users)
-
- # No pidfile, probably no daemon present
- [ ! -f "$PIDFILE" ] && return 1
- # Obtain the pid and check it against the binary name
- pid=`cat $PIDFILE`
- running_pid $pid $DAEMON || return 1
- return 0
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
}
-force_stop() {
-# Forcefully kill the process
- [ ! -f "$PIDFILE" ] && return
- if running ; then
- kill -15 $pid
- # Is it really dead?
- if running ; then
- kill -9 $pid
- if running ; then
- echo "Cannot kill $NAME (pid=$pid)!"
- exit 1
- fi
- fi
- fi
- rm -f $PIDFILE
- return 0
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
}
case "$1" in
start)
- echo -n "Starting $DESC: "
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --exec $DAEMON -- $DAEMON_OPTS
- if running ; then
- echo "$NAME."
- else
- echo " ERROR."
- fi
- ;;
- stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
- --exec $DAEMON
- echo "$NAME."
- ;;
- force-reload)
- start-stop-daemon --stop --test --quiet --pidfile \
- /var/run/$NAME.pid --exec $DAEMON \
- && $0 restart \
- || exit 0
- ;;
- restart)
- PID=$(cat $PIDFILE 2> /dev/null || true)
+ if init_is_upstart; then
+ exit 1
+ fi
- echo -n "Restarting $DESC: "
- start-stop-daemon --stop --quiet --oknodo --pidfile \
- /var/run/$NAME.pid --exec $DAEMON
-
- if [ -n "$PID" ]; then
- while running_pid $PID $DAEMON; do echo -n "."; sleep 1; done
- fi
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ if init_is_upstart; then
+ exit 0
+ fi
- start-stop-daemon --start --quiet --pidfile \
- /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
- echo "$NAME."
- ;;
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
status)
- echo -n "$NAME is "
- if running ; then
- echo "running"
- else
- echo " not running."
- exit 1
- fi
- ;;
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ if init_is_upstart; then
+ exit 1
+ fi
+
+ 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
+ ;;
*)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
- exit 1
- ;;
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 1
+ ;;
esac
-exit 0
+:
--
forked-daapd packaging
More information about the pkg-multimedia-commits
mailing list