From 0b092cbe2b5eed5dd6f9140ee35860ac32bdd577 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Mon, 5 Nov 2018 20:16:54 +0100 Subject: [PATCH] rtpproxy: add hotplug script Install hotplug script along with rtpproxy. It will only be used if enabled by the user (via uci config file). Signed-off-by: Sebastian Kemper --- net/rtpproxy/Makefile | 5 ++++- net/rtpproxy/files/rtpproxy.config | 3 +++ net/rtpproxy/files/rtpproxy.hotplug | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 net/rtpproxy/files/rtpproxy.hotplug diff --git a/net/rtpproxy/Makefile b/net/rtpproxy/Makefile index 8c8505b..87ecab8 100644 --- a/net/rtpproxy/Makefile +++ b/net/rtpproxy/Makefile @@ -64,13 +64,16 @@ TARGET_CFLAGS+=$(TARGET_CPPFLAGS) define Package/rtpproxy/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rtpproxy $(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_CONF) ./files/rtpproxy.config $(1)/etc/config/rtpproxy + + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_BIN) ./files/rtpproxy.hotplug $(1)/etc/hotplug.d/iface endef define Package/rtpproxy-mod-acct-csv/install diff --git a/net/rtpproxy/files/rtpproxy.config b/net/rtpproxy/files/rtpproxy.config index 7087251..2350c11 100644 --- a/net/rtpproxy/files/rtpproxy.config +++ b/net/rtpproxy/files/rtpproxy.config @@ -12,3 +12,6 @@ config instance 'site2' option socket 'udp:127.0.0.1:7724' option ipaddr '192.168.1.1' +config rtpproxy 'hotplug' + #option interface 'wan' # uncomment to enable hotplug + diff --git a/net/rtpproxy/files/rtpproxy.hotplug b/net/rtpproxy/files/rtpproxy.hotplug new file mode 100644 index 0000000..dfa6981 --- /dev/null +++ b/net/rtpproxy/files/rtpproxy.hotplug @@ -0,0 +1,24 @@ +#!/bin/sh + +[ "$ACTION" = ifup ] || exit 0 + +NAME=rtpproxy +COMMAND=/etc/init.d/$NAME +LOGGER="/usr/bin/logger -t hotplug" + +$COMMAND enabled || exit 0 + +. /lib/functions.sh + +config_load $NAME + +config_get_bool enabled global enabled 0 +[ $enabled -eq 0 ] && exit 0 + +config_get hotplug_iface hotplug interface + +[ "$INTERFACE" = "$hotplug_iface" ] && { + $LOGGER "Restarting $NAME due to \"$ACTION\" of \"$INTERFACE\"" + $COMMAND restart +} + -- 2.30.2