From 130d4853461c10bd1ec3253f3756e46772dde6f0 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 16:20:57 +0100 Subject: [PATCH 01/10] Updated Makefiles and added compilation instructions to work with Enterprise Linux (tested on CentOS 6.4 64-bit). Init scripts and .spec files for RPM builds to follow. --- daemon/Makefile | 22 +++++++--- el/README.md | 80 +++++++++++++++++++++++++++++++++++++ iptables-extension/Makefile | 11 ++++- kernel-module/Makefile | 15 +++++-- 4 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 el/README.md diff --git a/daemon/Makefile b/daemon/Makefile index e985bd2f7..a5d3dd6ff 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -7,7 +7,16 @@ CFLAGS+= `pkg-config --cflags openssl` CFLAGS+= `pcre-config --cflags` CFLAGS+= -I/lib/modules/`uname -r`/build/include/ -I../kernel-module/ CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" +ifneq ($(MEDIAPROXY_VERSION),) + CFLAGS+= -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" +else + DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) + ifneq ($(DPKG_PRSCHNGLG),) + CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" + else + CFLAGS+= -DMEDIAPROXY_VERSION="\"undefined\"" + endif +endif CFLAGS+= -DMP_PLUGIN_DIR="\"/usr/lib/mediaproxy-ng\"" #CFLAGS+= -DSRTCP_KEY_DERIVATION_RFC_COMPLIANCE @@ -27,10 +36,13 @@ LDFLAGS+= `pcre-config --libs` LDFLAGS+= `xmlrpc-c-config client --libs` ifneq ($(DBG),yes) -# support http://wiki.debian.org/Hardening for >=wheezy -CFLAGS+= `dpkg-buildflags --get CFLAGS` -CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` -LDFLAGS+= `dpkg-buildflags --get LDFLAGS` + DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) + ifneq ($(DPKG_BLDFLGS),) + # support http://wiki.debian.org/Hardening for >=wheezy + CFLAGS+= `dpkg-buildflags --get CFLAGS` + CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` + LDFLAGS+= `dpkg-buildflags --get LDFLAGS` + endif endif SRCS= main.c kernel.c poller.c aux.c control_tcp.c streambuf.c call.c control_udp.c redis.c \ diff --git a/el/README.md b/el/README.md new file mode 100644 index 000000000..21ae302e1 --- /dev/null +++ b/el/README.md @@ -0,0 +1,80 @@ +mediaproxy-ng for Enterprise Linux +================================== + +Installing from RPMs +-------------------- + +TBD + + +RPM Compliation +--------------- + +TBD + + +Manual Compilation +------------------ + +There are three parts to mediaproxy-ng, each of which can be found in the +respective subdirectories. + +* `daemon` + + The userspace daemon and workhorse, minimum requirement for anything + to work. Running `MEDIAPROXY_VERSION="\"\"" make` will + compile the binary, which will be called `mediaproxy-ng`. The + following software packages are required to compile the daemon: + + - *gcc* + - *make* + - *pkgconfig* + - *glib2-devel* + - *libcurl-devel* + - *openssl-devel* + - *pcre-devel* + - *xmlrpc-c-devel* + - *zlib-devel* + +* `iptables-extension` + + Required for in-kernel packet forwarding. Running + `MEDIAPROXY_VERSION="\"\"" make` will compile the plugin + for `iptables` and `ip6tables`. The file will be called + `libxt_MEDIAPROXY.so` and should be copied into the directory + `/lib/xtables/` in 32-bit environments and `/lib64/xtables/` in 64-bit + environments. The following software packages are required to compile + the plugin: + + - *gcc* + - *make* + - *iptables-devel* + +* `kernel-module` + + Required for in-kernel packet forwarding. Compilation of the kernel + module requires the kernel development packages for the kernel version + you are using (see output of `uname -r`) to be installed. Running + `MEDIAPROXY_VERSION="\"\"" make` will compile the kernel + module. + + Successful compilation of the module will produce the file + `xt_MEDIAPROXY.ko`. The module can be inserted into the running kernel + manually through `insmod xt_MEDIAPROXY.ko` (which will result in an + error if depending modules aren't loaded, for example the `x_tables` + module), but it's recommended to copy the module into + `/lib/modules//updates/`, followed by running + `depmod -a`. After this, the module can be loaded by issuing + `modprobe xt_MEDIAPROXY`. + + The following software packages are required to compile the plugin: + + - *gcc* + - *make* + - *kernel-devel* + - *kernel-headers* + + Note: the *kernel-devel* and *kernel-headers* packages are meta-packages + that install the headers and source for the latest kernel version. This + will be what you want unless you are running a custom or older kernel. + diff --git a/iptables-extension/Makefile b/iptables-extension/Makefile index d84fa7b53..660767893 100644 --- a/iptables-extension/Makefile +++ b/iptables-extension/Makefile @@ -1,5 +1,14 @@ CFLAGS = -O2 -Wall -shared -fPIC -CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" +ifneq ($(MEDIAPROXY_VERSION),) + CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" +else + DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) + ifneq ($(DPKG_PRSCHNGLG),) + CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" + else + CFLAGS += -DMEDIAPROXY_VERSION="\"undefined\"" + endif +endif XTABLES = $(shell test -e /usr/include/xtables.h && echo 1) IPTABLES = $(shell test -e /usr/include/iptables.h && echo 1) diff --git a/kernel-module/Makefile b/kernel-module/Makefile index bed10ccb0..6394c5fdf 100644 --- a/kernel-module/Makefile +++ b/kernel-module/Makefile @@ -1,11 +1,18 @@ PWD := $(shell pwd) KSRC ?= /lib/modules/$(shell uname -r)/build KBUILD := $(KSRC) -ifeq ($(origin MEDIAPROXY_VERSION), undefined) -MEDIAPROXY_VERSION := $(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}') -export MEDIAPROXY_VERSION + +ifneq ($(MEDIAPROXY_VERSION),) + EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" +else + DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) + ifneq ($(DPKG_PRSCHNGLG),) + EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" + else + EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"undefined\"" + endif endif -EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" -D__MP_EXTERNAL +EXTRA_CFLAGS += -D__MP_EXTERNAL obj-m += xt_MEDIAPROXY.o From c7c3ee0019e19bd4a61cab8175179796a7bc2b66 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 17:28:27 +0100 Subject: [PATCH 02/10] First go at creating a .spec file to build mediaproxy-ng for Enterprise Linux --- el/mediaproxy-ng.spec | 101 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 el/mediaproxy-ng.spec diff --git a/el/mediaproxy-ng.spec b/el/mediaproxy-ng.spec new file mode 100644 index 000000000..999655705 --- /dev/null +++ b/el/mediaproxy-ng.spec @@ -0,0 +1,101 @@ +Name: mediaproxy-ng +Version: 2.3.0 +Release: 1%{?dist} +Summary: The Sipwise NGCP mediaproxy-ng + +Group: System Environment/Daemons +License: unknown +URL: https://github.com/crocodilertc/mediaproxy-ng +Source: %{name}-%{version}.tar.gz +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 mediaproxy-ng 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. + + +%prep +%setup -q + + +%build +cd daemon +MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make +cd .. + + +%install +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT" + +# Install the userspace daemon +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 + +# Install the documentation +mkdir -p $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release} +install -m644 README.md \ + $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/README.md +install -m644 debian/changelog \ + $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/changelog +install -m644 debian/copyright \ + $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/copyright +install -m644 el/README.md \ + $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/README.el.md + + +%clean +rm -rf %{buildroot} + + +%pre +/usr/sbin/groupadd -r mediaproxy-ng 2> /dev/null || : +/usr/sbin/usradd -r -g mediaproxy-ng -s /bin/false -c "mediaproxy-ng daemon" \ + -d %{_docdir}/%{name}-%{version}-%{release} mediaproxy-ng \ + 2> /dev/null || : + + +#%post +#/sbin/chkconfig --add mediaproxy-ng +# +# +#%preun +#/sbin/service mediaproxy-ng stop +#/sbin/chkconfig --del mediaproxy-ng + + +%files +%defattr(-,root,root,-) +# Userspace daemon +%{_sbindir}/mediaproxy-ng + +# init.d script and configuration file +#%{_sysconfdir}/rc.d/init.d/mediaproxy-ng +#%{_sysconfdir}/sysconfig/mediaproxy-ng + +# Documentation +%dir %{_docdir}/%{name}-%{version}-%{release} +%doc %{_docdir}/%{name}-%{version}-%{release}/README.md +%doc %{_docdir}/%{name}-%{version}-%{release}/changelog +%doc %{_docdir}/%{name}-%{version}-%{release}/copyright +%doc %{_docdir}/%{name}-%{version}-%{release}/README.el.md + + +%changelog +* Wed Aug 14 2012 Peter Dunkley + - First version of .spec file + - Builds and instals userspace daemon (but no init.d scripts etc yet) From 44fc40fb089ba1b4895f6961c04b9861862ad459 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 18:06:58 +0100 Subject: [PATCH 03/10] .spec file now builds iptables plugin. Kernel module (using DKMS) to follow. --- el/mediaproxy-ng.spec | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/el/mediaproxy-ng.spec b/el/mediaproxy-ng.spec index 999655705..c76f1b32c 100644 --- a/el/mediaproxy-ng.spec +++ b/el/mediaproxy-ng.spec @@ -7,6 +7,7 @@ Group: System Environment/Daemons License: unknown URL: https://github.com/crocodilertc/mediaproxy-ng Source: %{name}-%{version}.tar.gz +Conflicts: %{name}-kernel < %{version} BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: gcc make pkgconfig redhat-rpm-config @@ -21,6 +22,16 @@ 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: In-kernel package forwarding support for mediaproxy-ng +Group: System Environment/Daemons +BuildRequires: iptables-devel +Requires: iptables iptables-ipv6 mediaproxy-ng = %{version} + +%description kernel +iptables plugin and kernel module for mediaproxy-ng in-kernal package forwarding + + %prep %setup -q @@ -28,6 +39,8 @@ drop-in replacement for any of the other available RTP and media proxies. %build cd daemon MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make +cd ../iptables-extension +MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make cd .. @@ -46,6 +59,11 @@ install -m755 daemon/mediaproxy-ng $RPM_BUILD_ROOT/%{_sbindir}/mediaproxy-ng #install -m644 el/mediaproxy-ng.sysconfig \ # $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/mediaproxy-ng +# Install the iptables plugin +mkdir -p $RPM_BUILD_ROOT/%{_lib}/xtables +install -m755 iptables-extension/libxt_MEDIAPROXY.so \ + $RPM_BUILD_ROOT/%{_lib}/xtables/libxt_MEDIAPROXY.so + # Install the documentation mkdir -p $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release} install -m644 README.md \ @@ -95,7 +113,12 @@ rm -rf %{buildroot} %doc %{_docdir}/%{name}-%{version}-%{release}/README.el.md +%files kernel +/%{_lib}/xtables/libxt_MEDIAPROXY.so + + %changelog * Wed Aug 14 2012 Peter Dunkley - First version of .spec file - - Builds and instals userspace daemon (but no init.d scripts etc yet) + - Builds and installs userspace daemon (but no init.d scripts etc yet) + - Builds and installs the iptables plugin (but no kernel module yet) From e32298958d31a9714388a4d5b7c898769bfb5191 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 19:44:10 +0100 Subject: [PATCH 04/10] Updated documentation for Enterprise Linux --- el/README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/el/README.md b/el/README.md index 21ae302e1..9d17a1fcc 100644 --- a/el/README.md +++ b/el/README.md @@ -4,13 +4,40 @@ mediaproxy-ng for Enterprise Linux Installing from RPMs -------------------- -TBD +There are three RPMs: + +- ngcp-mediaproxy-ng: the userspace daemon +- ngcp-mediaproxy-ng-kernel: the iptables plugin +- ngcp-mediaproxy-ng-dkms: the kernel module source + +All of the RPMs have correctly set dependencies and if you just want the +userspace daemon you can install it with yum (assuming you have access to a +CentOS repository). + +The ngcp-mediaproxy-ng-kernel package is dependent on the ngcp-mediaproxy-ng, +and ngcp-mediaproxy-ng-dkms packages. The ngcp-mediaproxy-ng-dkms package has +a dependency (DKMS) that cannot be met by the standard CentOS repository. If +you want to use in-kernel forwarding you need to download and install the +latest version of [DKMS](http://linux.dell.com/dkms/) before attempting to +install ngcp-mediaproxy-ng-dkms or ngcp-mediaproxy-ng-kernel. RPM Compliation --------------- -TBD +To build the RPMs you need all of the packages listed in the Manual Compilation section (except for kernel-devel and kernel-headers) plus: + +- redhat-rpm-config +- rpm-build + +To build the RPMs: +1. Checkout (clone) the Git repository +2. Create the "~/rpmbuild/SOURCES" directory +3. Create a tar archive. For example, from within the cloned directory you can use "git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz --prefix=ngcp-mediaproxy-ng-/ master" (where is the version number of the master branch) +4. Build the RPMs. For example, + "rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz" + +Once the build has completed the binary RPMs will be in "~/rpmbuild/RPMS". Manual Compilation From 6830b16184a15dc664129c435b1003985b324dd5 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 19:44:30 +0100 Subject: [PATCH 05/10] .spec file now builds kernel module using DKMS --- el/mediaproxy-ng.spec | 61 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/el/mediaproxy-ng.spec b/el/mediaproxy-ng.spec index c76f1b32c..2b93602a9 100644 --- a/el/mediaproxy-ng.spec +++ b/el/mediaproxy-ng.spec @@ -1,4 +1,4 @@ -Name: mediaproxy-ng +Name: ngcp-mediaproxy-ng Version: 2.3.0 Release: 1%{?dist} Summary: The Sipwise NGCP mediaproxy-ng @@ -23,13 +23,27 @@ drop-in replacement for any of the other available RTP and media proxies. %package kernel -Summary: In-kernel package forwarding support for mediaproxy-ng +Summary: NGCP mediaproxy-ng in-kernel packet forwarding Group: System Environment/Daemons -BuildRequires: iptables-devel -Requires: iptables iptables-ipv6 mediaproxy-ng = %{version} +BuildRequires: gcc make redhat-rpm-config iptables-devel +Requires: iptables iptables-ipv6 ngcp-mediaproxy-ng = %{version} +Requires: ngcp-mediaproxy-ng-dkms = %{version} %description kernel -iptables plugin and kernel module for mediaproxy-ng in-kernal package forwarding +NGCP mediaproxy-ng in-kernel packet forwarding + + +%package dkms +Summary: Kernel module for NGCP mediaproxy-ng in-kernel packet forwarding +Group: System Environment/Daemons +BuildArch: noarch +BuildRequires: redhat-rpm-config +Requires: gcc make +Requires(post): dkms +Requires(preun): dkms + +%description dkms +Kernel module for mediaproxy-ng in-kernel packet forwarding %prep @@ -75,6 +89,17 @@ install -m644 debian/copyright \ install -m644 el/README.md \ $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/README.el.md +## DKMS module source install +mkdir -p $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release} +install -m644 kernel-module/Makefile \ + $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/Makefile +install -m644 kernel-module/xt_MEDIAPROXY.c \ + $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.c +install -m644 kernel-module/xt_MEDIAPROXY.h \ + $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.h +sed "s/__VERSION__/%{version}-%{release}/g" debian/dkms.conf.in > \ + $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/dkms.conf + %clean rm -rf %{buildroot} @@ -90,12 +115,27 @@ rm -rf %{buildroot} #%post #/sbin/chkconfig --add mediaproxy-ng # -# + + +%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 #/sbin/service mediaproxy-ng stop #/sbin/chkconfig --del mediaproxy-ng +%preun dkms +# Remove from DKMS registry +dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all +true + + %files %defattr(-,root,root,-) # Userspace daemon @@ -114,11 +154,18 @@ rm -rf %{buildroot} %files kernel +%defattr(-,root,root,-) /%{_lib}/xtables/libxt_MEDIAPROXY.so +%files dkms +%defattr(-,root,root,0755) +%{_usrsrc}/%{name}-%{version}-%{release}/ + + %changelog * Wed Aug 14 2012 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 (but no kernel module yet) + - Builds and installs the iptables plugin + - DKMS package for the kernel module From ce9ac35a46e58641e36f5f35a5df5bffb7090f3d Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 19:49:52 +0100 Subject: [PATCH 06/10] Updated readme for Enterprise Linux --- el/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/el/README.md b/el/README.md index 9d17a1fcc..03ef52080 100644 --- a/el/README.md +++ b/el/README.md @@ -31,13 +31,13 @@ To build the RPMs you need all of the packages listed in the Manual Compilation - rpm-build To build the RPMs: -1. Checkout (clone) the Git repository -2. Create the "~/rpmbuild/SOURCES" directory -3. Create a tar archive. For example, from within the cloned directory you can use "git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz --prefix=ngcp-mediaproxy-ng-/ master" (where is the version number of the master branch) -4. Build the RPMs. For example, - "rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz" +- Checkout (clone) the Git repository +- Create the `~/rpmbuild/SOURCES` directory +- Create a tar archive. For example, from within the cloned directory you can use `git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz --prefix=ngcp-mediaproxy-ng-/ master` (where is the version number of the master branch) +- Build the RPMs. For example, + `rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz` -Once the build has completed the binary RPMs will be in "~/rpmbuild/RPMS". +Once the build has completed the binary RPMs will be in `~/rpmbuild/RPMS`. Manual Compilation From c0572a05dafffa5bbd15a8cd7a7f8d4760adb8b5 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Wed, 14 Aug 2013 19:53:44 +0100 Subject: [PATCH 07/10] More tidying of EL docs --- el/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/el/README.md b/el/README.md index 03ef52080..e0d533457 100644 --- a/el/README.md +++ b/el/README.md @@ -33,9 +33,12 @@ To build the RPMs you need all of the packages listed in the Manual Compilation To build the RPMs: - Checkout (clone) the Git repository - Create the `~/rpmbuild/SOURCES` directory -- Create a tar archive. For example, from within the cloned directory you can use `git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz --prefix=ngcp-mediaproxy-ng-/ master` (where is the version number of the master branch) +- Create a tar archive. For example, from within the cloned directory you can + use + `git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz --prefix=ngcp-mediaproxy-ng-/ master` + where `` is the version number of the master branch - Build the RPMs. For example, - `rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz` + `rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-.tar.gz` Once the build has completed the binary RPMs will be in `~/rpmbuild/RPMS`. From f16afa8c3e05ba3de2accd133b04a3ea046785be Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Thu, 15 Aug 2013 16:26:47 +0100 Subject: [PATCH 08/10] Added init.d script and config file --- el/mediaproxy-ng.init | 210 +++++++++++++++++++++++++++++++++++++ el/mediaproxy-ng.spec | 22 ++-- el/mediaproxy-ng.sysconfig | 38 +++++++ 3 files changed, 261 insertions(+), 9 deletions(-) create mode 100644 el/mediaproxy-ng.init create mode 100644 el/mediaproxy-ng.sysconfig 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 From 3468c170a77d86f6ede8389afea5179740d277e4 Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Thu, 22 Aug 2013 14:21:13 +0100 Subject: [PATCH 09/10] Fixes to init.d script and .spec --- el/mediaproxy-ng.init | 2 +- el/mediaproxy-ng.spec | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/el/mediaproxy-ng.init b/el/mediaproxy-ng.init index 9d6ce2349..dc13d99b5 100644 --- a/el/mediaproxy-ng.init +++ b/el/mediaproxy-ng.init @@ -2,7 +2,7 @@ # # mediaproxy-ng Startup script for NGCP mediaproxy-ng # -# chkconfig: - 345 84 16 +# chkconfig: 345 84 16 # description: NGCP mediaproxy-ng # # processname: mediaproxy-ng diff --git a/el/mediaproxy-ng.spec b/el/mediaproxy-ng.spec index ea7c4dd62..1fae138a0 100644 --- a/el/mediaproxy-ng.spec +++ b/el/mediaproxy-ng.spec @@ -113,9 +113,8 @@ rm -rf %{buildroot} 2> /dev/null || : -#%post -#/sbin/chkconfig --add mediaproxy-ng -# +%post +/sbin/chkconfig --add mediaproxy-ng %post dkms @@ -126,9 +125,9 @@ dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force true -#%preun -#/sbin/service mediaproxy-ng stop -#/sbin/chkconfig --del mediaproxy-ng +%preun +/sbin/service mediaproxy-ng stop +/sbin/chkconfig --del mediaproxy-ng %preun dkms From 10d991c81039d54023c3548a83f701717df5fb0b Mon Sep 17 00:00:00 2001 From: Peter Dunkley Date: Thu, 22 Aug 2013 14:29:07 +0100 Subject: [PATCH 10/10] Updated documentation for Enterprise Linux --- el/README.md | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/el/README.md b/el/README.md index e0d533457..05752f09d 100644 --- a/el/README.md +++ b/el/README.md @@ -6,29 +6,39 @@ Installing from RPMs There are three RPMs: -- ngcp-mediaproxy-ng: the userspace daemon -- ngcp-mediaproxy-ng-kernel: the iptables plugin -- ngcp-mediaproxy-ng-dkms: the kernel module source +- *ngcp-mediaproxy-ng*: the userspace daemon +- *ngcp-mediaproxy-ng-kernel*: the iptables plugin +- *ngcp-mediaproxy-ng-dkms*: the kernel module source All of the RPMs have correctly set dependencies and if you just want the userspace daemon you can install it with yum (assuming you have access to a CentOS repository). -The ngcp-mediaproxy-ng-kernel package is dependent on the ngcp-mediaproxy-ng, -and ngcp-mediaproxy-ng-dkms packages. The ngcp-mediaproxy-ng-dkms package has -a dependency (DKMS) that cannot be met by the standard CentOS repository. If -you want to use in-kernel forwarding you need to download and install the -latest version of [DKMS](http://linux.dell.com/dkms/) before attempting to -install ngcp-mediaproxy-ng-dkms or ngcp-mediaproxy-ng-kernel. +The *ngcp-mediaproxy-ng-kernel* package is dependent on the +*ngcp-mediaproxy-ng*, and *ngcp-mediaproxy-ng-dkms* packages. The +*ngcp-mediaproxy-ng-dkms* package has a dependency (DKMS) that cannot be met +by the standard CentOS repository. If you want to use in-kernel forwarding you +need to download and install the latest version of the +[*dkms*](http://linux.dell.com/dkms/) package before attempting to install +*ngcp-mediaproxy-ng-dkms* or *ngcp-mediaproxy-ng-kernel*. + +Note: installing *ngcp-mediaproxy-ng-dkms* builds a kernel module which requires +the sources for the running kernel. The *kernel-devel* and *kernel-headers* +packages are meta-packages that install the headers and source for the latest +kernel version. This will be what what you want unless you are running a custom +or older kernel. *ngcp-mediaproxy-ng-dkms* does not have *kernel-devel* and +*kernel-headers* as dependencies as this could cause problems if you are using +a custom or older kernel, so you need to install these manually. RPM Compliation --------------- -To build the RPMs you need all of the packages listed in the Manual Compilation section (except for kernel-devel and kernel-headers) plus: +To build the RPMs you need all of the packages listed in the Manual Compilation +section (except for *kernel-devel* and *kernel-headers*) plus: -- redhat-rpm-config -- rpm-build +- *redhat-rpm-config* +- *rpm-build* To build the RPMs: - Checkout (clone) the Git repository