]> git.parisson.com Git - piplayer.git/commitdiff
add daemon conf
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 25 Jul 2013 13:52:12 +0000 (15:52 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 25 Jul 2013 13:52:12 +0000 (15:52 +0200)
REAME.md [new file with mode: 0644]
etc/default/piplayer [new file with mode: 0644]
etc/init.d/piplayer [new file with mode: 0755]
install.py [new file with mode: 0644]

diff --git a/REAME.md b/REAME.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/etc/default/piplayer b/etc/default/piplayer
new file mode 100644 (file)
index 0000000..b17ece2
--- /dev/null
@@ -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 (executable)
index 0000000..80df210
--- /dev/null
@@ -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 (file)
index 0000000..e69de29