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