diff --git a/el/mediaproxy-ng.init b/el/mediaproxy-ng.init new file mode 100644 index 000000000..9d6ce2349 --- /dev/null +++ b/el/mediaproxy-ng.init @@ -0,0 +1,210 @@ +#!/bin/bash +# +# mediaproxy-ng Startup script for NGCP mediaproxy-ng +# +# chkconfig: - 345 84 16 +# description: NGCP mediaproxy-ng +# +# processname: mediaproxy-ng +# config: /etc/sysconfig/mediaproxy-ng +# pidfile: /var/run/mediaproxy-ng.pid +# +### BEGIN INIT INFO +# Provides: mediaproxy-ng +# Required-Start: $local_fs $network +# Short-Description: NGCP mediaproxy-ng +# Description: NGCP mediaproxy-ng +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ -f /etc/sysconfig/mediaproxy-ng ] +then + . /etc/sysconfig/mediaproxy-ng +else + echo "Error: /etc/sysconfig/mediproxy-ng not present" + exit -1 +fi + +mediaproxy_ng=/usr/sbin/mediaproxy-ng +prog=mediaproxy-ng +pidfile=${PIDFILE-/var/run/mediaproxy-ng.pid} +lockfile=${LOCKFILE-/var/lock/subsys/mediaproxy-ng} +cachefile=/var/lib/mediaproxy-ng/mediaproxy-ng.cfg +RETVAL=0 + +OPTS="--pidfile $pidfile" +MODULE=0 +IP6=0 + +build_opts() { + shopt -s nocasematch + RPMS=`rpm -qa | grep ngcp-mediaproxy-ng-kernel` + if [[ "$KERNEL" == "yes" && -n "$TABLE" && -n "$RPMS" ]] + then + MODULE=1 + OPTS+=" --table=$TABLE" + else + MODULE=0 + OPTS+=" --table=-1" + fi + + if [[ "$FALLBACK" != "yes" ]] + then + OPTS+=" --no-fallback" + fi + shopt -u nocasematch + + if [[ -n "$RTP_IP" ]] + then + OPTS+=" --ip=$RTP_IP" + fi + + if [[ -n "$RTP_ADV_IP" ]] + then + OPTS+=" --advertised-ip=$RTP_ADV_IP" + fi + + if [[ -n "$RTP_IP6" ]] + then + OPTS+=" --ip6=$RTP_IP6" + IP6=1 + fi + + if [[ -n "$RTP_ADV_IP6" ]] + then + OPTS+=" --advertised-ip6=$RTP_ADV_IP6" + fi + + if [[ -n "$LISTEN_TCP" ]] + then + OPTS+=" --listen-tcp=$LISTEN_TCP" + fi + + if [[ -n "$LISTEN_UDP" ]] + then + OPTS+=" --listen-udp=$LISTEN_UDP" + fi + + if [[ -n "$LISTEN_NG" ]] + then + OPTS+=" --listen-ng=$LISTEN_NG" + fi + + if [[ -n "$TOS" ]] + then + OPTS+=" --tos=$TOS" + fi + + if [[ -n "$TIMEOUT" ]] + then + OPTS+=" --timeout=$TIMEOUT" + fi + + if [[ -n "$SILENT_TIMEOUT" ]] + then + OPTS+=" --silent-timeout=$SILENT_TIMEOUT" + fi + + if [[ -n "$PORT_MIN" ]] + then + OPTS+=" --port-min=$PORT_MIN" + fi + + if [[ -n "$PORT_MAX" ]] + then + OPTS+=" --port-max=$PORT_MAX" + fi + + if [[ -n "$REDIS" ]] + then + OPTS+=" --redis=$REDIS" + fi + + if [[ -n "$REDIS_DB" ]] + then + OPTS+=" --redis-db=$REDIS_DB" + fi + + if [[ -n "$B2B_URL" ]] + then + OPTS+=" --b2b-url=$B2B_URL" + fi +} + +start() { + build_opts + if [[ $MODULE == 1 ]] + then + echo "Loading module for in-kernel packet forwarding" + modprobe xt_MEDIAPROXY + iptables -I INPUT -p udp -j MEDIAPROXY --id $TABLE + if [[ IP6 == 1 ]] + then + ip6tables -I INPUT -p udp -j MEDIAPROXY --id $TABLE + fi + + cat < "$cachefile" +CUR_TABLE=$TABLE +CUR_IP6=$IP6 +EOF + fi + echo -n $"Starting $prog: " + daemon --pidfile=${pidfile} $mediaproxy_ng $OPTS + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch ${lockfile} + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p ${pidfile} $mediaproxy_ng + RETVAL=$? + echo + if [ -f "$cachefile" ] + then + . "$cachefile" + echo "Unloading module for in-kernel packet forwarding" + echo "del $TABLE" > /proc/mediaproxy/control + iptables -D INPUT -p udp -j MEDIAPROXY --id $CUR_TABLE + if [[ CUR_IP6 == 1 ]] + then + ip6tables -D INPUT -p udp -j MEDIAPROXY --id $CUR_TABLE + fi +# rmmod xt_MEDIAPROXY + rm -f $cachefile + fi + + [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status -p ${pidfile} $mediaproxy_ng + RETVAL=$? + ;; + restart) + stop + start + ;; + condrestart|try-restart) + if status -p ${pidfile} $mediaproxy_ng >&/dev/null; then + stop + start + fi + ;; + *) + echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|status}" + RETVAL=2 +esac + +exit $RETVAL diff --git a/el/mediaproxy-ng.spec b/el/mediaproxy-ng.spec index 2b93602a9..ea7c4dd62 100644 --- a/el/mediaproxy-ng.spec +++ b/el/mediaproxy-ng.spec @@ -66,12 +66,13 @@ mkdir -p $RPM_BUILD_ROOT/%{_sbindir} install -m755 daemon/mediaproxy-ng $RPM_BUILD_ROOT/%{_sbindir}/mediaproxy-ng ## Install the init.d script and configuration file -#mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d -#install -m755 el/mediaproxy-ng.init \ -# $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/mediaproxy-ng -#mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig -#install -m644 el/mediaproxy-ng.sysconfig \ -# $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/mediaproxy-ng +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d +install -m755 el/mediaproxy-ng.init \ + $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/mediaproxy-ng +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig +install -m644 el/mediaproxy-ng.sysconfig \ + $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/mediaproxy-ng +mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/mediaproxy-ng # Install the iptables plugin mkdir -p $RPM_BUILD_ROOT/%{_lib}/xtables @@ -142,8 +143,9 @@ true %{_sbindir}/mediaproxy-ng # init.d script and configuration file -#%{_sysconfdir}/rc.d/init.d/mediaproxy-ng -#%{_sysconfdir}/sysconfig/mediaproxy-ng +%{_sysconfdir}/rc.d/init.d/mediaproxy-ng +%config(noreplace) %{_sysconfdir}/sysconfig/mediaproxy-ng +%dir %{_sharedstatedir}/mediaproxy-ng # Documentation %dir %{_docdir}/%{name}-%{version}-%{release} @@ -164,7 +166,9 @@ true %changelog -* Wed Aug 14 2012 Peter Dunkley +* Thu Aug 15 2013 Peter Dunkley + - init.d scripts and configuration file +* Wed Aug 14 2013 Peter Dunkley - First version of .spec file - Builds and installs userspace daemon (but no init.d scripts etc yet) - Builds and installs the iptables plugin diff --git a/el/mediaproxy-ng.sysconfig b/el/mediaproxy-ng.sysconfig new file mode 100644 index 000000000..b88d3a57f --- /dev/null +++ b/el/mediaproxy-ng.sysconfig @@ -0,0 +1,38 @@ +# For more information on configuring mediaproxy-ng see +# http://github.com/sipwise/mediproxy-ng +# +# (m) means the item is mandatory, (o) means the item is optional +# +KERNEL=yes # (m) "yes" enable in-kernel forwarding, "no" disables +TABLE=0 # (o) iptables table for in-kernel forwarding rules + # comment out when "KERNEL=no" +FALLBACK=yes # (m) "yes" enables fallback to userspace forwarding + # only, "no" disables +RTP_IP=127.0.0.1 # (m) Local IPv4 address for packet forwarding +#RTP_ADV_IP=127.0.0.1 # (o) IPv4 address to "advertise" for packet forwarding +#RTP_IP6=::1 # (o) Local IPv6 address for packet forwarding +#RTP_ADV_IP6=::1 # (o) IPv6 address to "advertise" for packet forwarding +# +# At least one of LISTEN_(TCP|UDP|NG) is required +#LISTEN_TCP=127.0.0.1:2222 # IP address and port combination for TCP + # control +LISTEN_UDP=127.0.0.1:2222 # IP address and port combination for UDP + # control +#LISTEN_NG=127.0.0.1:2223 # IP address and port combination for NG (UDP) + # control +# +#TOS=184 # (o) TOS value to use in outgoing packets +#TIMEOUT=60 # (o) Number of seconds after which a media stream is + # considered dead if there is no traffic. + # Default: 60 +#SILENT_TIMEOUT=3600 # (o) Number of seconds after which a muted or inactive + # stream is considered dead. Default: 3600 +#PORT_MIN=30000 # (o) Lowest port in the local port range for media + # traffic. Default: 30000 +#PORT_MAX=40000 # (o) Highest port in the local port range for media + # traffic. Default: 40000 +# +# The following items are for use with NGCP +#REDIS=127.0.0.1:6379 +#REDIS_DB=0 +#B2B_URL=http://127.0.0.1:8080/xmlrpc