bootwin9x 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/rc
  2. dosdisk=`{ls /dev/sd??/dos >[2]/dev/null | sed 1q | sed 's!.*/(.*)/dos!\1!'}
  3. if(~ $#dosdisk 0 || ! c: || ! test -f /n/c:/autoexec.bat || ! test -f /n/c:/config.sys) {
  4. echo 'Could not find autoexec.bat or config.sys on the first FAT disk.'
  5. exit bad
  6. }
  7. for (i in autoexec config msdos)
  8. if(test -f /n/c:/$i.p9) {
  9. echo 'A Plan 9 backup already exists; will not edit system files again.'
  10. exit bad
  11. }
  12. for (i in autoexec.bat config.sys msdos.sys)
  13. if(! cp /n/c:/$i /n/c:/^`{echo $i | sed 's/\.(bat|sys)$/.p9/'}) {
  14. echo 'Could not back up '^$i^'; will not continue.'
  15. exit bad
  16. }
  17. if(! test -d /n/c:/plan9 && ! mkdir /n/c:/plan9) {
  18. echo 'Could not create directory /n/c:/plan9.'
  19. exit bad
  20. }
  21. if(! cp /n/newfs/386/^(9load ld.com 9pcdisk) /tmp/plan9ini.bak /n/c:/plan9) {
  22. echo 'Could not copy Plan 9 boot files into /n/c:/plan9.'
  23. exit bad
  24. }
  25. chmod +w /n/c:/autoexec.bat /n/c:/config.sys /n/c:/msdos.sys
  26. if(grep -si 'Plan ?9' /n/c:/config.sys || grep -si 'Plan ?9' /n/c:/autoexec.bat) {
  27. echo 'Plan 9 entries already in config.sys or autoexec.bat.'
  28. echo 'Not changing them; refer to Plan 9 install documentation'
  29. echo 'to configure manually.'
  30. exit bad
  31. }
  32. if(! grep -si '\[menu\]' /n/c:/config.sys) {
  33. {
  34. echo 1
  35. echo i
  36. echo '[menu] '
  37. echo 'menuitem=windows, Windows '
  38. echo 'menudefault=windows '
  39. echo ' '
  40. echo '[common] '
  41. echo ' '
  42. echo '[windows] '
  43. echo .
  44. echo w
  45. echo q
  46. } | ed /n/c:/config.sys >/dev/null >[2]/dev/null
  47. }
  48. {
  49. echo 1
  50. echo '/\[[Mm][Ee][Nn][Uu]\]'
  51. echo '?^[Mm][Ee][Nn][Uu][Ii][Tt][Ee][Mm]='
  52. echo a
  53. echo 'menuitem=plan9, Plan 9 from Bell Labs '
  54. echo .
  55. echo '$'
  56. echo a
  57. echo ' '
  58. echo '[plan9] '
  59. echo ' '
  60. echo .
  61. echo w
  62. echo q
  63. } | ed /n/c:/config.sys >/dev/null>[2]/dev/null
  64. {
  65. echo 1
  66. echo i
  67. echo '@echo off '
  68. echo 'if %config%==plan9 goto plan9 '
  69. echo 'goto notplan9 '
  70. echo ':plan9 '
  71. echo 'plan9\ld '^$dosdisk^'!dos!plan9/9load '
  72. echo ':notplan9 '
  73. echo .
  74. echo w
  75. echo q
  76. } | ed /n/c:/autoexec.bat >/dev/null>[2]/dev/null
  77. fn zeroopt {
  78. if(grep -s '^'^$1^'=1' /n/c:/msdos.sys) {
  79. {
  80. echo '/^'^$1^'=1/s/=1/=0/'
  81. echo w
  82. echo q
  83. } | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
  84. }
  85. if not if (grep -s '^'^$1^'=0' /n/c:/msdos.sys)
  86. ;
  87. if not {
  88. {
  89. echo 1
  90. echo i
  91. echo '[Options] '
  92. echo 'Logo=0 '
  93. echo .
  94. echo w
  95. echo q
  96. } | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
  97. }
  98. }
  99. if(grep -si '^\[paths\]' /n/c:/msdos.sys){ # Windows 9x rather than DOS
  100. zeroopt Logo
  101. # zeroopt BootGUI
  102. }
  103. echo 'Plan 9 added to Windows 9X boot menu.'
  104. exit ''