[OpenWrt-Devel] [base-files] functions.sh: default_postinst() - create user:group first

Christian Schoenebeck christian.schoenebeck at gmail.com
Wed Nov 26 13:38:06 EST 2014


1.) create user:group
2.) run postinst-pkg
    now you can change owner and permission of installed files and directories in postinst-pkg (Makefile/postinst)
    otherwise you can't
3.) clear luci cache
4.) enable/start service
    
Signed-off-by: Christian Schoenebeck <christian.schoenebeck at gmail.com>
---
 package/base-files/files/lib/functions.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index d53be3e..3d987cf 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -173,7 +173,7 @@ default_prerm() {
 default_postinst() {
 	local name rusers
 	name=$(echo $(basename $1) | cut -d. -f1)
-	[ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg ] && ( . ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg )
+
 	rusers=$(grep "Require-User:" ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.control)
 	[ -n "$rusers" ] && {
 		local user group uid gid
@@ -212,6 +212,10 @@ default_postinst() {
 			done
 		done
 	}
+
+	[ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg ] && ( . ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.postinst-pkg )
+	[ -n "${IPKG_INSTROOT}" ] || rm -f /tmp/luci-indexcache 2>/dev/null
+
 	[ "$PKG_UPGRADE" = "1" ] || for i in `cat ${IPKG_INSTROOT}/usr/lib/opkg/info/${name}.list | grep "^/etc/init.d/"`; do
 		[ -n "${IPKG_INSTROOT}" ] && $(which bash) ${IPKG_INSTROOT}/etc/rc.common ${IPKG_INSTROOT}$i enable; \
 		[ -n "${IPKG_INSTROOT}" ] || {
@@ -219,7 +223,6 @@ default_postinst() {
 			$i start
 		}
 	done
-	[ -n "${IPKG_INSTROOT}" ] || rm -f /tmp/luci-indexcache 2>/dev/null
 	return 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