cbf3aaf68b4b7c6a5a3316210f856684633c765d
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / console
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/console
4 #
5 # Description : Sets keymap and screen font
6 #
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8 # Alexander E. Patrakov
9 #
10 # Version : 00.03
11 #
12 # Notes :
13 #
14 ########################################################################
15
16 . /etc/sysconfig/rc
17 . ${rc_functions}
18 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
19
20 FONT="lat0-16"
21 KEYMAP_CORRECTIONS="euro2"
22
23 is_true() {
24 [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
25 }
26
27 failed=0
28 trap failed=1 ERR
29
30 case "${1}" in
31 start)
32 boot_mesg "Setting up Linux console..."
33 # There should be no bogus failures below this line!
34
35 # Figure out if a framebuffer console is used
36 [ -d /sys/class/graphics/fb0 ] && USE_FB=1 || USE_FB=0
37
38 # Figure out the command to set the console into the
39 # desired mode
40 is_true "${UNICODE}" &&
41 MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" ||
42 MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a"
43
44 # On framebuffer consoles, font has to be set for each vt in
45 # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
46
47 ! is_true "${USE_FB}" || [ -z "${FONT}" ] ||
48 MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
49
50 # Apply that command to all consoles mentioned in
51 # /etc/inittab. Important: in the UTF-8 mode this should
52 # happen before setfont, otherwise a kernel bug will
53 # show up and the unicode map of the font will not be
54 # used.
55 # FIXME: Fedora Core also initializes two spare consoles
56 # - do we want that?
57
58 for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
59 grep -o '\btty[[:digit:]]*\b'`
60 do
61 openvt -f -w -c ${TTY#tty} -- \
62 /bin/sh -c "${MODE_COMMAND}"
63 done
64
65 # Set the font (if not already set above) and the keymap
66 is_true "${USE_FB}" || [ -z "${FONT}" ] || setfont $FONT
67 [ -z "${KEYMAP}" ] || loadkeys ${KEYMAP} &>/dev/null
68 [ -z "${KEYMAP_CORRECTIONS}" ] ||
69 loadkeys ${KEYMAP_CORRECTIONS} &>/dev/null
70
71 # Linux kernel generates wrong bytes when composing
72 # in Unicode mode. That's why we disable dead keys in Unicode
73 # mode by default. If you need them, download and apply
74 # http://www.linuxfromscratch.org/~alexander/patches/linux-2.6.12.5-utf8_input-2.patch
75 # After patching, add "-m charset_of_your_keymap" to the FONT
76 # variable and set BROKEN_COMPOSE=false
77 # in /etc/sysconfig/console
78
79 [ -n "$BROKEN_COMPOSE" ] || BROKEN_COMPOSE="$UNICODE"
80 ! is_true "$BROKEN_COMPOSE" ||
81 echo "" | loadkeys -c &>/dev/null
82
83 # Convert the keymap from $LEGACY_CHARSET to UTF-8
84 [ -z "$LEGACY_CHARSET" ] ||
85 dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u &>/dev/null
86
87 # If any of the commands above failed, the trap at the
88 # top would set $failed to 1
89 ( exit $failed )
90 evaluate_retval
91 ;;
92 *)
93 echo $"Usage:" "${0} {start}"
94 exit 1
95 ;;
96 esac
97
98 # End $rc_base/init.d/console