altboot:
authorMatthias Hentges <oe@hentges.net>
Wed, 18 Jan 2006 19:15:07 +0000 (19:15 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Wed, 18 Jan 2006 19:15:07 +0000 (19:15 +0000)
- Fixed a bug where altboot wouldn't prompt for the menu but do init 5 instead
- Cosmetic changes (Thanks to andrewy@#openzaurus)
- Fixed a bug where pressing enter to start altboot would launch the default option. (Thanks to prh@#openzaurus)
- Disabled "Copy RootFS" menu item as this part is not finished, yet.

packages/altboot/altboot.bb
packages/altboot/files/altboot-menu/Advanced/40-bootNFS
packages/altboot/files/altboot-menu/Advanced/80-copyrootfs
packages/altboot/files/altboot.func
packages/altboot/files/init.altboot

index de5d780..5fe8d22 100644 (file)
@@ -6,7 +6,7 @@ MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
 LICENSE = "GPL"
  
 
-PR = "r9"
+PR = "r10"
 
 
 SRC_URI = "file://altboot-menu \
index 33e869b..88e546a 100644 (file)
@@ -42,6 +42,11 @@ run_module() {
        nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
        nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"   
        
+       if test -z "$nfs_hosts"
+       then
+               echo -e "${C_RED}No configured NFS drives found in /etc/fstab$C_RESET"
+               exit 1
+       fi
        
        # WLAN with DHCP needs some time to get a lease, set up the routing, etc.       
        echo -n "Waiting for WLAN"
index 1949f20..13f98a0 100644 (file)
@@ -1,6 +1,8 @@
 # !/bin/sh
 M_TITLE="Copy rootfs to SD/CF"
 
+# Unfinished script.
+exit 0
 
 die() {
        echo "ERROR: $1" >/dev/tty0
@@ -50,7 +52,7 @@ ask_target() {
 ask_format() {
        if test "$ROOTFS_TARGET_FS" != ext2
        then
-               echo -e "\nYou are not using the ext2 filesystem on your target.\nYou now have two choices:"
+               echo -e "\nYou are not using the ext2 filesystem on your target ($ROOTFS_TARGET_FS)$.\nYou now have two choices:"
                echo -e "\t[1] Reformat to ext2"
                echo -e "\t[2] Use an image-file ontop of the existing filesystem"
                
@@ -113,7 +115,7 @@ ask_confirm() {
 
 direct_install() {
 
-       format_target
+       #format_target
                
        echo -n "Creating temporary directory..."
        mkdir -p /media/temp && echo ok || die "mkdir -p /media/temp failed!"
index 0598c8c..7afb372 100644 (file)
@@ -185,18 +185,26 @@ set_password() {
        then
                echo -e "\nAltboot is a boot-manager which allows to boot from SD,\nCF and NFS"
                echo -e "\nFor security reasons altboot requires a password\nto boot into init=/bin/sh."
-               echo -e "${C_RED}This is *not* your root password!\nIt is used by altboot alone!${C_RESET}"
-               echo -e "${C_BLUE}\nNote:\tThe password will be echoed to the screen\n\tand it will be asked twice for confirmation.${C_RESET}"
-               echo -e "\nPlease enter a new master password:\n"
+               echo -e "${C_RED}This is *not* your root password!\nIt is used by altboot alone!${C_RESET}\n"
+               #echo -e "${C_BLUE}\nNote:\tThe password will be echoed to the screen\n\tand it will be asked twice for confirmation.${C_RESET}"
+               #echo -e "\nPlease enter a new master password:\n"
 
                while true
                do
-                       echo -en "New password: "
+                       echo -en "\nNew password: "
+
+                       stty -echo
                        read junk1 < /dev/tty0
+                       stty echo
+
                        if ! test -z "$junk1"
                        then
-                               echo -n "Repeat: "
+                               echo -en "\nRepeat: "
+                               
+                               stty -echo
                                read junk2  < /dev/tty0
+                               stty echo
+                               echo ""
                                
                                if test "$junk1" = "$junk2"
                                then
index 2b7df14..830be08 100644 (file)
@@ -5,6 +5,7 @@
 # New menu entries can be created be putting files into /etc/altboot-menu.
 #
 
+
 test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
 
 CURRENT_ENV="`set`"
@@ -146,6 +147,7 @@ run_timer() {
                mount -t proc proc /proc >/dev/null 2>&1
                key_ints="`cat /proc/interrupts | grep keyboard | awk '{print $2}'`"
        
+               stty -echo
                echo -en "\n\nPlease press any key to launch altboot." > /dev/tty1
                
                test -z "$TIMEOUT" && TIMEOUT="3"
@@ -157,6 +159,7 @@ run_timer() {
                        if test "`cat /proc/interrupts | grep keyboard | awk '{print $2}'`" != "$key_ints" 
                        then                            
                                launch_altboot=yes                              
+                               stty echo
                                break
                        fi
                        echo -n "." >/dev/tty1
@@ -206,16 +209,28 @@ launch_selection() {
 wait_for_input() {
        while true
        do
-               echo -n "Please choose one of the above [$last_selection]: " </dev/tty0 > /dev/tty0 2>&1
-               read junk < /dev/tty0 2>&1
-
+               
+               
+               # Do _not_ change the next few lines!
+               #       
                # This is required to work around an annoying busybox bug.
                # Every key you press while this script runs will be
-               # picked up by the next "read $junk". And there's no goddamn way
-               # to prevent it. So the next read would pick up the "any" key the user pressed
+               # picked up by the next "read $junk".   
+               # So the next read would pick up the "any" key the user pressed
                # above to launch the altboot menu.             
-               junk="`echo "$junk" |  sed -n "s/.*\([0-9]\)/\1/p"`"
+                               
+               
+               # This filters an "<ENTER>" from the user as "any key"
+               ( while :; do read x< /dev/tty0 2>&1; done; ) > /dev/null 2>&1 &
+               sleep 1; kill $!
+                               
+               
+
+               echo -n "Please choose one of the above [$last_selection]: " </dev/tty0 > /dev/tty0 2>&1
+               read junk< /dev/tty0 2>&1
                
+               # This filters other chars the user may have used
+               junk="`echo "$junk" |  sed -n "s/.*\([0-9]\)/\1/p"`"
                
                if test "$junk" -lt "$cnt" -o "$junk" -eq "$cnt" 
                then
@@ -243,6 +258,9 @@ wait_for_input() {
 
 # * * * * * * This is the main function * * * * * *
 
+# if /sbin/init is launched with a parameter, it is very likely that the user is trying to switch runlevels
+# manually by running "/sbin/init $RUN_LEVEL". If it is empty (or just contains "tty1") we assume that the kernel
+# launched init during bootup
 if test -n "$*" -a "$*" != "tty1"
 then
        echo "altboot: Using real init [$REAL_INIT] [$*] *" >/dev/tty1
@@ -251,7 +269,7 @@ then
 else   
 
        # Execute scripts in /etc/altboot.rc before doing anything else.
-       # Required for special situations, like booting spitz
+       # Required in special situations, like booting spitz
        RC_FILES=`ls /etc/altboot.rc | grep \.sh$`
 
        for file in $RC_FILES