Annotation of elwix/config/etc/default/rc.init, revision 1.6.2.3
1.1 misho 1: #!/bin/sh
2: #
3: # Boot startup script for elwix :)
4: #
1.6.2.3 ! misho 5: # $Id: rc.init,v 1.6.2.2 2017/06/16 09:33:27 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.3 misho 21: SYSPKGDIR="/var/frm"
1.1 misho 22: BOOTLOG="/var/run/elwix.boot"
23:
1.2 misho 24: MGMT_VLAN="4093"
25: MGMT_NAME="mgmt"
26: MGMT_ADDR="10.254.254.254/30"
27:
1.1 misho 28: umask 022
29:
30: boot()
31: {
1.6 misho 32: echo "Loading ELWIX configz ..."
1.1 misho 33: cd /elwix/altroot
34: pax -rw -pe var /
35: chmod 1777 /var/tmp
1.6.2.3 ! misho 36: # mount -tunionfs -onoatime /var/db/etc /elwix/etc
1.6.2.2 misho 37: mount -ttmpfs tmpfs /var/db/pkg
1.1 misho 38: cd /
39: }
40:
1.5 misho 41: restore_uboot()
42: {
1.6 misho 43: echo "Restore configz from NAND ..."
1.6.2.3 ! misho 44: cfexec /etc/rc.cfg load /etc
1.5 misho 45: }
46:
1.1 misho 47: options()
48: {
49: echo "Set firmware options ..." | tee -a $BOOTLOG
50: [ -x /etc/sysctl.conf ] && /etc/sysctl.conf | tee -a $BOOTLOG
51: }
52:
53: passwd()
54: {
55: echo "Syncing password database ..." | tee -a $BOOTLOG
1.6.2.3 ! misho 56: cfexec pwd_mkdb /etc/master.passwd | tee -a $BOOTLOG 1>/dev/null 2>&1
1.1 misho 57: rm -f /etc/nologin
58: }
59:
60: local()
61: {
62: echo "Configurate localhost ..." | tee -a $BOOTLOG
63: ifconfig lo0 127.0.0.1 | tee -a $BOOTLOG 1>/dev/null 2>&1
64: hostname `cat /etc/myname`
65: }
66:
67: geteth()
68: {
69: ifconfig -a -u | awk '
70: (match($0, "[:alpha:]*\: ") && match($2, "flags=")) { eth = substr($1, 1, index($1, ":") - 1); next; };
71: (match($0, "media:\ Ethernet")) { printf("%s\n", eth); };
72: ' | head -1
73: }
74:
75: mgmt()
76: {
77: [ -r /etc/mylan ] && VDEV=`cat /etc/mylan`
1.2 misho 78: if [ -x /usr/bin/get1steth ]; then
79: VDEV=${VDEV:-`get1steth -g`}
80:
81: get1steth -v $VDEV | tee -a $BOOTLOG 1>/dev/null 2>&1
82: else
83: VDEV=${VDEV:-`geteth`}
1.4 misho 84: ifconfig $VDEV up
1.2 misho 85: ifconfig vlan$MGMT_VLAN create vlan $MGMT_VLAN vlandev $VDEV
86: ifconfig vlan$MGMT_VLAN name $MGMT_NAME
87: ifconfig $MGMT_NAME inet $MGMT_ADDR
88: fi
1.1 misho 89:
90: echo "Configurete management interface to ($VDEV) ..." | tee -a $BOOTLOG
91: }
92:
93: syspkg()
94: {
95: echo "Setup elwix dynamic link libraries ..."
96: ldconfig /etc/ld.so.conf
97:
98: echo "Mounting firmware system packages:" | tee -a $BOOTLOG
99: # Raw images
1.3 misho 100: for i in /elwix/cf/*-pkg.frm; do
1.1 misho 101: if [ -r $i ]; then
102: MDDEV=$(mdconfig -a -t vnode -f $i);
103: install -d $SYSPKGDIR/$MDDEV;
104: mount -r /dev/$MDDEV $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1;
105: if [ $? -ne 0 ]; then
106: mdconfig -d -u $MDDEV;
107: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG;
108: continue
109: else
110: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG;
111: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin
112: export PATH
113:
114: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \
115: tee -a $BOOTLOG 1>/dev/null 2>&1;
116:
117: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys;
118: fi
119: fi
120: done
121: # UZIP images
1.3 misho 122: for i in /elwix/cf/*-pkg.frz; do
1.1 misho 123: if [ -r $i ]; then
124: MDDEV=$(mdconfig -a -t vnode -f $i);
125: install -d $SYSPKGDIR/$MDDEV;
126: mount -r /dev/$MDDEV.uzip $SYSPKGDIR/$MDDEV | tee -a $BOOTLOG 1>/dev/null 2>&1;
127: if [ $? -ne 0 ]; then
128: mdconfig -d -u $MDDEV;
129: echo "Failed mount system package $i ... Corrupted!" | tee -a $BOOTLOG;
130: continue
131: else
132: echo "Added firmware system package ... $i($?)" | tee -a $BOOTLOG;
133: PATH=$PATH:$SYSPKGDIR/$MDDEV/bin:$SYSPKGDIR/$MDDEV/sbin
134: export PATH
135:
136: [ -d $SYSPKGDIR/$MDDEV/lib ] && ldconfig -v -m $SYSPKGDIR/$MDDEV/lib | \
137: tee -a $BOOTLOG 1>/dev/null 2>&1;
138:
139: [ -x $SYSPKGDIR/$MDDEV/.pkg2sys ] && $SYSPKGDIR/$MDDEV/.pkg2sys;
140: fi
141: fi
142: done
143: }
144:
145: service()
146: {
147: echo "Starting distribution static services:" | tee -a $BOOTLOG
148: for i in /etc/rc.d/*.run; do
149: if [ -x $i ]; then
150: $i
151: fi
152: done
153:
154: if [ -d /etc/rc.S ]; then
155: echo "Select boot service directory ..." `readlink /etc/rc.S` | tee -a $BOOTLOG
156:
157: echo "Starting distribution services:" | tee -a $BOOTLOG
158: for i in /etc/rc.S/*.run; do
159: if [ -x $i ]; then
160: $i
161: fi
162: done
163: fi
164: }
165:
166: #
167: ## main()
168: #
169:
170: boot
1.5 misho 171: restore_uboot
1.1 misho 172: echo "elwix>>> Start system boot stage at `date`" | tee $BOOTLOG
173: options
174: passwd
175: local
176: mgmt
177: syspkg
178: service
179: echo "elwix>>> Start local services:" | tee -a $BOOTLOG
180: [ -r /etc/rc.local ] && . /etc/rc.local
181: echo "elwix>>> Done." | tee -a $BOOTLOG
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>