78 lines
1.5 KiB
Plaintext
Executable File
78 lines
1.5 KiB
Plaintext
Executable File
# /etc/init.d/mplayerd
|
|
### BEGIN INIT INFO
|
|
# Provides: mplayer
|
|
# Required-Start: $network $syslog
|
|
# Required-Stop: $network $syslog
|
|
# Should-Start: $time
|
|
# Should-Stop: $time
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start and stop the mplayer daemon
|
|
# Description: mplayer daemon
|
|
### END INIT INFO
|
|
|
|
CONTROLFILE="/tmp/mplayercontrol"
|
|
DAEMONUSER=pi
|
|
|
|
DAEMON=/usr/bin/mplayer
|
|
#DAEMON_ARGS="-slave -idle -input file=$CONTROLFILE"
|
|
DAEMON_ARGS="-slave -idle -ao alsa -playlist http://volumio:8000/mpd.m3u"
|
|
PIDFILE=/tmp/mplayerd.pid
|
|
|
|
start() {
|
|
echo "Starting mplayer..."
|
|
|
|
# Prepare fifo file
|
|
rm -rf $CONTROLFILE
|
|
mkfifo $CONTROLFILE
|
|
chmod a+rw $CONTROLFILE
|
|
|
|
start-stop-daemon --start --quiet --user $DAEMONUSER \
|
|
--make-pidfile --pidfile $PIDFILE --background \
|
|
--exec /bin/bash -- -c "HOME=/home/$DAEMONUSER $DAEMON $DAEMON_ARGS > /tmp/mplayerd.log 2>&1"
|
|
|
|
echo "Started for user: $DAEMONUSER."
|
|
}
|
|
|
|
stop() {
|
|
echo "Stopping mplayer..."
|
|
killall mplayer
|
|
kill -9 `cat $PIDFILE`
|
|
# Cleanup fifo file
|
|
rm -rf $CONTROLFILE
|
|
}
|
|
|
|
status() {
|
|
if [ -z `cat $PIDFILE` ];
|
|
then
|
|
echo "mplayerd: not running."
|
|
else
|
|
echo "mplayerd: running."
|
|
fi
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
|
|
stop)
|
|
stop
|
|
;;
|
|
|
|
restart|reload|force-reload)
|
|
stop
|
|
start
|
|
;;
|
|
|
|
status)
|
|
status
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: /etc/init.d/mplayerd {start|stop|reload|force-reload|restart|status}"
|
|
exit 1
|
|
|
|
esac
|