Adding live-initramfs 1.87.3-1.
[live-boot-grml.git] / scripts / live-bottom / 25configure_init
1 #!/bin/sh
2
3 PREREQ=""
4 DESCRIPTION="Setting up init..."
5
6 . /scripts/live-functions
7
8 prereqs()
9 {
10        echo "$PREREQ"
11 }
12
13 case $1 in
14 # get pre-requisites
15 prereqs)
16        prereqs
17        exit 0
18        ;;
19 esac
20
21 log_begin_msg "$DESCRIPTION"
22
23 # Arrange for shells on virtual consoles, rather than login prompts
24
25 if [ -n "$USERNAME" ]; then
26     if [ ! -z "${LIVE_GETTY}" ]; then
27        if echo "${DEFCONSOLE}" | grep -qs ttyS; then
28             # AUTOMATIC SERIAL CONSOLE #
29             PORT=$(echo "${DEFCONSOLE}" | \
30                 sed -e 's%,.*%%')
31             SPEED=$(echo "${DEFCONSOLE}" | \
32                     sed -e 's%ttyS[0-9]\+,%%' \
33                         -e's%\([0-9]\+\).*%\1%')
34             if ! ( sed -n -e'/^[^#]/p' /root/etc/inittab | grep -qs ":respawn:/sbin/getty.*${PORT}" ) ; then
35                 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" 
36                 for ID1 in $IDs; do
37                     for ID2 in $IDs; do
38                         ID="${ID1}${ID2}"
39                         if ! grep "^${ID}:" /etc/inittab ; then
40                             #make sure it is not already in use
41                             break 2
42                         fi
43                     done
44                 done
45                 echo "${ID}:2345:respawn:/sbin/live-getty -L ${PORT} ${SPEED} vt100" \
46                 >>/root/etc/inittab
47             fi
48         fi
49         if [ -f /root/etc/inittab ]; then
50              sed -i -e'/^[^#]/s%respawn:/sbin/getty%respawn:/sbin/live-getty%' /root/etc/inittab
51         fi
52     else
53         if [ -f /root/etc/inittab ]; then
54             sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f $USERNAME </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab
55        fi
56         if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then
57             for f in /root/etc/event.d/tty*; do
58                 sed -i -e "s|^respawn.*|respawn /bin/login -f $USERNAME </dev/$(basename $f) > /dev/$(basename $f) 2>\&1|" $f
59             done
60         fi
61      fi
62 fi
63
64 # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in
65 # /etc/crontab remaining disabled, yet also not run by anacron
66 if [ -x /root/etc/init.d/anacron ]; then
67     for f in /root/etc/rc?.d/S??anacron; do
68         mv ${f} ${f%/*}/K00anacron
69     done
70 fi
71
72 # No point, really
73 rm -f /root/etc/rc?.d/[SK]??postfix
74
75 # Avoid clobbering the user's clock
76 rm -f /root/etc/rc?.d/K??hwclock.sh
77
78 # Disable readahead since it doesn't play well with squashfs + unionfs
79 # use chmod instead of mv to not trigger unionfs bugs.
80 if [ -e /root/sbin/readahead-list ]; then
81     chmod -x /root/sbin/readahead-list
82 fi
83
84 log_end_msg
85
86 exit 0