From d631b536acc1b7421cd032faa19bec7e318c49e6 Mon Sep 17 00:00:00 2001 From: Jiri Slachta Date: Sun, 21 Dec 2014 12:25:42 +0100 Subject: [PATCH] rtpproxy: add init script and UCI config Signed-off-by: Jiri Slachta --- net/rtpproxy/Makefile | 12 +++-- net/rtpproxy/files/rtpproxy.config | 14 ++++++ net/rtpproxy/files/rtpproxy.init | 70 ++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 net/rtpproxy/files/rtpproxy.config create mode 100644 net/rtpproxy/files/rtpproxy.init diff --git a/net/rtpproxy/Makefile b/net/rtpproxy/Makefile index 3aed248..2fa3014 100644 --- a/net/rtpproxy/Makefile +++ b/net/rtpproxy/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2013 OpenWrt.org +# Copyright (C) 2014 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rtpproxy PKG_VERSION:=1.2.1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://b2bua.org/chrome/site/ @@ -31,11 +31,15 @@ define Package/rtpproxy URL:=http://www.rtpproxy.org/ endef -# uses GNU configure - define Package/rtpproxy/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rtpproxy $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/rtpproxy.init $(1)/etc/init.d/rtpproxy + + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_BIN) ./files/rtpproxy.config $(1)/etc/config/rtpproxy endef $(eval $(call BuildPackage,rtpproxy)) diff --git a/net/rtpproxy/files/rtpproxy.config b/net/rtpproxy/files/rtpproxy.config new file mode 100644 index 0000000..9b72d7c --- /dev/null +++ b/net/rtpproxy/files/rtpproxy.config @@ -0,0 +1,14 @@ +config rtpproxy global + option enabled 0 # 0 - disabled, 1 - enabled + +config instance 'site1' + option socket 'udp:127.0.0.1:7723' # socket + option ipaddr '127.0.0.1' # IPv4 address + option ip6addr '2001:0db8:0000:0000:0000:0000:1428:57ab' # IPv6 address + option user 'nobody' # userid to run rtpproxy instance from + option opts '' # additional options for rtpproxy instance + +config instance 'site2' + option socket 'udp:127.0.0.1:7724' + option ipaddr '192.168.1.1' + diff --git a/net/rtpproxy/files/rtpproxy.init b/net/rtpproxy/files/rtpproxy.init new file mode 100644 index 0000000..d1e2b37 --- /dev/null +++ b/net/rtpproxy/files/rtpproxy.init @@ -0,0 +1,70 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 CESNET, z.s.p.o + +START=99 +RTPPROXY_BIN="/usr/bin/rtpproxy" + +run_instance(){ + local params="$1" + + ${RTPPROXY_BIN} $1 + echo "[INFO] rtpproxy instance $2 has started" +} + +check_param(){ + local param="$1" + local value="$2" + local default_value="$3" + + if [ "$value" != "" ]; then + rtpproxy_options=$rtpproxy_options" $param $value" + else + if [ "$default_value" != "" ]; then + rtpproxy_options=$rtpproxy_options" $param $default_value" + fi + fi +} + +check_special_param(){ + local param="$1" + + if [ "$param" != "" ]; then + rtpproxy_options=$rtpproxy_options" $param" + fi +} + +handle_instance() { + local site="$1" + local socket opts ipaddr ip6addr rtpproxy_options + + config_get socket "$site" socket + config_get opts "$site" opts + config_get ipaddr "$site" ipaddr + config_get ip6addr "$site" ip6addr + config_get user "$site" user + + check_param "-s" "$socket" + check_param "-l" "$ipaddr" + check_param "-6" "$ip6addr" + check_param "-u" "$user" "nobody" + check_special_param "$opts" + + run_instance "$rtpproxy_options" "$site" +} + +start(){ + config_load rtpproxy + local section="global" + config_get_bool enabled global enabled 0 + + if [ "$enabled" -eq 1 ]; then + config_foreach handle_instance instance + else + echo "[WARNING] rtpproxy not yet configured. Edit /etc/config/rtpproxy first." + fi +} + +stop() { + killall rtpproxy +} + -- 2.30.2