#!/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[A-Z][0-9]*/* >[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 }