#!/bin/bash
echo "=========mounting proc"
if [ -e /execute_cmds ] ; then
	/bin/mount /proc
fi
echo "=========insmod raid"
if [ -e /execute_cmds ] ; then
	/sbin/insmod md
	/sbin/insmod raid1
	/sbin/insmod raid0
fi
echo "=========starting devfs"
if [ -e /execute_cmds ] ; then
	/sbin/devfsd /dev -np
fi
for dodev in md199 md200; do
	allok=t
	echo "=========starting raid device ${dodev}"
	if [ -e /execute_cmds ] ; then
		success=f
		for adrive in hda hdb hdc hdd ; do
			if /sbin/raidstart --configfile /boot/raidtab.${adrive} /dev/${dodev} ; then
				echo "=========starting raid device ${dodev} success with drive ${adrive} as first in list"
				success=t
				break;
			fi
		done
		if [ "${success}" == "f" ] ; then
			allok=f
		fi
	fi
done
if [ "${allok}" == "f" ] ; then
	echo "=========raidstart failed...shelling out"
	/bin/bash
fi
echo "=========printing mdstat"
if [ -e /execute_cmds ] ; then
	/bin/cat /proc/mdstat
fi
if [ -e /doshell ] ; then
	echo "=========starting debug shell"
	/bin/bash
fi
echo "=========starting debug shell"
/bin/bash
echo "=========setting kernel root dev to 0x9C8"
if [ -e /execute_pivot ] ; then
	echo 0x9C8 > /proc/sys/kernel/real-root-dev
fi
echo "=========unmounting proc"
if [ -e /execute_cmds ] ; then
	/bin/umount /proc
fi
