bootsetup 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig
  31. echo 'mouseport='^$mouseport
  32. echo 'monitor='^$monitor
  33. echo 'vgasize='^$vgasize
  34. } >/tmp/plan9.ini
  35. }
  36. if(! test -f /tmp/plan9ini.bak)
  37. cp /tmp/plan9.ini /tmp/plan9ini.bak
  38. need9fatformat=no
  39. if(! isfat /dev/$disk/9fat)
  40. need9fatformat=yes
  41. if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
  42. need9fatformat=yes
  43. if not if(! test -f /n/9fat/plan9.ini)
  44. need9fatformat=yes
  45. if(~ $need9fatformat yes){
  46. log Initializing Plan 9 FAT partition.
  47. disk/format -r 2 -d -b /386/pbs \
  48. /dev/$disk/9fat /n/kfs/386/9load
  49. # silently install pbslba if the partition is way into the disk.
  50. # it''s our only hope. only need this for >8.5GB into the disk.
  51. # but...
  52. # there are so few non-LBA bioses out
  53. # there anymore that we'll do this even if we're only 2GB into
  54. # the disk. it's just not worth the headaches of dealing with
  55. # crappy bioses that don't address the whole 8.5GB properly
  56. 9fatoffset=`{grep '^part 9fat ' /dev/$disk/ctl | awk '{print $4}'}
  57. if(! ~ $#9fatoffset 1) {
  58. echo 'could not find plan 9 partition.'
  59. echo 'cannot happen'
  60. exit bad
  61. }
  62. if(test $9fatoffset -gt 2097152) # 2GB
  63. disk/format -b /386/pbslba /dev/$disk/9fat
  64. mount -c /srv/dos /n/9fat /dev/$disk/9fat
  65. }
  66. if(! test -f /n/9fat/4e){
  67. logprog cp /n/kfs/386/9load /n/9fat/9load
  68. logprog cp /n/kfs/386/9pcf /n/9fat/9pcf
  69. if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
  70. logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
  71. if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
  72. logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
  73. awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
  74. >/n/9fat/4e
  75. }
  76. echo
  77. echo 'There are myriad ways to boot a Plan 9 system.'
  78. echo 'You can use any of the following.'
  79. echo '(You can also repeat this task to use more than one).'
  80. echo
  81. echo ' floppy - create a boot floppy'
  82. echo ' plan9 - make the plan 9 disk partition the default for booting'
  83. echo ' win9x - add a plan 9 option to windows 9x boot menu'
  84. echo ' winnt - add a plan 9 option to windows nt/2000/xp boot manager'
  85. echo
  86. echo '(See the documentation for instructions on booting Plan 9 from LILO.)'
  87. echo
  88. echo 'If you are upgrading an extant third edition installation and booting'
  89. echo 'from something other than a floppy, you needn''t run anything here.'
  90. echo 'Just type ctl-d.'
  91. oldbootsetup=$didbootsetup
  92. didbootsetup=1
  93. export didbootsetup
  94. prompt 'Enable boot method' floppy plan9 win9x winnt
  95. if(! boot$rd){
  96. didbootsetup=$oldbootsetup
  97. export didbootsetup
  98. }
  99. case checkdone
  100. if(! isfat /dev/sd*/9fat || ! ~ $didbootsetup 1){
  101. bootsetup=ready
  102. export bootsetup
  103. }
  104. }