
; :ts=3
; HDInstall - Install Professional Draw onto a hard drive.
;
; Inputs:
;    dest   Directory to install PDraw into
;    help   Print instructions
;

;
; Some preliminary setup.
;
ASSIGN PDrawInstUtil: PDrawFonts:    ; Hook we can use when disk has been removed
ASSIGN PDrawInstOrig: ""            ; Save initial directory

; Make sure he's running WB 1.3!
; Under 1.3, the "1 gt 2" test fails; we proceed to "FAILAT 10".
; Under 1.2, however, the IF command itself dies, since GT is not defined;
; execution is not suspended, and the ECHO and SKIP are seen.
FAILAT 21
IF >NIL: 1 gt 2
	ECHO "*NVersion 1.3 of the Amiga Workbench software *E[;1mmust*E[m be"
	ECHO "present before this installation can proceed.*N"
   SKIP wrapup
ENDIF
FAILAT 10

; Start with a fresh copy, to avoid any screwups
IF EXISTS RAM:PDrawInstall
   DELETE >NIL: RAM:PDrawInstall/#?
ELSE
   MAKEDIR RAM:PDrawInstall
ENDIF


CD ram:PDrawInstall  ; Search it without adding it to path
Copy C:Copy    ""
; for V2.0 OS some of these commands are resident:
IF EXISTS C:If
   Copy C:If	  ""
ENDIF
IF EXISTS C:Endif
   Copy C:Endif   ""
ENDIF
IF EXISTS C:Else
   Copy C:Else	  ""
ENDIF
IF EXISTS C:Echo
   Copy C:Echo	  ""
ENDIF
IF EXISTS C:Failat
   Copy C:FailAt  ""
ENDIF
Copy C:Assign  ""
Copy C:Makedir ""
Copy C:Execute ""

COPY PDrawInstUtil:HD/DiskMount    RAM:PDrawInstall
COPY PDrawInstUtil:HD/InstUtil	   RAM:PDrawInstall
COPY PDrawInstUtil:HD/Install-Proc RAM:PDrawInstall

Assign PDrawInstPgm:		    ; Make sure these start fresh, too.

;
; Make sure needed system assignments exist.
;
INSTUTIL isdir T:
IF WARN
   INSTUTIL isdir RAM:T
   IF WARN
      MAKEDIR ram:T
   ENDIF
   ASSIGN T: ram:T
ENDIF

INSTUTIL isdir ENV:
IF WARN
   INSTUTIL isdir RAM:ENV
   IF WARN
      MAKEDIR ram:ENV
   ENDIF
   ASSIGN ENV: ram:ENV
ENDIF


;
; HELP processing
;
IF "" eq "HELP"
   SKIP showme
ENDIF

INSTUTIL ask -dy "Do you need instructions [Y/N]? Y"
IF WARN
   SKIP noshow
ENDIF

LAB showme
   EXECUTE RAM:PDrawInstall/DiskMount Program PDraw: PDrawInstPgm:
   PDrawInstPgm:showme PDrawInstUtil:HD/HELP-Install
LAB noshow


;
; Make sure that the destination exists, that its name is
; in a useable form (ie. that it ends with a '/' if it's a directory),
; and that the user in fact wants to install into it.
;
IF NOT EXISTS DH1:DeskTop
   ECHO "*N ********** Couldn't find Hard Disk drawer DH1:DeskTop **********"
   SKIP forhelp
ENDIF

INSTUTIL isdir DH1:DeskTop
IF WARN
   CD RAM:PDrawInstall
   ECHO "*N ********** DH1:DeskTop is not a drawer! **********"
LAB forhelp
   ECHO "*N For help, type"
   ECHO "      EXECUTE PDrawUtil:HD/HDInstall help"
   ECHO "*N or double-click on the *"Help*" icon in this drawer*N"
   SKIP wrapup
ENDIF
CD RAM:PDrawInstall

ECHO "*N Answering *"No*" to the following question will cancel"
ECHO " the installation.  Your hard drive will not be changed.*N"
INSTUTIL ask -dy "Install Professional Draw onto DH1:DeskTop [Y/N]? Y"
IF warn
   ECHO " Installation aborted!*N"
   SKIP wrapup
ENDIF

ECHO >ram:PDrawInstall/DestPath1 "DH1:DeskTop"
INSTUTIL <ram:PDrawInstall/DestPath1 >ram:PDrawInstall/DestPath2 fixdir


ECHO "*N*N ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*N"
ECHO " Begin installation of Professional Draw onto DH1:DeskTop*N"

EXECUTE <ram:PDrawInstall/DestPath2 >nil: ram:PDrawInstall/Install-Proc ?

ECHO "*N*N --------------------------------------------------------------------"
IF NOT EXISTS SYS:WBStartup
   ECHO "  Please add the following command to the file s:Startup-sequence:"
   ECHO "*N        Execute s:PDrawStartup*N"
   ECHO "  Then remove the Professional Draw floppy disks from the drive(s)"
   ECHO "  and reboot your Amiga to use Professional Draw"
ELSE
   ECHO "  Please remove the Professional Draw floppy disks from the drive(s)"
   ECHO "  and reboot your Amiga to use Professional Draw"
ENDIF

ECHO "*N --------------------------------------------------------------------"
ECHO "*N*N Installation of Professional Draw complete."
ECHO "*N ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*N"

;
; Clean up after ourselves
; Can't depend on anything but PDrawInstOrig: and PDrawInstUtil:,
; since we can come here from right after their definition.
;
LAB wrapup

CD PDrawInstOrig:
Assign PDrawInstOrig:
Assign PDrawInstPgm:
DELETE >NIL: RAM:PDrawInstall all quiet

PDrawInstUtil:HD/InstUtil ask "Press RETURN."
Assign PDrawInstUtil:


