#!/bin/ash
# /linuxrc: started by the kernel via initrd. 
# Allowd Kernel switches: 
#	f1722, f1440, loop=/dev/..., usr= 
# When /linuxrc terminates, the "real"
# root file system is mounted (what is that?)
#

export PATH=/bin:/sbin:/usr/bin:

. /etc/color
. /etc/utils

echo -e "$BRIGHT$CYAN"
echo "MicroSoft? is that some kind of a toilet paper?"
echo -e "$NORMAL"
[ -x /bin/sleep ] && sleep 2 

(
mount /proc
) 2>/dev/null

#----------------
# sys info
#----------------

# mem info
MIN=5242880
MEM=$(ram_total)
[ "$MEM" -le "$MIN" ] && lowmem=yes
set -- `cat /proc/cpuinfo`
export CPU=$6

# cpu info
echo "Ram             : $MEM bytes"
echo "Cpu             : $CPU"
cat /proc/cpuinfo | rgrep model 
cat /proc/cpuinfo | rgrep vendor 
cat /proc/cpuinfo | rgrep bogomips
echo 


#------------
# LOW MEMORY !
#-------------

if [ "$lowmem" = yes ]  ; then
        . /etc/rc/lowmem
	# no return!
fi

. /etc/rc/mount_root

#-------------------------
# parse kernel parameters
#-------------------------

SplitArgs `cat /proc/cmdline`

#------------------------
# mount startup partition
#------------------------

. /etc/rc/startup

#-----------------
# MAIN switch 
#-----------------

if [ "$dosinstall" ] ; then 
        # DOS installation
	sleep 2
	#[ "$rescue" ] && . /etc/rc/rescue
	cd /; umount /startup 2>/dev/null
        . /etc/rc/dosinstall
	# no return
elif [ "$loop" ] ; then
	[ "$loop" = true ] && loop=
	# loop muLinux 
	DEVICE=$loop
	echo "Try mount $DEVICE"
	mkdir -p /loop
	mount -o defaults $DEVICE /loop && echo "mount OK"
	losetup /dev/loop0 /loop/linux/mulinux.img
	exit 0
elif [ "$usr" ] ; then
	# ElTorito and ZIP muLinux
	. /etc/rc/mount_usr
fi


# load last-saved profile 

if setup -R; then
	rm -f /etc/first_boot
else
	> /etc/first_boot
fi

> /var/tmp/setup_reloaded

# need nfs-root?

[ -f /setup/cnf/nfs.cnf ] && . /setup/cnf/nfs.cnf

#--------------
# Main menu
#--------------

if [ "$NFS_ROOT" ] ; then 
	. /etc/rc/prep-nfs
else
	echo 0x0100 > /proc/sys/kernel/real-root-dev
fi

umount /proc

# mount real-root now!
