1
0

console 3.0 KB

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