5 # initramfs-tools header
21 # live-initramfs header
25 if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ]
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 ]
39 GDMCONF=/etc/gdm/gdm-cdd.conf
41 GDMCONF=/etc/gdm/gdm.conf
44 # chroot needed to handle symlinks correctly
45 if chroot /root [ -f ${GDMCONF} ]
47 # true hack ! -- nohar
48 chroot /root cp /usr/share/gdm/defaults.conf /etc/gdm/gdm.conf
50 # Configure GDM autologin
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/" \
58 elif [ -d /root/etc/gdm3 ]
60 GDMCustomFile=/root/etc/gdm3/custom.conf
61 AutologinParameters="AutomaticLoginEnable=true\n\
62 AutomaticLogin=$USERNAME\n\
63 TimedLoginEnable=true\n\
64 TimedLogin=$USERNAME\n\
67 # Prevent from updating if parameters already present (persistent usb
69 if ! $(grep -qs 'AutomaticLoginEnable' $GDMCustomFile)
71 if $(grep -qs '\[daemon\]' $GDMCustomFile)
73 sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile
75 printf "[daemon]\n$AutologinParameters" >> $GDMCustomFile
80 if [ -d /root/etc/default/kdm.d/ ]
82 if ! grep -qs "^AUTOLOGIN" /root/etc/default/kdm.d/live-autologin
85 cat >> /root/etc/default/kdm.d/live-autologin << EOF
86 AUTOLOGINUSER=${USERNAME}
93 elif [ -f /root/etc/kde3/kdm/kdmrc ]
95 # Configure KDM autologin
96 sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
97 -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=${USERNAME}/" \
98 -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
99 /root/etc/kde3/kdm/kdmrc
100 elif [ -f /root/etc/kde4/kdm/kdmrc ]
102 # Configure KDM-KDE4 autologin
103 sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
104 -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \
105 -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
106 /root/etc/kde4/kdm/kdmrc