bootsetup 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/rc
  2. # desc: create a boot floppy or configure hard disk to boot plan 9
  3. # prereq: copydist
  4. switch($1) {
  5. case go
  6. echo
  7. echo 'Initializing Plan 9 FAT configuration partition (9fat)'
  8. echo
  9. fat=(/dev/sd*/9fat)
  10. fat=$fat(1)
  11. disk=`{echo $fat | sed 's:/dev/::;s:/9fat::'}
  12. bootfs=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!\2:'}
  13. bootfat=`{echo $fs | sed 's:/dev/(sd..)/(.*):\1!9fat:'}
  14. if(! test -f /dev/$disk/9fat) {
  15. echo 'You have no 9fat partition. Can''t setup booting.'
  16. exit
  17. }
  18. if(! test -f /tmp/plan9.ini) {
  19. {
  20. sfs=`{echo $fs | sed 's;/dev;#S;'}
  21. if(~ $fstype fossil fossil+venti){
  22. echo bootfile'='$bootfat!9pcf
  23. echo 'bootargs=local!'^$sfs
  24. echo 'bootdisk=local!'^$sfs
  25. }
  26. if not {
  27. echo bootfile'='$bootfs!/386/9pcdisk
  28. echo 'bootdisk=local!'^$sfs
  29. }
  30. if(~ $fstype fossil+venti){
  31. venti=`{echo $ventiarena | sed 's;/dev;#S;'}
  32. echo venti'='^$venti
  33. }
  34. # sort -u avoids dups which could otherwise trigger
  35. # pointless boot menus.
  36. grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' |
  37. sort -u /tmp/plan9.orig
  38. echo 'mouseport='^$mouseport
  39. echo 'monitor='^$monitor
  40. echo 'vgasize='^$vgasize
  41. } >/tmp/plan9.ini
  42. }
  43. if(! test -f /tmp/plan9ini.bak)
  44. cp /tmp/plan9.ini /tmp/plan9ini.bak
  45. need9fatformat=no
  46. if(! isfat /dev/$disk/9fat)
  47. need9fatformat=yes
  48. if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
  49. need9fatformat=yes
  50. if not if(! test -f /n/9fat/plan9.ini)
  51. need9fatformat=yes
  52. if(~ $need9fatformat yes){
  53. log Initializing Plan 9 FAT partition.
  54. disk/format -r 2 -d -b /386/pbs \
  55. /dev/$disk/9fat /n/newfs/386/9load
  56. # silently install pbslba if the partition is way into the disk.
  57. # it''s our only hope. only need this for >8.5GB into the disk.
  58. # but...
  59. # there are so few non-LBA bioses out
  60. # there anymore that we'll do this even if we're only 2GB into
  61. # the disk. it's just not worth the headaches of dealing with
  62. # crappy bioses that don't address the whole 8.5GB properly
  63. 9fatoffset=`{grep '^part 9fat ' /dev/$disk/ctl | awk '{print $4}'}
  64. if(! ~ $#9fatoffset 1) {
  65. echo 'could not find plan 9 partition.'
  66. echo 'cannot happen'
  67. exit bad
  68. }
  69. if(test $9fatoffset -gt 2097152) # 2GB
  70. disk/format -b /386/pbslba /dev/$disk/9fat
  71. mount -c /srv/dos /n/9fat /dev/$disk/9fat
  72. }
  73. if(! test -f /n/9fat/4e){
  74. logprog cp /n/newfs/386/9load /n/9fat/9load
  75. logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
  76. if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
  77. logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
  78. if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
  79. logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
  80. awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
  81. >/n/9fat/4e
  82. }
  83. echo
  84. echo 'There are myriad ways to boot a Plan 9 system.'
  85. echo 'You can use any of the following.'
  86. echo
  87. echo ' floppy - create a boot floppy'
  88. echo ' plan9 - make the plan 9 disk partition the default for booting'
  89. echo ' win9x - add a plan 9 option to windows 9x boot menu'
  90. echo ' winnt - add a plan 9 option to windows nt/2000/xp boot manager'
  91. echo
  92. echo 'If you are upgrading an extant third edition installation and booting'
  93. echo 'from something other than a floppy, you needn''t run anything here.'
  94. echo 'Just type ctl-d.'
  95. oldbootsetup=$didbootsetup
  96. didbootsetup=1
  97. export didbootsetup
  98. prompt 'Enable boot method' floppy plan9 win9x winnt
  99. if(! boot$rd){
  100. didbootsetup=$oldbootsetup
  101. export didbootsetup
  102. }
  103. case checkdone
  104. xxxfat=(/dev/sd*/9fat)
  105. if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
  106. bootsetup=ready
  107. export bootsetup
  108. }
  109. }