base-files: evaluate uci-defaults on run-time installations
base-files: evaluate uci-defaults on run-time installations

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>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@49340 3c298f89-4303-0410-b956-a3cf2f4a3e73

--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -225,6 +225,17 @@
 		[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
 		cd /etc/uci-defaults
 		for i in $(grep -s "^/etc/uci-defaults/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
+			( . "./$(basename $i)" ) && rm -f "$i"
+		done
+		uci commit
+		cd $OLDPWD
+	fi
+
+	if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then
+		. /lib/functions/system.sh
+		[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
+		cd /etc/uci-defaults
+		for i in $(grep -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"); do
 			( . "./$(basename $i)" ) && rm -f "$i"
 		done
 		uci commit

comments