Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/boot/rc -m /boot/rcmain
2
# boot script for file servers, including standalone ones
3
path=(/boot /$cputype/bin /rc/bin .)
4
fn diskparts {
5
	# set up any /dev/sd partitions
6
	for(disk in /dev/sd*) {
7
		if(test -f $disk/data && test -f $disk/ctl)
8
			fdisk -p $disk/data >$disk/ctl >[2]/dev/null
9
		if(test -f $disk/plan9)
10
			parts=($disk/plan9*)
11
		if not
12
			parts=($disk/data)
13
		for(part in $parts)
14
			if(test -f $part)
15
				prep -p $part >$disk/ctl >[2]/dev/null
16
	}
17
}
18
 
19
cd /boot
20
echo -n boot...
21
if (! test -e /env/vmpc)
22
	vmpc=23			# % of free memory for venti
23
cp '#r/rtc' '#c/time'
24
bind -a '#I0' /net
25
bind -a '#l0' /net
26
bind -a '#¤' /dev
27
bind -a '#S' /dev
28
bind -a '#k' /dev
29
bind -a '#æ' /dev
30
bind -a '#u' /dev
31
bind '#p' /proc
32
bind '#d' /fd
33
bind -c '#s' /srv
34
# bind -a /boot /
35
 
36
# start usb for keyboard, disks, etc.
37
if (test -e /dev/usb/ctl) {
38
	echo -n usb...
39
	usbd
40
}
41
 
42
echo -n disks...
43
if(! ~ $dmaon no)
44
	for (ctl in /dev/sd[C-H]?/ctl)
45
		if (test -e $ctl)
46
			echo 'dma on' >$ctl
47
 
48
diskparts
49
 
50
# set up any fs(3) partitions (HACK)
51
# don't match AoE disks, as those may be shared.
52
if (test ! -e /env/fscfg)
53
	fscfg=`{ls -d /dev/sd[~e-h]?/fscfg >[2]/dev/null | sed 1q}
54
if (~ $#fscfg 1 && test -r $fscfg)
55
	zerotrunc <$fscfg | read -m >/dev/fs/ctl
56
 
57
# figure out which arenas and fossil partitions to use.
58
# don't match AoE disks, as those may be shared.
59
if(! test -e /env/arena0){
60
	if (test -e	/dev/fs/arena0)
61
		arena0=	/dev/fs/arena0
62
	if not if (test -e	/dev/sd[~e-h]?/arena0)
63
		arena0=		/dev/sd[~e-h]?/arena0
64
	if not
65
		arena0=/dev/null
66
}
67
if (test -e	/dev/fs/fossil)
68
	fossil=	/dev/fs/fossil
69
if not if (test -e	/dev/sd[~e-h]?/fossil)
70
	fossil=		/dev/sd[~e-h]?/fossil
71
if not
72
	fossil=/dev/null
73
 
74
#
75
# the local disks are now sorted out.
76
# set up the network, auth, venti and fossil.
77
#
78
 
79
echo -n ip...
80
if (~ $#ip 1 && ! ~ $ip '') {
81
	# need to supply ip, ipmask and ipgw in plan9.ini to use this
82
	ipconfig -g $ipgw ether /net/ether0 $ip $ipmask
83
	echo 'add 0 0 '^$ipgw >>/net/iproute
84
}
85
if not
86
	ipconfig
87
# if outside, add explicit vfw routing to the inside
88
switch (`{sed '/\.(0|255)[	 ]/d' /net/ipselftab}) {
89
case 135.104.24.*				# new outside
90
	echo 'add 135.104.9.0 255.255.255.0 135.104.24.13' >>/net/iproute
91
}
92
ipconfig loopback /dev/null 127.1
93
 
94
# local hackery: add extra sr luns of shelf 1
95
if (test -e /dev/aoe/1.1 && ! test -e /dev/sdf0)
96
	echo config switch on spec f type aoe//dev/aoe/1.1 >/dev/sdctl
97
if (test -e /dev/aoe/1.2 && ! test -e /dev/sdg0)
98
	echo config switch on spec g type aoe//dev/aoe/1.2 >/dev/sdctl
99
diskparts
100
 
101
# so far we're using the default key from $nvram, usually
102
# for insideout.plan9.bell-labs.com on outside machines,
103
# and have mounted our root over the net, if running diskless.
104
# factotum always mounts itself (on /mnt by default).
105
 
106
echo -n factotum...
107
if(~ $#auth 1){
108
	echo start factotum on $auth
109
	factotum -sfactotum -S -a $auth
110
}
111
if not
112
	factotum -sfactotum -S
113
mount -b /srv/factotum /mnt
114
 
115
# if a keys partition exists, add its contents to factotum's
116
keys=`{ls -d /dev/sd*/keys >[2]/dev/null | sed 1q}
117
if (~ $#keys 1 && test -r $keys) {
118
	echo -n add keys...
119
	zerotrunc <$keys | aescbc -n -d | read -m >/mnt/factotum/ctl
120
}
121
 
122
# get root from network if fsaddr set in plan9.ini, and bail out here
123
if (test -e /env/fs) {
124
	echo -n fs root...
125
	if(! srv tcp!$fs!564 boot)
126
		exec ./rc -m/boot/rcmain -i
127
	if(! mount -c /srv/boot /root)
128
		exec ./rc -m/boot/rcmain -i
129
}
130
 
131
# start venti store
132
if (! ~ $arena0 /dev/null && test -r $arena0) {
133
	echo -n start venti on $arena0...
134
	venti=tcp!127.0.0.1!17034
135
	vcfg=`{ls -d /dev/sd*/venticfg >[2]/dev/null | sed 1q}
136
	if (~ $#vcfg 1 && test -r $vcfg)
137
		venti -m $vmpc -c $vcfg
138
	if not
139
		venti -m $vmpc -c $arena0
140
	sleep 10
141
}
142
if not if (! test -e /env/venti)
143
	venti=tcp!135.104.9.33!17034		# local default
144
 
145
# start root fossil, may serve /srv/boot
146
if (! ~ $fossil /dev/null && test -r $fossil) {
147
	echo -n root fossil on $fossil...
148
	fossil -m 2 -f $fossil
149
	sleep 3
150
}
151
 
152
#
153
# normal start up on local fossil root
154
#
155
 
156
rootdir=/root
157
rootspec=main/active
158
 
159
# factotum is now mounted in /mnt; keep it visible.
160
# newns() needs it, among others.
161
 
162
# mount new root
163
if (test -e /srv/boot)
164
	srv=boot
165
if not if (test -e /srv/fossil)
166
	srv=fossil
167
if not if (test -e /srv/fsmain)
168
	srv=fsmain
169
if not {
170
	echo cannot find a root in /srv:
171
	ls -l /srv
172
}
173
echo -n mount -cC /srv/$srv $rootdir...
174
	mount -cC /srv/$srv $rootdir
175
bind -a $rootdir /
176
 
177
if (test -d $rootdir/mnt)
178
	bind -ac $rootdir/mnt /mnt
179
mount -b /srv/factotum /mnt
180
 
181
# standard bin
182
if (! test -d /$cputype) {
183
	echo /$cputype missing!
184
	exec ./rc -m/boot/rcmain -i
185
}
186
bind /$cputype/bin /bin
187
bind -a /rc/bin /bin
188
 
189
# run cpurc
190
echo cpurc...
191
path=(/bin . /boot)
192
/$cputype/init -c
193
 
194
exec ./rc -m/boot/rcmain -i