rm -f $keypress_wait
} &
- [ "$pi_preinit_no_failsafe" != "y" ] && echo "Press the [$1] key and hit [enter] $2"
- echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level"
- # if we're on the console we wait for input
- {
- while [ -r $keypress_wait ]; do
- timer="$(cat $keypress_sec)"
+ local consoles="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | sed -e 's/^console=//' -e 's/,.*//')"
+ [ -n "$consoles" ] || consoles=console
+ for console in $consoles; do
+ [ -c "/dev/$console" ] || continue
+ [ "$pi_preinit_no_failsafe" != "y" ] && echo "Press the [$1] key and hit [enter] $2" > "/dev/$console"
+ echo "Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level" > "/dev/$console"
+ {
+ while [ -r $keypress_wait ]; do
+ timer="$(cat $keypress_sec)"
- [ -n "$timer" ] || timer=1
- timer="${timer%%\ *}"
- [ $timer -ge 1 ] || timer=1
- do_keypress=""
- {
- read -t "$timer" do_keypress
- case "$do_keypress" in
- $1)
- echo "true" >$keypress_true
- ;;
- 1 | 2 | 3 | 4)
- echo "$do_keypress" >/tmp/debug_level
- ;;
- *)
- continue;
- ;;
- esac
- lock -u $keypress_wait
- rm -f $keypress_wait
- }
- done
- }
+ [ -n "$timer" ] || timer=1
+ timer="${timer%%\ *}"
+ [ $timer -ge 1 ] || timer=1
+ do_keypress=""
+ {
+ read -t "$timer" do_keypress < "/dev/$console"
+ case "$do_keypress" in
+ $1)
+ echo "true" >$keypress_true
+ ;;
+ 1 | 2 | 3 | 4)
+ echo "$do_keypress" >/tmp/debug_level
+ ;;
+ *)
+ continue;
+ ;;
+ esac
+ lock -u $keypress_wait
+ rm -f $keypress_wait
+ }
+ done
+ } &
+ done
lock -w $keypress_wait
keypressed=1
# Copyright (C) 2010 Vertical Communications
failsafe_shell() {
- local console="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | head -1 | sed -e 's/^console=//' -e 's/,.*//')"
- [ -n "$console" ] || console=console
- [ -c "/dev/$console" ] || return 0
- while true; do
- ash --login <"/dev/$console" >"/dev/$console" 2>"/dev/$console"
- sleep 1
- done &
+ local consoles="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | sed -e 's/^console=//' -e 's/,.*//')"
+ [ -n "$consoles" ] || consoles=console
+ for console in $consoles; do
+ [ -c "/dev/$console" ] && while true; do
+ ash --login <"/dev/$console" >"/dev/$console" 2>"/dev/$console"
+ sleep 1
+ done &
+ done
}
boot_hook_add failsafe failsafe_shell