File rcmediatomb of Package mediatomb
#!/bin/sh
#
# mediatomb This script starts and stops the mediatomb daemon
#
# processname: mediatomb
# description: mediatomb is a daemon process which provides a UPnP service
# config: /etc/mediatomb
# config: /etc/mediatomb/config.xml
# pidfile: /var/run/mediatomb.pid
### BEGIN INIT INFO
# Provides: mediatomb
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: MediaTomb daemon
# Description: This script starts and stops the mediatomb daemon
### END INIT INFO
# Source function library.
. /etc/rc.status
rc_reset
# Source networking configuration.
#. /etc/sysconfig/network
# Set default mediatomb configuration.
# either make an installation in /etc/mediatomb and leave this blank,
# or specify an alternative config file location using the -c option
# Note: be aware, that -i parameter is used to set the ip of the
# interface specified above
. /etc/mediatomb.conf
###############################
# make sure to run it as $MT_USER
MEDIATOMB="-d -u $MT_USER -g $MT_GROUP -P $MT_PIDFILE -l $MT_LOGFILE -m $MT_HOME -f $MT_CFGDIR -p $MT_PORT"
[ -f /usr/bin/mediatomb ] || exit 0
[ ${MT_INTERFACE} = "NOT_SET" ] && echo "Please edit /etc/mediatomb.conf and change \
the MT_INTERFACE variable to your network device (eth0, eth1, etc.)" && exit 0
PATH=$PATH:/usr/bin:/usr/local/bin
IFACE_IP=`ifconfig | grep -i "$MT_INTERFACE" -A 1|grep "inet addr"|cut -d " " -f 12|cut -d ":" -f 2`
# By default it's all good
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Applying multicast settings to $MT_INTERFACE... "
# those settings are necessary for us to react to M-SEARCH requests
route add -net 239.0.0.0 netmask 255.0.0.0 $MT_INTERFACE >/dev/null 2>&1
ifconfig $MT_INTERFACE allmulti
touch $MT_PIDFILE
chown $MT_USER $MT_PIDFILE
mkdir -p "/$MT_HOME/$MT_CFGDIR"
chown $MT_USER "/$MT_HOME/$MT_CFGDIR"
echo -n "Starting mediatomb: "
mediatomb $MEDIATOMB -i $IFACE_IP $MT_OPTIONS
RETVAL=$?
rc_status -v
[ $RETVAL = 0 ] && touch /var/lock/subsys/mediatomb
;;
stop)
# Stop daemons.
echo -n "Shutting down mediatomb: "
killproc mediatomb
RETVAL=$?
rc_status -v
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/mediatomb
;;
restart)
$0 stop
$0 start
;;
reload)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/mediatomb ] && $0 restart
;;
status)
if test -e $MT_PIDFILE ; then
echo " seems running"
else
echo " not running"
fi
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart|status|condrestart}"
RETVAL=1
;;
esac
rc_exit