base-files: allocate uid/gid starting from 65536
[openwrt/openwrt.git] / package / base-files / files / lib / functions.sh
index a5838f6035cd5462a2fb51043885923ad261a2b3..81ef84b8ef8fc44ae8731b80766c222094408010 100755 (executable)
@@ -178,7 +178,7 @@ default_prerm() {
                        if [ "$PKG_UPGRADE" != "1" ]; then
                                "$i" disable
                        fi
-                       "$i" stop
+                       "$i" stop || /bin/true
                fi
        done
 }
@@ -230,6 +230,11 @@ default_postinst() {
                ret=$?
        fi
 
+       if [ -d "$root/rootfs-overlay" ]; then
+               cp -R $root/rootfs-overlay/. $root/
+               rm -fR $root/rootfs-overlay/
+       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
@@ -301,8 +306,8 @@ group_add_next() {
        gid=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
        [ -n "$gid" ] && return $gid
        gids=$(cat ${IPKG_INSTROOT}/etc/group | cut -d: -f3)
-       gid=100
-       while [ -n "$(echo $gids | grep $gid)" ] ; do
+       gid=65536
+       while [ -n "$(echo "$gids" | grep "^$gid$")" ] ; do
                gid=$((gid + 1))
        done
        group_add $1 $gid
@@ -329,8 +334,8 @@ user_add() {
        local rc
        [ -z "$uid" ] && {
                uids=$(cat ${IPKG_INSTROOT}/etc/passwd | cut -d: -f3)
-               uid=100
-               while [ -n "$(echo $uids | grep $uid)" ] ; do
+               uid=65536
+               while [ -n "$(echo "$uids" | grep "^$uid$")" ] ; do
                        uid=$((uid + 1))
                done
        }
@@ -348,4 +353,8 @@ user_exists() {
        grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd
 }
 
+board_name() {
+       [ -e /tmp/sysinfo/board_name ] && cat /tmp/sysinfo/board_name || echo "generic"
+}
+
 [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh