[oe-commits] Damien Lespiau : initrd: Spawn an emergency shell when something goes wrong

git at git.openembedded.org git at git.openembedded.org
Fri Sep 28 10:15:27 UTC 2012


Module: openembedded-core.git
Branch: master
Commit: ae5e2bd994e3f60d3803ab56e6ed34d08fbc56f0
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=ae5e2bd994e3f60d3803ab56e6ed34d08fbc56f0

Author: Damien Lespiau <damien.lespiau at intel.com>
Date:   Thu Sep 27 15:20:50 2012 +0100

initrd: Spawn an emergency shell when something goes wrong

set -e allows to exit if a command fails. We install a trap and execute
emergency_shell() when either the init script exits or when ctrl-c is
typed (say if we are stuck somewhere and we want to debug it).

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
Signed-off-by: Saul Wold <sgw at linux.intel.com>

---

 meta/recipes-core/initrdscripts/files/init-live.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index 3fba7dc..fb7af31 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -2,6 +2,17 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
+emergency_shell()
+{
+    echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
+    echo
+    sh
+}
+trap "emergency_shell" 0 2
+
+# exit immediately if a command fails
+set -e
+
 ROOT_MOUNT="/rootfs/"
 ROOT_IMAGE="rootfs.img"
 MOUNT="/bin/mount"





More information about the Openembedded-commits mailing list