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