.key test/s,full/s
.bra [
.ket ]
;
echo "*Ec*N                   GFX-CAD 3.1 Hard Disk Installation*N"

;make sure the date on their system is reasonable.
resident >NIL: c:date force
echo "*NSystem date is currently `date`."
    Ask "         Is this correct ? (Y/N) "
if not warn
    echo "  Please enter date (DD-MMM-YY): " noline
    date >NIL: ?
    echo "      Please enter time (HH:MM): " noline
    date >NIL: ?
    setclock save
    echo "System date set to `date`."
endif
resident remove date
;
; Must have 2.0 roms for this script to work
;;failat 30
version >NIL: 36
if warn
echo "You must assign be using 2.0 Kickstart to this install routine!"
skip end
endif
;
; make required commands resident
;
echo "*NSetting up commands..."
;
resident c:Copy pure
resident c:Assign pure
resident c:Info pure
resident c:Rename pure
resident c:Delete pure
resident c:Makedir pure
resident c:Execute pure
resident c:List pure
resident c:Eval pure
resident >NIL: c:IconPos pure
;
; set directory to return to
assign tempdir: ""
cd ram:
; make sure they booted from the install disk
if NOT exists s:GFX-Boot
    echo "Please boot from your GFX-CAD Install disk to install GFX-CAD."
          skip exit
endif
;
failat 21
;
; attempt to figure out the name of sys: partition
;
; is it an A3000 style set up ?
assign >NIL: exists wb_2.x:
if not warn
; Get the volume name of the wb_2.x: device
    ; the .info will be deleted later with the rest of them
    echo "findme" >wb_2.x:.info
    set starget `list wb_2.x:.info lformat="%f"`
else
; is it a 2091 or A590 ?
assign >NIL: exists Workbench:
if not warn
set starget Workbench:
else
; is it a 2090a ?
assign >NIL: exists BOOT:
if not warn
    set starget fh0:
    ; see if they have the standard mounts
    if exists BOOT:devs/MountList.HD
        mount fh0: from BOOT:devs/MountList.HD
        mount fh1: from BOOT:devs/MountList.HD
    else
        mount fh0: from BOOT:devs/MountList
        mount fh1: from BOOT:devs/MountList
    endif
else
; is it a 2090 SCSI ?
assign >NIL: exists DH0:
if not warn
set starget DH0:
else
; is it a 2090 ST506 ?
assign >NIL: exists DH0:
if not warn
set starget DH0:
endif
endif
endif
endif
endif
;
; If we can't tell what kind of system it is, ask the user directly.
; Note that we must remember to ask for a keymap afterwords.
if "$target" EQ "GFX-Install:"
    set needSKeymap 1
    skip nameloop
endif

; make sure we got it right
Ask "*NIs your normal startup (S:) partition located on $starget? (Y/N) "
if not warn
lab snameloop
 echo "Enter the name of your startup (S:) partition? (Q = quit) " noline
  set >NIL: starget ?
; Test to see if they gave a reasonable response
  if "$starget" EQ "Q"
      skip exit
  endif

; first add a ":" if they forgot

  if "`echo $target len 1`" NOT EQ ":"
    set starget $starget:
  endif

  if "${starget}" EQ "SYS:"
    echo "ERROR:  Cannot install to the GFX-Install disk."
    echo "Please give the volume name of your SYS: partition.*N"
    skip back snameloop
  endif

  assign >NIL: exists "${starget}"
  if warn
    echo "ERROR: Partition does not exist.  The partition may not"
    echo "be mounted, or the driver for your card may not have"
    echo "been started.  If this is the case, you will need to"
    echo "copy the driver into the Expansion drawer of this disk,"
    echo "or perform the mount by hand before starting this Install.*N"
    skip back snameloop
  endif
  ;
  ; if full flag is set, we don't check for startup-sequence
  ; as we are assuming the partition is formatted.
  ;
  if "[full]" EQ ""
    if not exists "${starget}s/Startup-Sequence"
      echo "WARNING: There is no startup-sequence on this partition."
      ask "Continue anyway ? (Y/N) "
      if warn
	skip partok
      endif
      echo "Please try again.*N"
      skip back nameloop
    endif
  endif
endif


Ask "*N    Is $starget the partition you plan to install GFX-CAD? (Y/N) "
if warn
set xtarget $starget
endif

if not warn
lab xnameloop
 echo "Enter the name of your planned GFX-CAD partition? (Q = quit)  " noline
  set >NIL: xtarget ?
; Test to see if they gave a reasonable response
  if "$xtarget" EQ "Q"
      skip exit
  endif

