|
1 #!@l_prefix@/bin/openpkg rc |
|
2 ## |
|
3 ## rc.opensips -- Run-Commands |
|
4 ## |
|
5 |
|
6 %config |
|
7 opensips_enable="$openpkg_rc_def" |
|
8 opensips_flags="" |
|
9 opensips_rtpproxy="yes" |
|
10 opensips_log_prolog="true" |
|
11 opensips_log_epilog="true" |
|
12 opensips_log_numfiles="10" |
|
13 opensips_log_minsize="1M" |
|
14 opensips_log_complevel="9" |
|
15 |
|
16 %common |
|
17 opensips_cfgfile="@l_prefix@/etc/opensips/opensips.cfg" |
|
18 opensips_pidfile="@l_prefix@/var/opensips/opensips.pid" |
|
19 opensips_rtpproxy_pidfile="@l_prefix@/var/opensips/opensips_rtpproxy.pid" |
|
20 opensips_rtpproxy_socket="@l_prefix@/var/opensips/opensips_rtpproxy.sock" |
|
21 opensips_rtpproxy_listen=`grep '^listen=' $opensips_cfgfile | sed -e 's/^listen="\(.*\)".*/\1/'` |
|
22 opensips_rtpproxy_signal () { |
|
23 [ -f $opensips_rtpproxy_pidfile ] && kill -$1 `cat $opensips_rtpproxy_pidfile` |
|
24 } |
|
25 |
|
26 %status -u @l_susr@ -o |
|
27 opensips_usable="no" |
|
28 opensips_active="no" |
|
29 if @l_prefix@/sbin/opensips -c >/dev/null 2>&1; then |
|
30 opensips_usable="yes" |
|
31 fi |
|
32 if @l_prefix@/sbin/opensipsctl ps >/dev/null 2>&1; then |
|
33 opensips_active="yes" |
|
34 fi |
|
35 echo "opensips_enable=\"$opensips_enable\"" |
|
36 echo "opensips_usable=\"$opensips_usable\"" |
|
37 echo "opensips_active=\"$opensips_active\"" |
|
38 |
|
39 %start -u @l_susr@ |
|
40 rcService opensips enable yes || exit 0 |
|
41 rcService opensips active yes && exit 0 |
|
42 if rcVarIsYes opensips_rtpproxy; then |
|
43 cmd="@l_prefix@/sbin/opensips_rtpproxy" \ |
|
44 cmd="$cmd -l $opensips_rtpproxy_listen" |
|
45 cmd="$cmd -s unix:$opensips_rtpproxy_socket" |
|
46 cmd="$cmd -p $opensips_rtpproxy_pidfile" |
|
47 su @l_rusr@ -c "$cmd" |
|
48 fi |
|
49 @l_prefix@/sbin/opensips \ |
|
50 -P $opensips_pidfile \ |
|
51 ${opensips_flags} |
|
52 |
|
53 %stop -u @l_susr@ |
|
54 rcService opensips enable yes || exit 0 |
|
55 rcService opensips active no && exit 0 |
|
56 @l_prefix@/sbin/opensipsctl stop |
|
57 if rcVarIsYes opensips_rtpproxy; then |
|
58 opensips_rtpproxy_signal TERM |
|
59 fi |
|
60 sleep 2 |
|
61 |
|
62 %restart -u @l_susr@ |
|
63 rcService opensips enable yes || exit 0 |
|
64 rcService opensips active no && exit 0 |
|
65 rc opensips stop start |
|
66 |
|
67 %daily -u @l_susr@ |
|
68 rcService opensips enable yes || exit 0 |
|
69 shtool rotate -f \ |
|
70 -n ${opensips_log_numfiles} -s ${opensips_log_minsize} -d \ |
|
71 -z ${opensips_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \ |
|
72 -P "${opensips_log_prolog}" \ |
|
73 -E "${opensips_log_epilog}; rc opensips reload" \ |
|
74 @l_prefix@/var/opensips/opensips.log |
|
75 |