Adding debian version 2.0~a1-1.
[live-boot-grml.git] / scripts / live-bottom / 25configure_init
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-boot header
22
23 . /scripts/live-functions
24
25 log_begin_msg "Setting up init"
26
27 # live-boot script
28
29 # Arrange for shells on virtual consoles, rather than login prompts
30
31 if [ -z "${NOAUTOLOGIN}" ] && [ -n "${USERNAME}" ]
32 then
33         if [ ! -z "${LIVE_GETTY}" ]
34         then
35                 if echo "${DEFCONSOLE}" | grep -qs ttyS
36                 then
37                         # AUTOMATIC SERIAL CONSOLE #
38                         PORT=$(echo "${DEFCONSOLE}" | \
39                                 sed -e 's%,.*%%')
40                         SPEED=$(echo "${DEFCONSOLE}" | \
41                                 sed -e 's%ttyS[0-9]\+,%%' \
42                                 -e's%\([0-9]\+\).*%\1%')
43
44                         if ! ( sed -n -e'/^[^#]/p' /root/etc/inittab | grep -qs ":respawn:/sbin/getty.*${PORT}" )
45                         then
46                                 IDs="A B C D E F G H I J K L M N O P Q R S T Q U V V X Y Z 0 1 2 3 4 5 6 7 8 9"
47
48                                 for ID1 in ${IDs}
49                                 do
50                                         for ID2 in ${IDs}
51                                         do
52                                                 ID="${ID1}${ID2}"
53
54                                                 if ! grep "^${ID}:" /etc/inittab
55                                                 then
56                                                         #make sure it is not already in use
57                                                         break 2
58                                                 fi
59                                         done
60                                 done
61
62                                 echo "${ID}:2345:respawn:/sbin/live-getty -L ${PORT} ${SPEED} vt100" >> /root/etc/inittab
63                         fi
64                 fi
65
66                 if [ -f /root/etc/inittab ]
67                 then
68                         sed -i -e'/^[^#]/s%respawn:/sbin/getty%respawn:/sbin/live-getty%' /root/etc/inittab
69                 fi
70         else
71                 if [ -f /root/etc/inittab ]
72                 then
73                         sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f ${USERNAME} </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab
74                 fi
75
76                 if [ "/root/etc/init/tty*" != "$(echo /root/etc/init/tty*)" ]
77                 then
78                         for f in /root/etc/init/tty*
79                         do
80                                 sed -i -e "s|^exec.*|exec /bin/login -f $USERNAME </dev/$(basename $f .conf) > /dev/$(basename $f .conf) 2>\&1|" $f
81                         done
82                 fi
83         fi
84
85         # Since we use autologin, lastlog doesn't make sense on the console.
86         sed -i '/^[^#].*pam_lastlog\.so/s/^/# /' /root/etc/pam.d/login
87 fi
88
89 # do not try to remove files if using file-rc
90 if [ -d /root/etc/rc0.d ]
91 then
92         # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in
93         # /etc/crontab remaining disabled, yet also not run by anacron
94         if [ -x /root/usr/sbin/anacron ]
95         then
96                 chroot /root dpkg-divert --add --rename --quiet /usr/sbin/anacron
97                 ln -s /bin/true /root/usr/sbin/anacron
98         fi
99
100         # Avoid clobbering the user's clock
101         rm -f /root/etc/rc?.d/K??hwclock.sh /root/etc/init/hwclock-save.conf
102 fi
103
104 # Disable readahead since it doesn't play well with squashfs + unionfs
105 # use chmod instead of mv to not trigger unionfs bugs.
106 if [ -e /root/sbin/readahead-list ]
107 then
108         chmod -x /root/sbin/readahead-list
109 fi
110
111 # Disable ureadahead too since we don't ship a pack file for it anyway, so
112 # all we'll end up doing is profiling the live CD boot. ureadahead also
113 # breaks partman occasionally by reading from its synchronisation FIFOs.
114 rm -f /root/etc/init/ureadahead.conf
115
116 log_end_msg
117
118 exit 0