console 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/sysconfig/console.
  14. # X-LFS-Default-Start: S70
  15. # X-LFS-Default-Stop:
  16. # X-LFS-Provided-By: LFS
  17. ### END INIT INFO
  18. . /lib/lsb/init-functions
  19. MESSAGE="Setting up Linux console..."
  20. # Native English speakers probably don't have /etc/sysconfig/console at all
  21. if [ -f /etc/sysconfig/console ]
  22. then
  23. . /etc/sysconfig/console
  24. fi
  25. is_true() {
  26. [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
  27. }
  28. failed=0
  29. case "${1}" in
  30. start)
  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. # Convert the keymap from $LEGACY_CHARSET to UTF-8
  67. [ -z "$LEGACY_CHARSET" ] ||
  68. dumpkeys -c "$LEGACY_CHARSET" |
  69. loadkeys -u >/dev/null 2>&1 ||
  70. failed=1
  71. # If any of the commands above failed, the trap at the
  72. # top would set $failed to 1
  73. ( exit $failed )
  74. evaluate_retval standard
  75. ;;
  76. *)
  77. echo $"Usage:" "${0} {start}"
  78. exit 1
  79. ;;
  80. esac
  81. # End $rc_base/init.d/console