#!/bin/rc # spawns a fossil on a storage server from a given rootscore rfork scorefile=/n/9fat/scorenames listenport=10564 rootname=foo usedisk=no while(~ $1 -*){ switch($1){ case -l listenport=$2 shift case -v scorefile=$2 shift case -d usedisk=yes } shift } rootname=$1 if(! test -e $scorefile) mount /srv/fatsrv /n/9fat rootscore=`{ndb/query -f $scorefile scorename $rootname rootscore} if(~ $rootscore ''){ echo root $rootname not found >[2=1] exit } if(~ $usedisk yes){ disknum=`{cat /usr/grid/nextdisk} if(~ $disknum `{cat /usr/grid/diskmax}){ echo 'no available disk slots' >[2=1] exit } usedisk=`{cat /usr/grid/disk^$disknum} } if(~ $usedisk no){ namefossil -l $listenport $rootscore $rootname $rootname >>[2]/usr/grid/fossilogs echo /srv/$rootname >/usr/grid/$rootname } if not { namefossil -f $usedisk -l $listenport $rootscore $rootname $rootname >>[2]/usr/grid/fossilogs if(test -e /srv/$rootname^fossil){ disknum=`{echo $disknum + 1 |hoc} echo $disknum >/usr/grid/nextdisk echo $usedisk >/usr/grid/$rootname echo 'disknum=`{cat /usr/grid/nextdisk}' >>/usr/grid/killscript echo 'disknum=`{echo $disknum - 1 |hoc}' >>/usr/grid/killscript echo 'echo $disknum >/usr/grid/nextdisk' >>/usr/grid/killscript echo 'echo ' $usedisk ' >/usr/grid/disk^$disknum' >>/usr/grid/killscript } if not echo namefossil $rootname failed >[1=2] } echo 'spawncount=`{cat /usr/grid/spawncount}' >>/usr/grid/killscript echo 'spawncount=`{echo $spawncount - 1 |hoc}' >>/usr/grid/killscript echo 'echo $spawncount >/usr/grid/spawncount' >>/usr/grid/killscript mv /usr/grid/killscript /usr/grid/kill.$rootname