bootwinnt 1.0 KB

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