Patchwork [1/1] init-live.sh: allow users to choose the boot action

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date July 10, 2013, 7:12 a.m.
Message ID <afc49ee69b585666f57d826e2e5f526335f62835.1373440331.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/53429/
State New
Headers show

Comments

Qi.Chen@windriver.com - July 10, 2013, 7:12 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Previously, the boot action for live images was totally determined
by the LABEL value in the boot parameters (/proc/cmdline).

This behavior is not very convenient for users. The user may just want
to drop to a shell for troubleshooting the live image, or the user may
want to try to install the live image while the LABEL value is 'boot'.

We should provide the users a chance to choose the boot action when
the live image starts up.

This patch starts to implement this behavior by providing three choices
at boot time, 'boot', 'install' and 'shell'.

[YOCTO #4784]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/initrdscripts/files/init-live.sh |   39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
Tomas Frydrych - July 10, 2013, 8:32 a.m.
Hi,

On 10/07/13 08:12, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> Previously, the boot action for live images was totally determined
> by the LABEL value in the boot parameters (/proc/cmdline).
> 
> This behavior is not very convenient for users. The user may just want
> to drop to a shell for troubleshooting the live image, or the user may
> want to try to install the live image while the LABEL value is 'boot'.
> 
> We should provide the users a chance to choose the boot action when
> the live image starts up.

I am not entirely clear on why this is needed, the LABEL kernel cmdline
parameter is set up by syslinux, and its value can be specified by the
user from the syslinux prompt. If what you want is a more user friendly
menu, then I think the correct solution would be to tweak the syslinux
config, rather than to create a duplicate boot menu in the init script.

Tomas
Qi.Chen@windriver.com - July 10, 2013, 8:48 a.m.
On 07/10/2013 04:32 PM, Tomas Frydrych wrote:
> Hi,
>
> On 10/07/13 08:12, Qi.Chen@windriver.com wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> Previously, the boot action for live images was totally determined
>> by the LABEL value in the boot parameters (/proc/cmdline).
>>
>> This behavior is not very convenient for users. The user may just want
>> to drop to a shell for troubleshooting the live image, or the user may
>> want to try to install the live image while the LABEL value is 'boot'.
>>
>> We should provide the users a chance to choose the boot action when
>> the live image starts up.
> I am not entirely clear on why this is needed, the LABEL kernel cmdline
> parameter is set up by syslinux, and its value can be specified by the
> user from the syslinux prompt. If what you want is a more user friendly
> menu, then I think the correct solution would be to tweak the syslinux
> config, rather than to create a duplicate boot menu in the init script.
>
> Tomas
>
>
I agree.
Thanks for providing this info.

//Chen Qi

Patch

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index 890c562..2300381 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -73,6 +73,39 @@  read_args() {
     done
 }
 
+get_choice_from_user () {
+    # get the choice from user, determine the value of label
+    echo ""
+    echo "Boot options [6 seconds timeout]:"
+    echo "[1] boot: boot the live image"
+    echo "[2] install: install the live image to a local disk"
+    echo "[3] shell: drop to a shell"
+    while true; do
+       echo -n "Please enter your choice number [default action is $label]: "
+       read -t 6 choice
+       case "$choice" in
+           "")
+               break
+               ;;
+           "1")
+               label="boot"
+               break
+               ;;
+           "2")
+               label="install"
+               break
+               ;;
+           "3")
+               label="shell"
+               break
+               ;;
+           *)
+               echo "Invalid input"
+               ;;
+       esac
+    done
+}
+
 boot_live_root() {
     # Watches the udev event queue, and exits if all current events are handled
     udevadm settle --timeout=3 --quiet
@@ -192,6 +225,9 @@  mount_and_boot() {
     boot_live_root
 }
 
+# Get choice from user
+get_choice_from_user
+
 case $label in
     boot)
 	mount_and_boot
@@ -206,4 +242,7 @@  case $label in
 	# If we're getting here, we failed...
 	fatal "Installation image failed"
 	;;
+    shell)
+	exec sh
+	;;
 esac