#!/bin/sh
#
# Boot startup script for ELWIX RootFS ...
#
# $Id: rc,v 1.7.2.7 2018/07/06 00:23:20 misho Exp $
stty status '^T'
trap : 2
trap : 3
trap : 18
HOME=/root
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin
TERM=xterm
BLOCKSIZE=1k
EDITOR=vi
PAGER=less
export HOME PATH TERM BLOCKSIZE EDITOR PAGER
ETCDEV="md1"
ETCSIZE="8m"
VARDEV="md2"
VARSIZE="16m"
FRMDEV="md3"
FRMSIZE="48m"
FRMFILE="elwix-firmware.sys"
FRMDEV2="md4"
FRMSIZE2="24m"
FRMFILE2="elwix-firmware2.sys"
FRMPATH="/elwix"
FRM2PATH="/elwix/pkg"
FIT2CF="/dev/ufs/fit2cf"
CFDIR="/elwix/cf"
ELWIX2="/dev/ufs/elwix2"
ELWIX="/dev/ufs/elwix"
umask 022
failed_sysvol()
{
echo " RootFS: Failed $1 - $2 ... Go to emergency shell !!!"
exit 127
}
boot_elwix()
{
echo " RootFS: Loading ELWIX system firmware"
mdmfs -s $FRMSIZE -S -n -m0 -oasync $FRMDEV /usr
if [ "$?" != "0" ]; then
failed_sysvol "to mount firmware image " $FRMFILE
fi
cd /usr
pax -r -z -pe -f $FRMPATH/$FRMFILE
if [ "$?" != "0" ]; then
failed_sysvol "to load firmware image " $FRMFILE
fi
cd -
mount -ur /usr
}
boot_elwix2()
{
echo " RootFS: Loading ELWIX secondary firmware"
mdmfs -s $FRMSIZE2 -S -n -m0 -oasync $FRMDEV2 $FRM2PATH
if [ "$?" != "0" ]; then
failed_sysvol "to mount firmware image " $FRMFILE2
fi
cd $FRM2PATH
pax -r -z -pe -f $FRMPATH/$FRMFILE2
if [ "$?" != "0" ]; then
failed_sysvol "to load firmware image " $FRMFILE2
fi
cd -
mount -ur $FRM2PATH
}
mount_usr()
{
echo " RootFS: Mounting ELWIX system image"
mount -t nullfs -r $FRMPATH/usr /usr
if [ "$?" != "0" ]; then
failed_sysvol "to mount system image " $FRMFILE
fi
}
#
## main()
#
echo "ELWIX>>> Firmware RootFS boot stage ..."
mount -ttmpfs tmpfs /tmp
mdmfs -s $VARSIZE -S -n $VARDEV /var
if test -c $ELWIX2; then
BOOTSLICE=`kenv currdev`
if test "${BOOTSLICE#disk0}" != "a:"; then
ELWIX=$ELWIX2
fi
fi
if ! mount -o ro $ELWIX $FRMPATH 1>/dev/null 2>&1; then
umount $FRMPATH 1>/dev/null 2>&1
fsck -y $ELWIX 1>/dev/null 2>&1
if ! mount -o ro $ELWIX $FRMPATH 1>/dev/null 2>&1; then
umount -f $FRMPATH 1>/dev/null 2>&1
fsck -f -y $ELWIX 1>/dev/null 2>&1
if ! mount -o ro $ELWIX $FRMPATH; then
failed_sysvol mount "storage volume"
fi
fi
fi
if test -c "$FIT2CF" -a -d "$CFDIR"; then
echo " RootFS: Mount ELWIX flash volume"
if ! mount -o ro $FIT2CF $CFDIR; then
umount $CFDIR
fsck -y -tufs $FIT2CF 1>/dev/null 2>&1
if ! mount -o ro $FIT2CF $CFDIR; then
echo "Error:: mount of $FIT2CF to $CFDIR failed!"
fi
fi
fi
if [ -r $FRMPATH/$FRMFILE ]; then
boot_elwix
else
if [ -d $FRMPATH/usr ]; then
mount_usr
else
echo " RootFS: Skip loading ELWIX system firmware ..."
fi
fi
if [ -r $FRMPATH/$FRMFILE2 ]; then
boot_elwix2
fi
cd /elwix
mdmfs -s $ETCSIZE -S -n -m0 -oasync $ETCDEV /etc
pax -rw -pe etc /
exec /etc/rc.init
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>