console 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin console
  4. #
  5. # Description : Sets keymap and screen font
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # Alexander E. Patrakov
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. #
  11. # Version : LFS 7.0
  12. #
  13. ########################################################################
  14. . /lib/boot/functions
  15. ### BEGIN INIT INFO
  16. # Provides: console
  17. # Required-Start:
  18. # Should-Start: $local_fs
  19. # Required-Stop:
  20. # Should-Stop:
  21. # Default-Start: S
  22. # Default-Stop:
  23. # Short-Description: Sets up a localised console.
  24. # Description: Sets up fonts and language settings for the user's
  25. # local as defined by /etc/sysconfig/console.
  26. # X-LFS-Provided-By: LFS
  27. ### END INIT INFO
  28. # Native English speakers probably don't have /etc/sysconfig/console at all
  29. if [ -r /etc/sysconfig/console ]; then
  30. . /etc/sysconfig/console
  31. else
  32. exit 0
  33. fi
  34. is_true() {
  35. [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
  36. }
  37. failed=0
  38. case "${1}" in
  39. start)
  40. boot_mesg "Setting up Linux console..."
  41. # There should be no bogus failures below this line!
  42. # Figure out if a framebuffer console is used
  43. [ -d /sys/class/graphics/fb0 ] && USE_FB=1 || USE_FB=0
  44. # Figure out the command to set the console into the
  45. # desired mode
  46. is_true "${UNICODE}" &&
  47. MODE_COMMAND="${ECHO} -en '\033%G' && kbd_mode -u" ||
  48. MODE_COMMAND="${ECHO} -en '\033%@\033(K' && kbd_mode -a"
  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. ! is_true "${USE_FB}" || [ -z "${FONT}" ] ||
  52. MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
  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. for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
  61. grep -o '\btty[[:digit:]]*\b'`
  62. do
  63. openvt -f -w -c ${TTY#tty} -- \
  64. /bin/sh -c "${MODE_COMMAND}" || failed=1
  65. done
  66. # Set the font (if not already set above) and the keymap
  67. is_true "${USE_FB}" || [ -z "${FONT}" ] ||
  68. setfont $FONT ||
  69. failed=1
  70. [ -z "${KEYMAP}" ] ||
  71. loadkeys ${KEYMAP} >/dev/null 2>&1 ||
  72. failed=1
  73. [ -z "${KEYMAP_CORRECTIONS}" ] ||
  74. loadkeys ${KEYMAP_CORRECTIONS} >/dev/null 2>&1 ||
  75. failed=1
  76. # Convert the keymap from $LEGACY_CHARSET to UTF-8
  77. [ -z "$LEGACY_CHARSET" ] ||
  78. dumpkeys -c "$LEGACY_CHARSET" |
  79. loadkeys -u >/dev/null 2>&1 ||
  80. failed=1
  81. # If any of the commands above failed, the trap at the
  82. # top would set $failed to 1
  83. ( exit $failed )
  84. evaluate_retval
  85. ;;
  86. *)
  87. echo $"Usage:" "${0} {start}"
  88. exit 1
  89. ;;
  90. esac
  91. # End console