[1c48007] | 1 | #!/bin/sh
|
---|
| 2 | ########################################################################
|
---|
[0cda898] | 3 | # Begin console
|
---|
[1c48007] | 4 | #
|
---|
| 5 | # Description : Sets keymap and screen font
|
---|
| 6 | #
|
---|
| 7 | # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
|
---|
[0cda898] | 8 | # Alexander E. Patrakov
|
---|
[f874424] | 9 | # DJ Lucas - dj@linuxfromscratch.org
|
---|
[0cda898] | 10 | # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
|
---|
[1c48007] | 11 | #
|
---|
[0cda898] | 12 | # Version : LFS 7.0
|
---|
[1c48007] | 13 | #
|
---|
| 14 | ########################################################################
|
---|
| 15 |
|
---|
[0cda898] | 16 | ### BEGIN INIT INFO
|
---|
| 17 | # Provides: console
|
---|
| 18 | # Required-Start:
|
---|
| 19 | # Should-Start: $local_fs
|
---|
| 20 | # Required-Stop:
|
---|
| 21 | # Should-Stop:
|
---|
| 22 | # Default-Start: S
|
---|
| 23 | # Default-Stop:
|
---|
| 24 | # Short-Description: Sets up a localised console.
|
---|
| 25 | # Description: Sets up fonts and language settings for the user's
|
---|
| 26 | # local as defined by /etc/sysconfig/console.
|
---|
| 27 | # X-LFS-Provided-By: LFS
|
---|
| 28 | ### END INIT INFO
|
---|
[1c48007] | 29 |
|
---|
[f874424] | 30 | . /lib/lsb/init-functions
|
---|
| 31 |
|
---|
[1c48007] | 32 | # Native English speakers probably don't have /etc/sysconfig/console at all
|
---|
[f874424] | 33 | [ -r /etc/sysconfig/console ] && . /etc/sysconfig/console
|
---|
[1c48007] | 34 |
|
---|
[49f236b] | 35 | is_true()
|
---|
[f874424] | 36 | {
|
---|
[0cda898] | 37 | [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
|
---|
[1c48007] | 38 | }
|
---|
| 39 |
|
---|
| 40 | failed=0
|
---|
| 41 |
|
---|
| 42 | case "${1}" in
|
---|
[0cda898] | 43 | start)
|
---|
[17698aa] | 44 | # See if we need to do anything
|
---|
| 45 | if [ -z "${KEYMAP}" ] && [ -z "${KEYMAP_CORRECTIONS}" ] &&
|
---|
| 46 | [ -z "${FONT}" ] && [ -z "${LEGACY_CHARSET}" ] &&
|
---|
| 47 | ! is_true "${UNICODE}"; then
|
---|
| 48 | exit 0
|
---|
| 49 | fi
|
---|
| 50 |
|
---|
[0cda898] | 51 | # There should be no bogus failures below this line!
|
---|
[f874424] | 52 | log_info_msg "Setting up Linux console..."
|
---|
[0cda898] | 53 |
|
---|
| 54 | # Figure out if a framebuffer console is used
|
---|
[f874424] | 55 | [ -d /sys/class/graphics/fb0 ] && use_fb=1 || use_fb=0
|
---|
[0cda898] | 56 |
|
---|
| 57 | # Figure out the command to set the console into the
|
---|
| 58 | # desired mode
|
---|
| 59 | is_true "${UNICODE}" &&
|
---|
[f874424] | 60 | MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" ||
|
---|
| 61 | MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a"
|
---|
[0cda898] | 62 |
|
---|
| 63 | # On framebuffer consoles, font has to be set for each vt in
|
---|
| 64 | # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
|
---|
| 65 |
|
---|
[f874424] | 66 | ! is_true "${use_fb}" || [ -z "${FONT}" ] ||
|
---|
[0cda898] | 67 | MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
|
---|
| 68 |
|
---|
| 69 | # Apply that command to all consoles mentioned in
|
---|
| 70 | # /etc/inittab. Important: in the UTF-8 mode this should
|
---|
| 71 | # happen before setfont, otherwise a kernel bug will
|
---|
| 72 | # show up and the unicode map of the font will not be
|
---|
| 73 | # used.
|
---|
| 74 |
|
---|
| 75 | for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
|
---|
| 76 | grep -o '\btty[[:digit:]]*\b'`
|
---|
| 77 | do
|
---|
| 78 | openvt -f -w -c ${TTY#tty} -- \
|
---|
| 79 | /bin/sh -c "${MODE_COMMAND}" || failed=1
|
---|
| 80 | done
|
---|
| 81 |
|
---|
| 82 | # Set the font (if not already set above) and the keymap
|
---|
[620c6d0] | 83 | [ "${use_fb}" == "1" ] || [ -z "${FONT}" ] || setfont $FONT || failed=1
|
---|
[f874424] | 84 |
|
---|
[0cda898] | 85 | [ -z "${KEYMAP}" ] ||
|
---|
| 86 | loadkeys ${KEYMAP} >/dev/null 2>&1 ||
|
---|
| 87 | failed=1
|
---|
[f874424] | 88 |
|
---|
[0cda898] | 89 | [ -z "${KEYMAP_CORRECTIONS}" ] ||
|
---|
| 90 | loadkeys ${KEYMAP_CORRECTIONS} >/dev/null 2>&1 ||
|
---|
| 91 | failed=1
|
---|
| 92 |
|
---|
| 93 | # Convert the keymap from $LEGACY_CHARSET to UTF-8
|
---|
| 94 | [ -z "$LEGACY_CHARSET" ] ||
|
---|
[f874424] | 95 | dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u >/dev/null 2>&1 ||
|
---|
[0cda898] | 96 | failed=1
|
---|
| 97 |
|
---|
| 98 | # If any of the commands above failed, the trap at the
|
---|
| 99 | # top would set $failed to 1
|
---|
[f874424] | 100 | ( exit $failed )
|
---|
[0cda898] | 101 | evaluate_retval
|
---|
[f874424] | 102 |
|
---|
| 103 | exit $failed
|
---|
| 104 | ;;
|
---|
| 105 |
|
---|
| 106 | *)
|
---|
[17698aa] | 107 | echo "Usage: ${0} {start}"
|
---|
[f874424] | 108 | exit 1
|
---|
| 109 | ;;
|
---|
[1c48007] | 110 | esac
|
---|
| 111 |
|
---|
[0cda898] | 112 | # End console
|
---|