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>
$(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/
# Any other option can be put between the quotes below:
#option options ""
+config kamailio 'hotplug'
+ # Uncomment to enable hotplug:
+ #option interface 'wan'
+
--- /dev/null
+#!/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
+}
+