parser: some more const-correctness for the other functions in msg_parser.[c,h]
[sip-router] / etc / sr
1 #!/bin/sh
2 #
3 # $Id$
4 #
5 #
6 # 3w-xxxx:      Starts the sip_router process
7 #
8 # Version:      @(#) /etc/rc.d/init.d/3w-xxxx
9 #
10 # chkconfig: 2345 20 80
11 # description: controls execution of SIP router
12 # processname: sr
13 # config: /etc/sip-router/iptel.cfg
14
15 # Source function library.
16 . /etc/rc.d/init.d/functions
17
18 # we use a sip-router symlink -- that allows us to have a different name
19 # in process table so that killalls does not start other sip-routers
20 # run from somewhere else
21
22 BINNAME=sr
23 HM=/home/srouter
24 SERDIR=$HM/sip_router
25 ETC=/etc/sip-router/iptel.cfg
26 PIDFILE=/var/run/sr.pid
27 NOTIFY=sr@iptel.org
28 USR=510
29 GRP=510
30
31 MONIT=/usr/local/bin/monit
32 MONITRC=/usr/local/etc/monitrc
33
34 RETVAL=0
35
36 BIN=$HM/bin/$BINNAME
37 MYDIR=$HM/core
38 CORE=$MYDIR/core
39 TMP=/tmp/srcore.$$
40
41 sip-router_start() {
42         if [ -r $BIN -a -r $CORE ] ; then
43                 echo "before startup sip-router core found on `date` at $HOSTNAME" > $TMP
44                 echo "----------------------------------" >> $TMP
45                 DATE=`date "+%Y-%m-%d--%H-%M"`
46                 NEWCORE=$MYDIR/core.$DATE
47                 mv $CORE $NEWCORE
48                 echo core stored in $NEWCORE >> $TMP
49                 gdb $BIN $NEWCORE -x test/bt.gdb -batch >> $TMP
50                 chmod a+r $NEWCORE
51                 cd $SERDIR; tar czf $MYDIR/sip-router.$DATE.tgz .
52                 mail -s "sip-router core found" $NOTIFY < $TMP
53                 rm -f $TMP
54         fi
55         cd $MYDIR
56         #ulimit -c 1000000
57         echo "Starting SIP router: "
58         $BIN -f $ETC -w $MYDIR -P $PIDFILE
59         RETVAL=$?
60         echo
61 }
62
63 sip-router_stop() {
64         echo "Stopping SIP router: "
65         killproc $BINNAME
66         RETVAL=$?
67         echo
68 }
69
70 monit_start() {
71    echo "Command Monit to start Ser..."
72    ${MONIT} -c ${MONITRC} start sip-router
73    RETVAL=$?
74    echo
75 }
76
77 monit_stop() {
78    echo "Command Monit to stop Ser..."
79    ${MONIT} -c ${MONITRC} stop sip-router
80    RETVAL=$?
81    echo
82 }
83
84 # See how we were called.
85 case "$1" in
86   serstart)
87         sip-router_start
88         ;;
89   sip-routerstop)
90     sip-router_stop
91         ;;
92   sip-routerrestart)
93         sip-router_stop
94         echo
95         sip-router_start
96         ;;
97   start)
98     monit_start
99         ;;
100   stop)
101     monit_stop
102         ;;
103   restart)
104         monit_stop
105         sleep 1
106         monit_start
107         ;;
108   *)
109         echo "Usage: $0 {start|stop|restart}"
110         exit 1
111 esac
112
113 exit $RETVAL
114