12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #!/bin/rc
- # desc: initialize disks for a fossil server
- # prereq: configfs
- switch($1){
- case checkready checkdone
- if(! ~ $fstype fossil+venti fossil){
- fmtfossil=notdone
- export fmtfossil
- exit
- }
- ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
- if(~ $#ff 0){
- fmtfossil=notdone
- export fmtfossil
- exit
- }
- gg=()
- for(f in $ff)
- if(isfossil $f)
- gg=($gg $f)
- if(~ $#gg 0){
- fmtfossil=ready
- export fmtfossil
- exit
- }
- fmtfossil=done
- export fmtfossil
- exit
- case go
- ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
- if(~ $#ff 0){
- echo 'You need to create a partition or partitions to hold the Fossil write cache.'
- echo 'The partition name must begin with "fossil".'
- echo
- fmtfossil=notdone
- export fmtfossil
- exit
- }
- default=()
- if(~ $#ff 1){
- default=(-d $ff)
- }
- echo You have the following fossil partitions.
- echo
- prompt $default 'Fossil partition to format' $ff
- f=$rd
- do=yes
- if(isfossil $f){
- echo $f appears to already be formatted as Fossil file system.
- echo Do you really want to reformat it?
- echo
- prompt -d no 'Reformat '$f yes no
- do=$rd
- }
- if(~ $do yes){
- fossil/flfmt -y $f
- n=`{cat /dev/swap | grep ' user' | sed 's/^[0-9]+\/([0-9]+) .*/\1/'}
- if(test $n -gt 32768)
- m=3000 # if have at least 128 user MB, use 24MB for fossil
- if not if(test $n -gt 16384)
- m=1500 # 64 user MB => 12MB for fossil
- if not if(test $n -gt 8192)
- m=750 # 32 user MB => 6MB for fossil
- if not
- m=256 # 2MB for fossil (this will be slow)
- # if we're using a venti in the back, take hourly snapshots
- # that retire after three days, in addition to the daily dumps at 5am
- if(~ $fstype fossil+venti){
- v=''
- snap='fsys main snaptime -s 60 -a 0500 -t 2880'
- }
- # otherwise, take the daily dumps but nothing else --
- # we can't retire snapshots unless dumps are being archived
- if not{
- v='-V'
- snap=''
- }
- echo \
- 'fsys main config '^$f^'
- fsys main open '^$v^' -c '^$m^'
- '^$snap^'
- ' | fossil/conf -w $f
- }
-
- echo Done.
- }
|