2 # Copyright (C) 2006-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
9 local keypress_true
="$(mktemp)"
10 local keypress_wait
="$(mktemp)"
11 local keypress_sec
="$(mktemp)"
12 if [ -z "$keypress_wait" ]; then
13 keypress_wait
=/tmp
/.keypress_wait
16 if [ -z "$keypress_true" ]; then
17 keypress_true
=/tmp
/.keypress_true
20 if [ -z "$keypress_sec" ]; then
21 keypress_sec
=/tmp
/.keypress_sec
25 trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
26 trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
28 [ -n "$timeout" ] || timeout
=1
29 [ $timeout -ge 1 ] || timeout
=1
33 while [ $timer -gt 0 ]; do
34 echo "$timer" >$keypress_sec
38 lock
-u $keypress_wait
42 echo "Press $1<ENTER> $2"
43 # if we're on the console we wait for input
45 while [ -r $keypress_wait ]; do
46 timer
="$(cat $keypress_sec)"
48 [ -n "$timer" ] || timer
=1
50 [ $timer -ge 1 ] || timer
=1
53 read -t "$timer" do_failsafe
54 if [ "$do_failsafe" = "$1" ]; then
55 echo "true" >$keypress_true
56 lock
-u $keypress_wait
62 lock
-w $keypress_wait
68 [ "$(cat $keypress_true)" = "true" ] && keypressed
=0
78 pi_failsafe_net_message
=true
79 preinit_net_echo
"Please press button now to enter failsafe"
80 pi_failsafe_net_message
=false
82 fs_wait_for_key f
'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE
=true
&& export FAILSAFE
85 boot_hook_add preinit_main failsafe_wait