Adding upstream version 1.199.1.
[debian-live-boot/hramrach.git] / scripts / live-bottom / 15autologin
blob3f85d501547bcb974d2f14f16ad6d5e976ecd6df
1 #!/bin/sh
3 #set -e
5 # initramfs-tools header
7 PREREQ=""
9 prereqs()
11 echo "${PREREQ}"
14 case "${1}" in
15 prereqs)
16 prereqs
17 exit 0
19 esac
21 # live-initramfs header
23 . /live.vars
25 if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ]
26 then
27 exit 0
30 . /scripts/live-functions
32 log_begin_msg "Setting up automatic login"
34 # live-initramfs script
36 # chroot needed to handle symlinks correctly
37 if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]
38 then
39 GDMCONF=/etc/gdm/gdm-cdd.conf
40 else
41 GDMCONF=/etc/gdm/gdm.conf
44 # chroot needed to handle symlinks correctly
45 if chroot /root [ -f ${GDMCONF} ]
46 then
47 # true hack ! -- nohar
48 chroot /root cp /usr/share/gdm/defaults.conf /etc/gdm/gdm.conf
50 # Configure GDM autologin
51 chroot /root \
52 sed -i -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \
53 -e "s/^AutomaticLogin=.*\$/AutomaticLogin=${USERNAME}/" \
54 -e "s/^TimedLoginEnable=.*\$/TimedLoginEnable=true/" \
55 -e "s/^TimedLogin=.*\$/TimedLogin=${USERNAME}/" \
56 -e "s/^TimedLoginDelay=.*\$/TimedLoginDelay=10/" \
57 ${GDMCONF}
58 elif [ -d /root/etc/gdm3 ]
59 then
61 cat > /root/etc/gdm3/custom.conf << EOF
62 [daemon]
63 AutomaticLoginEnable=true
64 AutomaticLogin=$USERNAME
65 TimedLoginEnable=true
66 TimedLogin=$USERNAME
67 TimedLoginDelay=10
68 EOF
72 if [ -d /root/etc/default/kdm.d/ ]
73 then
74 if ! grep -qs "^AUTOLOGIN" /root/etc/default/kdm.d/live-autologin
75 then
77 cat >> /root/etc/default/kdm.d/live-autologin << EOF
78 AUTOLOGINUSER=${USERNAME}
79 AUTOLOGINAGAIN=true
80 AUTOLOGINDELAY=0
81 EOF
85 elif [ -f /root/etc/kde3/kdm/kdmrc ]
86 then
87 # Configure KDM autologin
88 sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
89 -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=${USERNAME}/" \
90 -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
91 /root/etc/kde3/kdm/kdmrc
92 elif [ -f /root/etc/kde4/kdm/kdmrc ]
93 then
94 # Configure KDM-KDE4 autologin
95 sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
96 -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \
97 -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
98 /root/etc/kde4/kdm/kdmrc
101 log_end_msg