opensips/rc.opensips

changeset 377
67e813202d53
parent 376
8f552d1cd671
equal deleted inserted replaced
0:c2ac79538fa2 1:1707a5f49a29
3 ## rc.opensips -- Run-Commands 3 ## rc.opensips -- Run-Commands
4 ## 4 ##
5 5
6 %config 6 %config
7 opensips_enable="$openpkg_rc_def" 7 opensips_enable="$openpkg_rc_def"
8 opensips_flags=""
9 opensips_rtpproxy="yes" 8 opensips_rtpproxy="yes"
9 opensips_rtpproxy_addr="127.0.0.1:12345"
10 opensips_log_prolog="true" 10 opensips_log_prolog="true"
11 opensips_log_epilog="true" 11 opensips_log_epilog="true"
12 opensips_log_numfiles="10" 12 opensips_log_numfiles="10"
13 opensips_log_minsize="1M" 13 opensips_log_minsize="1M"
14 opensips_log_complevel="9" 14 opensips_log_complevel="9"
16 %common 16 %common
17 opensips_cfgfile="@l_prefix@/etc/opensips/opensips.cfg" 17 opensips_cfgfile="@l_prefix@/etc/opensips/opensips.cfg"
18 opensips_pidfile="@l_prefix@/var/opensips/opensips.pid" 18 opensips_pidfile="@l_prefix@/var/opensips/opensips.pid"
19 opensips_rtpproxy_pidfile="@l_prefix@/var/opensips/opensips_rtpproxy.pid" 19 opensips_rtpproxy_pidfile="@l_prefix@/var/opensips/opensips_rtpproxy.pid"
20 opensips_rtpproxy_socket="@l_prefix@/var/opensips/opensips_rtpproxy.sock" 20 opensips_rtpproxy_socket="@l_prefix@/var/opensips/opensips_rtpproxy.sock"
21 opensips_rtpproxy_listen=`grep '^listen=' $opensips_cfgfile | sed -e 's/^listen="\(.*\)".*/\1/'` 21 opensips_signal () {
22 [ -f $opensips_pidfile ] && kill -$1 `cat $opensips_pidfile`
23 }
22 opensips_rtpproxy_signal () { 24 opensips_rtpproxy_signal () {
23 [ -f $opensips_rtpproxy_pidfile ] && kill -$1 `cat $opensips_rtpproxy_pidfile` 25 [ -f $opensips_rtpproxy_pidfile ] && kill -$1 `cat $opensips_rtpproxy_pidfile`
24 } 26 }
25 27
26 %status -u @l_susr@ -o 28 %status -u @l_susr@ -o
27 opensips_usable="no" 29 opensips_usable="no"
28 opensips_active="no" 30 opensips_active="no"
29 if @l_prefix@/sbin/opensips -c >/dev/null 2>&1; then 31 if @l_prefix@/sbin/opensips -c >/dev/null 2>&1; then
30 opensips_usable="yes" 32 opensips_usable="yes"
31 fi 33 fi
32 if @l_prefix@/sbin/opensipsctl ps >/dev/null 2>&1; then 34 if rcService opensips enable yes && opensips_signal 0; then
33 opensips_active="yes" 35 opensips_active="yes"
34 fi 36 fi
35 echo "opensips_enable=\"$opensips_enable\"" 37 echo "opensips_enable=\"$opensips_enable\""
36 echo "opensips_usable=\"$opensips_usable\"" 38 echo "opensips_usable=\"$opensips_usable\""
37 echo "opensips_active=\"$opensips_active\"" 39 echo "opensips_active=\"$opensips_active\""
38 40
39 %start -u @l_susr@ 41 %start -u @l_susr@
40 rcService opensips enable yes || exit 0 42 rcService opensips enable yes || exit 0
41 rcService opensips active yes && exit 0 43 rcService opensips active yes && exit 0
42 if rcVarIsYes opensips_rtpproxy; then 44 if rcVarIsYes opensips_rtpproxy; then
43 cmd="@l_prefix@/sbin/opensips_rtpproxy" \ 45 cmd="@l_prefix@/sbin/rtpproxy" \
44 cmd="$cmd -l $opensips_rtpproxy_listen" 46 cmd="$cmd -u @l_rusr@"
47 cmd="$cmd -l $opensips_rtpproxy_addr"
45 cmd="$cmd -s unix:$opensips_rtpproxy_socket" 48 cmd="$cmd -s unix:$opensips_rtpproxy_socket"
46 cmd="$cmd -p $opensips_rtpproxy_pidfile" 49 cmd="$cmd -p $opensips_rtpproxy_pidfile"
47 su @l_rusr@ -c "$cmd" 50 su @l_rusr@ -c "$cmd"
48 fi 51 fi
49 @l_prefix@/sbin/opensips \ 52 @l_prefix@/sbin/opensipsctl start
50 -P $opensips_pidfile \
51 ${opensips_flags}
52 53
53 %stop -u @l_susr@ 54 %stop -u @l_susr@
54 rcService opensips enable yes || exit 0 55 rcService opensips enable yes || exit 0
55 rcService opensips active no && exit 0 56 rcService opensips active no && exit 0
56 @l_prefix@/sbin/opensipsctl stop 57 @l_prefix@/sbin/opensipsctl stop
58 rm -f $opensips_pidfile 2>/dev/null || true
57 if rcVarIsYes opensips_rtpproxy; then 59 if rcVarIsYes opensips_rtpproxy; then
58 opensips_rtpproxy_signal TERM 60 opensips_rtpproxy_signal TERM
59 fi 61 fi
60 sleep 2 62 sleep 2
61 63

mercurial