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