Adding live-initramfs 1.95.2-1.
[live-initramfs-grml.git] / scripts / live-bottom / 10adduser
1 #!/bin/sh
2
3 #set -e
4
5 # initramfs-tools header
6
7 PREREQ=""
8
9 prereqs()
10 {
11         echo "${PREREQ}"
12 }
13
14 case "${1}" in
15         prereqs)
16                 prereqs
17                 exit 0
18                 ;;
19 esac
20
21 # live-initramfs header
22
23 . /scripts/live-functions
24
25 log_begin_msg "Adding live session user..."
26
27 # live-initramfs script
28
29 if [ "${BUILD_SYSTEM}" = "Debian" ]; then
30     user_crypted="8Ab05sVQ4LLps" # as in `echo "live" | mkpasswd -s`
31 else
32     user_crypted="U6aMy0wojraho" # "ubuntu"
33 fi
34
35 # U6aMy0wojraho is just a blank password
36 chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF
37 set passwd/make-user true
38 set passwd/root-password-crypted *
39 set passwd/user-password-crypted ${user_crypted}
40 set passwd/user-fullname $USERFULLNAME
41 set passwd/username $USERNAME
42 set passwd/user-uid 999
43 EOF
44
45 if [ "${BUILD_SYSTEM}" = "Debian" ]; then
46     chroot /root /usr/bin/env -i HOME="/root" \
47         TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
48         /usr/lib/user-setup/user-setup-apply > /dev/null
49 else
50     chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null
51 fi
52
53 # Clear out debconf database again to avoid confusing ubiquity later.
54 chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF
55 set passwd/make-user
56 set passwd/root-password-crypted
57 set passwd/user-password-crypted
58 set passwd/user-fullname
59 set passwd/username
60 set passwd/user-uid
61 EOF
62
63 if [ -z "${NOSUDO}" ]
64 then
65
66 if [ -f /root/etc/sudoers ]; then
67     if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then
68         grep -q '^%admin' /root/etc/sudoers && sed -i -e '/^%admin/s/ALL$/NOPASSWD: ALL/' /root/etc/sudoers || echo '%admin  ALL=(ALL) NOPASSWD: ALL' >> /root/etc/sudoers
69
70         # XXX - awful hack to stop xscreensaver locking the screen (#7150)
71         echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment
72
73         for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do
74             if [ -f "/root/$file" ]; then
75                 chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file")
76                 break
77             fi
78         done
79     elif [ "${BUILD_SYSTEM}" = "Debian" ]; then
80         echo "${USERNAME}  ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers
81
82         chroot /root sudo -u "${USERNAME}" sh -c "echo 'SU_TO_ROOT_SU=sudo' >> /home/${USERNAME}/.su-to-rootrc"
83
84         chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/sudo-mode true
85         chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/display-no-pass-info false
86
87 chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/config && cat > /home/${USERNAME}/.kde/share/config/kdesurc" << EOF
88 [super-user-command]
89 super-user-command=sudo
90 EOF
91
92         if [ -f /root/usr/share/apps/konsole/sumc.desktop ]
93         then
94                 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"
95         fi
96
97         if [ -f /root/usr/share/apps/konsole/su.desktop ]
98         then
99                 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"
100         fi
101     fi
102 fi
103
104 fi
105
106 if [ -L /root/home/$USERNAME/Examples ]; then
107     chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/
108     mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/
109 fi
110
111 log_end_msg