1
0

bootwinnt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/rc
  2. disk=`{ls /dev/sd??/plan9 >[2]/dev/null | sed 1q | sed 's!.*/(.*)/plan9!\1!'}
  3. if(! ~ $#disk 1) {
  4. echo 'No plan 9 disk found' >[1=2]
  5. exit
  6. }
  7. if(! c: || ! test -f /n/c:/boot.ini) {
  8. echo 'Could not find NT''s boot.ini on the first FAT disk.' >[1=2]
  9. exit
  10. }
  11. if(test -f /n/c:/boot.p9) {
  12. echo 'A Plan 9 backup already exists; will not edit boot.ini again.' >[1=2]
  13. exit
  14. }
  15. if(! cp /n/c:/boot.ini /n/c:/boot.p9) {
  16. echo 'Could not back up boot.ini; will not continue.' >[1=2]
  17. exit
  18. }
  19. chmod +w /n/c:/boot.ini
  20. if(! grep -si '\[operating systems\]' /n/c:/boot.ini) {
  21. echo 'Could not parse boot.ini.' >[1=2]
  22. exit
  23. }
  24. if(grep -si 'Plan 9' /n/c:/boot.ini) {
  25. p9file=`{grep 'Plan 9' /n/c:/boot.ini | sed 1q | sed 's/=.*//'}
  26. if(! ~ $p9file [Cc]:'\'*) {
  27. echo 'Unexpected Plan 9 entry in boot.ini already; not continuing.' >[1=2]
  28. exit
  29. }
  30. }
  31. if not {
  32. p9file='c:\bootsect.p9'
  33. echo 'c:\bootsect.p9 = "Plan 9 from Bell Labs" ' >>/n/c:/boot.ini
  34. }
  35. p9file=/n/^`{echo $p9file | sed 's!\\!/!g'}
  36. if(dd -if /dev/$disk/plan9 -bs 512 -count 1 -of $p9file >/dev/null >[2]/dev/null) {
  37. echo 'Plan 9 added to Windows NT boot menu.' >[1=2]
  38. exit
  39. }
  40. echo 'Error copying Plan 9 boot sector to file.'
  41. exit