From 74fd55a69be15127822fd688f6c12f7434834f27 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 25 Jul 2013 15:52:12 +0200 Subject: [PATCH] add daemon conf --- REAME.md | 0 etc/default/piplayer | 4 +++ etc/init.d/piplayer | 62 ++++++++++++++++++++++++++++++++++++++++++++ install.py | 0 4 files changed, 66 insertions(+) create mode 100644 REAME.md create mode 100644 etc/default/piplayer create mode 100755 etc/init.d/piplayer create mode 100644 install.py 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 -- 2.39.5