; first add a ":" if they forgot

  if "`echo $xtarget len 1`" NOT EQ ":"
    set xtarget $xtarget:
  endif

  if "${xtarget}" EQ "SYS:"
    echo "ERROR:  Cannot install to the GFX-Install disk."
    echo "        Please give the volume name of your SYS: partition.*N"
    skip back xnameloop
  endif

  assign >NIL: exists "${xtarget}"
  if warn
    echo "ERROR: partition does not exist.  The partition may not"
    echo "be mounted, or the driver for your card may not have"
    echo "been started.  If this is the case, you will need to"
    echo "copy the driver into the Expansion drawer of this disk,"
    echo "or perform the mount by hand before starting this Install.*N"
    skip back xnameloop
  endif
  ;
  ; if full flag is set, we don't check for startup-sequence
  ; as we are assuming the partition is formatted.
  ;
echo ""  

;aliases for testing

if "[test]" NOT EQ ""
    echo "In test mode"
    alias copy echo "-> copy"
    alias delete echo "-> delete"
    alias iconpos echo "-> iconpos"
    alias rename echo "-> rename"
endif

;make some source assignments for convenience

assign a: GFX-Install:
assign target: "${xtarget}"
assign starter: "${starget}"
echo "*EcWARNING: You will need 2.5 megs free on $xtarget for GFX-CAD."
   echo "         The following procedure will install GFX-CAD files to $xtarget."
    Ask "         Do you really wish to continue?  (Y/N) "
if not warn
echo "        Installation process stopped."
skip exit
endif
;
;;xjwilsonxx;;
echo "*NNow creating GFX-CAD directory for XCAD & X-Shell"

if exists target:GFX-CAD
echo "*NWARNING: ${xtarget}GFX-CAD exists already!" 
ask  "Do you want it renamed & have another one created? (Y/N)" 
if warn
    set newname `date`
    set newname `echo "$newname" len 18`
    set newname GFX-CAD_`echo "$newname" first 1 len 9`
    echo "${xtarget}GFX-CAD will be renamed as"
    echo " *"$newname*" and a new ${xtarget}GFX-CAD created."
    rename >NIL: target:GFX-CAD target:$newname
    if not exists  target:$newname
echo "Could not rename existing GFX-CAD directory. Exiting!"
	skip exit
    endif	
endif
    makedir >NIL: target:GFX-CAD
endif

if not exists target:GFX-CAD
    makedir >NIL: target:GFX-CAD
endif
echo ""
echo "Copying XSHELL startup files to hard disk"
copy GFX-Install:s-hd to starter:s all 
echo ""
echo "Copying XSHELL assignment files to hard disk"
copy GFX-Install:AssignXCAD#? target:gfx-cad all 
copy GFX-Install:UnsignXCAD#? target:gfx-cad all 
echo "Copying XCAD documentation files to hard disk"
copy GFX-Install:xcdocs target:gfx-cad/xcdocs all
copy GFX-Install:xmdocs target:gfx-cad/xmdocs all
	
assign X3: X-FILES:
if exists X-FILES: 
echo ""
echo "Copying XCAD command files to hard disk"
copy X-FILES:povly to target:GFX-CAD/povly all 
echo ""
echo "Copying XCAD program files to hard disk"
copy X-FILES:x#? to target:GFX-CAD
copy X-FILES:GFXCAD#? to target:GFX-CAD
copy X-FILES:HP-Aegis#?  target:GFX-CAD all
copy X-FILES:HP-Sculpt#? target:GFX-CAD all

copy ram:drawer.icon target:GFX-CAD.info
else
echo "WARNING: Could not find X-FILES! Installation not complete!"
endif

assign x2: X-SHELL:
if exists X-SHELL:
if not exists target:GFX-CAD/coms
echo ""
echo "Copying XSHELL command files to hard disk"
copy X-SHELL:coms target:GFX-CAD/coms all 
endif

if not exists target:GFX-CAD/mnus
echo ""
echo "Copying XSHELL menu files to hard disk"
copy X-SHELL:mnus target:GFX-CAD/mnus all 
endif

if not exists target:GFX-CAD/xdrs
echo ""
echo "Copying XSHELL drawing files to hard disk"
copy X-SHELL:xdrs to target:GFX-CAD/xdrs all 
endif

if not exists target:GFX-CAD/syms
echo ""
echo "Copying XSHELL symbol files to hard disk"
copy X-SHELL:syms target:GFX-CAD/syms all 
endif

if not exists target:GFX-CAD/xfonts
echo ""
echo "Copying XSHELL font files to hard disk"
copy X-SHELL:xfonts target:GFX-CAD/xfonts all 
endif

if not exists target:GFX-CAD/xcdata
echo ""
echo "Copying XSHELL data files to hard disk"
copy X-SHELL:xcdata target:GFX-CAD/xcdata all 
endif

if not exists target:GFX-CAD/lovly
echo ""
echo "Copying XCAD library files to hard disk"
copy X-SHELL:lovly target:GFX-CAD/lovly all 
endif

