From ceaf23cfaa70505f7027097deb732c0274d38d25 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sun, 26 Feb 2012 01:01:42 +0000 Subject: [PATCH] add an init script to run djrandom-client as daemon with the debian package --- client/debian/changelog | 6 +++ client/debian/control | 2 +- client/debian/djrandom-client.default | 4 ++ client/debian/djrandom-client.init | 65 +++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 client/debian/djrandom-client.default create mode 100755 client/debian/djrandom-client.init diff --git a/client/debian/changelog b/client/debian/changelog index 2aa79a9..a9d3aa2 100644 --- a/client/debian/changelog +++ b/client/debian/changelog @@ -1,3 +1,9 @@ +djrandom-client (0.2.7-1) unstable; urgency=low + + * Add an init script to run it as a daemon. + + -- ale <ale@incal.net> Sun, 25 Feb 2012 00:59:43 +0000 + djrandom-client (0.2.7) unstable; urgency=low * Add --exclude option. diff --git a/client/debian/control b/client/debian/control index 5b8d5c0..456a35a 100644 --- a/client/debian/control +++ b/client/debian/control @@ -8,7 +8,7 @@ Standards-Version: 3.8.0.1 Package: djrandom-client Architecture: all -Depends: ${python:Depends}, python-pyinotify +Depends: ${python:Depends} Description: DJRandom uploader client. Uploads your music in the background. diff --git a/client/debian/djrandom-client.default b/client/debian/djrandom-client.default new file mode 100644 index 0000000..e72bbba --- /dev/null +++ b/client/debian/djrandom-client.default @@ -0,0 +1,4 @@ + +# Set this to 'true' to enable the daemon. +ENABLED=false + diff --git a/client/debian/djrandom-client.init b/client/debian/djrandom-client.init new file mode 100755 index 0000000..3227884 --- /dev/null +++ b/client/debian/djrandom-client.init @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Start/stop the DJRandom client. +# +### BEGIN INIT INFO +# Provides: djrandom +# Required-Start: $network $local_fs +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: DJRandom Client +# Description: DJRandom Client +### END INIT INFO + + +NAME=djrandom-client +DESCR="DJRandom client" +DAEMON=/usr/bin/djrandom-client +RUNDIR=/var/run/djrandom +PIDFILE=${RUNDIR}/${NAME}.pid +USER=nobody +OPTIONS= +ENABLED=false + +test -e /etc/default/${NAME} && . /etc/default/${NAME} + +test -x ${DAEMON} || exit 0 + +if [ "${ENABLED}" != "true" ]; then + echo "DJRandom will not start as a daemon." + echo "Set ENABLED=true in /etc/default/${NAME} to enable." + exit 0 +fi + +case "$1" in +start) + test -d ${RUNDIR} || mkdir -p ${RUNDIR} + if [ -n "${USER}" ]; then + chown ${USER} ${RUNDIR} + OPTIONS="--user ${USER} ${OPTIONS}" + fi + OPTIONS="--skip_version_check ${OPTIONS}" + + echo -n "Starting ${DESCR}... " + start-stop-daemon --start --pidfile ${PIDFILE} \ + --exec ${DAEMON} -- ${OPTIONS} + echo "ok" + ;; +stop) + echo -n "Stopping ${DESCR}... " + start-stop-daemon --stop \ + --pidfile ${PIDFILE} && rm -f ${PIDFILE} + echo "ok" + ;; +restart) + $0 stop + sleep 3 + $0 start + ;; +esac + +exit 0 + -- GitLab