fmtfossil 1.9 KB

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