From 748cff514e9033e1a7984f26ece7ed25079e3535 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Mon, 3 Sep 2007 11:45:39 +0200 Subject: init: search for valid init Fixes bootfailure on bogus init bootarg too. Plus there may be a rootfs without init, but with sh. --- debian/changelog | 4 +++- init | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 66dceea..0bdb6b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,10 @@ initramfs-tools (0.91) UNRELEASED; urgency=low * init: Call panic for debug sh if run-init fails. * init-top/framebuffer: Check that fb minor is below 32. * init: Export noresume if set. uswsusp and kdump need it. + * init: Try harder to find a valid init on rootmnt. Fixes bootfailure on + bogus init bootarg too. - -- maximilian attems Sat, 01 Sep 2007 13:40:24 +0200 + -- maximilian attems Mon, 03 Sep 2007 11:44:04 +0200 initramfs-tools (0.90a) unstable; urgency=high diff --git a/init b/init index 6d06bc1..e66cac2 100755 --- a/init +++ b/init @@ -176,9 +176,26 @@ run_scripts /scripts/init-bottom mount -n -o move /sys ${rootmnt}/sys mount -n -o move /proc ${rootmnt}/proc -while [ ! -x ${rootmnt}${init} ]; do - panic "Target filesystem doesn't have ${init}" -done +# Check init bootarg +if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then + init= + echo "Target filesystem doesn't have ${init}." +fi + +# Search for valid init +if [ -z "${init}" ] ; then + for init in /sbin/init /etc/init /bin/init /bin/sh; do + if [ ! -x "${rootmnt}${i}" ]; then + continue + fi + break + done +fi + +# No init on rootmount +if [ ! -x "${rootmnt}${init}" ]; then + panic "No init found. Try passing init= bootarg." +fi # Confuses /etc/init.d/rc if [ -n ${debug} ]; then -- cgit v1.2.3