blob: e90f4799f155fe8c581d2c12b525960dba929f14 (
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
|
#!/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/LICENSE)
exit
}
fn havedist {
test -f $1/LICENSE
}
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=()
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)
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)'
}
}
echo
mountstatus=x
while(! ~ $mountstatus ''){
prompt -w '' 'Distribution disk' $fat $x9660
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 *
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
first=no
}
prompt -d $dir 'Location of archives'
dir=$rd
if(~ $#dir 0)
dir=/
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(havedist /n/distmedia/$distmediadir){
bind /n/distmedia/$distmediadir /n/dist
exitifdone
mountdist=notdone
export mountdist
exit notdone
}
mountdist=notdone
export mountdist
exit notdone
}
|