diff mbox

[OpenWrt-Devel,v2] base-files: evalute uci-defaults on run-time installations

Message ID 20160427233755.GA21020@makrotopia.org
State Superseded
Headers show

Commit Message

Daniel Golle April 27, 2016, 11:37 p.m. UTC
Packages may install scripts into /etc/uci-defaults to be executed once
after installation, usually at the first boot of the target. This works
fine if the package was installed to the rootfs during build or using
the ImageBuilder.
If the package is installed using opkg during run-time uci-defaults
were applied only after a reboot of the device. Avoid the need to
reboot by evaluting the package's uci-defaults in default-postinst.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v2: remove superflus expansions of always-empty variable

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

Patch

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index dde1ac4..7db703f 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -214,6 +214,11 @@  default_postinst() {
 		ret=$?
 	fi
 
+	[ -n "$root" ] || for i in $(grep -s "^/etc/uci-defaults/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
+		( . "$i" )
+		rm "$i"
+	done
+
 	[ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
 
 	if [ "$PKG_UPGRADE" != "1" ]; then