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. --- init | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'init') 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