 ttl 5" Gimix Init Task
 pag
 opt nol
 lib sysdef
 lib sysints
 opt lis

 info Special UniFLEX INIT Task (task 1) for 5" Gimix system
 info Version 2.01, Released June 26, 1984
 info Copyright (c) 1984 by
 info Technical Systems Consultants, Inc.
 info All rights reserved

STDERR equ 2 File descriptor for terminal
 abs
 org 0

start
 sys cpint,INTI,1 ignore Control-C
 sys cpint,QUITI,1 and Control-Backslash
 sys open,ttyname,2 stdin
 sys open,ttyname,2 stdout
 sys open,ttyname,2 stderr
 ldd #2
 sys write,msg1,msg1s

ask ldd #2 print prompt
 sys write,msg2,msg2s
 ldd #2 get response
 sys read,response,BUF_SIZE
 bcs quit abort if error
 cmpd #0
 beq quit also on EOF
 lda response get response
 ora #$20 make lower case
 cmpa #'u if "u" - the guy wants to update
 beq do_update
 if 0
 cmpa #'r if "r" - the guy wants to repair his system disk
 beq do_repair
 endif
 cmpa #'b if "b" - the guy wants to build a new system disk
 beq do_build
 ldd #2 rebuf the guy!
 sys write,msg3,msg3s -- Huh?
 bra ask

 if 0
do_repair sys fork create a task for "diskrepair"
 bra runrepair
 bra wait_done wait for it to finish
 endif

do_build  ldx #new_sys
 bra go

do_update ldx #old_sys

go stx cmd_name
 ldd #0 close stdin
 sys close
 sys open,null,0
 sys fork create new task
 bra runshell

wait_done pshs d save task id
wait0 sys wait wait for task to terminate
 cmpd 0,s last task?
 bne wait0
quit ldd #STDERR write "stopped" message
 sys write,msg0,msg0s
 sys update update disks
 bra * hang up

*
* execute shell to build hard disk system
*
runshell
 sys cpint,INTI,0 allow Control-C
 sys cpint,QUITI,0 and Control-Backslash
 sys exec,shell,args
 sys term

 if 0
*
* execute the disk repair program for the hard disk
*
runrepair
 sys cpint,INTI,0 allow Control-C
 sys cpint,QUITI,0 and Control-Backslash
 sys exec,diskrepair,diskargs
 sys term
 endif

ttyname fcc '/dev/tty00',0
null    fcc '/dev/null',0
old_sys fcc '/update-hd',0
new_sys fcc '/make-hd',0
*
shell fcc '/bin/shell',0
args fdb arg0
 fdb arg1
cmd_name fdb 0
 fdb 0
arg0 fcc 'shell',0
arg1 fcc '+c',0

 if 0
*
diskrepair fcc '/root/etc/diskrepair',0
diskargs fdb d_arg0
 fdb d_arg1
 fdb d_arg2
 fdb 0
d_arg0 fcc 'diskrepair',0
d_arg1 fcc '/dev/hd0',0
d_arg2 fcc '+vp',0
 endif

msg0 fcc 'System stopped!',$d
msg0s equ *-msg0

msg1 fcc $d
 fcc '*******************************************',$d
 fcc '*                                         *',$d
 fcc '*    UniFLEX 10.10 System Build/Update    *',$d
 fcc '*                                         *',$d
 fcc '*******************************************',$d
 fcc $d
msg1s equ *-msg1

msg2 fcc $d,'You may chose from the following options:',$d
     fcc $d
     fcc 'B - Build a new UniFLEX System on /dev/hd0',$d
     fcc 'U - Upgrade an existing UniFLEX System to version 10.10',$d
     if 0
     fcc 'R - Repair an existing UniFLEX System disk',$d
     endif
     fcc $d
     fcc 'Which function would you like to perform? '
msg2s equ *-msg2

msg3 fcc $d,'-- Illegal function choice - Please try again'
msg3s equ *-msg3

BUF_SIZE equ 80
response rzb BUF_SIZE

 end start
