X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive-bottom%2F10adduser;h=51868d4900defa18ea30a5c72d9baaf667288c5e;hb=35667bd4deb41faa9247fb7321a4d15e7f524cf7;hp=394f007006e16e18e52132f4cd3adf658d454bf2;hpb=0a854a1e9307affdeaf96cb3ec0c864b171d66ca;p=live-boot-grml.git diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser index 394f007..51868d4 100755 --- a/scripts/live-bottom/10adduser +++ b/scripts/live-bottom/10adduser @@ -1,98 +1,127 @@ #!/bin/sh -PREREQ="" -DESCRIPTION="Adding live session user..." +#set -e -. /scripts/live-functions +# initramfs-tools header + +PREREQ="" prereqs() { - echo "$PREREQ" + echo "${PREREQ}" } -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; +case "${1}" in + prereqs) + prereqs + exit 0 + ;; esac -log_begin_msg "$DESCRIPTION" +# live-initramfs header -if [ "${BUILD_SYSTEM}" == "Debian" ]; then - user_crypted="8Ab05sVQ4LLps" # as in `echo "live" | mkpasswd -s` -else - user_crypted="U6aMy0wojraho" # "ubuntu" +if [ -n "${NOUSER}" ] +then + exit 0 fi -# U6aMy0wojraho is just a blank password -chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null < /dev/null -else - chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null -fi +log_begin_msg "Adding live session user" -# Clear out debconf database again to avoid confusing ubiquity later. -chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <> /root/etc/sudoers +# U6aMy0wojraho is just a blank password +db_set passwd/make-user true +db_set passwd/root-password-crypted '*' +db_set passwd/user-password-crypted ${user_crypted} +db_set passwd/user-fullname "$USERFULLNAME" +db_set passwd/username "$USERNAME" +db_set passwd/user-uid 999 + +chroot /root /usr/bin/env -i HOME="/root" \ + TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \ + /usr/lib/user-setup/user-setup-apply 2>&1 \ + | grep -v "Shadow passwords are now on" - # XXX - awful hack to stop xscreensaver locking the screen (#7150) - echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment +# Clear out debconf database again to avoid confusing ubiquity later. +db_set passwd/make-user +db_set passwd/root-password-crypted +db_set passwd/user-password-crypted +db_set passwd/user-fullname +db_set passwd/username +db_set passwd/user-uid + +if ! grep -qs "${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 - for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do - if [ -f "/root/$file" ]; then - chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file") - break - fi - done - elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers +if [ -z "${NOSUDO}" ] +then + if ! grep -q "${USERNAME}" /root/etc/sudoers + then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers - chroot /root sudo -u "${USERNAME}" sh -c "echo 'SU_TO_ROOT_SU=sudo' >> /home/${USERNAME}/.su-to-rootrc" + chroot /root sudo -u "${USERNAME}" sh -c "echo 'SU_TO_ROOT_SU=sudo' >> /home/${USERNAME}/.su-to-rootrc" - chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/sudo-mode true - chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/display-no-pass-info false + if [ -x /root/usr/bin/gconftool-2 ] + then + chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/sudo-mode true + chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/display-no-pass-info false + fi chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/config && cat > /home/${USERNAME}/.kde/share/config/kdesurc" << EOF [super-user-command] super-user-command=sudo EOF - if [ -f /root/usr/share/apps/konsole/sumc.desktop ] - then - chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo mc -c/' /usr/share/apps/konsole/sumc.desktop > /home/${USERNAME}/.kde/share/apps/konsole/sumc.desktop" - fi + if [ -f /root/usr/share/apps/konsole/sumc.desktop ] + then + chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo mc -c/' /usr/share/apps/konsole/sumc.desktop > /home/${USERNAME}/.kde/share/apps/konsole/sumc.desktop" + fi - if [ -f /root/usr/share/apps/konsole/su.desktop ] - then - chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo -i/' /usr/share/apps/konsole/su.desktop > /home/${USERNAME}/.kde/share/apps/konsole/su.desktop" + if [ -f /root/usr/share/apps/konsole/su.desktop ] + then + chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo -i/' /usr/share/apps/konsole/su.desktop > /home/${USERNAME}/.kde/share/apps/konsole/su.desktop" + fi fi - fi fi -if [ -L /root/home/$USERNAME/Examples ]; then +if [ -L /root/home/${USERNAME}/Examples ] +then + chroot /root install -o ${USERNAME} -g ${USERNAME} -d /home/${USERNAME}/Desktop/ + mv /root/home/${USERNAME}/Examples /root/home/${USERNAME}/Desktop/ +fi + +if [ -f /root/home/$USERNAME/examples.desktop ]; then chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ - mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/ + mv /root/home/$USERNAME/examples.desktop /root/home/$USERNAME/Desktop/ +fi + +if [ -e /root/usr/share/applications/live-installer-launcher.desktop ] +then + chroot /root install -D -o ${USERNAME} -g ${USERNAME} /usr/share/applications/live-installer-launcher.desktop /home/${USERNAME}/Desktop/live-installer-launcher.desktop fi log_end_msg