[openwrt/openwrt] procd: add support for reload triggers on data change
LEDE Commits
lede-commits at lists.infradead.org
Tue Dec 17 13:01:09 PST 2024
nbd pushed a commit to openwrt/openwrt.git, branch openwrt-24.10:
https://git.openwrt.org/6642ee73bc72cf6052510c3320adaf50edd5a3c8
commit 6642ee73bc72cf6052510c3320adaf50edd5a3c8
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Tue Dec 17 21:54:14 2024 +0100
procd: add support for reload triggers on data change
This can be useful to reload the firewall when procd firewall data changes
Signed-off-by: Felix Fietkau <nbd at nbd.name>
(cherry picked from commit 49d92d3e933c45e3684da2fbf0a198d195635581)
---
package/system/procd/files/procd.sh | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh
index 59e002036d..0f9405a222 100644
--- a/package/system/procd/files/procd.sh
+++ b/package/system/procd/files/procd.sh
@@ -308,6 +308,36 @@ _procd_add_reload_interface_trigger() {
_procd_close_trigger
}
+_procd_add_data_trigger() {
+ json_add_array
+ _procd_add_array_data "service.data.update"
+
+ json_add_array
+ _procd_add_array_data "if"
+
+ json_add_array
+ _procd_add_array_data "eq" "name" "$1"
+ shift
+ json_close_array
+
+ json_add_array
+ _procd_add_array_data "run_script" "$@"
+ json_close_array
+
+ json_close_array
+ _procd_add_timeout
+ json_close_array
+}
+
+_procd_add_reload_data_trigger() {
+ local script=$(readlink "$initscript")
+ local name=$(basename ${script:-$initscript})
+
+ _procd_open_trigger
+ _procd_add_data_trigger $1 /etc/init.d/$name reload
+ _procd_close_trigger
+}
+
_procd_add_config_trigger() {
json_add_array
_procd_add_array_data "$1"
@@ -661,6 +691,7 @@ _procd_wrapper \
procd_add_interface_trigger \
procd_add_mount_trigger \
procd_add_reload_trigger \
+ procd_add_reload_data_trigger \
procd_add_reload_interface_trigger \
procd_add_action_mount_trigger \
procd_add_reload_mount_trigger \
More information about the lede-commits
mailing list