echo ""
echo "Copying XCAD compilers to hard disk"
copy X-SHELL:comp#? to target:GFX-CAD 
copy X-SHELL:GFXMENU#? to target:GFX-CAD 
	copy X-SHELL::Tablet#? to  target:GFX-CAD
	copy X-SHELL:Modifier#? to target:GFX-CAD
	copy X-SHELL:Attribute#? to target:GFX-CAD
	copy X-SHELL:VerbNoun#? to target:GFX-CAD
	
else
echo "WARNING: Could not find X-SHELL! Installation not complete!"
"
endif

assign x1: X-BENCH:
if exists X-BENCH:
echo ""
echo "Copying XCAD overlay files to hard disk"
	makedir >NIL: target:GFX-CAD/mods
copy X-BENCH:mods to target:GFX-CAD/mods all 
copy X-BENCH:c/wmove starter:c
copy X-BENCH:PATCH starter:c

	makedir >NIL: target:GFX-CAD/plts
	makedir >NIL: target:GFX-CAD/iffs
	makedir >NIL: target:GFX-CAD/adgs
	makedir >NIL: target:GFX-CAD/dxfs
	makedir >NIL: target:GFX-CAD/xdrs
	makedir >NIL: target:GFX-CAD/xmcs
	makedir >NIL: target:GFX-CAD/xfls
	makedir >NIL: target:GFX-CAD/drawings

echo "*NPositioning new icons..."
	iconpos >NIL: target:GFX-CAD/HP-Aegis.info type=PROJECT 405 4
	iconpos >NIL: target:GFX-CAD/HP-Sculpt.info type=PROJECT 405 54

	iconpos >NIL: target:GFX-CAD/Tablet type=PROJECT 475 4
	iconpos >NIL: target:GFX-CAD/Attribute type=PROJECT 545 4
	iconpos >NIL: target:GFX-CAD/Modifier type=PROJECT 475 54
	iconpos >NIL: target:GFX-CAD/VerbNoun type=PROJECT 545 54

	iconpos >NIL: target:GFX-CAD/GFXCAD type=PROJECT 25 19
	iconpos >NIL: target:GFX-CAD/GFXMENU type=TOOL 25 56
	iconpos >NIL: target:GFX-CAD/AssignXCAD type=PROJECT 142 4
	iconpos >NIL: target:GFX-CAD/UnsignXCAD type=PROJECT 142 54
	iconpos >NIL: target:GFX-CAD type=DRAWER 10 10

	copy ram:drawer.icon target:GFX-CAD/DRAWINGS.info
	iconpos >NIL: target:GFX-CAD/drawings type=DRAWER 245 4
	copy ram:drawer.icon target:GFX-CAD/xdrs.info
	iconpos >NIL: target:GFX-CAD/xdrs type=DRAWER 245 34
	copy ram:drawer.icon target:GFX-CAD/plts.info
	iconpos >NIL: target:GFX-CAD/plts type=DRAWER 245 64
	copy ram:drawer.icon target:GFX-CAD/dxfs.info
	iconpos >NIL: target:GFX-CAD/dxfs type=DRAWER 245 94
	copy ram:drawer.icon target:GFX-CAD/syms.info
	iconpos >NIL: target:GFX-CAD/syms type=DRAWER 325 4
	copy ram:drawer.icon target:GFX-CAD/adgs.info
	iconpos >NIL: target:GFX-CAD/adgs type=DRAWER 325 34
	copy ram:drawer.icon target:GFX-CAD/iffs.info
	iconpos >NIL: target:GFX-CAD/iffs type=DRAWER 325 64
	copy ram:drawer.icon target:GFX-CAD/xmcs.info
	iconpos >NIL: target:GFX-CAD/xmcs type=DRAWER 325 94

echo ""
echo "You may use XCAD special libraries only if you have a math coprocessor."
echo ""

Ask  "Do you have a 68881 math coprocessor on you system? (Y/N) "
echo "                         (If you have any doubt answer N)"	
if not warn 
skip exit
else
Ask  " Do you want to install special math libraries? (Y/N) "
	if not warn
	skip exit
	else
	echo "Copying XCAD special math libraries?"
	copy X-BENCH:lovly-68881 to target:GFX-CAD/lovly all 
	endif	  
endif
else
echo "WARNING: Could not find X-BENCH! Installation not complete!"
endif

echo "*Ec"
echo ""
echo "        Installation of GFX-CAD 3.1 is finished. "
echo ""
;echo "   NOW: Customize your User-Startup (if using WorkBench 2.0),"
;echo "     or customize your StartUp II (if using WorkBench 1.3)."
;
lab exit
; remove the temporary installation assignments
assign a:
assign target:
;
cd tempdir:
assign tempdir:
; remove the test aliases and sets
if "[test]" NOT EQ ""
unset echo    
unalias copy
unalias rename
unalias delete
endif
; unset our temporary variables
unset size
unset target
unset starter
unset newname
lab end

