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