diff options
| author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
|---|---|---|
| committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
| commit | 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch) | |
| tree | f6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/pc/bootwinnt | |
| parent | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff) | |
| download | plan9front-2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f.tar.xz | |
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/pc/bootwinnt')
| -rwxr-xr-x | rc/bin/pc/bootwinnt | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/rc/bin/pc/bootwinnt b/rc/bin/pc/bootwinnt new file mode 100755 index 000000000..cab89deda --- /dev/null +++ b/rc/bin/pc/bootwinnt @@ -0,0 +1,53 @@ +#!/bin/rc + +disk=`{ls /dev/sd??/plan9 >[2]/dev/null | sed 1q | sed 's!.*/(.*)/plan9!\1!'} +if(! ~ $#disk 1) { + echo 'No plan 9 disk found' >[1=2] + exit +} + +if(! c: || ! test -f /n/c:/boot.ini) { + echo 'Could not find NT''s boot.ini on the first FAT disk.' >[1=2] + exit +} + +if(test -f /n/c:/boot.p9) { + echo 'A Plan 9 backup already exists; will not edit boot.ini again.' >[1=2] + exit +} + +if(! cp /n/c:/boot.ini /n/c:/boot.p9) { + echo 'Could not back up boot.ini; will not continue.' >[1=2] + exit +} + +chmod +w /n/c:/boot.ini + +if(! grep -si '\[operating systems\]' /n/c:/boot.ini) { + echo 'Could not parse boot.ini.' >[1=2] + exit +} + +if(grep -si 'Plan 9' /n/c:/boot.ini) { + p9file=`{grep 'Plan 9' /n/c:/boot.ini | sed 1q | sed 's/=.*//'} + if(! ~ $p9file [Cc]:'\'*) { + echo 'Unexpected Plan 9 entry in boot.ini already; not continuing.' >[1=2] + exit + } +} + +if not { + p9file='c:\bootsect.p9' + echo 'c:\bootsect.p9 = "Plan 9 from Bell Labs"
' >>/n/c:/boot.ini +} + +p9file=/n/^`{echo $p9file | sed 's!\\!/!g'} + + +if(dd -if /dev/$disk/plan9 -bs 512 -count 1 -of $p9file >/dev/null >[2]/dev/null) { + echo 'Plan 9 added to Windows NT boot menu.' >[1=2] + exit +} + +echo 'Error copying Plan 9 boot sector to file.' +exit |
