[OE-core] [PATCH 1/1] init-live.sh: allow users to choose the boot action
Qi.Chen at windriver.com
Qi.Chen at windriver.com
Wed Jul 10 07:12:59 UTC 2013
From: Chen Qi <Qi.Chen at 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 at windriver.com>
---
meta/recipes-core/initrdscripts/files/init-live.sh | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
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
--
1.7.9.5
More information about the Openembedded-core
mailing list