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