blob: 8d171a1ccf8365e270c97fbce4cee32af4195dab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#!/bin/rc
# prereq: mountfs configdist
# desc: locate and mount the distribution
fn domount{
if(! test -e $mountmedia(2))
logprog $srvmedia
unmount /n/distmedia >[2]/dev/null
logprog $mountmedia
}
fn exitifdone{
if(test -f /n/dist/dist/replica/plan9.db)
exit
}
fn trycdimage{
if(test -f $1){
rm -f /srv/9660.dist
unmount /n/dist
9660srv 9660.dist >[2]/dev/null
logprog mount /srv/9660.dist /n/dist $1
exitifdone
mountdist=notdone
export mountdist
exit notdone
}
}
fn trycdimagebz2 {
if(test -f $1){
echo -n 'bunzip2 < '^$1^' >/n/newfs/dist/plan9.iso'
bunzip2 < $1 >/n/newfs/dist/_plan9.iso &&
mv /n/newfs/dist/_plan9.iso /n/newfs/dist/plan9.iso
echo
trycdimage /n/newfs/dist/plan9.iso
mountdist=notdone
export mountdist
exit notdone
}
}
fn havedist {
test -f $1/dist/replica/plan9.db ||
test -f $1/plan9.iso ||
test -f $1/plan9.iso.bz2
}
switch($1){
case checkready
if(! ~ $distisfrom local && ! ~ $download done){
mountdist=notdone
export mountdist
}
if(! ~ $#mountmedia 0 1){
if(domount){
mountdist=done
export mountdist
if(mountdist checkdone)
exit
}
srvmedia=()
mountmedia=()
mountdist=ready
export srvmedia mountmedia mountdist
}
case go
fat=()
ext2=()
x9660=()
fossil=()
echo Please wait... Scanning storage devices...
parts=`{ls /dev/sd??/* >[2]/dev/null | grep -v '/(plan9.*|ctl|log|raw)$'}
for (i in $parts) {
echo -n ' '^$i
n=`{echo $i | sed 's;/;_;g'}
if(! test -f /tmp/localpart.$n)
dd -if $i -bs 2048 -count 32 -of /tmp/localpart.$n >[2]/dev/null
if(isfat /tmp/localpart.$n)
fat=($fat $i)
if(isext2 /tmp/localpart.$n)
ext2=($ext2 $i)
if(is9660 /tmp/localpart.$n)
x9660=($x9660 $i)
if(isfossil $i)
fossil=($fossil $i)
echo
}
echo
echo The following storage media were detected.
echo Choose the one containing the distribution.
echo
for(i in $parts){
switch($i){
case $fat
echo ' '^$i^' (microsoft fat)'
case $ext2
echo ' '^$i^' (linux ext2)'
case $x9660
echo ' '^$i^' (iso9660 cdrom)'
case $fossil
echo ' '^$i^' (plan9 fossil)'
}
}
echo
mountstatus=x
while(! ~ $mountstatus ''){
prompt -w '' 'Distribution disk' $fat $x9660 $fossil
disk=$rd
srvmedia=()
mountmedia=()
switch($disk){
case $fs
mountmedia=(bind /n/newfs /n/distmedia)
case $fat
srvmedia=(dossrv)
mountmedia=(mount /srv/dos /n/distmedia $disk)
case $ext2
srvmedia=(ext2srv -r)
mountmedia=(mount /srv/ext2 /n/distmedia $disk)
case $x9660
srvmedia=(9660srv)
mountmedia=(mount /srv/9660 /n/distmedia $disk)
case $fossil
echo 'srv fossil.mountdist' > /tmp/fossi.conf
echo 'fsys main config '^$disk >> /tmp/fossil.conf
echo 'fsys main open -AWVP' >> /tmp/fossil.conf
echo 'fsys main' >> /tmp/fossil.conf
srvmedia=(fossil/fossil -c '. /tmp/fossil.conf')
mountmedia=(mount /srv/fossil.mountdist /n/distmedia)
case *
echo Unknown disk type '(cannot happen)'
exit oops
}
export srvmedia mountmedia
domount
mountstatus=$status
}
first=yes
dir=/
while(~ $first yes || ! havedist /n/distmedia/$dir){
if(~ $first yes){
echo
echo Which directory contains the distribution?
echo 'Any of the following will suffice (in order of preference):'
echo ' - the root directory of the cd image'
echo ' - the directory containing plan9.iso'
echo ' - the directory containing plan9.iso.bz2'
echo 'Typing `browse'' will put you in a shell that you can use to'
echo 'look for the directory.'
echo
first=no
}
prompt -d browse 'Location of archives'
dir=$rd
if(~ $dir browse){
echo This is a simple shell. Commands are:
echo ' cd directory - change to directory'
echo ' lc - list contents of current directory'
echo ' exit - exit shell'
echo
echo 'Move to the directory containing the distribution'
echo 'and then exit.'
echo
oifs=$ifs
ifs=$nl
dir=`{cdsh -r /n/distmedia}
ifs=$oifs
}
if(~ $#dir 0)
dir=safdsfdsfdsf
if(! ~ $#dir 1)
dir=$"dir
if(! havedist /n/distmedia/$dir)
echo 'No distribution found in '^`{cleanname /$dir}
}
distmediadir=$dir
export distmediadir
case checkdone
if(! ~ $#distmediadir 1){
mountdist=notdone
export mountdist
exit notdone
}
if(! havedist /n/distmedia/$distmediadir && ! havedist /n/newfs/dist){
mountdist=notdone
export mountdist
exit notdone
}
exitifdone
if(test -f /n/distmedia/$distmediadir/dist/replica/plan9.db){
bind /n/distmedia/$distmediadir /n/dist
bind -a /n/dist/386/bin /bin
bind -a /n/dist/rc/bin /bin
exitifdone
mountdist=notdone
export mountdist
exit notdone
}
trycdimage /n/distmedia/$distmediadir/plan9.iso
trycdimage /n/newfs/dist/plan9.iso
trycdimagebz2 /n/distmedia/$distmediadir/plan9.iso.bz2
trycdimagebz2 /n/newfs/dist/plan9.iso.bz2
mountdist=notdone
export mountdist
exit notdone
}
|