[OpenWrt-Devel] [PATCH v4] base-files: evaluate uci-defaults on run-time installations
Daniel Golle
daniel at makrotopia.org
Thu Apr 28 08:37:36 EDT 2016
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 at makrotopia.org>
---
v2: remove superflus expansions of always-empty variable
v3: fix typo in patch description, sorry for the noise...
v4: mimic original uci-defaults behaviour more exactly
package/base-files/files/lib/functions.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index dde1ac4..8582605 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -214,6 +214,17 @@ default_postinst() {
ret=$?
fi
+ if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "$root/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/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
+ ( . "./$(basename $i)" ) && rm -f "$i"
+ done
+ uci commit
+ cd $OLDPWD
+ fi
+
[ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
if [ "$PKG_UPGRADE" != "1" ]; then
--
2.8.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list