From: Guillaume Pellerin Date: Thu, 25 Jul 2013 13:52:12 +0000 (+0200) Subject: add daemon conf X-Git-Tag: 0.3~14 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=74fd55a69be15127822fd688f6c12f7434834f27;p=piplayer.git add daemon conf --- diff --git a/REAME.md b/REAME.md new file mode 100644 index 0000000..e69de29 diff --git a/etc/default/piplayer b/etc/default/piplayer new file mode 100644 index 0000000..b17ece2 --- /dev/null +++ b/etc/default/piplayer @@ -0,0 +1,4 @@ + +START_DAEMON="yes" + +PLAYLIST_DIR="/home/pi/music" diff --git a/etc/init.d/piplayer b/etc/init.d/piplayer new file mode 100755 index 0000000..80df210 --- /dev/null +++ b/etc/init.d/piplayer @@ -0,0 +1,62 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: piplayer +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: init-Script for piplayer +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=piplayer +CONF=/etc/default/piplayer +LOG=/var/log/piplayer.log +PIDFILE=/var/run/piplayer.pid +NAME=$DAEMON +DESC="Rpi piplayer" + +test -f $CONF || exit 0 +. $CONF + +if [ ! "x$START_DAEMON" = "xyes" -a ! "$1" = "stop" ]; then + echo "Edit $CONF to start piplayer" + exit 0 +fi + +#test -f $DAEMON || exit 0 + +. /lib/lsb/init-functions + + +case "$1" in + start) + log_begin_msg "Starting piplayer:" "piplayer" + $DAEMON $PLAYLIST_DIR > $LOG & + pid=`pgrep -u ${USER} $DAEMON` + if [ pid = '' ]; then + log_failure_msg "PiPlayer daemon can't be started! Check logfile: $LOG" + log_end_msg 1 + else + echo $pid > $PIDFILE + log_end_msg 0 + fi + + ;; + + stop) + log_begin_msg "Stopping piplayer:" "piplayer" + pid=`cat $PIDFILE | sed -e 's/\s.*//'|head -n1` + if [ ! pid = '' ]; then + pkill -9 -f "piplayer $PLAYLIST_DIR" + log_end_msg 0 + else + log_end_msg 1 + exit 1 + fi + rm $PIDFILE + ;; + +esac + +exit 0 diff --git a/install.py b/install.py new file mode 100644 index 0000000..e69de29