add preinit modularization work by Daniel Dickinson (cshore)
[openwrt.git] / package / base-files / files / lib / preinit / 50_choose_console
1 #!/bin/sh
2 # Copyright (C) 2006-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4
5 choose_console() {
6 # the shell really doesn't like having stdin/out closed
7 # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
8 # for /dev/console if there's no serial console available
9
10 if grep devfs /proc/filesystems > /dev/null; then
11 M0=/dev/pty/m0
12 M1=/dev/pty/m1
13 M2=/dev/pty/m1
14 elif [ -x /sbin/hotplug2 ]; then
15 M0=/dev/ptmx
16 M1=/dev/ptmx
17 M2=/dev/ptmx
18 elif [ -x /sbin/udevd ]; then
19 M0=/dev/pty/ptmx
20 M1=/dev/pty/ptmx
21 M2=/dev/pty/ptmx
22 fi
23 dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
24 M0=/dev/console
25 M1=/dev/console
26 M2=/dev/console
27 }
28 }
29
30 boot_hook_add preinit_essential choose_console
31
This page took 0.062152 seconds and 5 git commands to generate.