From: Rafał Miłecki <ra...@milecki.pl>

With this change "postinst" scripts can perform extra actions after
applying all kind of fixups implemented using uci-defaults.

This is needed e.g. by uhttpd-mod-ubus which after installation in a
running systems needs to:
1. Update uhttpd config using its uci-defaults script
2. Reload uhttpd

Cc: Hauke Mehrtens <ha...@hauke-m.de>
Signed-off-by: Rafał Miłecki <ra...@milecki.pl>
---
I noticed that kind of hacky code was added in the commit d25d281fd668
("uhttpd: Reload config after uhttpd-mod-ubus was added") to reload
uhttpd after "opkg install". It abuses uci-defaults script to call
init.d script. It's a wrong idea as uci-defaults should run before
running services during first boot. It doesn't allow further config
adjustments by other uci-defaults as uhttpd gets started early.

This change would allow moving uhttpd-mod-ubus's reload to postinst.

The question is: can this change break anything?

 package/base-files/files/lib/functions.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh 
b/package/base-files/files/lib/functions.sh
index d9628dbb7a..851d2f1791 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -270,11 +270,6 @@ default_postinst() {
 
        add_group_and_user "${pkgname}"
 
-       if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
-               ( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
-               ret=$?
-       fi
-
        if [ -d "$root/rootfs-overlay" ]; then
                cp -R $root/rootfs-overlay/. $root/
                rm -fR $root/rootfs-overlay/
@@ -300,6 +295,11 @@ default_postinst() {
                rm -f /tmp/luci-indexcache
        fi
 
+       if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
+               ( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
+               ret=$?
+       fi
+
        local shell="$(command -v bash)"
        for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
                if [ -n "$root" ]; then
-- 
2.35.3


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

Reply via email to