summaryrefslogtreecommitdiff
path: root/rc/bin/inst/bootwin9x
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-04-12 15:53:55 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-04-12 15:53:55 +0000
commit67e93d6a0a4f15192638e131413b9d64c4269c76 (patch)
tree88fd1d17c4be283683a96ced44159e3ce6b6f2f7 /rc/bin/inst/bootwin9x
parent7208d528bd42f981f2535403f72e4c0d7d8df643 (diff)
downloadplan9front-67e93d6a0a4f15192638e131413b9d64c4269c76.tar.xz
updating cwfs and moving installer in /rc/bin
Diffstat (limited to 'rc/bin/inst/bootwin9x')
-rwxr-xr-xrc/bin/inst/bootwin9x117
1 files changed, 117 insertions, 0 deletions
diff --git a/rc/bin/inst/bootwin9x b/rc/bin/inst/bootwin9x
new file mode 100755
index 000000000..68c2d1923
--- /dev/null
+++ b/rc/bin/inst/bootwin9x
@@ -0,0 +1,117 @@
+#!/bin/rc
+
+dosdisk=`{ls /dev/sd??/dos >[2]/dev/null | sed 1q | sed 's!.*/(.*)/dos!\1!'}
+if(~ $#dosdisk 0 || ! c: || ! test -f /n/c:/autoexec.bat || ! test -f /n/c:/config.sys) {
+ echo 'Could not find autoexec.bat or config.sys on the first FAT disk.'
+ exit bad
+}
+
+for (i in autoexec config msdos)
+ if(test -f /n/c:/$i.p9) {
+ echo 'A Plan 9 backup already exists; will not edit system files again.'
+ exit bad
+ }
+
+for (i in autoexec.bat config.sys msdos.sys)
+ if(! cp /n/c:/$i /n/c:/^`{echo $i | sed 's/\.(bat|sys)$/.p9/'}) {
+ echo 'Could not back up '^$i^'; will not continue.'
+ exit bad
+ }
+
+if(! test -d /n/c:/plan9 && ! mkdir /n/c:/plan9) {
+ echo 'Could not create directory /n/c:/plan9.'
+ exit bad
+}
+
+if(! cp /n/newfs/386/^(9load ld.com 9pcdisk) /tmp/plan9ini.bak /n/c:/plan9) {
+ echo 'Could not copy Plan 9 boot files into /n/c:/plan9.'
+ exit bad
+}
+
+chmod +w /n/c:/autoexec.bat /n/c:/config.sys /n/c:/msdos.sys
+
+if(grep -si 'Plan ?9' /n/c:/config.sys || grep -si 'Plan ?9' /n/c:/autoexec.bat) {
+ echo 'Plan 9 entries already in config.sys or autoexec.bat.'
+ echo 'Not changing them; refer to Plan 9 install documentation'
+ echo 'to configure manually.'
+ exit bad
+}
+
+if(! grep -si '\[menu\]' /n/c:/config.sys) {
+ {
+ echo 1
+ echo i
+ echo '[menu] '
+ echo 'menuitem=windows, Windows '
+ echo 'menudefault=windows '
+ echo ' '
+ echo '[common] '
+ echo ' '
+ echo '[windows] '
+ echo .
+ echo w
+ echo q
+ } | ed /n/c:/config.sys >/dev/null >[2]/dev/null
+}
+
+{
+ echo 1
+ echo '/\[[Mm][Ee][Nn][Uu]\]'
+ echo '?^[Mm][Ee][Nn][Uu][Ii][Tt][Ee][Mm]='
+ echo a
+ echo 'menuitem=plan9, Plan 9 from Bell Labs '
+ echo .
+ echo '$'
+ echo a
+ echo ' '
+ echo '[plan9] '
+ echo ' '
+ echo .
+ echo w
+ echo q
+} | ed /n/c:/config.sys >/dev/null>[2]/dev/null
+
+{
+ echo 1
+ echo i
+ echo '@echo off '
+ echo 'if %config%==plan9 goto plan9 '
+ echo 'goto notplan9 '
+ echo ':plan9 '
+ echo 'plan9\ld '^$dosdisk^'!dos!plan9/9load '
+ echo ':notplan9 '
+ echo .
+ echo w
+ echo q
+} | ed /n/c:/autoexec.bat >/dev/null>[2]/dev/null
+
+fn zeroopt {
+ if(grep -s '^'^$1^'=1' /n/c:/msdos.sys) {
+ {
+ echo '/^'^$1^'=1/s/=1/=0/'
+ echo w
+ echo q
+ } | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
+ }
+ if not if (grep -s '^'^$1^'=0' /n/c:/msdos.sys)
+ ;
+ if not {
+ {
+ echo 1
+ echo i
+ echo '[Options] '
+ echo 'Logo=0 '
+ echo .
+ echo w
+ echo q
+ } | ed /n/c:/msdos.sys>/dev/null>[2]/dev/null
+ }
+}
+
+if(grep -si '^\[paths\]' /n/c:/msdos.sys){ # Windows 9x rather than DOS
+ zeroopt Logo
+# zeroopt BootGUI
+}
+
+echo 'Plan 9 added to Windows 9X boot menu.'
+exit ''