50_choose_console 775 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. # Copyright (C) 2010 Vertical Communications
  4. choose_console() {
  5. # the shell really doesn't like having stdin/out closed
  6. # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
  7. # for /dev/console if there's no serial console available
  8. if grep devfs /proc/filesystems > /dev/null; then
  9. M0=/dev/pty/m0
  10. M1=/dev/pty/m1
  11. M2=/dev/pty/m1
  12. elif [ -x /sbin/hotplug2 ]; then
  13. M0=/dev/ptmx
  14. M1=/dev/ptmx
  15. M2=/dev/ptmx
  16. elif [ -x /sbin/udevd ]; then
  17. M0=/dev/pty/ptmx
  18. M1=/dev/pty/ptmx
  19. M2=/dev/pty/ptmx
  20. fi
  21. dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
  22. M0=/dev/console
  23. M1=/dev/console
  24. M2=/dev/console
  25. }
  26. }
  27. boot_hook_add preinit_essential choose_console