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