summaryrefslogtreecommitdiff
path: root/packages/altboot/files/init.altboot
diff options
context:
space:
mode:
authorErik Hovland <erik@hovland.org>2006-05-08 18:59:10 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-05-08 18:59:10 +0000
commit7ed412e1e868f20a0e803e91e3d7e3529f61b44e (patch)
treee8fb8fb8ea912ff29dca4bfdc0ce0e1aca3bc0a5 /packages/altboot/files/init.altboot
parent07423bdbbb7ce2d14455d6b886d4b0156cd28a18 (diff)
parent9e3e9161817697df633d46cc88f0ce9e8365c032 (diff)
merge of 406934f50b9f92db47af1cb9d9777b268c5484b5
and 6ba2bb7b7ce5ef334cf514386df28b8d6a2aad86
Diffstat (limited to 'packages/altboot/files/init.altboot')
-rw-r--r--packages/altboot/files/init.altboot72
1 files changed, 37 insertions, 35 deletions
diff --git a/packages/altboot/files/init.altboot b/packages/altboot/files/init.altboot
index 3dc7c60240..08ba81e962 100644
--- a/packages/altboot/files/init.altboot
+++ b/packages/altboot/files/init.altboot
@@ -17,6 +17,8 @@ REAL_INIT="/sbin/init.sysvinit"
INIT_RUNLEVEL="`cat /etc/inittab | sed -n "/^id\:/s/id\:\([0-9]\)\:.*$/\1/p"`"
test -z "$INIT_RUNLEVEL" && INIT_RUNLEVEL=5
+OUT_TTY="`tty`" ; test -z "$OUT_TTY" && OUT_TTY="/dev/tty1"
+
case "`uname -r`" in
2.6*) ALTBOOT_CFG_FILE="/etc/altboot-2.6.cfg";;
2.4*) ALTBOOT_CFG_FILE="/etc/altboot-2.4.cfg";;
@@ -24,7 +26,7 @@ case "`uname -r`" in
ALTBOOT_CFG_FILE="/etc/altboot-2.6.cfg";;
esac
-test -e "$ALTBOOT_CFG_FILE" && . "$ALTBOOT_CFG_FILE" || echo "WARNING: No $ALTBOOT_CFG_FILE found! Check your installation of Altboot!" > /dev/tty1
+test -e "$ALTBOOT_CFG_FILE" && . "$ALTBOOT_CFG_FILE" || echo "WARNING: No $ALTBOOT_CFG_FILE found! Check your installation of Altboot!" > "$OUT_TTY"
C_RED="\033[31m"
C_YELLOW="\033[33m"
@@ -34,8 +36,8 @@ C_RESET="\033[0m"
die() {
- echo -e "${C_RED}ERROR: $1${C_RESET}" >/dev/tty0
- exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+ echo -e "${C_RED}ERROR: $1${C_RESET}" >"$OUT_TTY"
+ exec $SH_SHELL <"$OUT_TTY" >"$OUT_TTY" 2>&1
}
debug_shell() {
@@ -178,8 +180,8 @@ run_timer() {
test -z "$key_ints" && key_ints="`cat /proc/interrupts | grep -i corgikbd`";;
esac
- stty -echo </dev/tty0 >/dev/tty0 2>&1
- echo -en "\n\nPlease press any key to launch altboot." > /dev/tty1
+ stty -echo <"$OUT_TTY" >"$OUT_TTY" 2>&1
+ echo -en "\n\nPlease press any key to launch altboot." > "$OUT_TTY"
test -z "$TIMEOUT" && TIMEOUT="3"
@@ -196,10 +198,10 @@ run_timer() {
if test "$key_ints_now" != "$key_ints" -o -z "$key_ints_now"
then
launch_altboot=yes
- stty echo </dev/tty0 >/dev/tty0 2>&1
+ stty echo <"$OUT_TTY" >"$OUT_TTY" 2>&1
break
fi
- echo -n "." >/dev/tty1
+ echo -n "." >"$OUT_TTY"
let cnt=$cnt+1
done
@@ -233,22 +235,22 @@ launch_selection() {
# The selected menu-item points to a directory
if test "$type" = DIR
then
- show_sub_menu /etc/altboot-menu/$file >/dev/tty0
- wait_for_input >/dev/tty0
- launch_selection /etc/altboot-menu >/dev/tty0
+ show_sub_menu /etc/altboot-menu/$file >"$OUT_TTY"
+ wait_for_input >"$OUT_TTY"
+ launch_selection /etc/altboot-menu >"$OUT_TTY"
fi
if test "$type" = MAIN
then
- show_sub_menu /etc/altboot-menu >/dev/tty0
- wait_for_input >/dev/tty0
- launch_selection /etc/altboot-menu >/dev/tty0
+ show_sub_menu /etc/altboot-menu >"$OUT_TTY"
+ wait_for_input >"$OUT_TTY"
+ launch_selection /etc/altboot-menu >"$OUT_TTY"
fi
- . $1/$file run "$file" >/dev/tty0
- die "WARNING: Using failsafe shell" >/dev/tty0
+ . $1/$file run "$file" >"$OUT_TTY"
+ die "WARNING: Using failsafe shell" >"$OUT_TTY"
;;
esac
@@ -273,13 +275,13 @@ wait_for_input() {
if ! (readlink /bin/sh | grep -q bash)
then
# This filters an "<ENTER>" from the user as "any key"
- ( while :; do read x< /dev/tty0 2>&1; done; ) > /dev/null 2>&1 &
+ ( while :; do read x< "$OUT_TTY" 2>&1; done; ) > /dev/null 2>&1 &
sleep 1; kill $! >/dev/null 2>&1
fi
- echo -n "Please choose one of the above [$last_selection]: " </dev/tty0 > /dev/tty0 2>&1
- stty echo </dev/tty0 >/dev/tty0 2>&1
- read junk< /dev/tty0 2>&1
+ echo -n "Please choose one of the above [$last_selection]: " <"$OUT_TTY" > "$OUT_TTY" 2>&1
+ stty echo <"$OUT_TTY" >"$OUT_TTY" 2>&1
+ read junk< "$OUT_TTY" 2>&1
# This filters other chars the user may have used
@@ -323,7 +325,7 @@ fi
if test -f /proc/cmdline -a "`ps ax|wc -l|tr -d " "`" -gt 30 -a "$1" != "-force"
then
- echo "altboot: Using real init [$REAL_INIT] [$*] [`ps ax|wc -l|tr -d " "`] *" >/dev/tty1
+ echo "altboot: Using real init [$REAL_INIT] [$*] [`ps ax|wc -l|tr -d " "`] *" >"$OUT_TTY"
exec $REAL_INIT $*
# exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
exit 0
@@ -331,7 +333,7 @@ else
# Boot original init if altboot is turned off
if test "$ENABLE_ALTBOOT" != "yes"
then
- echo "altboot: Using real init [$REAL_INIT] **" >/dev/tty1
+ echo "altboot: Using real init [$REAL_INIT] **" >"$OUT_TTY"
exec $REAL_INIT $INIT_RUNLEVEL
exit 0
fi
@@ -342,22 +344,22 @@ else
for file in $RC_FILES
do
- . /etc/altboot.rc/$file >/dev/tty1 2>&1 || echo "/etc/altboot.rc/$file failed!"
+ . /etc/altboot.rc/$file >"$OUT_TTY" 2>&1 || echo "/etc/altboot.rc/$file failed!"
done
# Make sure altboots master password is set
- set_password >/dev/tty0
+ set_password >"$OUT_TTY"
- test "$ASK_PW_ON_BOOT" = "yes" && verify_master_pw >/dev/tty0
+ test "$ASK_PW_ON_BOOT" = "yes" && verify_master_pw >"$OUT_TTY"
# When started with -force, always print the menu
echo "$*" | grep -q -- "-force" && TIMEOUT=0
# This timeout works by reading /proc/interrupts to see if the keyboard interrupt
# increases while the timer is running. A TIMEOUT of 0 will always launch altboot.
- run_timer >/dev/tty1
+ run_timer >"$OUT_TTY"
- echo "" >/dev/tty0
+ echo "" >"$OUT_TTY"
if test "$launch_altboot" != yes
@@ -366,40 +368,40 @@ else
last_selection="`cat /etc/altboot.conf`" >/dev/null 2>&1
test -z "$last_selection" && last_selection="1"
- echo "Booting last selection: [$last_selection]" >/dev/tty0
+ echo "Booting last selection: [$last_selection]" >"$OUT_TTY"
# Set up the wanna-be array of available menu entries and their numbers
show_menu /etc/altboot-menu >/dev/null
junk="$last_selection"
- launch_selection /etc/altboot-menu >/dev/tty0
+ launch_selection /etc/altboot-menu >"$OUT_TTY"
fi
# Anything after this point will never be reached if $launch_altboot != yes
# Show the altboot menu
- stty -echo </dev/tty0 >/dev/tty0 2>&1
- show_menu /etc/altboot-menu >/dev/tty0
+ stty -echo <"$OUT_TTY" >"$OUT_TTY" 2>&1
+ show_menu /etc/altboot-menu >"$OUT_TTY"
# Load last selection for use as default if <ENTER> is pressed at the prompt
last_selection="`cat /etc/altboot.conf`" >/dev/null 2>&1
test -z "$last_selection" && last_selection="1"
# Ask the user which menu-item to use
- wait_for_input >/dev/tty0
+ wait_for_input >"$OUT_TTY"
# This should _never_ happen.
if test -z "$junk"
then
- echo "WARNING: Trying failsafe mode" >/dev/tty0
- mount -o remount,rw / >/dev/tty0 2>&1
+ echo "WARNING: Trying failsafe mode" >"$OUT_TTY"
+ mount -o remount,rw / >"$OUT_TTY" 2>&1
echo "Dumping environment to /altboot.env"
echo "$CURRENT_ENV" > /altboot.env
- mount -o remount,ro / >/dev/tty0 2>&1
+ mount -o remount,ro / >"$OUT_TTY" 2>&1
junk=1
fi
- launch_selection /etc/altboot-menu >/dev/tty0
+ launch_selection /etc/altboot-menu >"$OUT_TTY"
# Uhoh, something went terribly wrong if we reach this point!
die "WARNING: Failsafe fall-through activated. Spawning emergency shell"