#!/bin/sh
#
# mediaproxy starts and stops the SER MediaProxy server
# PROVIDE: mediaproxy
# Add the following line to /etc/rc.conf to enable mysql:
# mediaproxy_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable mediaproxy.
. /etc/rc.subr
name="mediaproxy"
rcvar=`set_rcvar`
load_rc_config $name
: ${mediaproxy_enable="NO"}
INSTALL_DIR="%%PREFIX%%"
RUNTIME_DIR="/var/run"
PROXY="$INSTALL_DIR/mediaproxy/mediaproxy.py"
DISPATCHER="$INSTALL_DIR/mediaproxy/proxydispatcher.py"
PROXY_PID="$RUNTIME_DIR/mediaproxy.pid"
DISPATCHER_PID="$RUNTIME_DIR/proxydispatcher.pid"
# Options for mediaproxy and dispatcher. Do not include --pid <pidfile>
# --pid <pidfile> will be added automatically if needed.
PROXY_OPTIONS=""
DISPATCHER_OPTIONS=""
NAME="mediaproxy"
DESC="SER MediaProxy server"
echo $PROXY
test -f $PROXY || exit 0
test -f $DISPATCHER || exit 0
if [ "$PROXY_PID" != "/var/run/mediaproxy.pid" ]; then
PROXY_OPTIONS="--pid $PROXY_PID $PROXY_OPTIONS"
fi
if [ "$DISPATCHER_PID" != "/var/run/proxydispatcher.pid" ]; then
DISPATCHER_OPTIONS="--pid $DISPATCHER_PID $DISPATCHER_OPTIONS"
fi
start() {
if [ $mediaproxy_enable = "YES" ]; then
echo -n "Starting $DESC: $NAME"
$PROXY $PROXY_OPTIONS
$DISPATCHER $DISPATCHER_OPTIONS
echo "."
fi
}
stop () {
echo -n "Stopping $DESC: $NAME"
if [ -f $PROXY_PID ]; then
kill `cat $PROXY_PID`
fi
if [ -f $DISPATCHER_PID ]; then
kill `cat $DISPATCHER_PID`
fi
echo "."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
#sleep 1
start
;;
*)
echo "Usage: ${INSTALL_DIR}/etc/rc.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
syntax highlighted by Code2HTML, v. 0.9.1