From 0dd94c624eb5f756872001c440fa43d041f5d82d Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Mon, 5 Nov 2018 22:32:56 +0100 Subject: [PATCH] kamailio-5.x: add hotplug script Add hotplug script to base package. Hotplug will only occur if user enables it via uci config. Signed-off-by: Sebastian Kemper --- net/kamailio-5.x/Makefile | 4 ++++ net/kamailio-5.x/files/kamailio.config | 4 ++++ net/kamailio-5.x/files/kamailio.hotplug | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 net/kamailio-5.x/files/kamailio.hotplug diff --git a/net/kamailio-5.x/Makefile b/net/kamailio-5.x/Makefile index 9bf139c..899c573 100644 --- a/net/kamailio-5.x/Makefile +++ b/net/kamailio-5.x/Makefile @@ -271,6 +271,10 @@ $(foreach c,kamailio.cfg kamctlrc,$(call Package/kamailio5/install/conffile,$(1) $(INSTALL_BIN) \ ./files/kamailio.init \ $(1)/etc/init.d/kamailio + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_BIN) \ + ./files/kamailio.hotplug \ + $(1)/etc/hotplug.d/iface $(CP) \ $(PKG_INSTALL_DIR)/usr/lib/kamailio/kamctl \ $(1)/usr/lib/kamailio/ diff --git a/net/kamailio-5.x/files/kamailio.config b/net/kamailio-5.x/files/kamailio.config index aaa9af8..f1a9c36 100644 --- a/net/kamailio-5.x/files/kamailio.config +++ b/net/kamailio-5.x/files/kamailio.config @@ -19,3 +19,7 @@ config kamailio 'general' # Any other option can be put between the quotes below: #option options "" +config kamailio 'hotplug' + # Uncomment to enable hotplug: + #option interface 'wan' + diff --git a/net/kamailio-5.x/files/kamailio.hotplug b/net/kamailio-5.x/files/kamailio.hotplug new file mode 100644 index 0000000..0dec974 --- /dev/null +++ b/net/kamailio-5.x/files/kamailio.hotplug @@ -0,0 +1,24 @@ +#!/bin/sh + +[ "$ACTION" = ifup ] || exit 0 + +NAME=kamailio +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 general 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 +} +