; Install script for Bump
; ©1999 Robin Cloutman

(set @default-dest "C:")

;---------------------------------------------------------------------------
;(if (= @language "english)
;(
(set #setup-text "Checking system and application...")

(set #dest-prompt "Where do you want to install RC-FTPd?\n(A new drawer will NOT be created)")
(set #dest-help "It doesn't matter where you put this,\nalthough I strongly suggest you\ndon't hide it 30 levels down...")

(set #cpu-prompt "Which version of RC-FTPd do you wish to install?")
(set #cpu-help "Unless you have some reason to choose\na different version, best leave\nthis to the default version.\n(The 68000 version is safe for all cpu's)")

(set #patch-prompt "Patching the executable")
(set #patch-help "Got to do this for your CPU")

(set #install-prompt "Installing RC-FTPd...")
(set #install-help "It's pretty useless without this...")

(set #help-prompt "Installing the Guide...")
(set #help-help "This one isn't updated every time the main\nprogram is, however whenever it\nis I bump the version to match\nthe server...")

(set #screenshot-prompt "Installing the Screenshots...")
(set #screenshot-help "These files are linked from the guide,\nif you know what you're doing then they're\nnot needed...")

(set #mui-prompt "Checking MUI libs...")
(set #mui-help "It's pretty useless without these...")

(set #icon-prompt "Installing the default icon...")
(set #icon-help "Eye candy for Workbench 3.5+ users,\nyou'll need to be running HappyEnv or env-handler\nto be able to use this right off,\notherwise copy the icon from ENVARC: to ENV:...")

(set #locale-prompt "Copying other languages...\n(English built in)")
(set #locale-help "Just choose the languages you wish installed...")

(set #key-prompt "Installing the RC-FTPd keyfile...")
(set #key-help "Well, why don't you want to install it,\nit's not as if you really want to use\nall the features anyway...")

(set #readme-prompt "Reading a relevent file")
(set #readme-help "Erm? Help? Anyone???")
;)
;---------------------------------------------------------------------------

(if (= (exists "ftpd") 0)(abort "ERROR - Cannot find default executable!!!"))

(welcome)

(complete 0)

(working #setup-text)
(set #cpu (substr (database "cpu") 3 1))
(if (>= @user-level 1)
	(
		(if (> #cpu 5)(set #cpu (- #cpu 1)))
		(if (> #cpu 2)(set #cpu (- #cpu 1)))
		(if (> #cpu 0)(set #cpu (- #cpu 1)))
		(set #cpu
			(askchoice
				(choices "68000" "68020" "68040" "68060")
				(default #cpu)
				(prompt #cpu-prompt)
				(help #cpu-help)
			)
		)
		(if (= #cpu 1)(set #cpu 2))
		(if (= #cpu 2)(set #cpu 4))
		(if (= #cpu 3)(set #cpu 6))
	)
)

(complete 25)

(if (>= @user-level 1)
	(set @default-dest
		(askdir
			(prompt #dest-prompt)
			(help #dest-help)
			(default @default-dest)
		)
	)
)

(complete 50)

(run "Copy ftpd.info T:")
(if (= #cpu 0)
	(run "Copy ftpd T:")
	(
		(set #file (cat "ftpd_0" #cpu "0.pch"))
		(if (= (exists #file) 1)(run (cat "spatch -oT:ftpd -p" #file " ftpd")))
	)
)
(copylib
	(prompt #install-prompt)
	(help #install-help)
	(source "T:ftpd")
	(dest @default-dest)
	(newname "ftpd")
	(infos)
	(noposition)
	(if (>= @user-level 2)(confirm))
)

(copylib
	(prompt #help-prompt)
	(help #help-help)
	(source "ftpd.guide")
	(dest @default-dest)
	(infos)
	(noposition)
	(if (>= @user-level 1)(confirm))
)

(copyfiles
	(prompt #screenshot-prompt)
	(help #screenshot-help)
	(source "")
	(pattern "pic_#?.iff")
	(dest @default-dest)
	(optional nofail)
	(if (>= @user-level 1)(confirm))
)

(complete 70)

(if (= (exists "libs/mui") 2)
	(foreach "libs/mui/" "#?.mc(c|p)"
		(copylib
			(prompt #mui-prompt)
			(help #mui-help)
			(source (cat "libs/mui/" @each-name))
			(dest "Libs:mui/")
)))

(complete 80)

(if (= (exists "ENVARC/Sys/def_rc-ftpd.info") 1)
	(copyfiles
		(prompt #icon-prompt)
		(help #icon-help)
		(source "ENVARC/Sys/def_rc-ftpd.info")
		(dest "ENVARC:Sys/")
		(if (>= @user-level 2)(confirm))
))

(complete 85)

(copyfiles
	(prompt #locale-prompt)
	(help #locale-help)
	(source "Catalogs")
	(pattern "~(ftpd.c?)")
	(dest "Locale:Catalogs/")
	(optional nofail)
	(if (>= @user-level 1)(confirm))
)

(complete 90)

(if (= (exists (tackon @default-dest "ftpd.key")) 0)
	(if (= (exists "ftpd.key") 1)
		(copyfiles
			(prompt #key-prompt)
			(help #key-help)
			(source "ftpd.key")
			(dest @default-dest)
			(if (>= @user-level 2)(confirm))
)))

(complete 95)

(if (= (exists "Thanks.txt") 1)
	(run "Run More Thanks.txt"
		(prompt #readme-prompt)
		(help #readme-help)
	)
	(if (= (exists "ftpd.readme") 1)
		(run "More ftpd.readme"
			(prompt #readme-prompt)
			(help #readme-help)
)))

(complete 100)

(exit "Installation complete\n\nRC-FTPd has been installed in " @default-dest (quiet))
