MPD start script
#!/bin/bash
#
# mpd This script takes care of starting and stopping
# mpd (Music Player Deamon) server
#
# This script has been tested on redhat/fedora distribution and
# should run on other "system V" like Mandrake
#
# To get mpd please visite www.musicpd.org
# To get rpm package check at http://sourceforge.net
#
# Thank to schmandman (original script for BSD system)
#
# Installation
# 1) copy this script into /etc/init.d/
# 2) make this script executable ( chmod a-x /etc/init.d/mpd )
# 3) Create link to start mpd at the desired level (usually level 5)
# ln -s /etc/init.d/mpd /etc/rc.d/rc5.d/S99mpd
# 4) Create link to stop properly the deamon
# ln -s /etc/init.d/mpd /etc/rc.d/rc0.d/K99mpd
# ln -s /etc/init.d/mpd /etc/rc.d/rc1.d/K99mpd
# ln -s /etc/init.d/mpd /etc/rc.d/rc6.d/K99mpd
#
# Source function library.
. /etc/rc.d/init.d/functions
prog="Music Player Daemon"
configfile="/etc/mpd.conf"
daemonx="/usr/local/bin/mpd"
pid="/var/run/mpd.pid"
if [ ! -x $daemonx ]; then
echo -e "Fatal error: $daemonx not found"
return 1
fi
if [ ! -f $configfile ]; then
echo -e "Fatal Error: config file $configfile not found...exiting"
return 1
fi
music=`grep music_dir $configfile|cut -d " " -f2|sed -e 's/\"//g'`
if [ ! -d $music ]; then
echo -e "no music found\n why start?"
return 1
fi
start() {
echo -n $"Starting $prog: "
daemon $daemonx $configfile
ret=$?
echo
[ $ret -eq 0 ] && touch $pid
return $ret
}
stop() {
echo -n $"Stopping $prog: "
killproc $daemonx
ret=$?
echo
[ $ret -eq 0 ] && rm -f $pid
}
createdb() {
echo -n $"Create/Recreate db "
$daemonx --create-db
ret=$?
echo
[ $ret -eq 0 ] && touch $pid
return $ret
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $daemonx
ret=$?
;;
restart)
stop
start
;;
createdb)
stop
createdb
start
;;
*)
echo $"Usage: $0 {start|stop|status|createdb|restart}"
exit 1
esac
exit $?
#
# mpd This script takes care of starting and stopping
# mpd (Music Player Deamon) server
#
# This script has been tested on redhat/fedora distribution and
# should run on other "system V" like Mandrake
#
# To get mpd please visite www.musicpd.org
# To get rpm package check at http://sourceforge.net
#
# Thank to schmandman (original script for BSD system)
#
# Installation
# 1) copy this script into /etc/init.d/
# 2) make this script executable ( chmod a-x /etc/init.d/mpd )
# 3) Create link to start mpd at the desired level (usually level 5)
# ln -s /etc/init.d/mpd /etc/rc.d/rc5.d/S99mpd
# 4) Create link to stop properly the deamon
# ln -s /etc/init.d/mpd /etc/rc.d/rc0.d/K99mpd
# ln -s /etc/init.d/mpd /etc/rc.d/rc1.d/K99mpd
# ln -s /etc/init.d/mpd /etc/rc.d/rc6.d/K99mpd
#
# Source function library.
. /etc/rc.d/init.d/functions
prog="Music Player Daemon"
configfile="/etc/mpd.conf"
daemonx="/usr/local/bin/mpd"
pid="/var/run/mpd.pid"
if [ ! -x $daemonx ]; then
echo -e "Fatal error: $daemonx not found"
return 1
fi
if [ ! -f $configfile ]; then
echo -e "Fatal Error: config file $configfile not found...exiting"
return 1
fi
music=`grep music_dir $configfile|cut -d " " -f2|sed -e 's/\"//g'`
if [ ! -d $music ]; then
echo -e "no music found\n why start?"
return 1
fi
start() {
echo -n $"Starting $prog: "
daemon $daemonx $configfile
ret=$?
echo
[ $ret -eq 0 ] && touch $pid
return $ret
}
stop() {
echo -n $"Stopping $prog: "
killproc $daemonx
ret=$?
echo
[ $ret -eq 0 ] && rm -f $pid
}
createdb() {
echo -n $"Create/Recreate db "
$daemonx --create-db
ret=$?
echo
[ $ret -eq 0 ] && touch $pid
return $ret
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $daemonx
ret=$?
;;
restart)
stop
start
;;
createdb)
stop
createdb
start
;;
*)
echo $"Usage: $0 {start|stop|status|createdb|restart}"
exit 1
esac
exit $?
vireas - 2. Mai, 16:05