[Serusers] Path to sc (serctl)
Tomas Björklund
tomas at webservices.se
Fri Feb 21 22:58:56 CET 2003
Hi,
I was getting tired of starting/stopping ser by hand so i added
stop/start/restart functionality to serctl
Se patch (made to cvs version 1.41)
Best regards,
Thomas Björklund
-------------- next part --------------
--- /usr/local/ser/src/sip_router/scripts/sc Mon Jan 27 20:42:48 2003
+++ sc Fri Feb 21 22:54:43 2003
@@ -5,6 +5,11 @@
# sc: ser control; tool for maintaining ser's databases
#
+# configuration for starting/stopping ser
+PID_FILE=/var/run/ser.pid
+SYSLOG=1 # 0=output to console, 1=output to syslog
+STARTOPTIONS= # for example -dddd
+
# ser's FIFO server
if [ -z "$SER_FIFO" ]; then
SER_FIFO=/tmp/ser_fifo
@@ -455,9 +460,11 @@
#================================================================
if [ -z "$SIP_DOMAIN" ] ; then
+ echo
echo "You need to set environment variable SIP_DOMAIN (e.g. to 'foobar.com') first"
echo
- usage
+# This confuses new users cause its easy to miss the information above
+# usage
exit 1
fi
@@ -465,6 +472,61 @@
export PW
case $1 in
+
+ start)
+ echo -n "Starting SER : "
+ if [ -r $PID_FILE ] ; then
+ echo "PID file exists! ($PID_FILE) already running?"
+ exit 1
+ else
+ if [ $SYSLOG = 1 ] ; then
+ ser -P $PID_FILE $STARTOPTIONS 1>/dev/null 2>/dev/null
+ else
+ ser -P $PID_FILE $STARTOPTIONS
+ fi
+ sleep 1
+ echo "started pid(`cat $PID_FILE`)"
+ fi
+ exit 0
+ ;;
+
+ stop)
+ echo -n "Stopping SER : "
+ if [ -r $PID_FILE ] ; then
+ kill `cat $PID_FILE`
+ echo "stopped"
+ else
+ echo No PID file found!
+ exit 1
+ fi
+ exit 0
+ ;;
+
+ restart)
+ echo -n "Stopping SER : "
+ if [ -r $PID_FILE ] ; then
+ kill `cat $PID_FILE`
+ echo "stopped"
+ else
+ echo No PID file found! SER problably not running
+ exit 1
+ fi
+ sleep 2
+ echo -n "Starting SER : "
+ if [ -r $PID_FILE ] ; then
+ echo "PID file exists! ($PID_FILE) already running?"
+ exit 1
+ else
+ if [ $SYSLOG = 1 ] ; then
+ ser -P $PID_FILE $STARTOPTIONS 1>/dev/null 2>/dev/null
+ else
+ ser -P $PID_FILE $STARTOPTIONS
+ fi
+ sleep 1
+ echo "started pid(`cat $PID_FILE`)"
+ fi
+ exit 0
+ ;;
passwd)
if [ $# -ne 3 ] ; then
More information about the sr-users
mailing list