[1/2] initrd: Spawn an emergency shell when something goes wrong

Submitted by Ross Burton on Sept. 27, 2012, 2:20 p.m.


Message ID 20043bb7087432cc241e5d1eaa1059f787701cc4.1348755513.git.ross.burton@intel.com
State Accepted
Commit ae5e2bd994e3f60d3803ab56e6ed34d08fbc56f0
Headers show

Commit Message

Ross Burton Sept. 27, 2012, 2:20 p.m.
From: Damien Lespiau <damien.lespiau@intel.com>

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>
 meta/recipes-core/initrdscripts/files/init-live.sh |   11 +++++++++++
 1 file changed, 11 insertions(+)

Patch hide | download patch | download mbox

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 @@ 
+    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