5 # initramfs-tools header
21 # live-initramfs header
23 . /scripts/live-functions
25 log_begin_msg "Setting up init..."
27 # live-initramfs script
29 # Arrange for shells on virtual consoles, rather than login prompts
31 if [ -z "${NOAUTOLOGIN}" ]
33 if [ -n "${USERNAME}" ]
35 if [ ! -z "${LIVE_GETTY}" ]
37 if echo "${DEFCONSOLE}" | grep -qs ttyS
39 # AUTOMATIC SERIAL CONSOLE #
40 PORT=$(echo "${DEFCONSOLE}" | \
42 SPEED=$(echo "${DEFCONSOLE}" | \
43 sed -e 's%ttyS[0-9]\+,%%' \
44 -e's%\([0-9]\+\).*%\1%')
46 if ! ( sed -n -e'/^[^#]/p' /root/etc/inittab | grep -qs ":respawn:/sbin/getty.*${PORT}" )
48 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"
56 if ! grep "^${ID}:" /etc/inittab
58 #make sure it is not already in use
64 echo "${ID}:2345:respawn:/sbin/live-getty -L ${PORT} ${SPEED} vt100" >> /root/etc/inittab
68 if [ -f /root/etc/inittab ]
70 sed -i -e'/^[^#]/s%respawn:/sbin/getty%respawn:/sbin/live-getty%' /root/etc/inittab
73 if [ -f /root/etc/inittab ]
75 sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f ${USERNAME} </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab
78 if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]
80 for f in /root/etc/event.d/tty*
82 sed -i -e "s|^respawn.*|respawn /bin/login -f ${USERNAME} </dev/$(basename ${f}) > /dev/$(basename ${f}) 2>\&1|" ${f}
87 # Since we use autologin, lastlog doesn't make sense on the console.
88 sed -i '/^[^#].*pam_lastlog\.so/s/^/# /' /root/etc/pam.d/login
92 # do not try to remove files if using file-rc
95 # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in
96 # /etc/crontab remaining disabled, yet also not run by anacron
97 if [ -x /root/usr/sbin/anacron ]
99 chroot /root dpkg-divert --add --rename --quiet /usr/sbin/anacron
100 ln -s /bin/true /usr/sbin/anacron
104 rm -f /root/etc/rc?.d/[SK]??postfix
106 # Avoid clobbering the user's clock
107 rm -f /root/etc/rc?.d/K??hwclock.sh
110 # Disable readahead since it doesn't play well with squashfs + unionfs
111 # use chmod instead of mv to not trigger unionfs bugs.
112 if [ -e /root/sbin/readahead-list ]
114 chmod -x /root/sbin/readahead-list