Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- ### BEGIN INIT INFO
- # Provides: mplayer
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Example initscript
- # Description: This file should be used to construct scripts to be
- # placed in /etc/init.d.
- ### END INIT INFO
- # Author: Foo Bar <foobar@baz.org>
- #
- # Please remove the "Author" lines above and replace them
- # with your own name if you copy and modify this script.
- # Do NOT "set -e"
- # PATH should only include /usr/* if it runs after the mountnfs.sh script
- PATH=/sbin:/usr/sbin:/bin:/usr/bin
- DESC="Music"
- DAEMONUSER=uberalles
- NAME=mplayer
- CONTROLFILE="/tmp/mplayercontrol"
- DAEMON=/usr/bin/$NAME
- DAEMON_ARGS="-loop 0 -shuffle -playlist /media/nfs_share/playlist"
- PIDFILE=/var/run/$NAME.pid
- SCRIPTNAME=/etc/init.d/$NAME
- 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..."
- 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
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement