#!/bin/rc
switch($1){
case checkready checkdone
if(~ $fstype fossil+venti && ! ~ $fmtventi done){
mountfs=notdone
export mountfs
exit
}
if(! ~ $fmtfossil done){
mountfs=notdone
export mountfs
exit
}
if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*){
mountfs=notdone
export mountfs
exit
}
if(~ $fstype fossil+venti)
if(! ~ $#venti 1 || ! test -f $venti){
mountfs=ready
export mountfs
exit
}
if(! ~ $#fossil 1 || ! test -f $fossil){
mountfs=ready
export mountfs
exit
}
if(~ $fstype fossil+venti && ! ps | grep -s ' venti$'){
if(! logprog venti/venti -a tcp!127.1!17034 -c $venti >>[2]/srv/log){
echo 'venti: '^$status
mountfs=ready
export mountfs
exit oops
}
if(ps |grep -s ' fossil$'){
# reconnect to venti
echo fsys main venti 127.0.0.1 >>/srv/fscons
}
}
if(! ps | grep -s ' fossil$'){
{echo 'srv -p fscons'; echo 'srv -AP fossil'; fossil/conf $fossil | sed 's/^fsys main open .*/& -AWP/'}>/env/fossilconf
if(! logprog fossil/fossil -c .' /env/fossilconf'>>[2]/srv/log){
echo 'fossil: '^$status
mountfs=ready
export mountfs
exit oops
}
if(! test -f /srv/fossil){
echo 'fossil did not create /srv/fossil'
mountfs=ready
exit oops
}
cat /srv/fscons >>/srv/log &
if(! logprog mount -c /srv/fossil /n/fossil){
echo 'mount: '^$status
mountfs=ready
export mountfs
exit oops
}
fs=$fossil
export fs
}
if(! test -s /n/fossil/adm/users){
echo fsys main create /active/adm adm sys d775 >>/srv/fscons
echo fsys main create /active/adm/users adm sys 664 >>/srv/fscons
echo uname upas :upas >>/srv/fscons
echo users -w >>/srv/fscons
sleep 2
}
if(! test -s /n/fossil/adm/users){
echo 'could not create /adm/users'
mountfs=ready
export mountfs
exit oops
}
for(i in dist dist/replica dist/replica/client){
if(! test -d /n/fossil/$i)
echo fsys main create /active/$i sys sys d775 >>/srv/fscons
sleep 2
}
if(! test -d /n/fossil/dist/replica/client){
echo 'could not create /dist/replica/client'
mountfs=ready
export mountfs
exit oops
}
if(! test -e /n/fossil/dist/replica/client/plan9.db){
echo fsys main create /active/dist/replica/client/plan9.db sys sys 664 >>/srv/fscons
echo fsys main create /active/dist/replica/client/plan9.log sys sys a664 >>/srv/fscons
}
if(test -d /n/fossil/dist/replica/client && test -f /n/fossil/adm/users){
# the rest of the install assumes /n/kfs
bind -c /n/fossil /n/kfs
mountfs=done
export mountfs
exit
}
mountfs=ready
export mountfs
exit
case go
if(~ $fstype fossil+venti){
echo 'The following formatted Venti arenas were found.'
echo
echo 'Please choose one to use as the Venti server.'
echo
files=(`{ls /dev/sd*/v.arenas* /dev/fs/v.arenas* >[2]/dev/null})
ls -l $files
echo
if(~ $#venti 1 && ~ $venti $files)
default=(-d $venti)
if not if(~ $#files 1)
default=(-d $files)
if not
default=()
prompt $default 'Venti arena w/ config file' $files
if(! ~ $#venti 1 || ! ~ $venti $rd){
slay venti|rc
venti=$rd
export venti
}
}
echo 'The following partitions named fossil* were found.'
echo
echo 'Please choose one to use as the installation file system'
echo 'for your Plan 9 installation.'
echo
files=(`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null})
ls -l $files
echo
if(~ $#fossil 1 && ~ $fossil $files)
default=(-d $fossil)
if not if(~ $#files 1)
default=(-d $files)
if not
default=()
prompt $default 'Fossil partition' $files
slay fossil|rc
fossil=$rd
export fossil
}
|