summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2024-04-16 08:44:31 +0200
committerGitHub <noreply@github.com>2024-04-16 08:44:31 +0200
commitd5c413d2853fde0d5cec98641606a0a30f93281c (patch)
treedfc648c2c1881e7510c3b1857f3e2c7e11912c34 /modules
parentb5b14a48c7d8c81cc765ada82df524caa5fe38cd (diff)
parent4cffc9fd63d43f13942e28aa972d128a3cd35f77 (diff)
Merge pull request #7056 from TDT-AG/pr/20240411-ucitrack
luci-base: conversion of ucitrack handling from uci to json
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/Makefile1
-rw-r--r--modules/luci-base/root/etc/config/ucitrack56
-rwxr-xr-xmodules/luci-base/root/etc/init.d/ucitrack41
-rwxr-xr-xmodules/luci-base/root/sbin/luci-reload45
-rw-r--r--modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-dnsmasq.json7
-rw-r--r--modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-interfaces.json7
-rw-r--r--modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-odhcpd.json4
-rw-r--r--modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-wireless.json6
-rw-r--r--modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-dropbear.json4
-rw-r--r--modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-mounts.json4
-rw-r--r--modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-system.json9
11 files changed, 73 insertions, 111 deletions
diff --git a/modules/luci-base/Makefile b/modules/luci-base/Makefile
index 6913568948..789e6a4bf6 100644
--- a/modules/luci-base/Makefile
+++ b/modules/luci-base/Makefile
@@ -36,7 +36,6 @@ include $(INCLUDE_DIR)/host-build.mk
define Package/luci-base/conffiles
/etc/luci-uploads
/etc/config/luci
-/etc/config/ucitrack
endef
define Package/luci-base/postinst
diff --git a/modules/luci-base/root/etc/config/ucitrack b/modules/luci-base/root/etc/config/ucitrack
deleted file mode 100644
index bb4cdbc3c4..0000000000
--- a/modules/luci-base/root/etc/config/ucitrack
+++ /dev/null
@@ -1,56 +0,0 @@
-config network
- option init network
- list affects dhcp
-
-config wireless
- list affects network
-
-config firewall
- option init firewall
- list affects luci-splash
- list affects qos
- list affects miniupnpd
-
-config olsr
- option init olsrd
-
-config dhcp
- option init dnsmasq
- list affects odhcpd
-
-config odhcpd
- option init odhcpd
-
-config dropbear
- option init dropbear
-
-config httpd
- option init httpd
-
-config fstab
- option exec '/sbin/block mount'
-
-config qos
- option init qos
-
-config system
- option init led
- option exec '/etc/init.d/log reload'
- list affects luci_statistics
- list affects dhcp
-
-config luci_splash
- option init luci_splash
-
-config upnpd
- option init miniupnpd
-
-config ntpclient
- option init ntpclient
-
-config samba
- option init samba
-
-config tinyproxy
- option init tinyproxy
-
diff --git a/modules/luci-base/root/etc/init.d/ucitrack b/modules/luci-base/root/etc/init.d/ucitrack
index 57ac11857f..495949f64f 100755
--- a/modules/luci-base/root/etc/init.d/ucitrack
+++ b/modules/luci-base/root/etc/init.d/ucitrack
@@ -3,6 +3,8 @@
START=80
USE_PROCD=1
+. "$IPKG_INSTROOT/usr/share/libubox/jshn.sh"
+
register_init() {
local config="$1"
local init="$2"
@@ -15,13 +17,25 @@ register_init() {
}
register_trigger() {
- local sid="$1"
+ local uci="$1"
+ local file="$2"
+
local config init exec affects affected
+ local prev
- config_get config "$sid" TYPE
- config_get init "$sid" init
- config_get exec "$sid" exec
- config_get affects "$sid" affects
+ json_set_namespace config prev
+ json_init
+ json_load_file "${file}" >/dev/null 2>&1
+ json_get_var config 'config'
+ [ "$config" = "$uci" ] || {
+ json_set_namespace "$prev"
+ return
+ }
+ json_get_var init 'init'
+ json_get_var exec 'exec'
+ json_get_values affects 'affects'
+ json_cleanup
+ json_set_namespace "$prev"
if [ -n "$init" ]; then
register_init "$config" "/etc/init.d/$init" "reload"
@@ -48,10 +62,19 @@ register_trigger() {
done
}
-service_triggers() {
- config_foreach register_trigger
+check_trigger() {
+ local config="$1"
+
+ local file
+
+ for file in /usr/share/ucitrack/*.json; do
+ [ -f "$file" ] || continue
+ register_trigger "$config" "$file"
+ done
}
-start_service() {
- config_load ucitrack
+service_triggers() {
+ for config in /etc/config/*; do
+ check_trigger "${config##*/}"
+ done
}
diff --git a/modules/luci-base/root/sbin/luci-reload b/modules/luci-base/root/sbin/luci-reload
deleted file mode 100755
index cc41da2bb7..0000000000
--- a/modules/luci-base/root/sbin/luci-reload
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-. /lib/functions.sh
-
-apply_config() {
- config_get init "$1" init
- config_get exec "$1" exec
- config_get test "$1" test
-
- echo "$2" > "/var/run/luci-reload-status"
-
- [ -n "$init" ] && reload_init "$2" "$init" "$test"
- [ -n "$exec" ] && reload_exec "$2" "$exec" "$test"
-}
-
-reload_exec() {
- local service="$1"
- local ok="$3"
- set -- $2
- local cmd="$1"; shift
-
- [ -x "$cmd" ] && {
- echo "Reloading $service... "
- ( $cmd "$@" ) 2>/dev/null 1>&2
- [ -n "$ok" -a "$?" != "$ok" ] && echo '!!! Failed to reload' $service '!!!'
- }
-}
-
-reload_init() {
- [ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && {
- echo "Reloading $1... "
- /etc/init.d/$2 reload >/dev/null 2>&1
- [ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
- }
-}
-
-lock "/var/run/luci-reload"
-
-config_load ucitrack
-
-for i in $*; do
- config_foreach apply_config $i $i
-done
-
-rm -f "/var/run/luci-reload-status"
-lock -u "/var/run/luci-reload"
diff --git a/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-dnsmasq.json b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-dnsmasq.json
new file mode 100644
index 0000000000..260ee3dd3b
--- /dev/null
+++ b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-dnsmasq.json
@@ -0,0 +1,7 @@
+{
+ "config": "dhcp",
+ "init": "dnsmasq",
+ "affects": [
+ "odhcpd"
+ ]
+}
diff --git a/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-interfaces.json b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-interfaces.json
new file mode 100644
index 0000000000..99d31fc61e
--- /dev/null
+++ b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-interfaces.json
@@ -0,0 +1,7 @@
+{
+ "config": "network",
+ "init": "network",
+ "affects": [
+ "dhcp"
+ ]
+}
diff --git a/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-odhcpd.json b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-odhcpd.json
new file mode 100644
index 0000000000..2c78e1e349
--- /dev/null
+++ b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-odhcpd.json
@@ -0,0 +1,4 @@
+{
+ "config": "odhcpd",
+ "init": "odhcpd"
+}
diff --git a/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-wireless.json b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-wireless.json
new file mode 100644
index 0000000000..edbaee704b
--- /dev/null
+++ b/modules/luci-mod-network/root/usr/share/ucitrack/luci-mod-network-wireless.json
@@ -0,0 +1,6 @@
+{
+ "config": "wireless",
+ "affects": [
+ "network"
+ ]
+}
diff --git a/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-dropbear.json b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-dropbear.json
new file mode 100644
index 0000000000..fc24cd9978
--- /dev/null
+++ b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-dropbear.json
@@ -0,0 +1,4 @@
+{
+ "config": "dropbear",
+ "init": "dropbear"
+}
diff --git a/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-mounts.json b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-mounts.json
new file mode 100644
index 0000000000..95b071167c
--- /dev/null
+++ b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-mounts.json
@@ -0,0 +1,4 @@
+{
+ "config": "fstab",
+ "exec": "/sbin/block mount"
+}
diff --git a/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-system.json b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-system.json
new file mode 100644
index 0000000000..f3da5ce8c4
--- /dev/null
+++ b/modules/luci-mod-system/root/usr/share/ucitrack/luci-mod-system-system.json
@@ -0,0 +1,9 @@
+{
+ "config": "system",
+ "init": "led",
+ "exec": "/etc/init.d/log reload",
+ "affects": [
+ "luci_statistics",
+ "dhcp"
+ ]
+}