kamailio-5.x: add hotplug script
authorSebastian Kemper <sebastian_ml@gmx.net>
Mon, 5 Nov 2018 21:32:56 +0000 (22:32 +0100)
committerSebastian Kemper <sebastian_ml@gmx.net>
Mon, 5 Nov 2018 21:32:58 +0000 (22:32 +0100)
Add hotplug script to base package. Hotplug will only occur if user
enables it via uci config.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
net/kamailio-5.x/Makefile
net/kamailio-5.x/files/kamailio.config
net/kamailio-5.x/files/kamailio.hotplug [new file with mode: 0644]

index 9bf139c1dfca90725093884f82a61e3dc9ad3190..899c573a731b8edcb91a918cb42ebf1f2b25173a 100644 (file)
@@ -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/
index aaa9af86daa539538b5c1216e54e5b21a6b8a9d6..f1a9c36a4bcee4899df07a35e1fe7a2feff91ebc 100644 (file)
@@ -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 (file)
index 0000000..0dec974
--- /dev/null
@@ -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
+}
+