From: Luka Perkov Date: Tue, 10 May 2016 22:36:49 +0000 (+0000) Subject: base-files: evaluate uci-defaults on run-time installations X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=f84e4ad598e24d5565874852539cb66cb9408ee0;p=openwrt%2Fsvn-archive%2Farchive.git 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 SVN-Revision: 49340 --- diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 4ec0cac332..cf1fa4874a 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -231,6 +231,17 @@ default_postinst() { 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 + cd $OLDPWD + fi + [ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null if [ "$PKG_UPGRADE" != "1" ]; then