]> code.ossystems Code Review - openembedded-core.git/commitdiff
initrd: Spawn an emergency shell when something goes wrong
authorDamien Lespiau <damien.lespiau@intel.com>
Thu, 27 Sep 2012 14:20:50 +0000 (15:20 +0100)
committerSaul Wold <sgw@linux.intel.com>
Fri, 28 Sep 2012 08:14:02 +0000 (01:14 -0700)
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@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
meta/recipes-core/initrdscripts/files/init-live.sh

index 3fba7dc3a16d4270be1fc14187e3884ab00d3f4d..fb7af31a13057b60cc19a4637459ea0e95d9c984 100644 (file)
@@ -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"