Debian Codegraph @

misc/examples/scripts/sr

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/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/functionsscip-shell source . . `/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/srouterscip-shell filesystem . . `/home/srouter`.
24 SERDIR=$HM/sip_router
25 ETC=/etc/sip-router/iptel.cfgscip-shell filesystem . . `/etc/sip-router/iptel.cfg`.
26 PIDFILE=/run/sr.pidscip-shell filesystem . . `/run/sr.pid`.
27 NOTIFY[email protected]
28 USR=510
29 GRP=510
30
31 MONIT=/usr/local/bin/monitscip-shell filesystem . . `/usr/local/bin/monit`.
32 MONITRC=/usr/local/etc/monitrcscip-shell filesystem . . `/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_startscip-shell shell shell-project 0.0.0 sip_router_start().() {
42 if [scip-shell system . . `[`. -r $BIN -a -r $CORE ] ; then
43 echoscip-shell system . . echo. "before startup sip-router core found on `datescip-shell system . . date.` at `hostnamescip-shell system . . hostname.`" > $TMP
44 echoscip-shell system . . echo. "----------------------------------" >> $TMP
45 DATE=`datescip-shell system . . date. "+%Y-%m-%d--%H-%M"`
46 NEWCORE=$MYDIR/core.$DATE
47 mvscip-shell system . . mv. $CORE $NEWCORE
48 echoscip-shell system . . echo. core stored in $NEWCORE >> $TMP
49 gdb $BIN $NEWCORE -x test/bt.gdb -batch >> $TMP
50 chmodscip-shell system . . chmod. a+r $NEWCORE
51 cd $SERDIR; tarscip-shell system . . tar. czf $MYDIR/sip-router.$DATE.tgz .
52 mail -s "sip-router core found" $NOTIFY < $TMP
53 rmscip-shell system . . rm. -f $TMP
54 fi
55 cd $MYDIR
56 #ulimit -c 1000000
57 echoscip-shell system . . echo. "Starting SIP router: "
58 $BIN -f $ETC -w $MYDIR -P $PIDFILE
59 RETVAL=$?
60 echoscip-shell system . . echo.
61 }
62
63 sip_router_stopscip-shell shell shell-project 0.0.0 sip_router_stop().() {
64 echoscip-shell system . . echo. "Stopping SIP router: "
65 killproc $BINNAME
66 RETVAL=$?
67 echoscip-shell system . . echo.
68 }
69
70 monit_startscip-shell shell shell-project 0.0.0 monit_start().() {
71 echoscip-shell system . . echo. "Command Monit to start Ser..."
72 ${MONIT} -c ${MONITRC} start sip-router
73 RETVAL=$?
74 echoscip-shell system . . echo.
75 }
76
77 monit_stopscip-shell shell shell-project 0.0.0 monit_stop().() {
78 echoscip-shell system . . echo. "Command Monit to stop Ser..."
79 ${MONIT} -c ${MONITRC} stop sip-router
80 RETVAL=$?
81 echoscip-shell system . . echo.
82 }
83
84 # See how we were called.
85 case "$1" in
86 serstart)
87 sip_router_startscip-shell shell shell-project 0.0.0 sip_router_start().
88 ;;
89 sip-routerstop)
90 sip_router_stopscip-shell shell shell-project 0.0.0 sip_router_stop().
91 ;;
92 sip-routerrestart)
93 sip_router_stopscip-shell shell shell-project 0.0.0 sip_router_stop().
94 echoscip-shell system . . echo.
95 sip_router_startscip-shell shell shell-project 0.0.0 sip_router_start().
96 ;;
97 start)
98 monit_startscip-shell shell shell-project 0.0.0 monit_start().
99 ;;
100 stop)
101 monit_stopscip-shell shell shell-project 0.0.0 monit_stop().
102 ;;
103 restart)
104 monit_stopscip-shell shell shell-project 0.0.0 monit_stop().
105 sleepscip-shell system . . sleep. 1
106 monit_startscip-shell shell shell-project 0.0.0 monit_start().
107 ;;
108 *)
109 echoscip-shell system . . echo. "Usage: $0 {start|stop|restart}"
110 exit 1
111 esac
112
113 exit $RETVAL
114