Releasing debian version 1.236.2-1.
[live-boot-grml.git] / scripts / live-bottom / 15autologin
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 . /live.vars
24
25 if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ]
26 then
27         exit 0
28 fi
29
30 . /scripts/live-functions
31
32 log_begin_msg "Setting up automatic login"
33
34 # live-initramfs script
35
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
42 fi
43
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
49
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
60         GDMCustomFile=/root/etc/gdm3/custom.conf
61         AutologinParameters="AutomaticLoginEnable=true\n\
62 AutomaticLogin=$USERNAME\n\
63 TimedLoginEnable=true\n\
64 TimedLogin=$USERNAME\n\
65 TimedLoginDelay=10"
66
67         # Prevent from updating if parameters already present (persistent usb
68         # key)
69         if ! $(grep -qs '\[daemon\]' $GDMCustomFile)
70         then
71                 echo '[daemon]' >> $GDMCustomFile
72         fi
73
74         sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile
75 fi
76
77 if [ -d /root/etc/default/kdm.d/ ]
78 then
79         if ! grep -qs "^AUTOLOGIN" /root/etc/default/kdm.d/live-autologin
80         then
81
82 cat >> /root/etc/default/kdm.d/live-autologin << EOF
83 AUTOLOGINUSER=${USERNAME}
84 AUTOLOGINAGAIN=true
85 AUTOLOGINDELAY=0
86 EOF
87
88         fi
89
90 elif [ -f /root/etc/kde3/kdm/kdmrc ]
91 then
92         # Configure KDM autologin
93         sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
94                   -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=${USERNAME}/" \
95                   -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
96         /root/etc/kde3/kdm/kdmrc
97 elif [ -f /root/etc/kde4/kdm/kdmrc ]
98 then
99         # Configure KDM-KDE4 autologin
100         sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
101                   -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \
102                   -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
103         /root/etc/kde4/kdm/kdmrc
104 fi
105
106 if [ -f /root/etc/lxdm/lxdm.conf ]
107 then
108         # Configure LXDM autologin
109         sed -i -r -e "s/^# autologin=dgod/autologin=$USERNAME/" \
110                   -e "s/^# session/session/" \
111         /root/etc/lxdm/lxdm.conf
112 fi
113
114 log_end_msg