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