aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/preinit/30_failsafe_wait
diff options
context:
space:
mode:
authorLuka Perkov <luka@openwrt.org>2013-12-09 11:30:14 +0000
committerLuka Perkov <luka@openwrt.org>2013-12-09 11:30:14 +0000
commit3ceb6b3274d75fb5dc05b9eb42f2a98ee445f122 (patch)
tree30f8751c74750a210d9321522993e8fa17ffcd1c /package/base-files/files/lib/preinit/30_failsafe_wait
parent18dd10190370853c3efc10b33711313a3ecb9a09 (diff)
downloadupstream-3ceb6b3274d75fb5dc05b9eb42f2a98ee445f122.tar.gz
upstream-3ceb6b3274d75fb5dc05b9eb42f2a98ee445f122.tar.bz2
upstream-3ceb6b3274d75fb5dc05b9eb42f2a98ee445f122.zip
base-files: fix whitespaces
Signed-off-by: Luka Perkov <luka@openwrt.org> SVN-Revision: 39006
Diffstat (limited to 'package/base-files/files/lib/preinit/30_failsafe_wait')
-rw-r--r--package/base-files/files/lib/preinit/30_failsafe_wait161
1 files changed, 80 insertions, 81 deletions
diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait
index 522565940c..3d69baf3a4 100644
--- a/package/base-files/files/lib/preinit/30_failsafe_wait
+++ b/package/base-files/files/lib/preinit/30_failsafe_wait
@@ -3,95 +3,94 @@
# Copyright (C) 2010 Vertical Communications
fs_wait_for_key () {
- local timeout=$3
- local timer
- local do_keypress
- local keypress_true="$(mktemp)"
- local keypress_wait="$(mktemp)"
- local keypress_sec="$(mktemp)"
- if [ -z "$keypress_wait" ]; then
- keypress_wait=/tmp/.keypress_wait
- touch $keypress_wait
- fi
- if [ -z "$keypress_true" ]; then
- keypress_true=/tmp/.keypress_true
- touch $keypress_true
- fi
- if [ -z "$keypress_sec" ]; then
- keypress_sec=/tmp/.keypress_sec
- touch $keypress_sec
- fi
+ local timeout=$3
+ local timer
+ local do_keypress
+ local keypress_true="$(mktemp)"
+ local keypress_wait="$(mktemp)"
+ local keypress_sec="$(mktemp)"
+ if [ -z "$keypress_wait" ]; then
+ keypress_wait=/tmp/.keypress_wait
+ touch $keypress_wait
+ fi
+ if [ -z "$keypress_true" ]; then
+ keypress_true=/tmp/.keypress_true
+ touch $keypress_true
+ fi
+ if [ -z "$keypress_sec" ]; then
+ keypress_sec=/tmp/.keypress_sec
+ touch $keypress_sec
+ fi
- trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
- trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
+ trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
- [ -n "$timeout" ] || timeout=1
- [ $timeout -ge 1 ] || timeout=1
- timer=$timeout
- lock $keypress_wait
- {
- while [ $timer -gt 0 ]; do
- echo "$timer" >$keypress_sec
- timer=$(($timer - 1))
- sleep 1
- done
- lock -u $keypress_wait
- rm -f $keypress_wait
- } &
-
- 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)"
-
- [ -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
+ [ -n "$timeout" ] || timeout=1
+ [ $timeout -ge 1 ] || timeout=1
+ timer=$timeout
+ lock $keypress_wait
+ {
+ while [ $timer -gt 0 ]; do
+ echo "$timer" >$keypress_sec
+ timer=$(($timer - 1))
+ sleep 1
+ done
lock -u $keypress_wait
rm -f $keypress_wait
- }
- done
- }
- lock -w $keypress_wait
+ } &
+
+ 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)"
+
+ [ -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
+ }
+ lock -w $keypress_wait
- keypressed=1
- [ "$(cat $keypress_true)" = "true" ] && keypressed=0
-
- rm -f $keypress_true
- rm -f $keypress_wait
- rm -f $keypress_sec
-
- return $keypressed
+ keypressed=1
+ [ "$(cat $keypress_true)" = "true" ] && keypressed=0
+
+ rm -f $keypress_true
+ rm -f $keypress_wait
+ rm -f $keypress_sec
+
+ return $keypressed
}
failsafe_wait() {
- FAILSAFE=
- grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
- if [ "$FAILSAFE" != "true" ]; then
- pi_failsafe_net_message=true
- preinit_net_echo "Please press button now to enter failsafe"
- pi_failsafe_net_message=false
- fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
- [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
- [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
- fi
+ FAILSAFE=
+ grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
+ if [ "$FAILSAFE" != "true" ]; then
+ pi_failsafe_net_message=true
+ preinit_net_echo "Please press button now to enter failsafe"
+ pi_failsafe_net_message=false
+ fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
+ [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
+ [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
+ fi
}
boot_hook_add preinit_main failsafe_wait
-