2011-03-30 13:53:33 +00:00
|
|
|
#!/bin/rc
|
|
|
|
|
2015-06-06 00:00:51 +00:00
|
|
|
# desc: configure hard disk to boot plan 9
|
2013-08-02 01:47:27 +00:00
|
|
|
# prereq: copydist
|
2011-03-30 13:53:33 +00:00
|
|
|
|
2011-06-09 20:43:04 +00:00
|
|
|
fats=()
|
|
|
|
for(i in /dev/sd*/9fat){
|
|
|
|
if(test -f $i)
|
|
|
|
fats=($fats $i)
|
|
|
|
}
|
2011-06-09 20:31:04 +00:00
|
|
|
|
2011-03-30 13:53:33 +00:00
|
|
|
switch($1) {
|
2011-06-09 20:31:04 +00:00
|
|
|
case checkdone checkready
|
|
|
|
if(~ $#fats 0 || ~ $#9fat 1 && ~ `{fstype $9fat} dos && ~ $didbootsetup 1)
|
|
|
|
bootsetup=done
|
|
|
|
if not
|
|
|
|
bootsetup=ready
|
|
|
|
export bootsetup
|
|
|
|
|
2011-03-30 13:53:33 +00:00
|
|
|
case go
|
|
|
|
echo
|
2011-06-09 20:31:04 +00:00
|
|
|
echo 'Setup Plan 9 FAT boot partition (9fat)'
|
2011-03-30 13:53:33 +00:00
|
|
|
echo
|
|
|
|
|
2011-06-09 20:31:04 +00:00
|
|
|
if(~ $#fats 1)
|
|
|
|
default=(-d $fats)
|
|
|
|
if not
|
|
|
|
default=()
|
|
|
|
prompt $default 'Plan 9 FAT partition' $fats
|
|
|
|
9fat=$rd
|
|
|
|
export 9fat
|
2011-06-09 21:14:14 +00:00
|
|
|
|
2018-01-05 07:38:23 +00:00
|
|
|
bootfile=`{basename $bootfile}
|
|
|
|
|
2011-03-30 13:53:33 +00:00
|
|
|
if(! test -f /tmp/plan9.ini) {
|
2012-06-18 20:54:16 +00:00
|
|
|
@{
|
2011-05-04 18:55:08 +00:00
|
|
|
echo 'bootfile='^$bootfile
|
2012-08-07 16:01:53 +00:00
|
|
|
echo 'bootargs=local!'^$fs' '$"fsflags
|
2011-06-09 20:31:04 +00:00
|
|
|
if(~ $#nvram 1)
|
|
|
|
echo 'nvram='^$nvram
|
2011-03-30 13:53:33 +00:00
|
|
|
echo 'mouseport='^$mouseport
|
|
|
|
echo 'monitor='^$monitor
|
|
|
|
echo 'vgasize='^$vgasize
|
2012-06-18 20:54:16 +00:00
|
|
|
cd '#ec'
|
|
|
|
for(i in *){
|
|
|
|
echo -n $"i'='
|
|
|
|
cat $i
|
|
|
|
echo
|
2014-10-19 19:17:08 +00:00
|
|
|
} | grep -v '(apm0|e820|bootfile|bootargs|bootscreen|nvram|mouseport|monitor|vgasize|cdboot)'
|
2011-03-30 13:53:33 +00:00
|
|
|
} >/tmp/plan9.ini
|
|
|
|
}
|
|
|
|
|
2012-12-20 10:17:10 +00:00
|
|
|
# clean state
|
|
|
|
rm -f /tmp/oldplan9.ini /tmp/pbs.bak
|
|
|
|
unmount /n/9fat >[2]/dev/null
|
|
|
|
|
2011-04-22 00:50:41 +00:00
|
|
|
if(! test -f /srv/dos)
|
|
|
|
dossrv
|
2012-12-20 10:17:10 +00:00
|
|
|
|
|
|
|
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
|
2011-03-30 13:53:33 +00:00
|
|
|
|
|
|
|
if(~ $need9fatformat yes){
|
|
|
|
log Initializing Plan 9 FAT partition.
|
2015-06-06 00:00:51 +00:00
|
|
|
logprog disk/format -r 2 -d -b /n/newfs/386/pbs -l PLAN9 $9fat
|
2011-03-30 13:53:33 +00:00
|
|
|
}
|
2011-06-13 13:18:16 +00:00
|
|
|
if not {
|
|
|
|
log Updating bootsector.
|
2012-12-20 10:17:10 +00:00
|
|
|
logprog disk/format -b /n/newfs/386/pbs $9fat
|
2011-06-13 13:18:16 +00:00
|
|
|
}
|
|
|
|
|
2012-12-20 10:17:10 +00:00
|
|
|
logprog mount -c /srv/dos /n/9fat $9fat
|
|
|
|
|
2018-01-05 07:38:23 +00:00
|
|
|
logprog rm -f /n/9fat/^(9bootfat plan9.ini $bootfile)
|
2012-12-20 10:17:10 +00:00
|
|
|
|
2011-04-22 00:50:41 +00:00
|
|
|
logprog cp /n/newfs/386/9bootfat /n/9fat/9bootfat
|
2011-06-04 21:35:28 +00:00
|
|
|
# make file continous on disk
|
2011-06-04 21:34:51 +00:00
|
|
|
logprog chmod +al /n/9fat/9bootfat
|
2012-12-20 10:17:10 +00:00
|
|
|
|
2014-11-05 20:38:28 +00:00
|
|
|
# copy config
|
2011-06-04 22:25:35 +00:00
|
|
|
logprog cp /tmp/plan9.ini /n/9fat/plan9.ini
|
2014-11-05 20:38:28 +00:00
|
|
|
|
|
|
|
# copy kernel
|
2018-01-05 07:38:23 +00:00
|
|
|
logprog cp /n/newfs/$cputype/$bootfile /n/9fat/
|
2011-03-30 13:53:33 +00:00
|
|
|
|
2014-11-05 20:38:28 +00:00
|
|
|
# copy efi bootloader
|
|
|
|
logprog mkdir -p /n/9fat/efi/boot
|
|
|
|
logprog cp /386/^(bootia32.efi bootx64.efi) /n/9fat/efi/boot
|
|
|
|
|
2012-12-20 10:17:10 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
logprog unmount /n/9fat
|
|
|
|
|
2011-06-09 22:02:50 +00:00
|
|
|
disk=`{basename `{basename -d $9fat}}
|
2013-10-26 18:17:56 +00:00
|
|
|
if(./bootplan9){
|
2012-12-06 05:35:36 +00:00
|
|
|
didbootsetup=1
|
2011-03-30 13:53:33 +00:00
|
|
|
export didbootsetup
|
|
|
|
}
|
|
|
|
}
|