mountfossil 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/rc
  2. switch($1){
  3. case checkready checkdone
  4. if(~ $fstype fossil+venti && ! ~ $fmtventi done){
  5. mountfs=notdone
  6. export mountfs
  7. exit
  8. }
  9. if(! ~ $fmtfossil done){
  10. mountfs=notdone
  11. export mountfs
  12. exit
  13. }
  14. if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*){
  15. mountfs=notdone
  16. export mountfs
  17. exit
  18. }
  19. if(~ $fstype fossil+venti)
  20. if(! ~ $#venti 1 || ! test -f $venti){
  21. mountfs=ready
  22. export mountfs
  23. exit
  24. }
  25. if(! ~ $#fossil 1 || ! test -f $fossil){
  26. mountfs=ready
  27. export mountfs
  28. exit
  29. }
  30. if(~ $fstype fossil+venti && ! ps | grep -s ' venti$'){
  31. if(! logprog venti/venti -a tcp!127.1!17034 -c $venti >>[2]/srv/log){
  32. echo 'venti: '^$status
  33. mountfs=ready
  34. export mountfs
  35. exit oops
  36. }
  37. if(ps |grep -s ' fossil$'){
  38. # reconnect to venti
  39. echo fsys main venti 127.0.0.1 >>/srv/fscons
  40. }
  41. }
  42. if(! ps | grep -s ' fossil$'){
  43. {echo 'srv -p fscons'; echo 'srv -AP fossil'; fossil/conf $fossil | sed 's/^fsys main open .*/& -AWP/'}>/env/fossilconf
  44. if(! logprog fossil/fossil -c .' /env/fossilconf'>>[2]/srv/log){
  45. echo 'fossil: '^$status
  46. mountfs=ready
  47. export mountfs
  48. exit oops
  49. }
  50. if(! test -f /srv/fossil){
  51. echo 'fossil did not create /srv/fossil'
  52. mountfs=ready
  53. exit oops
  54. }
  55. cat /srv/fscons >>/srv/log &
  56. if(! logprog mount -c /srv/fossil /n/fossil){
  57. echo 'mount: '^$status
  58. mountfs=ready
  59. export mountfs
  60. exit oops
  61. }
  62. fs=$fossil
  63. export fs
  64. }
  65. if(! test -s /n/fossil/adm/users){
  66. echo fsys main create /active/adm adm sys d775 >>/srv/fscons
  67. echo fsys main create /active/adm/users adm sys 664 >>/srv/fscons
  68. echo uname upas :upas >>/srv/fscons
  69. echo users -w >>/srv/fscons
  70. sleep 2
  71. }
  72. if(! test -s /n/fossil/adm/users){
  73. echo 'could not create /adm/users'
  74. mountfs=ready
  75. export mountfs
  76. exit oops
  77. }
  78. for(i in dist dist/replica dist/replica/client){
  79. if(! test -d /n/fossil/$i)
  80. echo fsys main create /active/$i sys sys d775 >>/srv/fscons
  81. sleep 2
  82. }
  83. if(! test -d /n/fossil/dist/replica/client){
  84. echo 'could not create /dist/replica/client'
  85. mountfs=ready
  86. export mountfs
  87. exit oops
  88. }
  89. if(! test -e /n/fossil/dist/replica/client/plan9.db){
  90. echo fsys main create /active/dist/replica/client/plan9.db sys sys 664 >>/srv/fscons
  91. echo fsys main create /active/dist/replica/client/plan9.log sys sys a664 >>/srv/fscons
  92. }
  93. if(test -d /n/fossil/dist/replica/client && test -f /n/fossil/adm/users){
  94. # the rest of the install assumes /n/kfs
  95. bind -c /n/fossil /n/kfs
  96. mountfs=done
  97. export mountfs
  98. exit
  99. }
  100. mountfs=ready
  101. export mountfs
  102. exit
  103. case go
  104. if(~ $fstype fossil+venti){
  105. echo 'The following formatted Venti arenas were found.'
  106. echo
  107. echo 'Please choose one to use as the Venti server.'
  108. echo
  109. files=(`{ls /dev/sd*/v.arenas* /dev/fs/v.arenas* >[2]/dev/null})
  110. ls -l $files
  111. echo
  112. if(~ $#venti 1 && ~ $venti $files)
  113. default=(-d $venti)
  114. if not if(~ $#files 1)
  115. default=(-d $files)
  116. if not
  117. default=()
  118. prompt $default 'Venti arena w/ config file' $files
  119. if(! ~ $#venti 1 || ! ~ $venti $rd){
  120. slay venti|rc
  121. venti=$rd
  122. export venti
  123. }
  124. }
  125. echo 'The following partitions named fossil* were found.'
  126. echo
  127. echo 'Please choose one to use as the installation file system'
  128. echo 'for your Plan 9 installation.'
  129. echo
  130. files=(`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null})
  131. ls -l $files
  132. echo
  133. if(~ $#fossil 1 && ~ $fossil $files)
  134. default=(-d $fossil)
  135. if not if(~ $#files 1)
  136. default=(-d $files)
  137. if not
  138. default=()
  139. prompt $default 'Fossil partition' $files
  140. slay fossil|rc
  141. fossil=$rd
  142. export fossil
  143. }