]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/initscripts/system/console
Early spring clean: Remove trailing whitespaces, and correct licence headers
[people/mfischer/ipfire-2.x.git] / src / initscripts / system / console
1 #!/bin/sh
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
25
26 FONT="latarcyrheb-sun16"
27 KEYMAP_CORRECTIONS="euro2"
28 UNICODE="1"
29 BROKEN_COMPOSE="0"
30
31 is_true() {
32 [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
33 }
34
35 failed=0
36 trap failed=1 ERR
37
38 case "${1}" in
39 start)
40 boot_mesg "Setting up Linux console..."
41 # There should be no bogus failures below this line!
42
43 # Figure out if a framebuffer console is used
44 [ -d /sys/class/graphics/fb0 ] && USE_FB=1 || USE_FB=0
45
46 # Figure out the command to set the console into the
47 # desired mode
48 is_true "${UNICODE}" &&
49 MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" ||
50 MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a"
51
52 # On framebuffer consoles, font has to be set for each vt in
53 # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
54
55 ! is_true "${USE_FB}" || [ -z "${FONT}" ] ||
56 MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
57
58 # Apply that command to all consoles mentioned in
59 # /etc/inittab. Important: in the UTF-8 mode this should
60 # happen before setfont, otherwise a kernel bug will
61 # show up and the unicode map of the font will not be
62 # used.
63 # FIXME: Fedora Core also initializes two spare consoles
64 # - do we want that?
65
66 for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
67 grep -o '\btty[[:digit:]]*\b'`
68 do
69 openvt -f -w -c ${TTY#tty} -- \
70 /bin/sh -c "${MODE_COMMAND}" 2>/dev/null
71 done
72
73 # Set the font (if not already set above) and the keymap
74 is_true "${USE_FB}" || [ -z "${FONT}" ] || setfont $FONT
75 [ -z "${KEYMAP}" ] || loadkeys ${KEYMAP} &>/dev/null
76 [ -z "${KEYMAP_CORRECTIONS}" ] ||
77 loadkeys ${KEYMAP_CORRECTIONS} &>/dev/null
78
79 # Linux kernel generates wrong bytes when composing
80 # in Unicode mode. That's why we disable dead keys in Unicode
81 # mode by default. If you need them, download and apply
82 # http://www.linuxfromscratch.org/~alexander/patches/linux-2.6.12.5-utf8_input-2.patch
83 # After patching, add "-m charset_of_your_keymap" to the FONT
84 # variable and set BROKEN_COMPOSE=false
85 # in /etc/sysconfig/console
86
87 [ -n "$BROKEN_COMPOSE" ] || BROKEN_COMPOSE="$UNICODE"
88 ! is_true "$BROKEN_COMPOSE" ||
89 echo "" | loadkeys -c &>/dev/null
90
91 # Convert the keymap from $LEGACY_CHARSET to UTF-8
92 [ -z "$LEGACY_CHARSET" ] ||
93 dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u &>/dev/null
94
95 # If any of the commands above failed, the trap at the
96 # top would set $failed to 1
97 ( exit $failed )
98 evaluate_retval
99 ;;
100 *)
101 echo $"Usage:" "${0} {start}"
102 exit 1
103 ;;
104 esac