Annotation of elwix/config/etc/default/rc.init, revision 1.3.4.1
1.1 misho 1: #!/bin/sh
2: #
3: # Boot startup script for elwix :)
4: #
1.3.4.1 ! misho 5: # $Id: rc.init,v 1.3 2013/08/05 13:10:17 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: XML="/etc/config.xml"
24:
1.2 misho 25: MGMT_VLAN="4093"
26: MGMT_NAME="mgmt"
27: MGMT_ADDR="10.254.254.254/30"
28:
1.1 misho 29: umask 022
30:
31: boot()
32: {
33: echo "Check and mount filesystems ..."
34: fsck -y 1>/dev/null 2>&1 && mount -a || fsck -f -y
35:
36: echo "Loading elwix firmware variables ..."
37: cd /elwix/altroot
38: pax -rw -pe var /
39: chmod 1777 /var/tmp
40: cd /
41: }
42:
43: options()
44: {
45: echo "Set firmware options ..." | tee -a $BOOTLOG
46: [ -x /etc/sysctl.conf ] && /etc/sysctl.conf | tee -a $BOOTLOG
47: }
48:
49: passwd()
50: {
51: echo "Syncing password database ..." | tee -a $BOOTLOG
52: pwd_mkdb /etc/master.passwd | tee -a $BOOTLOG 1>/dev/null 2>&1
53: rm -f /etc/nologin
54: }
55:
56: local()
57: {
58: echo "Configurate localhost ..." | tee -a $BOOTLOG
59: ifconfig lo0 127.0.0.1 | tee -a $BOOTLOG 1>/dev/null 2>&1
60: hostname `cat /etc/myname`
1.2 misho 61: if [ -x /usr/bin/xmler ]; then
62: hostname `xmler -g /elwix/system/hostname $XML`
63: domainname `xmler -g /elwix/system/domain $XML`
64: fi
1.1 misho 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.3.4.1 ! 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
171: echo "elwix>>> Start system boot stage at `date`" | tee $BOOTLOG
172: options
173: passwd
174: local
175: mgmt
176: syspkg
177: service
178: echo "elwix>>> Start local services:" | tee -a $BOOTLOG
179: [ -r /etc/rc.local ] && . /etc/rc.local
180: echo "elwix>>> Done." | tee -a $BOOTLOG
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>