Removed all "cat | grep", with grep, awk and sed.
[live-boot-grml.git] / scripts / live-bottom / 10adduser
index 60d6028..4c0fe80 100755 (executable)
@@ -40,12 +40,13 @@ set passwd/root-password-crypted *
 set passwd/user-password-crypted ${user_crypted}
 set passwd/user-fullname ${USERFULLNAME}
 set passwd/username ${USERNAME}
-set passwd/user-uid 999
+set passwd/user-uid 1000
 EOF
 
 chroot /root /usr/bin/env -i HOME="/root" \
        TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
-       /usr/lib/user-setup/user-setup-apply > /dev/null
+       /usr/lib/user-setup/user-setup-apply 2>&1 \
+               | grep -v "Shadow passwords are now on"
 
 # Clear out debconf database again to avoid confusing ubiquity later.
 chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
@@ -57,6 +58,28 @@ set passwd/username
 set passwd/user-uid
 EOF
 
+if ! grep "${USERNAME}" /root/etc/passwd
+then
+       echo "The default user (${USERNAME}) is not present,"
+       first_user=$(grep '^[^:]*:[^:]*:[12]\?[0-9][0-9][0-9][0-9]:' /root/etc/passwd | head -1 | cut -f1 -d ':')
+       if [ -n "${first_user}" ];
+       then
+               echo "setting default user to: ${first_user}."
+               USERNAME="${first_user}"
+               really_export USERNAME
+       else
+               echo "no other valid users found, disabling autologin."
+               NOAUTOLOGIN="Yes"
+               NOXAUTOLOGIN="Yes"
+               USERNAME=""
+               really_export NOAUTOLOGIN
+               really_export NOXAUTOLOGIN
+               really_export USERNAME
+               log_end_msg
+               exit 0
+       fi
+fi
+
 if [ -z "${NOSUDO}" ]
 then
        if ! grep -q "${USERNAME}" /root/etc/sudoers