mountfossil 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/rc
  2. switch($1){
  3. case checkready checkdone
  4. if(! ~ $fmtfossil done){
  5. mountfs=notdone
  6. export mountfs
  7. exit
  8. }
  9. if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*){
  10. mountfs=notdone
  11. export mountfs
  12. exit
  13. }
  14. if(! ~ $#fossil 1 || ! test -f $fossil){
  15. mountfs=ready
  16. export mountfs
  17. exit
  18. }
  19. if(! ps | grep -s ' fossil$'){
  20. echo 'srv -p fscons' > /env/fossilconf
  21. echo 'srv -AP fossil' >> /env/fossilconf
  22. fossil/conf $fossil | sed 's/^fsys main open .*/& -AWVP/' |
  23. sed 's/^fsys main snaptime .*//' >> /env/fossilconf
  24. if(! logprog fossil/fossil -c .' /env/fossilconf'>>[2]/srv/log){
  25. echo 'fossil: '^$status
  26. mountfs=ready
  27. export mountfs
  28. exit oops
  29. }
  30. if(! test -f /srv/fossil){
  31. echo 'fossil did not create /srv/fossil'
  32. mountfs=ready
  33. exit oops
  34. }
  35. cat /srv/fscons >>/srv/log &
  36. if(! logprog mount -c /srv/fossil /n/newfs){
  37. echo 'mount: '^$status
  38. mountfs=ready
  39. export mountfs
  40. exit oops
  41. }
  42. fs=$fossil
  43. export fs
  44. }
  45. if(! test -s /n/newfs/adm/users){
  46. echo fsys main create /active/adm adm sys d775 >>/srv/fscons
  47. echo fsys main create /active/adm/users adm sys 664 >>/srv/fscons
  48. echo uname upas :upas >>/srv/fscons
  49. echo users -w >>/srv/fscons
  50. sleep 2
  51. }
  52. if(! test -s /n/newfs/adm/users){
  53. echo 'could not create /adm/users'
  54. mountfs=ready
  55. export mountfs
  56. exit oops
  57. }
  58. for(i in dist dist/replica dist/replica/client){
  59. if(! test -d /n/newfs/$i)
  60. echo fsys main create /active/$i sys sys d775 >>/srv/fscons
  61. sleep 2
  62. }
  63. if(! test -d /n/newfs/dist/replica/client){
  64. echo 'could not create /dist/replica/client'
  65. mountfs=ready
  66. export mountfs
  67. exit oops
  68. }
  69. if(! test -e /n/newfs/dist/replica/client/plan9.db){
  70. echo fsys main create /active/dist/replica/client/plan9.db sys sys 664 >>/srv/fscons
  71. echo fsys main create /active/dist/replica/client/plan9.log sys sys a664 >>/srv/fscons
  72. }
  73. if(test -d /n/newfs/dist/replica/client && test -f /n/newfs/adm/users){
  74. mountfs=done
  75. export mountfs
  76. exit
  77. }
  78. mountfs=ready
  79. export mountfs
  80. exit
  81. case go
  82. echo 'The following partitions named fossil* were found.'
  83. echo
  84. echo 'Please choose one to use as the installation file system'
  85. echo 'for your Plan 9 installation.'
  86. echo
  87. files=(`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null})
  88. ls -l $files
  89. echo
  90. if(~ $#fossil 1 && ~ $fossil $files)
  91. default=(-d $fossil)
  92. if not if(~ $#files 1)
  93. default=(-d $files)
  94. if not
  95. default=()
  96. prompt $default 'Fossil partition' $files
  97. slay fossil|rc
  98. fossil=$rd
  99. export fossil
  100. }