#!/bin/rc
# desc: create a boot floppy or configure hard disk to boot plan 9
-# prereq: systype copydist
+# prereq: copydist
fats=()
for(i in /dev/sd*/9fat){
export 9fat
if(! test -f /tmp/plan9.ini) {
- if(~ $syst cpu)
- bootfile=9pccpuf
- if not
- bootfile=9pcf
+ bootfile=9pcf
@{
echo 'bootfile='^$bootfile
- echo 'bootargs=local!'^$fs
+ echo 'bootargs=local!'^$fs' '$"fsflags
if(~ $#nvram 1)
echo 'nvram='^$nvram
echo 'mouseport='^$mouseport
} >/tmp/plan9.ini
}
- need9fatformat=no
- if(! ~ `{fstype $9fat} dos)
- need9fatformat=yes
+ # clean state
+ rm -f /tmp/oldplan9.ini /tmp/pbs.bak
+ unmount /n/9fat >[2]/dev/null
+
if(! test -f /srv/dos)
dossrv
- if(! mount -c /srv/dos /n/9fat $9fat >[2]/dev/null)
- need9fatformat=yes
- if not if(! test -f /n/9fat/plan9.ini)
- need9fatformat=yes
+
+ need9fatformat=yes
+ if(~ `{fstype $9fat} dos){
+ if(mount /srv/dos /n/9fat $9fat >[2]/dev/null){
+ if(cp /n/9fat/plan9.ini /tmp/oldplan9.ini >[2]/dev/null)
+ need9fatformat=no
+ unmount /n/9fat >[2]/dev/null
+
+ # make sure dossrv is gone
+ sleep 1
+ }
+ }
+
+ # always make backup of old bootsector
+ logprog dd -bs 512 -count 1 -if $9fat -of /tmp/pbs.bak
if(~ $need9fatformat yes){
log Initializing Plan 9 FAT partition.
- logprog disk/format -r 2 -d -b /386/pbs $9fat
- logprog mount -c /srv/dos /n/9fat $9fat
+ logprog disk/format -r 2 -d -b /n/newfs/386/pbs $9fat
}
if not {
log Updating bootsector.
- logprog dd -if $9fat -of /n/9fat/pbs.bak -bs 512 -count 1
- logprog disk/format -b /386/pbs $9fat
+ logprog disk/format -b /n/newfs/386/pbs $9fat
}
- logprog rm -f /n/9fat/^(9bootfat plan9.ini 9pcf 9pccpuf)
+ logprog mount -c /srv/dos /n/9fat $9fat
+
+ logprog rm -f /n/9fat/^(9bootfat plan9.ini 9pcf)
+
logprog cp /n/newfs/386/9bootfat /n/9fat/9bootfat
# make file continous on disk
logprog chmod +al /n/9fat/9bootfat
+
logprog cp /tmp/plan9.ini /n/9fat/plan9.ini
logprog cp /n/newfs/386/9pcf /n/9fat/9pcf
- logprog cp /n/newfs/386/9pccpuf /n/9fat/9pccpuf
-
- echo
- echo 'There are myriad ways to boot a Plan 9 system.'
- echo 'You can use any of the following.'
- echo
- echo ' plan9 - make the plan 9 disk partition the default for booting'
- echo ' winnt - add a plan 9 option to windows nt/2000/xp boot manager'
- echo
- echo 'If you are upgrading an extant third edition installation and booting'
- echo 'from something other than a floppy, you needn''t run anything here.'
- echo 'Just type ctl-d.'
- oldbootsetup=$didbootsetup
- didbootsetup=1
- export didbootsetup
+ # copy in backups
+ if(test -f /tmp/oldplan9.ini)
+ logprog cp /tmp/oldplan9.ini /n/9fat
+ if(test -f /tmp/pbs.bak)
+ logprog cp /tmp/pbs.bak /n/9fat
- prompt 'Enable boot method' plan9 winnt
+ logprog unmount /n/9fat
disk=`{basename `{basename -d $9fat}}
-
- if(! boot$rd){
- didbootsetup=$oldbootsetup
+ if(./bootplan9){
+ didbootsetup=1
export didbootsetup
}
}