Annotation of elwix/config/etc/rootfs/rc, revision 1.7.2.3
1.1 misho 1: #!/bin/sh
2: #
3: # Boot startup script for ELWIX RootFS ...
4: #
1.7.2.3 ! misho 5: # $Id: rc,v 1.7.2.2 2017/06/19 20:26:48 misho Exp $
1.1 misho 6:
7: stty status '^T'
8:
9: trap : 2
10: trap : 3
11: trap : 18
12:
13: HOME=/root
14: PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin
15: TERM=xterm
16: BLOCKSIZE=1k
17: EDITOR=vi
18: PAGER=less
19: export HOME PATH TERM BLOCKSIZE EDITOR PAGER
20:
1.7.2.2 misho 21: ETCDEV="md1"
22: ETCSIZE="8m"
23:
24: FRMDEV="md3"
1.6 misho 25: FRMSIZE="42m"
1.2 misho 26: FRMFILE="elwix-firmware.sys"
27:
1.7.2.2 misho 28: FRMDEV2="md4"
1.3 misho 29: FRMSIZE2="21m"
1.2 misho 30: FRMFILE2="elwix-firmware2.sys"
31:
32: FRMPATH="/elwix"
33: FIT2CF="/dev/ufs/fit2cf"
34: CFDIR="/elwix/cf"
35:
1.7.2.3 ! misho 36: ELWIX2="/dev/ufs/elwix2"
! 37:
1.1 misho 38: umask 022
39:
40: failed_sysvol()
41: {
1.2 misho 42: echo " RootFS: Failed $1 - $2 ... Go to emergency shell !!!"
1.1 misho 43:
44: exit 127
45: }
46:
47: boot_elwix()
48: {
1.2 misho 49: echo " RootFS: Loading ELWIX system firmware"
50:
1.7.2.2 misho 51: mdmfs -s $FRMSIZE -S -n -m0 -oasync $FRMDEV /usr
1.2 misho 52: if [ "$?" != "0" ]; then
53: failed_sysvol "to mount firmware image " $FRMFILE
1.1 misho 54: fi
1.2 misho 55: cd /usr
56: pax -r -z -pe -f $FRMPATH/$FRMFILE
57: if [ "$?" != "0" ]; then
58: failed_sysvol "to load firmware image " $FRMFILE
59: fi
60: cd -
61: mount -ur /usr
62: }
1.1 misho 63:
1.2 misho 64: boot_elwix2()
65: {
66: echo " RootFS: Loading ELWIX secondary firmware"
67:
1.7.2.2 misho 68: mdmfs -s $FRMSIZE2 -S -n -m0 -oasync $FRMDEV2 /elwix/pkg
1.2 misho 69: if [ "$?" != "0" ]; then
70: failed_sysvol "to mount firmware image " $FRMFILE2
71: fi
1.7.2.1 misho 72: cd /elwix/pkg
1.2 misho 73: pax -r -z -pe -f $FRMPATH/$FRMFILE2
74: if [ "$?" != "0" ]; then
75: failed_sysvol "to load firmware image " $FRMFILE2
76: fi
77: cd -
1.7.2.1 misho 78: mount -ur /elwix/pkg
1.2 misho 79: }
80:
81: mount_usr()
82: {
83: echo " RootFS: Mounting ELWIX system image"
84:
85: mount -t nullfs -r $FRMPATH/usr /usr
86: if [ "$?" != "0" ]; then
87: failed_sysvol "to mount system image " $FRMFILE
88: fi
1.1 misho 89: }
90:
91: #
92: ## main()
93: #
94:
95: echo "ELWIX>>> Firmware RootFS boot stage ..."
1.7 misho 96:
1.7.2.3 ! misho 97: if test -c $ELWIX2; then
! 98: BOOTSLICE=`kenv currdev`
! 99: if test "${BOOTSLICE#disk0}" != "a:"; then
! 100: mount -o ro $ELWIX2 /
! 101: else
! 102: mount /
! 103: fi
! 104: else
! 105: mount /
! 106: fi
! 107:
1.7 misho 108: if ! mount -a; then
109: umount -A
110: fsck -y 1>/dev/null 2>&1
111: if ! mount -a; then
112: umount -A -f
113: fsck -f -y 1>/dev/null 2>&1
114: if ! mount -a; then
115: failed_sysvol mount "system volume"
116: fi
117: fi
118: fi
1.2 misho 119:
1.4 misho 120: if test -c "$FIT2CF" -a -d "$CFDIR"; then
1.2 misho 121: echo " RootFS: Mount ELWIX flash volume"
1.7.2.3 ! misho 122: mount -o ro $FIT2CF $CFDIR || \
! 123: fsck -y -tufs $FIT2CF 1>/dev/null 2>&1 && mount -o ro $FIT2CF $CFDIR || \
1.2 misho 124: failed_sysvol mount "flash volume"
125: fi
126:
127: if [ -r $FRMPATH/$FRMFILE ]; then
128: boot_elwix
129: else
130: if [ -d $FRMPATH/usr ]; then
131: mount_usr
132: else
133: echo " RootFS: Skip loading ELWIX system firmware ..."
134: fi
135: fi
1.1 misho 136:
1.2 misho 137: if [ -r $FRMPATH/$FRMFILE2 ]; then
138: boot_elwix2
139: fi
1.7.2.2 misho 140:
141: cd /elwix
142: mdmfs -s $ETCSIZE -S -n -m0 -oasync $ETCDEV /etc
143: pax -rw -pe etc /
1.1 misho 144:
1.2 misho 145: exec /etc/rc.init
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>