Annotation of elwix/config/etc/rootfs/rc, revision 1.7.2.6
1.1 misho 1: #!/bin/sh
2: #
3: # Boot startup script for ELWIX RootFS ...
4: #
1.7.2.6 ! misho 5: # $Id: rc,v 1.7.2.5 2017/10/08 01:38: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.7.2.6 ! misho 25: FRMSIZE="48m"
1.2 misho 26: FRMFILE="elwix-firmware.sys"
27:
1.7.2.2 misho 28: FRMDEV2="md4"
1.7.2.6 ! misho 29: FRMSIZE2="24m"
1.2 misho 30: FRMFILE2="elwix-firmware2.sys"
31:
32: FRMPATH="/elwix"
1.7.2.5 misho 33: FRM2PATH="/elwix/pkg"
1.2 misho 34: FIT2CF="/dev/ufs/fit2cf"
35: CFDIR="/elwix/cf"
36:
1.7.2.3 misho 37: ELWIX2="/dev/ufs/elwix2"
1.7.2.4 misho 38: ELWIX="/dev/ufs/elwix"
1.7.2.3 misho 39:
1.1 misho 40: umask 022
41:
42: failed_sysvol()
43: {
1.2 misho 44: echo " RootFS: Failed $1 - $2 ... Go to emergency shell !!!"
1.1 misho 45:
46: exit 127
47: }
48:
49: boot_elwix()
50: {
1.2 misho 51: echo " RootFS: Loading ELWIX system firmware"
52:
1.7.2.2 misho 53: mdmfs -s $FRMSIZE -S -n -m0 -oasync $FRMDEV /usr
1.2 misho 54: if [ "$?" != "0" ]; then
55: failed_sysvol "to mount firmware image " $FRMFILE
1.1 misho 56: fi
1.2 misho 57: cd /usr
58: pax -r -z -pe -f $FRMPATH/$FRMFILE
59: if [ "$?" != "0" ]; then
60: failed_sysvol "to load firmware image " $FRMFILE
61: fi
62: cd -
63: mount -ur /usr
64: }
1.1 misho 65:
1.2 misho 66: boot_elwix2()
67: {
68: echo " RootFS: Loading ELWIX secondary firmware"
69:
1.7.2.5 misho 70: mdmfs -s $FRMSIZE2 -S -n -m0 -oasync $FRMDEV2 $FRM2PATH
1.2 misho 71: if [ "$?" != "0" ]; then
72: failed_sysvol "to mount firmware image " $FRMFILE2
73: fi
1.7.2.5 misho 74: cd $FRM2PATH
1.2 misho 75: pax -r -z -pe -f $FRMPATH/$FRMFILE2
76: if [ "$?" != "0" ]; then
77: failed_sysvol "to load firmware image " $FRMFILE2
78: fi
79: cd -
1.7.2.5 misho 80: mount -ur $FRM2PATH
1.2 misho 81: }
82:
83: mount_usr()
84: {
85: echo " RootFS: Mounting ELWIX system image"
86:
87: mount -t nullfs -r $FRMPATH/usr /usr
88: if [ "$?" != "0" ]; then
89: failed_sysvol "to mount system image " $FRMFILE
90: fi
1.1 misho 91: }
92:
93: #
94: ## main()
95: #
96:
97: echo "ELWIX>>> Firmware RootFS boot stage ..."
1.7 misho 98:
1.7.2.3 misho 99: if test -c $ELWIX2; then
100: BOOTSLICE=`kenv currdev`
101: if test "${BOOTSLICE#disk0}" != "a:"; then
1.7.2.4 misho 102: ELWIX=$ELWIX2
103: fi
104: fi
105:
106: if ! mount -o ro $ELWIX $FRMPATH; then
107: umount $FRMPATH
108: fsck -y $ELWIX 1>/dev/null 2>&1
109: if ! mount -o ro $ELWIX $FRMPATH; then
110: umount -f $FRMPATH
111: fsck -f -y $ELWIX 1>/dev/null 2>&1
112: if ! mount -o ro $ELWIX $FRMPATH; then
113: failed_sysvol mount "system volume"
114: fi
1.7.2.3 misho 115: fi
116: fi
117:
1.7 misho 118: if ! mount -a; then
119: umount -A
120: fsck -y 1>/dev/null 2>&1
121: if ! mount -a; then
122: umount -A -f
123: fsck -f -y 1>/dev/null 2>&1
124: if ! mount -a; then
125: failed_sysvol mount "system volume"
126: fi
127: fi
128: fi
1.2 misho 129:
1.4 misho 130: if test -c "$FIT2CF" -a -d "$CFDIR"; then
1.2 misho 131: echo " RootFS: Mount ELWIX flash volume"
1.7.2.4 misho 132: if ! mount -o ro $FIT2CF $CFDIR; then
133: umount $CFDIR
134: fsck -y -tufs $FIT2CF 1>/dev/null 2>&1
135: if ! mount -o ro $FIT2CF $CFDIR; then
136: echo "Error:: mount of $FIT2CF to $CFDIR failed!"
137: fi
138: fi
1.2 misho 139: fi
140:
141: if [ -r $FRMPATH/$FRMFILE ]; then
142: boot_elwix
143: else
144: if [ -d $FRMPATH/usr ]; then
145: mount_usr
146: else
147: echo " RootFS: Skip loading ELWIX system firmware ..."
148: fi
149: fi
1.1 misho 150:
1.2 misho 151: if [ -r $FRMPATH/$FRMFILE2 ]; then
152: boot_elwix2
153: fi
1.7.2.2 misho 154:
155: cd /elwix
156: mdmfs -s $ETCSIZE -S -n -m0 -oasync $ETCDEV /etc
157: pax -rw -pe etc /
1.1 misho 158:
1.2 misho 159: exec /etc/rc.init
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>