1#!/bin/rc 2 3# desc: initialize disks for a fossil server 4# prereq: configfs 5 6switch($1){ 7case checkready checkdone 8 if(! ~ $fstype fossil+venti fossil){ 9 fmtfossil=notdone 10 export fmtfossil 11 exit 12 } 13 ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null} 14 if(~ $#ff 0){ 15 fmtfossil=notdone 16 export fmtfossil 17 exit 18 } 19 gg=() 20 for(f in $ff) 21 if(isfossil $f) 22 gg=($gg $f) 23 if(~ $#gg 0){ 24 fmtfossil=ready 25 export fmtfossil 26 exit 27 } 28 fmtfossil=done 29 export fmtfossil 30 exit 31 32case go 33 ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null} 34 if(~ $#ff 0){ 35 echo 'You need to create a partition or partitions to hold the Fossil write cache.' 36 echo 'The partition name must begin with "fossil".' 37 echo 38 fmtfossil=notdone 39 export fmtfossil 40 exit 41 } 42 default=() 43 if(~ $#ff 1){ 44 default=(-d $ff) 45 } 46 echo You have the following fossil partitions. 47 echo 48 prompt $default 'Fossil partition to format' $ff 49 f=$rd 50 51 do=yes 52 if(isfossil $f){ 53 echo $f appears to already be formatted as Fossil file system. 54 echo Do you really want to reformat it? 55 echo 56 prompt -d no 'Reformat '$f yes no 57 do=$rd 58 } 59 if(~ $do yes){ 60 fossil/flfmt -y $f 61 n=`{cat /dev/swap | grep ' user' | sed 's/^[0-9]+\/([0-9]+) .*/\1/'} 62 if(test $n -gt 32768) 63 m=3000 # if have at least 128 user MB, use 24MB for fossil 64 if not if(test $n -gt 16384) 65 m=1500 # 64 user MB => 12MB for fossil 66 if not if(test $n -gt 8192) 67 m=750 # 32 user MB => 6MB for fossil 68 if not 69 m=256 # 2MB for fossil (this will be slow) 70 71 # if we're using a venti in the back, take hourly snapshots 72 # that retire after three days, in addition to the daily dumps at 5am 73 if(~ $fstype fossil+venti){ 74 v='' 75 snap='fsys main snaptime -s 60 -a 0500 -t 2880' 76 } 77 # otherwise, take the daily dumps but nothing else -- 78 # we can't retire snapshots unless dumps are being archived 79 if not{ 80 v='-V' 81 snap='' 82 } 83 echo \ 84'fsys main config '^$f^' 85fsys main open '^$v^' -c '^$m^' 86'^$snap^' 87' | fossil/conf -w $f 88 } 89 90 echo Done. 91} 92