diff options
| author | cinap_lenrek <cinap_lenrek@localhost> | 2011-04-12 15:53:55 +0000 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-04-12 15:53:55 +0000 |
| commit | 67e93d6a0a4f15192638e131413b9d64c4269c76 (patch) | |
| tree | 88fd1d17c4be283683a96ced44159e3ce6b6f2f7 /rc/bin/inst/fmtfossil | |
| parent | 7208d528bd42f981f2535403f72e4c0d7d8df643 (diff) | |
| download | plan9front-67e93d6a0a4f15192638e131413b9d64c4269c76.tar.xz | |
updating cwfs and moving installer in /rc/bin
Diffstat (limited to 'rc/bin/inst/fmtfossil')
| -rwxr-xr-x | rc/bin/inst/fmtfossil | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/rc/bin/inst/fmtfossil b/rc/bin/inst/fmtfossil new file mode 100755 index 000000000..98bf33fc1 --- /dev/null +++ b/rc/bin/inst/fmtfossil @@ -0,0 +1,91 @@ +#!/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. +} |
