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