[PATCH] uhttpd: handle reload after uhttpd-mod-ubus installation using postinst
Rafał Miłecki
zajec5 at gmail.com
Wed Dec 27 07:20:45 PST 2023
From: Rafał Miłecki <rafal at milecki.pl>
Use postinst script to reload service instead of uci-defaults hack. It's
possible thanks to recent base-files change that executes postinst after
uci-defaults.
This fixes support for uhttpd customizations. It's possible (again) to
adjust uhttpd config with custom uci-defaults before it gets started.
Cc: Hauke Mehrtens <hauke at hauke-m.de>
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Ref: b799dd3c705d ("base-files: execute package's "postinst" after executing uci-defaults")
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
This is a clean fix compared to my proposed hack:
[PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install
https://patchwork.ozlabs.org/project/openwrt/patch/20231126204739.14315-1-zajec5@gmail.com/
I'm planning to push it in few days unless base-files change blows up
some existing packages.
package/network/services/uhttpd/Makefile | 9 ++++++++-
package/network/services/uhttpd/files/ubus.default | 6 ------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/package/network/services/uhttpd/Makefile b/package/network/services/uhttpd/Makefile
index 02a02405fd..37117bf911 100644
--- a/package/network/services/uhttpd/Makefile
+++ b/package/network/services/uhttpd/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uhttpd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uhttpd.git
@@ -107,6 +107,13 @@ define Package/uhttpd-mod-ubus/install
$(INSTALL_DATA) ./files/ubus.default $(1)/etc/uci-defaults/00_uhttpd_ubus
endef
+define Package/uhttpd-mod-ubus/postinst
+#!/bin/sh
+if [ -z "$${IPKG_INSTROOT}" ]; then
+ /etc/init.d/uhttpd reload
+fi
+endef
+
define Package/uhttpd-mod-ucode/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_ucode.so $(1)/usr/lib/
diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..d0a218a0ad 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -1,17 +1,11 @@
#!/bin/sh
-commit=0
-
if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then
uci set uhttpd.main.ubus_prefix=/ubus
- commit=1
fi
[ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
- commit=1
}
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
-
exit 0
--
2.35.3
More information about the openwrt-devel
mailing list