Adding live-initramfs 1.87.4-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-initramfs header
22
23 . /scripts/live-functions
24
25 log_begin_msg "Setting up init..."
26
27 # live-initramfs script
28
29 # Arrange for shells on virtual consoles, rather than login prompts
30
31 if [ -z "${NOAUTOLOGIN}" ]
32 then
33
34 if [ -n "$USERNAME" ]; then
35     if [ ! -z "${LIVE_GETTY}" ]; then
36        if echo "${DEFCONSOLE}" | grep -qs ttyS; 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             if ! ( sed -n -e'/^[^#]/p' /root/etc/inittab | grep -qs ":respawn:/sbin/getty.*${PORT}" ) ; then
44                 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" 
45                 for ID1 in $IDs; do
46                     for ID2 in $IDs; do
47                         ID="${ID1}${ID2}"
48                         if ! grep "^${ID}:" /etc/inittab ; then
49                             #make sure it is not already in use
50                             break 2
51                         fi
52                     done
53                 done
54                 echo "${ID}:2345:respawn:/sbin/live-getty -L ${PORT} ${SPEED} vt100" \
55                 >>/root/etc/inittab
56             fi
57         fi
58         if [ -f /root/etc/inittab ]; then
59              sed -i -e'/^[^#]/s%respawn:/sbin/getty%respawn:/sbin/live-getty%' /root/etc/inittab
60         fi
61     else
62         if [ -f /root/etc/inittab ]; then
63             sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f $USERNAME </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab
64        fi
65         if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then
66             for f in /root/etc/event.d/tty*; do
67                 sed -i -e "s|^respawn.*|respawn /bin/login -f $USERNAME </dev/$(basename $f) > /dev/$(basename $f) 2>\&1|" $f
68             done
69         fi
70      fi
71 fi
72
73 fi
74
75 # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in
76 # /etc/crontab remaining disabled, yet also not run by anacron
77 if [ -x /root/etc/init.d/anacron ]; then
78     for f in /root/etc/rc?.d/S??anacron; do
79         mv ${f} ${f%/*}/K00anacron
80     done
81 fi
82
83 # No point, really
84 rm -f /root/etc/rc?.d/[SK]??postfix
85
86 # Avoid clobbering the user's clock
87 rm -f /root/etc/rc?.d/K??hwclock.sh
88
89 # Disable readahead since it doesn't play well with squashfs + unionfs
90 # use chmod instead of mv to not trigger unionfs bugs.
91 if [ -e /root/sbin/readahead-list ]; then
92     chmod -x /root/sbin/readahead-list
93 fi
94
95 log_end_msg
96
97 exit 0