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