]>
Commit | Line | Data |
---|---|---|
73d9a908 MT |
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} | |
97de2cae | 18 | eval $(/usr/local/bin/readhash /var/ipfire/main/settings) |
73d9a908 | 19 | |
1e5b8be9 AF |
20 | # English is default |
21 | FONT="lat0-16" | |
22 | KEYMAP_CORRECTIONS="euro2" | |
23 | ||
4aedc962 | 24 | if [ "$LANGUAGE" == "de" ]; then |
4aedc962 MT |
25 | LEGACY_CHARSET="iso-8859-15" |
26 | #FONT="LatArCyrHeb-16 -m 8859-15" | |
27 | FONT="lat0-16 -m 8859-15" | |
1e5b8be9 AF |
28 | fi |
29 | ||
30 | if [ "$LANGUAGE" == "pl" ]; then | |
31 | FONT="lat2-16" | |
4aedc962 MT |
32 | fi |
33 | ||
2bb7b134 AF |
34 | if [ "$LANGUAGE" == "ru" ]; then |
35 | FONT="LatArCyrHeb-16" | |
36 | fi | |
37 | ||
4aedc962 MT |
38 | UNICODE="1" |
39 | BROKEN_COMPOSE="0" | |
73d9a908 MT |
40 | |
41 | is_true() { | |
42 | [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] | |
43 | } | |
44 | ||
45 | failed=0 | |
46 | trap failed=1 ERR | |
47 | ||
48 | case "${1}" in | |
49 | start) | |
50 | boot_mesg "Setting up Linux console..." | |
51 | # There should be no bogus failures below this line! | |
52 | ||
53 | # Figure out if a framebuffer console is used | |
54 | [ -d /sys/class/graphics/fb0 ] && USE_FB=1 || USE_FB=0 | |
55 | ||
56 | # Figure out the command to set the console into the | |
57 | # desired mode | |
58 | is_true "${UNICODE}" && | |
59 | MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" || | |
60 | MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a" | |
61 | ||
62 | # On framebuffer consoles, font has to be set for each vt in | |
63 | # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also. | |
64 | ||
65 | ! is_true "${USE_FB}" || [ -z "${FONT}" ] || | |
66 | MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}" | |
67 | ||
68 | # Apply that command to all consoles mentioned in | |
69 | # /etc/inittab. Important: in the UTF-8 mode this should | |
70 | # happen before setfont, otherwise a kernel bug will | |
71 | # show up and the unicode map of the font will not be | |
72 | # used. | |
73 | # FIXME: Fedora Core also initializes two spare consoles | |
74 | # - do we want that? | |
75 | ||
76 | for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab | | |
77 | grep -o '\btty[[:digit:]]*\b'` | |
78 | do | |
79 | openvt -f -w -c ${TTY#tty} -- \ | |
2f3973e4 | 80 | /bin/sh -c "${MODE_COMMAND}" 2>/dev/null |
73d9a908 MT |
81 | done |
82 | ||
83 | # Set the font (if not already set above) and the keymap | |
84 | is_true "${USE_FB}" || [ -z "${FONT}" ] || setfont $FONT | |
85 | [ -z "${KEYMAP}" ] || loadkeys ${KEYMAP} &>/dev/null | |
86 | [ -z "${KEYMAP_CORRECTIONS}" ] || | |
87 | loadkeys ${KEYMAP_CORRECTIONS} &>/dev/null | |
88 | ||
89 | # Linux kernel generates wrong bytes when composing | |
90 | # in Unicode mode. That's why we disable dead keys in Unicode | |
91 | # mode by default. If you need them, download and apply | |
92 | # http://www.linuxfromscratch.org/~alexander/patches/linux-2.6.12.5-utf8_input-2.patch | |
93 | # After patching, add "-m charset_of_your_keymap" to the FONT | |
94 | # variable and set BROKEN_COMPOSE=false | |
95 | # in /etc/sysconfig/console | |
96 | ||
97 | [ -n "$BROKEN_COMPOSE" ] || BROKEN_COMPOSE="$UNICODE" | |
98 | ! is_true "$BROKEN_COMPOSE" || | |
99 | echo "" | loadkeys -c &>/dev/null | |
100 | ||
101 | # Convert the keymap from $LEGACY_CHARSET to UTF-8 | |
102 | [ -z "$LEGACY_CHARSET" ] || | |
103 | dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u &>/dev/null | |
104 | ||
105 | # If any of the commands above failed, the trap at the | |
106 | # top would set $failed to 1 | |
107 | ( exit $failed ) | |
108 | evaluate_retval | |
109 | ;; | |
110 | *) | |
111 | echo $"Usage:" "${0} {start}" | |
112 | exit 1 | |
113 | ;; | |
114 | esac | |
115 | ||
116 | # End $rc_base/init.d/console |