1
0

console 2.7 KB

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