mirror of https://github.com/sipwise/rtpengine.git
parent
f562844a35
commit
73b56db7de
@ -0,0 +1,219 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rtpengine Startup script for NGCP rtpengine
|
||||
#
|
||||
# chkconfig: 345 84 16
|
||||
# description: NGCP rtpengine
|
||||
#
|
||||
# processname: rtpengine
|
||||
# config: /etc/sysconfig/rtpengine
|
||||
# pidfile: /var/run/rtpengine.pid
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: rtpengine
|
||||
# Required-Start: $local_fs $network
|
||||
# Short-Description: NGCP rtpengine
|
||||
# Description: NGCP rtpengine
|
||||
### END INIT INFO
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
if [ -f /etc/sysconfig/rtpengine ]
|
||||
then
|
||||
. /etc/sysconfig/rtpengine
|
||||
else
|
||||
echo "Error: /etc/sysconfig/mediproxy-ng not present"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
mediaproxy_ng=/usr/sbin/rtpengine
|
||||
prog=rtpengine
|
||||
pidfile=${PIDFILE-/var/run/rtpengine.pid}
|
||||
lockfile=${LOCKFILE-/var/lock/subsys/rtpengine}
|
||||
cachefile=/var/lib/rtpengine/rtpengine.cfg
|
||||
RETVAL=0
|
||||
|
||||
OPTS="--pidfile $pidfile"
|
||||
MODULE=0
|
||||
IP6=0
|
||||
|
||||
build_opts() {
|
||||
shopt -s nocasematch
|
||||
RPMS=`rpm -qa | grep ngcp-rtpengine-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
|
||||
|
||||
if [[ -n "$LOG_LEVEL" ]]
|
||||
then
|
||||
OPTS+=" --log-level=$LOG_LEVEL"
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
build_opts
|
||||
if [[ $MODULE == 1 ]]
|
||||
then
|
||||
echo "Loading module for in-kernel packet forwarding"
|
||||
modprobe xt_MEDIAPROXY
|
||||
iptables -N mediaproxy
|
||||
iptables -t filter -A INPUT -j mediaproxy
|
||||
iptables -I mediaproxy -p udp -j MEDIAPROXY --id $TABLE
|
||||
if [[ IP6 == 1 ]]
|
||||
then
|
||||
ip6tables -I mediaproxy -p udp -j MEDIAPROXY --id $TABLE
|
||||
fi
|
||||
|
||||
cat <<EOF > "$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 mediaproxy -p udp -j MEDIAPROXY --id $CUR_TABLE
|
||||
if [[ CUR_IP6 == 1 ]]
|
||||
then
|
||||
ip6tables -D mediaproxy -p udp -j MEDIAPROXY --id $CUR_TABLE
|
||||
fi
|
||||
iptables -t filter -D INPUT -j mediaproxy
|
||||
iptables -X mediaproxy
|
||||
# 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
|
@ -0,0 +1,156 @@
|
||||
Name: ngcp-rtpengine
|
||||
Version: 2.3.6
|
||||
Release: 0%{?dist}
|
||||
Summary: The Sipwise NGCP rtpengine
|
||||
|
||||
Group: System Environment/Daemons
|
||||
License: GPLv3
|
||||
URL: https://github.com/sipwise/rtpengine
|
||||
Source0: https://github.com/sipwise/rtpengine/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
Conflicts: %{name}-kernel < %{version}
|
||||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
||||
|
||||
BuildRequires: gcc make pkgconfig redhat-rpm-config
|
||||
BuildRequires: glib2-devel libcurl-devel openssl-devel pcre-devel
|
||||
BuildRequires: xmlrpc-c-devel zlib-devel
|
||||
Requires: glibc libcurl openssl pcre xmlrpc-c
|
||||
|
||||
|
||||
%description
|
||||
The Sipwise NGCP rtpengine is a proxy for RTP traffic and other UDP based
|
||||
media traffic. It's meant to be used with the Kamailio SIP proxy and forms a
|
||||
drop-in replacement for any of the other available RTP and media proxies.
|
||||
|
||||
|
||||
%package kernel
|
||||
Summary: NGCP rtpengine in-kernel packet forwarding
|
||||
Group: System Environment/Daemons
|
||||
BuildRequires: gcc make redhat-rpm-config iptables-devel
|
||||
Requires: iptables iptables-ipv6 ngcp-rtpengine = %{version}
|
||||
Requires: ngcp-rtpengine-dkms = %{version}
|
||||
|
||||
%description kernel
|
||||
NGCP rtpengine in-kernel packet forwarding
|
||||
|
||||
|
||||
%package dkms
|
||||
Summary: Kernel module for NGCP rtpengine in-kernel packet forwarding
|
||||
Group: System Environment/Daemons
|
||||
BuildArch: noarch
|
||||
BuildRequires: redhat-rpm-config
|
||||
Requires: gcc make
|
||||
Requires(post): epel-release dkms
|
||||
Requires(preun): epel-release dkms
|
||||
|
||||
%description dkms
|
||||
Kernel module for rtpengine in-kernel packet forwarding
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
|
||||
%build
|
||||
cd daemon
|
||||
MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make
|
||||
cd ../iptables-extension
|
||||
MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make
|
||||
cd ..
|
||||
|
||||
|
||||
%install
|
||||
# Install the userspace daemon
|
||||
install -D -p -m755 daemon/rtpengine %{buildroot}/%{_sbindir}/rtpengine
|
||||
|
||||
## Install the init.d script and configuration file
|
||||
install -D -p -m755 el/rtpengine.init \
|
||||
%{buildroot}/%{_sysconfdir}/rc.d/init.d/rtpengine
|
||||
install -D -p -m644 el/rtpengine.sysconfig \
|
||||
%{buildroot}/%{_sysconfdir}/sysconfig/rtpengine
|
||||
mkdir -p %{buildroot}/%{_sharedstatedir}/rtpengine
|
||||
|
||||
# Install the iptables plugin
|
||||
install -D -p -m755 iptables-extension/libxt_MEDIAPROXY.so \
|
||||
%{buildroot}/%{_lib}/xtables/libxt_MEDIAPROXY.so
|
||||
|
||||
## DKMS module source install
|
||||
install -D -p -m644 kernel-module/Makefile \
|
||||
%{buildroot}/%{_usrsrc}/%{name}-%{version}-%{release}/Makefile
|
||||
install -D -p -m644 kernel-module/xt_MEDIAPROXY.c \
|
||||
%{buildroot}/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.c
|
||||
install -D -p -m644 kernel-module/xt_MEDIAPROXY.h \
|
||||
%{buildroot}/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.h
|
||||
sed "s/__VERSION__/%{version}-%{release}/g" debian/dkms.conf.in > \
|
||||
%{buildroot}/%{_usrsrc}/%{name}-%{version}-%{release}/dkms.conf
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
|
||||
%pre
|
||||
/usr/sbin/groupadd -r rtpengine 2> /dev/null || :
|
||||
/usr/sbin/useradd -r -g rtpengine -s /sbin/nologin -c "rtpengine daemon" \
|
||||
-d %{_sharedstatedir}/rtpengine rtpengine \
|
||||
2> /dev/null || :
|
||||
|
||||
|
||||
%post
|
||||
if [ $1 -eq 1 ]; then
|
||||
/sbin/chkconfig --add %{name} || :
|
||||
fi
|
||||
|
||||
|
||||
%post dkms
|
||||
# Add to DKMS registry, build, and install module
|
||||
dkms add -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
|
||||
dkms build -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
|
||||
dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force
|
||||
true
|
||||
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ] ; then
|
||||
/sbin/service %{name} stop >/dev/null 2>&1
|
||||
/sbin/chkconfig --del %{name}
|
||||
fi
|
||||
|
||||
|
||||
%preun dkms
|
||||
# Remove from DKMS registry
|
||||
dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
|
||||
true
|
||||
|
||||
|
||||
%files
|
||||
# Userspace daemon
|
||||
%{_sbindir}/rtpengine
|
||||
|
||||
# init.d script and configuration file
|
||||
%{_sysconfdir}/rc.d/init.d/rtpengine
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/rtpengine
|
||||
%dir %{_sharedstatedir}/rtpengine
|
||||
|
||||
# Documentation
|
||||
%doc LICENSE README.md el/README.el.md debian/changelog debian/copyright
|
||||
|
||||
|
||||
%files kernel
|
||||
/%{_lib}/xtables/libxt_MEDIAPROXY.so
|
||||
|
||||
|
||||
%files dkms
|
||||
%attr(0755,root,root) %{_usrsrc}/%{name}-%{version}-%{release}/
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Nov 11 2013 Peter Dunkley <peter.dunkley@crocodilertc.net>
|
||||
- Updated version to 2.3.2
|
||||
- Set license to GPLv3
|
||||
* Thu Aug 15 2013 Peter Dunkley <peter.dunkley@crocodilertc.net>
|
||||
- init.d scripts and configuration file
|
||||
* Wed Aug 14 2013 Peter Dunkley <peter.dunkley@crocodilertc.net>
|
||||
- First version of .spec file
|
||||
- Builds and installs userspace daemon (but no init.d scripts etc yet)
|
||||
- Builds and installs the iptables plugin
|
||||
- DKMS package for the kernel module
|
@ -0,0 +1,39 @@
|
||||
# For more information on configuring rtpengine see
|
||||
# http://github.com/sipwise/rtpengine
|
||||
#
|
||||
# (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
|
||||
#
|
||||
#LOG_LEVEL=6 # Log level to use
|
||||
# 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
|
Loading…
Reference in new issue