bcp38: add init script
authorJo-Philipp Wich <jo@mein.io>
Thu, 19 Apr 2018 07:04:30 +0000 (09:04 +0200)
committerToke Høiland-Jørgensen <toke@toke.dk>
Thu, 19 Apr 2018 09:02:10 +0000 (11:02 +0200)
This commit adds a simple procd init script for bcp38 with the sole purpose
to register a configuration change trigger for /etc/config/bcp38.

The change will allow for automatic firewall reloads triggered by invoking
/sbin/reload_config or through ubus config change events emitted by LuCI.

With the init script in place and started, calling

  ubus call service event '{"type":"config.change","data":{"package":"bcp38"}}'

or

  /sbin/reload_config

will issue an /etc/init.d/firewall reload if /etc/config/bcp38 has been
modified since the last reload_config call.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
net/bcp38/Makefile
net/bcp38/files/bcp38.init [new file with mode: 0755]

index c62aed87e065ab29f682b6c46a2f4e3df1839e04..70ac63c81580626ff444e3f2ab18636901278302 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=bcp38
 PKG_VERSION:=5
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 PKG_LICENCE:=GPL-3.0+
 
 include $(INCLUDE_DIR)/package.mk
@@ -50,6 +50,8 @@ define Package/bcp38/install
        $(INSTALL_BIN) ./files/run.sh $(1)/usr/lib/bcp38/run.sh
        $(INSTALL_DIR) $(1)/etc/uci-defaults
        $(INSTALL_BIN) ./files/bcp38.defaults $(1)/etc/uci-defaults/bcp38
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/bcp38.init $(1)/etc/init.d/bcp38
 endef
 
 define Package/bcp38/postinst
diff --git a/net/bcp38/files/bcp38.init b/net/bcp38/files/bcp38.init
new file mode 100755 (executable)
index 0000000..6c22c22
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh /etc/rc.common
+
+START=20
+
+USE_PROCD=1
+NAME=bcp38
+
+service_triggers()
+{
+       procd_add_config_trigger "config.change" "bcp38" /etc/init.d/firewall reload
+}