; $VER: Install 1.0 (30.01.95)
; Script to install Release 1 StartupManager
(complete 0)

(set @default-dest "SYS:WBStartup")
(set @startupdir "SYS:Startup")

(set target @default-dest)

;********************************************************************

(set #Yes-text
(cat "Yes"
))

(set #No-text
(cat "No"
))


(set #Overwrite
(cat "Replace"
))

(set #Abort
(cat "Abort"
))

(set #Proceed
(cat	 "Proceed"
))

(set #Skip-This-Part
(cat	 "Skip this part"
))

;********************************************************************

(set #warn-kickstart-text
(cat	"\nBAD VERSION OF KICKSTART\n\n"
	"StartupManager requires KickStart 2.0 (V37) or higher. It will not work on earlier versions.\n"
	"You currently are running KickStart V%ld.\n\n"
	"Continue with installation?"
))

;********************************************************************

(set #docs-install-text
(cat "Installing documentation"
))

(set #docs-query-text
(cat "\nWould you like to install documentation for StartupManager?"
))

(set #docs-help-text
(cat ""
))

(set #docs-query-dir-text
(cat "Where to install documentation?"
))

(set #docs-query-dir-help
(cat @askdir-help
))

;********************************************************************

(set #MainQuery-text
(cat "\nStartupManager Installer\n\n"
     "Startup Manager is about to be copied into your SYS:WBStartup directory. The programs "
     "currently in this directory will be moved to a directory called SYS:Startup. "
     "Startup manager will load and run the programs in this directory just as if "
     "they had been run from workbench."
))

(set #MainQuery-help
(cat ""
))
(set #Main-abort-text
(cat "Startup manager has not been installed!"
))

(set #Overwrite-text
(cat "\nThere is a version of StartupManager installed already. "
     "Would you like to replace it with this version?"
))

(set #Overwrite-abort-text
(cat "Installation has been aborted, old version remains untouched."
))

(set #MovingFiles
(cat "\n\nMoving files from SYS:WBStartup to SYS:Startup..."
))

;********************************************************************

(set #WBHandler-text
(cat "\nInstalling WBStart-Handler\n\nCopyright ©1991-93 Stefan Becker"
))

(set #WBHandler-help
(cat  "This will copy WBStart-Handler into your L: directory.\nCopyright ©1991-93 Stefan Becker\n\n"
     @copylib-help
))

;********************************************************************

(set #MatrixLib-text
(cat "\nInstalling matrix.library\n\nCopyright ©1992-95 David Swasbrook"
))

(set #MatrixLib-help
(cat "This will copy matrix.library into your LIBS: directory.\nCopyright ©1992-95 David Swasbrook\n\n"
     @copylib-help
))


;********************************************************************

(set #goodbye
(cat "\nStartup manager has been installed, it will be used the next time "
     "you boot your system.\n\nI hope you like it."
))

;********************************************************************

;********************************************************************
;**** END OF TEXT
;********************************************************************


;********************************
;**** CHECK THE KICKSTART VERSION
;****
(set ver (/ (getversion) 65536) )
(if (< ver 37) (
	(set warning (#warn-kickstart-text ver) ) (message warning)
))

(complete 10)

(if (exists "SYS:WBStartup/StartupManager")
(
	(if(askbool (prompt #Overwrite-text) (help #Overwrite-text) (choices #Overwrite #Abort)  )
	(
		(copyfiles (source "StartupManager") (dest "SYS:WBStartup") )
	)
	(
		(abort #Overwrite-abort-text )
	))
)
(
	(if(askbool (prompt #MainQuery-text) (help #MainQuery-text) )
	(
		(makedir (infos) "SYS:Startup" )
		(complete 20)
		(set warning (#MovingFiles) ) (working warning)
		(run "Copy SYS:WBStartup/#? SYS:Startup/" (help "") (prompt ""))
		(complete 40)
		(run "Delete SYS:WBStartup/#?" (help "") (prompt ""))
		(complete 50)
		(copyfiles (source "StartupManager") (dest "SYS:WBStartup") (infos) )
		(complete 60)
		(tooltype	(dest "SYS:WBStartup/StartupManager")
			(settooltype "PATHS" "\"SYS:Startup/\"" )
			(settooltype "PATHPRI" "NO" )
			(settooltype "DONOTWAIT" )
		)
		(complete 65)
	)
	(
		(abort #Main-abort-text )
	))
))

(complete 70)

(copylib (prompt #WBHandler-text) (help #WBHandler-help) (source "WBStart-Handler") (dest "L:") (confirm) )

(complete 75)

(copylib (prompt #MatrixLib-text) (help #MatrixLib-help) (source "matrix.library") (dest "LIBS:") (confirm) )

(complete 80) (working #docs-install-text)

(if(= (askbool (prompt #docs-query-text) (help #docs-query-help)) 1)
	(
		(set docs-target (askdir (prompt #docs-query-dir-text) (help #docs-query-dir-help) (default "SYS:")))
		(copyfiles (source "StartupManager.guide") (dest docs-target ) (infos) )
	)
)

(message #goodbye)


(complete 100)
