#
# DESCRIPTION:
#
#   run the init process, this scriplet will never return !!
#
# part of the LiveBackup project:  
#
#                     http://livebackup.sourceforge.net/
#
# Copyright 2006-2010 by Wolfgang Rohrmoser <info@rohrmoser-engineering.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#


#
# Tell kernel where to find modprobe
#
if [ -x /sbin/modprobe ]; then
    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
else
    msg -w "warning: /sbin/modprobe not found"
fi


#
# check for single user mode
#
init_args=""
if [ "$(grep single /proc/cmdline)" ]; then
    init_args="s"
fi

#
# ensure that we are in root directory
#
cd /

#
# continue linux boot procedure
#
if [ "$$" -eq 1 ]; then

    # if linuxrc has pid=1 this process can continue as init
    # you may need init=linuxrc ram=/dev/ram0 as boot parameters

    if [ -x /usr/sbin/chroot ]; then
	msg -i "starting init (chroot) ..."
	exec /usr/sbin/chroot . /sbin/init $init_args < dev/console > dev/console 2>&1
    elif [ -x /sbin/init ]; then
	msg -i "starting init ..."
	exec /sbin/init $init_args < dev/console > dev/console 2>&1
    else
        rescue_shell "FATAL: cannot execute /sbin/init"
    fi

else

    msg -i "booting with root device $MAJOR $MINOR"
    printf 0x%x%.2x $MAJOR $MINOR > /proc/sys/kernel/real-root-dev

fi

#
# the end ...  
#
exit 0


#
# Local Variables: 
# mode: shell-script
# End: 
#
