Re: [PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install

2024-01-10 Thread Rafał Miłecki

On 26.11.2023 21:47, Rafał Miłecki wrote:

From: Rafał Miłecki 

Reloading service from uci-defaults script is a hack to workaround
postinst limitation. It should not be executed during boot as other
uci-defaults scripts may want to adjust uhttpd's config too.

Cc: Hauke Mehrtens 
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Signed-off-by: Rafał Miłecki 


PATCH obsoleted by
[PATCH] uhttpd: handle reload after uhttpd-mod-ubus installation using postinst
https://patchwork.ozlabs.org/project/openwrt/patch/20231227152045.18336-1-zaj...@gmail.com/



---
  package/network/services/uhttpd/Makefile   |  2 +-
  package/network/services/uhttpd/files/ubus.default | 13 -
  2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/package/network/services/uhttpd/Makefile 
b/package/network/services/uhttpd/Makefile
index 02a02405fd..9405070626 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
diff --git a/package/network/services/uhttpd/files/ubus.default 
b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..e2240a1018 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -12,6 +12,17 @@ fi
commit=1
  }
  
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload

+# Normally (when executing this script during boot) we want to adjust config
+# only. Actual uhttpd start will happen later.
+#
+# If this is package installation in a running system however then we need to
+# reload uhttpd to make ubus access work right after. Ideally this should be
+# handled by a "postinst" script but those get executed *before* uci-defaults
+# scripts. For that reason we abuse uci-defaults to call init.d script.
+#
+# Check for $PKG_ROOT to detect "opkg install" case in a running system.
+if [ -n "$PKG_ROOT" ]; then
+   [ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+fi
  
  exit 0



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install

2023-11-26 Thread Rafał Miłecki
From: Rafał Miłecki 

Reloading service from uci-defaults script is a hack to workaround
postinst limitation. It should not be executed during boot as other
uci-defaults scripts may want to adjust uhttpd's config too.

Cc: Hauke Mehrtens 
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Signed-off-by: Rafał Miłecki 
---
 package/network/services/uhttpd/Makefile   |  2 +-
 package/network/services/uhttpd/files/ubus.default | 13 -
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/package/network/services/uhttpd/Makefile 
b/package/network/services/uhttpd/Makefile
index 02a02405fd..9405070626 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
diff --git a/package/network/services/uhttpd/files/ubus.default 
b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..e2240a1018 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -12,6 +12,17 @@ fi
commit=1
 }
 
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+# Normally (when executing this script during boot) we want to adjust config
+# only. Actual uhttpd start will happen later.
+#
+# If this is package installation in a running system however then we need to
+# reload uhttpd to make ubus access work right after. Ideally this should be
+# handled by a "postinst" script but those get executed *before* uci-defaults
+# scripts. For that reason we abuse uci-defaults to call init.d script.
+#
+# Check for $PKG_ROOT to detect "opkg install" case in a running system.
+if [ -n "$PKG_ROOT" ]; then
+   [ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+fi
 
 exit 0
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel