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