[1c48007] | 1 | #!/bin/sh
|
---|
| 2 | # Begin $rc_base/init.d/console
|
---|
| 3 |
|
---|
| 4 | ### BEGIN INIT INFO
|
---|
| 5 | # Provides: console
|
---|
| 6 | # Required-Start:
|
---|
| 7 | # Should-Start: $local_fs
|
---|
| 8 | # Required-Stop:
|
---|
| 9 | # Should-Stop:
|
---|
| 10 | # Default-Start: sysinit
|
---|
| 11 | # Default-Stop:
|
---|
| 12 | # Short-Description: Sets up a localised console.
|
---|
| 13 | # Description: Sets up fonts and language settings for the user's
|
---|
| 14 | # local as defined by /etc/sysconfig/console.
|
---|
| 15 | # X-LFS-Default-Start: S70
|
---|
| 16 | # X-LFS-Default-Stop:
|
---|
| 17 | # X-LFS-Provided-By: LFS
|
---|
| 18 | ### END INIT INFO
|
---|
| 19 |
|
---|
| 20 | . /lib/lsb/init-functions
|
---|
| 21 |
|
---|
| 22 | MESSAGE="Setting up Linux console..."
|
---|
| 23 |
|
---|
| 24 | # Native English speakers probably don't have /etc/sysconfig/console at all
|
---|
| 25 | if [ -f /etc/sysconfig/console ]
|
---|
| 26 | then
|
---|
| 27 | . /etc/sysconfig/console
|
---|
| 28 | fi
|
---|
| 29 |
|
---|
| 30 | is_true() {
|
---|
| 31 | [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | failed=0
|
---|
| 35 |
|
---|
| 36 | case "${1}" in
|
---|
| 37 | start)
|
---|
| 38 | # There should be no bogus failures below this line!
|
---|
| 39 |
|
---|
| 40 | # Figure out if a framebuffer console is used
|
---|
| 41 | [ -d /sys/class/graphics/fb0 ] && USE_FB=1 || USE_FB=0
|
---|
| 42 |
|
---|
| 43 | # Figure out the command to set the console into the
|
---|
| 44 | # desired mode
|
---|
| 45 | is_true "${UNICODE}" &&
|
---|
| 46 | MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" ||
|
---|
| 47 | MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a"
|
---|
| 48 |
|
---|
| 49 | # On framebuffer consoles, font has to be set for each vt in
|
---|
| 50 | # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
|
---|
| 51 |
|
---|
| 52 | ! is_true "${USE_FB}" || [ -z "${FONT}" ] ||
|
---|
| 53 | MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
|
---|
| 54 |
|
---|
| 55 | # Apply that command to all consoles mentioned in
|
---|
| 56 | # /etc/inittab. Important: in the UTF-8 mode this should
|
---|
| 57 | # happen before setfont, otherwise a kernel bug will
|
---|
| 58 | # show up and the unicode map of the font will not be
|
---|
| 59 | # used.
|
---|
| 60 | # FIXME: Fedora Core also initializes two spare consoles
|
---|
| 61 | # - do we want that?
|
---|
| 62 |
|
---|
| 63 | for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
|
---|
| 64 | grep -o '\btty[[:digit:]]*\b'`
|
---|
| 65 | do
|
---|
| 66 | openvt -f -w -c ${TTY#tty} -- \
|
---|
| 67 | /bin/sh -c "${MODE_COMMAND}" || failed=1
|
---|
| 68 | done
|
---|
| 69 |
|
---|
| 70 | # Set the font (if not already set above) and the keymap
|
---|
| 71 | is_true "${USE_FB}" || [ -z "${FONT}" ] ||
|
---|
| 72 | setfont $FONT ||
|
---|
| 73 | failed=1
|
---|
| 74 | [ -z "${KEYMAP}" ] ||
|
---|
| 75 | loadkeys ${KEYMAP} >/dev/null 2>&1 ||
|
---|
| 76 | failed=1
|
---|
| 77 | [ -z "${KEYMAP_CORRECTIONS}" ] ||
|
---|
| 78 | loadkeys ${KEYMAP_CORRECTIONS} >/dev/null 2>&1 ||
|
---|
| 79 | failed=1
|
---|
| 80 |
|
---|
| 81 | # Linux kernel generates wrong bytes when composing
|
---|
| 82 | # in Unicode mode. That's why we disable dead keys in Unicode
|
---|
| 83 | # mode by default. If you need them, download and apply
|
---|
| 84 | # http://www.linuxfromscratch.org/~alexander/patches/linux-2.6.12.5-utf8_input-2.patch
|
---|
| 85 | # After patching, add "-m charset_of_your_keymap" to the FONT
|
---|
| 86 | # variable and set BROKEN_COMPOSE=false
|
---|
| 87 | # in /etc/sysconfig/console
|
---|
| 88 |
|
---|
| 89 | [ -n "$BROKEN_COMPOSE" ] || BROKEN_COMPOSE="$UNICODE"
|
---|
| 90 | ! is_true "$BROKEN_COMPOSE" ||
|
---|
| 91 | echo "" | loadkeys -c >/dev/null 2>&1 ||
|
---|
| 92 | failed=1
|
---|
| 93 |
|
---|
| 94 | # Convert the keymap from $LEGACY_CHARSET to UTF-8
|
---|
| 95 | [ -z "$LEGACY_CHARSET" ] ||
|
---|
| 96 | dumpkeys -c "$LEGACY_CHARSET" |
|
---|
| 97 | loadkeys -u >/dev/null 2>&1 ||
|
---|
| 98 | failed=1
|
---|
| 99 |
|
---|
| 100 | # If any of the commands above failed, the trap at the
|
---|
| 101 | # top would set $failed to 1
|
---|
| 102 | ( exit $failed )
|
---|
| 103 | evaluate_retval standard
|
---|
| 104 | ;;
|
---|
| 105 | *)
|
---|
| 106 | echo $"Usage:" "${0} {start}"
|
---|
| 107 | exit 1
|
---|
| 108 | ;;
|
---|
| 109 | esac
|
---|
| 110 |
|
---|
| 111 | # End $rc_base/init.d/console
|
---|