1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/opensips/rc.opensips Wed Sep 21 14:02:13 2011 +0200 1.3 @@ -0,0 +1,75 @@ 1.4 +#!@l_prefix@/bin/openpkg rc 1.5 +## 1.6 +## rc.opensips -- Run-Commands 1.7 +## 1.8 + 1.9 +%config 1.10 + opensips_enable="$openpkg_rc_def" 1.11 + opensips_flags="" 1.12 + opensips_rtpproxy="yes" 1.13 + opensips_log_prolog="true" 1.14 + opensips_log_epilog="true" 1.15 + opensips_log_numfiles="10" 1.16 + opensips_log_minsize="1M" 1.17 + opensips_log_complevel="9" 1.18 + 1.19 +%common 1.20 + opensips_cfgfile="@l_prefix@/etc/opensips/opensips.cfg" 1.21 + opensips_pidfile="@l_prefix@/var/opensips/opensips.pid" 1.22 + opensips_rtpproxy_pidfile="@l_prefix@/var/opensips/opensips_rtpproxy.pid" 1.23 + opensips_rtpproxy_socket="@l_prefix@/var/opensips/opensips_rtpproxy.sock" 1.24 + opensips_rtpproxy_listen=`grep '^listen=' $opensips_cfgfile | sed -e 's/^listen="\(.*\)".*/\1/'` 1.25 + opensips_rtpproxy_signal () { 1.26 + [ -f $opensips_rtpproxy_pidfile ] && kill -$1 `cat $opensips_rtpproxy_pidfile` 1.27 + } 1.28 + 1.29 +%status -u @l_susr@ -o 1.30 + opensips_usable="no" 1.31 + opensips_active="no" 1.32 + if @l_prefix@/sbin/opensips -c >/dev/null 2>&1; then 1.33 + opensips_usable="yes" 1.34 + fi 1.35 + if @l_prefix@/sbin/opensipsctl ps >/dev/null 2>&1; then 1.36 + opensips_active="yes" 1.37 + fi 1.38 + echo "opensips_enable=\"$opensips_enable\"" 1.39 + echo "opensips_usable=\"$opensips_usable\"" 1.40 + echo "opensips_active=\"$opensips_active\"" 1.41 + 1.42 +%start -u @l_susr@ 1.43 + rcService opensips enable yes || exit 0 1.44 + rcService opensips active yes && exit 0 1.45 + if rcVarIsYes opensips_rtpproxy; then 1.46 + cmd="@l_prefix@/sbin/opensips_rtpproxy" \ 1.47 + cmd="$cmd -l $opensips_rtpproxy_listen" 1.48 + cmd="$cmd -s unix:$opensips_rtpproxy_socket" 1.49 + cmd="$cmd -p $opensips_rtpproxy_pidfile" 1.50 + su @l_rusr@ -c "$cmd" 1.51 + fi 1.52 + @l_prefix@/sbin/opensips \ 1.53 + -P $opensips_pidfile \ 1.54 + ${opensips_flags} 1.55 + 1.56 +%stop -u @l_susr@ 1.57 + rcService opensips enable yes || exit 0 1.58 + rcService opensips active no && exit 0 1.59 + @l_prefix@/sbin/opensipsctl stop 1.60 + if rcVarIsYes opensips_rtpproxy; then 1.61 + opensips_rtpproxy_signal TERM 1.62 + fi 1.63 + sleep 2 1.64 + 1.65 +%restart -u @l_susr@ 1.66 + rcService opensips enable yes || exit 0 1.67 + rcService opensips active no && exit 0 1.68 + rc opensips stop start 1.69 + 1.70 +%daily -u @l_susr@ 1.71 + rcService opensips enable yes || exit 0 1.72 + shtool rotate -f \ 1.73 + -n ${opensips_log_numfiles} -s ${opensips_log_minsize} -d \ 1.74 + -z ${opensips_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \ 1.75 + -P "${opensips_log_prolog}" \ 1.76 + -E "${opensips_log_epilog}; rc opensips reload" \ 1.77 + @l_prefix@/var/opensips/opensips.log 1.78 +