; 000520 T.Neidhardt, ft112@fen.baynet.de, EasySystem
; AmigaShell script
; Script for starting up the iGuide and
; preparing the installation procedure.
; To be executed by double-clicking it's Project Icon.
; Commands and filenames must be used case sensitive
; because PFS3 or SFS seem to make problems in other cases.

;-------------------------------- variables
failat 30
stack 40000

set app EASys!
set remove 0

;-------------------------------- preparations

c:relabel RAM: RAM-Disk
assign "RAM Disk:" RAM: ADD
unalias lha
unalias list

version >NIL: workbench.library 44
IF warn
 setenv osver 3.x
ELSE
 setenv osver 3.5
ENDIF

; Arq may cause heavy problems while installing on OS3.5:
c/CLIExchange "Arq 1.83" KILL
c/CLIExchange "Arq" KILL

LAB begin
unset dest

if $osver eq 3.5
 c/requestchoice TITLE "iGuide request" BODY "$app installation:*n*nPlease enter a device or volume*nwith >= 10MB free temporary disk space*n(best is RAM: - don't use BootPartition! )" GADGETS "select Volume.."
 c/RequestDevice TITLE "? Tmp Device: >= 10MB free" VAR dest
else
 echo "*ec*n$app installation:*n*nPlease enter a device or volume*nwith >= 10MB free temporary disk space*n(best is RAM: - don't use BootPartition! )"
 set >NIL: dest "RAM:"
 set >NIL: dest ?
endif

c:assign >NIL: "$dest" exists
if warn
 skip begin back
endif
if "$dest" eq "EASys!_CD:"
 skip begin back
endif
if "$dest" eq "CD0:"
 skip begin back
endif
if not exists "$dest"
 skip begin back
endif

cd >ENV:$app_StarterDir
set instdir "$dest$app_inst"

;-------------------------------- remove a misinstalled system
if $remove eq 1
 execute remove_$app.script
endif

;-------------------------------- check for already unpacked iGuide
if exists "$instdir/$app_iGuide/c/RemoteEd.rexx"
  skip STARTER
endif

if not exists $app.lha
 skip error
endif

if not exists $app_iGuide.lha
 skip error
endif

if not exists Lha
 skip error
endif

;--------------------------------
echo "*ec*n*n*e[1m Preparing Installation ...*e[0m*n ___________________________________________*n"

if not exists $instdir
 makedir "$instdir"
endif

assign >NIL: T: exists
if warn
 makedir RAM:T
 assign T: RAM:T
endif
wait 3

;--------------------------------
LAB INSTALLER
if exists "$instdir/$app_iGuide/c/RemoteEd.rexx"
 skip STARTER
endif
echo "*ec*n*n*e[1m Extracting*e[0m Installer archive ...*n"
wait 3
LhA x -am $app_iGuide.lha "$instdir/"
wait 2

;--------------------------------
LAB STARTER
echo "*ec*n*n*e[1m Starting Installer...*e[0m*n"
wait 3

cd "$instdir"
if not exists $app_iGuide/c/RemoteEd.rexx
 echo "*ec*n*e[1m $app-Guide Start Process:*e[0m*n Error occured unpacking $app_iGuide.lha"
 skip END
endif

assign iGuide_Root: ""

cd "$app_iGuide"
assign iGuide: ""
assign install_C: c

;-------------------------------- PrepareOS

; 000307 T.Neidhardt, ft112@fen.baynet.de, EasySystem
; AmigaShell script
; Script for general system preparation and supplying
; original OS commands for reliable iGuide scripting.

resident C:copy PURE

path SYS:c add
path SYS:Utilities add
path SYS:System add
path SYS:Tools add
path SYS:Tools/Commodities add
path S: add

;-------------------------------- Check OS Version
if not $osver eq 3.5
 skip oldOS
ELSE
 echo "*n*n ... please insert original OS3.5 CDROM !"
 ask  " ... then press [ENTER]"
ENDIF

;-------------------------------- OS3.5
IF EXISTS AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Assign
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Assign Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/copy Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Date Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Delete Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Execute Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/makedir Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Rename Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Search Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Sort Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/C/Wait Install_C: CLONE QUIET

 copy AmigaOS3.5:OS-Version3.5/Workbench/c/List Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.5/Workbench/c/Status Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.5/Workbench/c/Type Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.5/Workbench/c/Version Install_C: CLONE QUIET

 copy AmigaOS3.5:OS-Version3.5/Workbench/Utilities/MultiView Install_C: CLONE QUIET
 copy AmigaOS3.5:OS-Version3.1/Workbench3.1/Libs/rexx#? libs: CLONE QUIET

 Install_C:assign Install_C: AmigaOS3.5:OS-Version3.5/Workbench/c ADD
 Install_C:assign Install_C: AmigaOS3.5:OS-Version3.5/Workbench/System ADD
 Install_C:assign Install_C: AmigaOS3.5:OS-Version3.5/Workbench/Tools ADD
 Install_C:assign Install_C: AmigaOS3.5:OS-Version3.5/Workbench/Utilities ADD

 skip DoRest
