]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/inst/bootsetup
update installer for 9bootfat
[plan9front.git] / rc / bin / inst / bootsetup
1 #!/bin/rc
2
3 # desc: create a boot floppy or configure hard disk to boot plan 9
4 # prereq: copydist
5
6 switch($1) {
7 case 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 'bootargs=local!'^$sfs
28                                 echo 'bootdisk=local!'^$sfs
29                         }
30                         if not {
31                                 echo bootfile'='$bootfs!/386/9pcdisk
32                                 echo 'bootdisk=local!'^$sfs
33                         }
34                         if(~ $fstype fossil+venti){
35                                 venti=`{echo $ventiarena | sed 's;/dev;#S;'}
36                                 echo venti'='^$venti
37                         }
38                         # sort -u avoids dups which could otherwise trigger
39                         # pointless boot menus.
40                         grep -v '(^\[)|menuitem|adisk|bootfile|bootdisk|bootargs|nobootprompt|mouseport|vgasize|monitor|cdboot' /tmp/plan9.orig |
41                                 sort -u
42                         echo 'mouseport='^$mouseport
43                         echo 'monitor='^$monitor
44                         echo 'vgasize='^$vgasize
45                 } >/tmp/plan9.ini
46         }
47         if(! test -f /tmp/plan9ini.bak)
48                 cp /tmp/plan9.ini /tmp/plan9ini.bak
49
50         need9fatformat=no
51         if(! isfat /dev/$disk/9fat)
52                 need9fatformat=yes
53         if not if(! mount -c /srv/dos /n/9fat /dev/$disk/9fat >[2]/dev/null)
54                 need9fatformat=yes
55         if not if(! test -f /n/9fat/plan9.ini)
56                 need9fatformat=yes
57
58         if(~ $need9fatformat yes){
59                 log Initializing Plan 9 FAT partition.
60                 disk/format -r 2 -d -b /386/pbs \
61                         /dev/$disk/9fat /n/newfs/386/9bootfat
62                 mount -c /srv/dos /n/9fat /dev/$disk/9fat
63         }
64
65         if(! test -f /n/9fat/4e){
66                 logprog cp /n/newfs/386/9bootfat /n/9fat/9bootfat
67                 logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
68                 if(test -f /n/9fat/plan9.ini && ! test -f /n/9fat/plan9-3e.ini)
69                         logprog mv /n/9fat/plan9.ini /n/9fat/plan9-3e.ini
70                 if(test -f /n/9fat/9pcdisk && ! test -f /n/9fat/9pc3e)
71                         logprog mv /n/9fat/9pcdisk /n/9fat/9pc3e
72
73                 awk -f /bin/inst/mkini.awk >/n/9fat/plan9.ini
74                 >/n/9fat/4e
75         }
76
77         echo
78         echo 'There are myriad ways to boot a Plan 9 system.'
79         echo 'You can use any of the following.'
80         echo
81         echo '  plan9  - make the plan 9 disk partition the default for booting'
82         echo '  winnt  - add a plan 9 option to windows nt/2000/xp boot manager'
83         echo
84         echo 'If you are upgrading an extant third edition installation and booting'
85         echo 'from something other than a floppy, you needn''t run anything here.'
86         echo 'Just type ctl-d.'
87
88         oldbootsetup=$didbootsetup
89         didbootsetup=1
90         export didbootsetup
91         prompt 'Enable boot method' plan9 winnt
92         
93         if(! boot$rd){
94                 didbootsetup=$oldbootsetup
95                 export didbootsetup
96         }
97
98 case checkdone
99         xxxfat=(/dev/sd*/9fat)
100         if(! isfat $xxxfat(1) || ! ~ $didbootsetup 1){
101                 bootsetup=ready
102                 export bootsetup
103         }
104 }