#!/bin/sh
#
# Boot startup script for ELWIX BaseFS ...
#
# $Id: rc,v 1.4 2021/03/11 13:59:50 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"
FRMDEV2="md4"
FRMSIZE2="32m"
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 " BaseFS: Failed $1 - $2 ... Go to emergency shell !!!"
exit 127
}
boot_elwix2()
{
echo " BaseFS: Loading ELWIX secondary firmware"
mdmfs -s $FRMSIZE2 -S -n -m0 -oasync $FRMDEV2 $FRM2PATH
if test $? -ne 0; then
failed_sysvol "to mount firmware image " $FRMFILE2
fi
cd $FRM2PATH
pax -r -z -pe -f $FRMPATH/$FRMFILE2
if test $? -ne 0; then
failed_sysvol "to load firmware image " $FRMFILE2
fi
cd -
mount -ur $FRM2PATH
}
#
## main()
#
echo "ELWIX>>> Firmware BaseFS boot stage ..."
if ! mount -a; then
umount -A
fsck -y 1>/dev/null 2>&1
if ! mount -a; then
umount -A -f
fsck -f -y 1>/dev/null 2>&1
if ! mount -a; then
failed_sysvol mount "system volumes"
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 test -r "$FRMPATH/$FRMFILE2"; then
boot_elwix2
fi
mkdir /var/etc
mount -tunionfs /var/etc /etc
exec /etc/rc.init
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>