; $VER: Install-InfoNexus V1.0 (30.11.94)
; Installation script to install InfoNexus to hard disk using the 
; Installer utility
; Copyright Optonica Limited 1994 All Rights Reserved

(welcome "Install InfoNexus")

; source directory path
(set sourceName
	(pathonly @icon)
)

; destination directory path = <user-select>
(set destName
	(tackon
		(askdir
			(prompt "Where shall I place the InfoNexus Directory ?")
			(help @askdir-help)
			(default @default-dest)
		)
		"InfoNexus"
	)
)

; if dir doesn't exist, create it (with icon file)
(if (= (exists destName) 0)
	(makedir destName (safe) (infos))
)

; set dest dir
(set @default-dest destName)

; Copy all files that belong in the InfoNexus directory
(copyfiles
	(help @copyfiles-help)
	(source (tackon sourceName "InfoNexus"))
	(dest destName)
	(all)
)

(set vernum (getversion))
(set ver (/ vernum 65536))
(if (= ver 34)
	(copyfiles
		(source (tackon sourceName "1.3Icons/Infonexus.info"))
		(dest destName)
	)
)

; install ARexx Scripts
;(transcript "Ask Install ARexx scripts" )
;(set InsArexx
;	(askchoice
;		(prompt "Install Example ARexx Scripts ?")
;		(help @askchoice-help)
;		(choices "Yes" "No")
;		(default 0)
;	)
;)
;(if (= InsArexx 0)
;	(
;		(makedir (tackon destName "Rexx") (safe) )
;		(copyfiles
;			(help @copyfiles-help)
;			(source (tackon sourceName "Rexx"))
;			(dest (tackon destName "Rexx"))
;			(all)
;		)
;	)
;)

; install InfoNexus.Service
(set InsService 1)
(if (= (exists "SYS:Envoy") 2)
	(
		(transcript "Ask Install InfoNexus Service" )

		(set InsService
			(askchoice
				(prompt "Install InfoNexus Service ?")
				(help @askchoice-help)
				(choices "Yes" "No")
				(default 0)
			)
		)
		(if (= InsService 0)
			(
				(copyfiles
					(help @copyfiles-help)
					(source (tackon sourceName "ServiceExtras"))
					(dest destName)
					(all)
				)
				(copyfiles
					(help @copyfiles-help)
					(source (tackon sourceName "Service"))
					(dest "SYS:Envoy/Services")
					(all)
				)
			)
		)
	)
	(
		(transcript "Ask Install InfoNexus Service" )

		(set InsService
			(askchoice
				(prompt "Is Envoy Installed, Do you want InfoNexus.Service installed ?")
				(help @askchoice-help)
				(choices "Yes" "No")
				(default 1)
			)
		)
		(if (= InsService 0)
			(
				(copyfiles
					(help @copyfiles-help)
					(source (tackon sourceName "ServiceExtras"))
					(dest destName)
					(all)
				)
				(set destName
					(tackon
						(askdir
							(prompt "Where is the Envoy Root Directory ?")
							(help @askdir-help)
							(default @default-dest)
							)
						"Envoy/Services"
					)
				)

				(copyfiles
					(help @copyfiles-help)
					(source (tackon sourceName "Service"))
					(dest destName)
					(all)
				)
			)
		)
	)
)

; Copy each of the required library files
; (only done if it is a LATER version)
(working "Copying Libraries into Libs: directory")
(set sourceLibs (tackon sourceName "Libs"))
(foreach
	sourceLibs
	"#?.library"
	(copylib
		(help @copylib-help)
		(source (tackon sourceLibs @each-name))
	(dest "Libs:")
	)
)

(if (= InsService 0)
	(
		(message "\nThe installation of InfoNexus is now complete.\n\n"
      		   "To enable the InfoNexus.service (see manual for more details) use ENVOY services configuration tool found in the envoy/configuration directory.\n\n"
					"NOTE Under OS2.x the Services Configuration program may misbehave, the ADD and DELETE buttons are obscured with a string gadget from the list view, a narrow portion of these buttons remain revealed and usable\n"
		)
		(message	"Three 8SVX samples are included, these may be replaced with your favorite sound.\n"
					"Please note to keep them short\n\n"
					"InfoNexus.PosSnd  - Sound on Key Presses\n"
					"InfoNexus.NegSnd  - Sound on Illegal operations\n"
					"InfoNexus.MailSnd - Sound on receipt of mail\n"
		)
	)
	(
		(message "\nThe installation of InfoNexus is now complete.\n\n"
					"Two 8SVX samples are included, these may be replaced with your favorite sound.\n"
					"Please note to keep them short\n\n"
					"InfoNexus.PosSnd  - Sound on Key Presses\n"
					"InfoNexus.NegSnd  - Sound on Illegal operations\n"
		)
	)
)
