set quiet
set TM0 lock
mkdir -p dsk
attach RR0 -iy dsk/sys3_root.rp03
attach RR1 -iy dsk/sys3_home.rp03
attach RK1 -iy dsk/sys3_swap.rk05
attach TM0 -er dist/sys3.tap
:SETUP
echo ************************************************************************
set ENV -p "root Password" ROOTPWD=uts%DATE_MM%%DATE_DD%
set ENV -p "System Name (8 characters max)" SYS=uts
set ENV -p "Operating System Version (8 characters max)" VER=%DATE_MM%%DATE_DD%
set ENV -p "Node Name (for UUCP)" NODE=system3
set ENV -p "New User Usernam (8 characters max)" USER=att
echo ************************************************************************
set ENV -p "Are you satisfied with your setup options? [Y/N]" REDOSETUP=N
if -i REDOSETUP geq "Y" goto EOI
else goto SETUP
:EOI
echo ************************************************************************
echo * End of user input; please wait until the installation is complete.   *
echo *                                                                      *
set CONSOLE LOG=install.log
echo ************************************************************************
echo *     INSTALLATION STARTED AT %TIME%                                 *
echo ************************************************************************
expect "RP03 at address 176710?: " send "y\n"; continue
expect "Drive number (0-7)?: " send "0\n"; continue
expect "Ready?: " send "y\n"; continue
expect "TU10/TM11 at address 172520?: " send "y\n"; continue
expect "Drive number (0-7)?: " send "0\n"; continue
expect "Ready?: " send "y\n"; continue
expect "What is the pack volume label? (e.g. p0001): " send "p1701\n"; continue
boot TM0
noexpect
expect "#" send "0unixrptm\n"; continue
expect "# " send "date %DATE_MM%%DATE_DD%%TIME_HH%%TIME_MM%%DATE_19XX_YY%\n"; continue
expect "# " send "ln /unixrptm /unix\n"; continue
expect "# " send "echo </dev/mt4\n"; continue
expect "# " send "echo </dev/mt4\n"; continue
expect "# " send "echo </dev/mt4\n"; continue
expect "# " send "echo </dev/mt4\n"; continue
expect "# " send "cd /\n"; continue
expect "# " send "mkfs /dev/rrp1 71200 0 200\n"; continue
expect "# " send "labelit /dev/rrp1 usr p1701\n"; continue
expect "# " send "mount /dev/rp1 /usr\n"; continue
expect "# " send "cd /usr\n"; continue
expect "# " send "cpio -idmB </dev/rmt4\n"; continue
expect "# " send "cd /usr/src\n"; continue
expect "# " send "cpio -idmB </dev/rmt4\n"; continue
expect "# " send "cpio -idmB </dev/rmt4\n"; continue
expect "# " send "cd /usr/man\n"; continue
expect "# " send "cpio -idmB </dev/rmt4\n"; continue
expect "# " send "mkdir /tmp\n"; goto EDIT_DFILE1
boot RR0
:EDIT_DFILE1
noexpect
expect "# " send "cd /usr/src/uts/pdp11/cf\n"; continue
expect "# " send "touch %SYS%%VER%\n"; continue
expect "# " send "ed %SYS%%VER%\n"; goto EDIT_DFILE2
goto EOS
:EDIT_DFILE2
noexpect
expect "0\r\n" send -t DELAY=200k "a\n* Device Table\nrp03\t254\t176710\t5\nrk05\t220\t177400\t5\nlp11\t200\t177514\t4\ntu10\t224\t172520\t5\ndl11\t300\t176500\t4\ndl11\t310\t176510\t4\ndz11\t320\t160100\t5\ntrace\t0\t0\t0\nprf\t0\t0\t0\n* root/pipe/dump/sawp Device Specifications\nroot\trp03\t0\npipe\trp03\t0\ndump\ttu10\t0\nswap\trk05\t1\t0\t4871\n* UNIX Configuration Parameters\nbuffers\t42\nsabufs\t12\ninodes\t125\nfiles\t125\nmounts\t8\ncoremap\t75\nswapmap\t75\ncalls\t45\nprocs\t150\ntexts\t35\nclists\t200\nmaxproc\t15\npower\t0\n.\nw\nq\n"; goto BUILD_SYSTEM
goto EOS
:BUILD_SYSTEM
noexpect
expect "# " send "/etc/config /usr/src/uts/pdp11/cf/%SYS%%VER%\n"; continue
expect "# " send "make VER=%VER% SYS=%SYS% CONFIG=%SYS%%VER% TYPE=id NODE=%NODE%\n"; continue
expect "# " send "cp ../%SYS%%VER% /\n"; continue
expect "# " send "cd /\n"; continue
expect "# " send "rm /unix\n"; continue
expect "# " send "chmod 775 /%SYS%%VER%\n"; continue
expect "# " send "ln /%SYS%%VER% /unix\n"; continue
expect "# " send "sync\n"; continue
expect "# " send "sync\n"; continue
expect "# " send "sync\n"; continue
expect "# " goto BOOT_NEW
goto EOS
:BOOT_NEW
noexpect
expect "#" send "0unix\n"; continue
expect "# " send "date %DATE_MM%%DATE_DD%%TIME_HH%%TIME_MM%%DATE_19XX_YY%\n"; continue
expect "# " send "mount /dev/rp1 /usr\n"; goto MKNOD
boot RR0
:MKNOD
noexpect
expect "# " send "cd /dev\n"; continue
expect "# " send "/etc/config -t /usr/src/uts/pdp11/cf/s3\n"; continue
expect "# " send "rm *\n"; continue
expect "# " send "mknod console c 0 0\n"; continue
expect "# " send "mknod tty01 c 0 01\n"; continue
expect "# " send "mknod tty02 c 0 02\n"; continue
expect "# " send "mknod tty03 c 1 00\n"; continue
expect "# " send "mknod tty04 c 1 01\n"; continue
expect "# " send "mknod tty05 c 1 02\n"; continue
expect "# " send "mknod tty06 c 1 03\n"; continue
expect "# " send "mknod tty07 c 1 04\n"; continue
expect "# " send "mknod tty08 c 1 05\n"; continue
expect "# " send "mknod tty09 c 1 06\n"; continue
expect "# " send "mknod tty10 c 1 07\n"; continue
expect "# " send "mknod mem c 2 00\n"; continue
expect "# " send "mknod kmem c 2 01\n"; continue
expect "# " send "mknod null c 2 02\n"; continue
expect "# " send "mknod rmt0 c 6 00\n"; continue
expect "# " send "mknod rmt1 c 6 01\n"; continue
expect "# " send "mknod rmt4 c 6 04\n"; continue
expect "# " send "mknod rmt5 c 6 05\n"; continue
expect "# " send "mknod rrp0 c 7 00\n"; continue
expect "# " send "mknod rrp1 c 7 01\n"; continue
expect "# " send "mknod rrp17 c 7 017\n"; continue
expect "# " send "mknod tty c 13 00\n"; continue
expect "# " send "mknod lp c 14 00\n"; continue
expect "# " send "mknod trace c 16 00\n"; continue
expect "# " send "mknod error c 20 00\n"; continue
expect "# " send "mknod rrk0 c 35 00\n"; continue
expect "# " send "mknod rp0 b 0 00\n"; continue
expect "# " send "mknod rp1 b 0 01\n"; continue
expect "# " send "mknod rp17 b 0 017\n"; continue
expect "# " send "mknod mt0 b 1 00\n"; continue
expect "# " send "mknod mt1 b 1 01\n"; continue
expect "# " send "mknod mt4 b 1 04\n"; continue
expect "# " send "mknod mt5 b 1 05\n"; continue
expect "# " send "mknod rk0 b 4 00\n"; continue
expect "# " send "mknod swap b 4 01\n"; continue
expect "# " send "chmod 622 console\n"; continue
expect "# " send "chmod 444 error\n"; continue
expect "# " send "chmod 644 mem kmem\n"; continue
expect "# " send "chmod 666 null\n"; continue
expect "# " send "chmod 440 swap\n"; continue
expect "# " send "chmod 666 tty\n"; continue
expect "# " send "chmod 400 rp0 rrp0\n"; continue
expect "# " send "chmod 400 rp1 rrp1\n"; continue
expect "# " send "chmod 400 rp17 rrp17\n"; continue
expect "# " send "chmod 400 rk0 rrk0\n"; continue
expect "# " send "chmod 666 mt0 rmt0\n"; continue
expect "# " send "chmod 666 mt1 rmt1\n"; continue
expect "# " send "chmod 666 mt4 rmt4\n"; continue
expect "# " send "chmod 666 mt5 rmt5\n"; continue
expect "# " send "chmod 666 lp\n"; continue
expect "# " send "chmod 666 tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty10\n"; goto MAKE_HOME
goto EOS
:MAKE_HOME
noexpect
expect "# " send "mkfs /dev/rrp17 81200 0 200\n"; continue
expect "# " send "labelit /dev/rrp17 home p1703\n"; continue
expect "# " send "mkdir /home\n"; continue
expect "# " send "mount /dev/rp17 /home\n"; goto EDIT_RC
goto EOS
:EDIT_RC
noexpect
expect "# " send "cd /etc\n"; continue
expect "# " send "ed /etc/rc\n"; continue
expect "1197\r\n" send -t DELAY=200k "/umount/\na\n\t\t/etc/umount /dev/rp1\n\t\t/etc/umount /dev/rp17\n.\n/mount/\na\n\t/etc/mount /dev/rp1 /usr\n\t/etc/mount /dev/rp17 /home\n.\n/spool\\/lpd\\/lock/\nd\ni\n\trm -f /usr/spool/lpd/lock\n.\n/usr\\/lib\\/lpd/\nd\ni\n\t/usr/lib/lpd\n.\nw\nq\n"; goto EDIT_CHECKLIST
goto EOS
:EDIT_CHECKLIST
noexpect
expect "# " send "ed /etc/checklist\n"; continue
expect "9\r\n" send -t DELAY=200k "$a\n/dev/rp1\n/dev/rp17\n.\nw\nq\n"; goto EDIT_INITTAB
goto EOS
:EDIT_INITTAB
noexpect
expect "# " send "ed /etc/inittab\n"; continue
expect "168\r\n" send -t DELAY=200k "$a\n2:t1:c:/etc/getty tty01 5\n2:t2:c:/etc/getty tty02 5\n2:t3:c:/etc/getty tty03 5 10\n2:t4:c:/etc/getty tty04 5 10\n2:t5:c:/etc/getty tty05 5 10\n2:t6:c:/etc/getty tty06 5 10\n2:t7:c:/etc/getty tty07 5 10\n2:t8:c:/etc/getty tty08 5 10\n2:t9:c:/etc/getty tty09 5 10\n2:ta:c:/etc/getty tty10 5 10\n.\nw\nq\n"; goto EDIT_PASSWD
goto EOS
:EDIT_PASSWD
noexpect
expect "# " send "ed /etc/passwd\n"; continue
expect "368\r\n" send -t AFTER=100k DELAY=200k "2\ns/::/:ACCT.DISABLED,.\\/:/\n3\ns/::/:ACCT.DISABLED,.\\/:/\n4\ns/::/:ACCT.DISABLED,.\\/:/\n5\ns/::/:ACCT.DISABLED,.\\/:/\n8\ns/::/:ACCT.DISABLED,.\\/:/\n9\ns/::/:ACCT.DISABLED,.\\/:/\n10\ns/::/:ACCT.DISABLED,.\\/:/\n$a\n%USER%:,..:1000:1:0000-%USER%(0000):/home/%USER%:\n.\nw\nq\n"; continue
expect "# " send "passwd root\n"; continue
expect "New password:" send "%ROOTPWD%\n"; continue
expect "Re-enter new password:" send "%ROOTPWD%\n"; goto EDIT_MOTD
goto EOS
:EDIT_MOTD
noexpect
expect "# " send "mv /etc/motd /etc/motd.old\n"; continue
expect "# " send "touch /etc/motd\n"; continue
expect "# " send "ed /etc/motd\n"; continue
expect "0\r\n" send -t DELAY=200k "a\nWelcome to \"%NODE%\", a UNIX System III (release 3.0.1) system.\n.\nw\nq\n"; goto MAKE_USERDIR
goto EOS
:MAKE_USERDIR
noexpect
expect "# " send "cd /\n"; continue
expect "# " send "mkdir /home/%USER%\n"; continue
expect "# " send "chown %USER% /home/%USER%\n"; goto MAKE_COMMANDS
goto EOS
:MAKE_COMMANDS
noexpect
expect "# " send "/usr/src/:mkcmd cc\n"; continue
expect "# " send "/usr/src/:mkcmd f77\n"; continue
expect "# " send "/usr/src/:mkcmd acct\n"; continue
expect "# " send "/usr/src/:mkcmd adb\n"; continue
expect "# " send "/usr/src/:mkcmd awk\n"; continue
expect "# " send "/usr/src/:mkcmd bs\n"; continue
expect "# " send "/usr/src/:mkcmd cpio\n"; continue
expect "# " send "/usr/src/:mkcmd dc\n"; continue
expect "# " send "/usr/src/:mkcmd du\n"; continue
expect "# " send "/usr/src/:mkcmd dump\n"; continue
expect "# " send "/usr/src/:mkcmd efl\n"; continue
expect "# " send "/usr/src/:mkcmd fgrep\n"; continue
expect "# " send "/usr/src/:mkcmd find\n"; continue
expect "# " send "/usr/src/:mkcmd fsck\n"; continue
expect "# " send "/usr/src/:mkcmd lex\n"; continue
expect "# " send "/usr/src/:mkcmd make\n"; continue
expect "# " send "/usr/src/:mkcmd mkfs,\n"; continue
expect "# " send "/usr/src/:mkcmd nm\n"; continue
expect "# " send "/usr/src/:mkcmd pack\n"; continue
expect "# " send "/usr/src/:mkcmd pcat\n"; continue
expect "# " send "/usr/src/:mkcmd restor\n"; continue
expect "# " send "/usr/src/:mkcmd spell\n"; continue
expect "# " send "/usr/src/:mkcmd spline\n"; continue
expect "# " send "/usr/src/:mkcmd tbl\n"; continue
expect "# " send "/usr/src/:mkcmd tplot\n"; continue
expect "# " send "/usr/src/:mkcmd troff\n"; continue
expect "# " send "/usr/src/:mkcmd typo\n"; continue
expect "# " send "/usr/src/:mkcmd units\n"; continue
expect "# " send "/usr/src/:mkcmd unpack\n"; continue
expect "# " send "/usr/src/:mkcmd uucp\n"; continue
expect "# " send "/usr/src/:mkcmd volcopy\n"; continue
expect "# " send "/usr/src/:mkcmd yacc\n"; goto MAKE_DIRS
goto EOS
:MAKE_DIRS
noexpect
expect "# " send "mkdir /usr/adm\n"; continue
expect "# " send "mkdir /usr/news\n"; continue
expect "# " send "mkdir /usr/spool\n"; continue
expect "# " send "mkdir /usr/spool/lpd\n"; goto EDIT_WELCOME1
goto EOS
:EDIT_WELCOME1
noexpect
expect "# " send "touch /usr/news/welcome\n"; continue
expect "# " send "ed /usr/news/welcome\n"; continue
expect "0\r\n" send -t DELAY=250k "a\nWelcome to the AT&T UNIX Support Group (USG) UNIX System III turnkey!\n\n.\nw\nq\n"; continue
expect "# " send "ed /usr/news/welcome\n"; goto EDIT_WELCOME2
goto EOS
:EDIT_WELCOME2
noexpect
expect "71\r\n" send -t DELAY=250k "$a\nThis a turnkey system created for  educational  purposes--and  because  it\n(the  distribution/installation tape) was there, and I wanted to know if I\ncould get actually get it setup and customized.  It should be  noted  that\nthe  \"Setting  Up  UNIX\"  manual lies, and there was much faffing about to\nactually to build a custom kernel.  (There was also much  further  faffing\nabout  to  build  a  custom  kernel that worked, but that was on me and my\nincorrectly specified configuration file.)\n\n.\nw\nq\n"; continue
expect "# " send "ed /usr/news/welcome\n"; goto EDIT_WELCOME3
goto EOS
:EDIT_WELCOME3
noexpect
expect "565\r\n" send -t DELAY=250k "$a\nBeing this is System III, it has the \"feel\" of  Seventh  Edition  UNIX  or\nUNIX/32V--which  is  to  be  expected,  given its heritage is a mixture of\nSeventh Edition, 32V, PWB/UNIX, CB UNIX, and UNIX/RT.\n\n.\nw\nq\n"; continue
expect "# " send "ed /usr/news/welcome\n"; goto EDIT_WELCOME4
goto EOS
:EDIT_WELCOME4
noexpect
expect "770\r\n" send -t DELAY=250k "$a\nThe emulated system that  this  turnkey  is  running  on  is  an  emulated\nPDP-11/70  (KB11-C)  with  1536 KB of MOS RAM (that is three MK11-B boxes)\nand floating-point processor (FP11-C).  Peripherals-wise the system has an\nRP11-C  with  two  RP03  disk drives (on which live the /, /usr, and /home\nfile systems), an RK11-D with two RK05 disk drives (unit  0  is  free  and\navailable  to  mount  disks, unit 1 is the system swap volume), two DL11-C\n.\nw\nq\n"; continue
expect "# " send "ed /usr/news/welcome\n"; goto EDIT_WELCOME5
goto EOS
:EDIT_WELCOME5
noexpect
expect "1220\r\n" send -t DELAY=250k "$a\nserial line units, a DZ11-A serial multiplexer, and an LP11 line  printer.\nThe  DL11-C  and  DZ11-A lines are all setup to accept logins, however the\nDL11  lines  are  not  configured  to  receive  a  socket  in   the   SIMH\nconfiguration,  as  they  will be used in the future for UUCP; the LP11 is\nsetup for printing (with the lpd daemon as spooler, obviously).\n.\nw\nq\n"; goto FINAL
goto EOS
:FINAL
expect "# " send "sync\n"; continue
expect "# " send "sync\n"; continue
expect "# " send "sync\n"; continue
expect "# " send "/etc/shutdown\n"; continue
expect "SHUTDOWN PROGRAM" continue
expect "Do you want to continue? (y or n):   " send "y\n"; continue
expect "Type either ( y or n ) :   " send "n\n"; continue
expect "# " goto STOP
goto EOS
:EOS
continue
:STOP
echo  
echo ************************************************************************
echo * UNIX System III "Turnkey" system installion is complete.             *
echo *                                                                      *
echo *     INSTALLATION ENDED AT %TIME%                                   *
echo *                                                                      *
echo * Exit the PDP-11 simulator before booting the system.                 *
echo ************************************************************************
set CONSOLE NOLOG
:END
