Generally, the system has to be configured so that the installed programmes are executed at start-up. Normally, this is completed by providing files in /etc/init.d. We leave it to the user to configure the services of their own system; however we have provided example scripts to start the SER and mediaproxy processes. Please note, if you are not supporting RTP proxying, then you do not need to run the mediaproxy process.
To install the scripts, please create the file(s) in the /etc/init.d directory and then run the commands :-
# chkconfig -add ser
# chkconfig -add mediaproxy
#!/bin/bash
#
# Startup script for SER
#
# chkconfig: 345 91 15
# description: Ser is a fast SIP Proxy.
#
# processname: ser
# pidfile: /var/run/ser.pid
# config: /etc/ser/ser.cfg
# Source function library.
. /etc/rc.d/init.d/functions
ser=/usr/local/sbin/ser
prog=ser
OPTIONS="-d -d -d -d -d -d -d -d -d"
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $ser $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/ser
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $ser
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/ser /var/run/ser.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $ser -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $ser
RETVAL=$?
;;
restart)
stop
sleep 3
start
;;
condrestart)
if [ -f /var/run/ser.pid ] ; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
exit 1
esac
exit $RETVALThe mediaproxy programme is used to support NAT configurations.
#!/bin/sh
#
# chkconfig: 2345 90 20
# description: VoIP RTP Proxy Server
#
# processname: mediaproxy
# pidfile: /var/run/mediaproxy.pid
# source function library
. /etc/rc.d/init.d/functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
INSTALL_DIR="/usr/local"
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="--ip=10.3.0.221 --listen=127.0.0.1"
DISPATCHER_OPTIONS="domain://sip.dialez.com"
NAME="mediaproxy"
DESC="SER MediaProxy server"
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() {
echo -n "Starting $DESC: $NAME"
$PROXY $PROXY_OPTIONS
$DISPATCHER $DISPATCHER_OPTIONS
echo "."
}
stop () {
echo -n "Stopping $DESC: $NAME"
kill `cat $PROXY_PID`
kill `cat $DISPATCHER_PID`
echo "."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
#sleep 1
start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0