Skip to contentSkip to conversation

init-live.sh: allow user to choose the boot action

PATCH In review [email protected] 2 participants 4 messages Jul 10, 2013

lore
Share & tools
lore
#0 lore raw

cover init-live.sh: allow user to choose the boot action

From: Chen Qi <[email protected]>

The following changes since commit 4285e856aa073979bf046168a75188ccf5a1e7d4:

lib/oeqa/runtime: add gcc test (2013-07-09 10:53:45 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/live-image-user-choice
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/live-image-user-choice

Chen Qi (1):
init-live.sh: allow users to choose the boot action

 meta/recipes-core/initrdscripts/files/init-live.sh |   39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 init-live.sh: allow users to choose the boot action

From: Chen Qi <[email protected]>

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]

---
 meta/recipes-core/initrdscripts/files/init-live.sh |   39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
meta/recipes-core/initrdscripts/files/init-live.sh +39 -0
index 890c562..2300381 100644
@@ -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
Signature · 1 line
1.7.9.5
#2 lore raw

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

Hi,

Quoted 11 lines · On 10/07/13 08:12, [email protected] wrote:

From: Chen Qi <[email protected]>

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

Signature · 1 line
http://sleepfive.com
author
#3 lore raw

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

Quoted 14 lines · Tomas Frydrych

Hi,

Quoted 11 lines · On 10/07/13 08:12, [email protected] wrote:

From: Chen Qi <[email protected]>

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.

Quoted 9 lines

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