ENDIF

;-------------------------------- OS3.0 or OS3.1
LAB oldOS
copy C:assign Install_C: CLONE QUIET
copy C:copy Install_C: CLONE QUIET
copy C:Date Install_C: CLONE QUIET
copy C:Delete Install_C: CLONE QUIET
copy C:Execute Install_C: CLONE QUIET
copy C:List Install_C: CLONE QUIET
copy C:makedir Install_C: CLONE QUIET
copy C:Rename Install_C: CLONE QUIET
copy C:Search Install_C: CLONE QUIET
copy C:Sort Install_C: CLONE QUIET
copy C:Status Install_C: CLONE QUIET
copy C:Type Install_C: CLONE QUIET
copy C:Version Install_C: CLONE QUIET
copy C:Wait Install_C: CLONE QUIET

IF EXISTS c:MultiView
 copy c:MultiView Install_C: CLONE QUIET
ENDIF

IF EXISTS SYS:System/MultiView
 copy SYS:System/MultiView Install_C: CLONE QUIET
ENDIF

IF EXISTS SYS:Tools/MultiView
 copy SYS:Tools/MultiView Install_C: CLONE QUIET
ENDIF

IF EXISTS SYS:Utilities/MultiView
 copy SYS:Utilities/MultiView Install_C: CLONE QUIET
ENDIF

;--------------------------------
LAB DoRest
resident Install_C:assign PURE
resident Install_C:CLIexchange PURE
resident Install_C:date PURE
resident Install_C:delete PURE
resident Install_C:execute PURE
resident Install_C:list PURE
resident Install_C:makedir PURE
resident Install_C:move PURE
resident Install_C:rename PURE
resident Install_C:search PURE
resident Install_C:sort PURE
resident Install_C:version PURE
resident Install_C:wait PURE

assign Install_C: c: ADD
assign Install_C: SYS:System ADD
assign Install_C: SYS:Tools ADD
assign Install_C: SYS:Utilities ADD

path reset
path Install_C:
path c: ADD
path SYS:System ADD
path SYS:Utilities ADD
path SYS:Tools ADD
;-------------------------------- end PrepareOS
;-------------------------------- StartRexx

; 000307 T.Neidhardt, ft112@fen.baynet.de, EasySystem
; AmigaShell script
; Start Rexxmaster and make available RexxReqtools
; deliver rexxmast and rxlib if not existent on the host system's
; appropriate pathes. SYS:Rexxc/ IS A STANDARD!

;--------------------------------
setenv Msg Rexx_log

;--------------------------------
if ${Flags/REXX_INSTALLED} eq 1
 skip EndRexx
endif

;--------------------------------
if not exists sys:system
 makedir sys:System
 setenv RexxInstalledNow 1   ;for signalling if $Msg must be popped up
endif

if not exists sys:system/rexxmast
 copy Inst_rexx/system/rexxmast#? SYS:System CLONE QUIET
 delete SYS:WBstartup/rexxmast#? force quiet
 setenv RexxInstalledNow 1
endif

avail >NIL: flush
copy Inst_rexx/libs SYS:libs CLONE ALL QUIET

;this should be standard on up-to-date systems, but who
;knows if any user has deleted those libraries? Keep sure...
;so everything will work properly.

if not exists sys:rexxc
 makedir sys:RexxC
 setenv RexxInstalledNow 1
endif

if not exists sys:rexxc/rxlib
 copy Inst_rexx/rexxc/rxlib SYS:RexxC CLONE QUIET
 setenv RexxInstalledNow 1
endif

if not exists sys:rexxc/rx
 copy Inst_rexx/rexxc/rx SYS:RexxC CLONE QUIET
 setenv RexxInstalledNow 1
endif

resident SYS:rexxc/rx PURE

;--------------------------------
LAB Create

 run >NIL: sys:system/rexxmast
 wait 1

 SYS:RexxC/rxlib rexxsupport.library 80 -30
 SYS:RexxC/rxlib rexxreqtools.library 50 -30
 SYS:RexxC/rxlib rexxarplib.library 30 -30

 if not exists ENV:Flags
    makedir ENV:Flags
 endif

 setenv Flags/REXX_INSTALLED 1

LAB EndRexx
;-------------------------------- end StartRexx
;-------------------------------- GetCode

echo "*n"
Install_C:GetCode

;-------------------------------- END
lab END
wait 5
cd SYS:
endcli

;--------------------------------
lab ERROR
echo "*ec*n*e[1m Error installing $app:*e[0m*n*n The following files must be in this directory:*n*n $app.lha*n Install_Guide*n $app_iGuide.lha*n Lha*n*n*n Your version is*e[1m not up to date*e[0m or it is*e[1m incomplete*e[0m.*n*n Closing this window 1
wait 15
cd SYS:

