diff mbox series

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

Message ID 20231126204739.14315-1-zajec5@gmail.com
State Superseded
Delegated to: Rafał Miłecki
Headers show
Series uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install | expand

Commit Message

Rafał Miłecki Nov. 26, 2023, 8:47 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

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 <hauke@hauke-m.de>
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 package/network/services/uhttpd/Makefile           |  2 +-
 package/network/services/uhttpd/files/ubus.default | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Rafał Miłecki Jan. 10, 2024, 4:06 p.m. UTC | #1
On 26.11.2023 21:47, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> 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 <hauke@hauke-m.de>
> Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

PATCH obsoleted by
[PATCH] uhttpd: handle reload after uhttpd-mod-ubus installation using postinst
https://patchwork.ozlabs.org/project/openwrt/patch/20231227152045.18336-1-zajec5@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
diff mbox series

Patch

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