; script to install AXsh (WB 2.1)

	; set up a error cleanup routine

(onerror
	(makeassign "AXsh" (safe))
)

(set #bad-kick
(cat "You must be using Kickstart 2.04 to install using this script."
	" Double-click the 'AXsh-Install_1.3' icon to install AXsh on"
	" Kickstart 1.2 or 1.3 machines."
))


(complete 0)
	; just in case the installation was restarted

(makeassign "AXsh" (safe))	; start fresh

	; check kick
(if (< (/ (getversion) 65536) 37)
(    (abort #bad-kick)
))

	; see if this is really an update
(set is_update 0)
(set AXsh_dest (getassign "AXsh" "a"))

	; if update, be sure they want program in same place
(if AXsh_dest
	(if (askbool
			(prompt "Your current copy of AXsh appears to be located in the drawer named \""
				AXsh_dest
				"\". Do you want the update installed in that drawer?"
			)
			(help	"The installer has determined that you may already have a "
				"copy of AXsh installed on your system. If this is wrong or "
				"you want the update installed elsewhere, select NO as an "
				"answer. Otherwise, select YES."
			)
			(default 1)
		)

		(set is_update 1)		; if user wants in same place
		(set AXsh_dest			; if user wants in different place
			(askdir	(prompt "In which disk or drawer should AXsh be installed?")
				(help @askdir-help)
				(default @default-dest)
			)
		)
	)

; else if not an update, get a location for program
	(set AXsh_dest
		(askdir	(prompt "In which disk or drawer should AXsh be installed?")
			(help @askdir-help)
			(default @default-dest)
		)
	)
)

	; now lock on to volume 'AXsh'
(askdisk
	(prompt "Please insert \n the master program disk \n labeled \"AXshPack\".")
	(help	"The AXsh program and other options will be copied "
		"from the \"AXsh\" into your system.")
	(dest  "AXshPack")
	(newname "AXsh")
)

	; make AXsh drawer & icon if not there
;(if (not is_update)	(makedir AXsh_dest (infos)))

	; at this point we have a valid destination, so we tell installer where
	; the application will end up so the exit page will be correct -- also,
	; the installation log file (if any) will be copied to the destination
(set @default-dest AXsh_dest)

(set whichfiles 
	(askoptions
		(prompt "Please select the files to be copied")
		(help	"This allows you to select only certain parts of the AXsh "
			"system to be installed on your hard drive. For normal installation "
			"select all the items")
		(choices "AXsh system"
			 "Manual pages"
			 "Language support & WB launchable system services")
	)
)


(if	(in whichfiles 0)
	(	(makedir (tackon AXsh_dest "bin")	(infos))
		(makedir (tackon AXsh_dest "etc")	(infos))
		(makedir (tackon AXsh_dest "dev")	(infos))
		(makedir (tackon AXsh_dest "home")	(infos))
		(makedir (tackon AXsh_dest "usr")	(infos))
		(makedir (tackon AXsh_dest "storage")	(infos))

		(copyfiles
			(source "AXshPack:bin")
			(dest (tackon AXsh_dest "bin"))
			(infos)	(all)
		)

		(copyfiles
			(source "AXshPack:dev")
			(dest (tackon AXsh_dest "dev"))
			(infos)	(all)
		)

		(copyfiles
			(source "AXshPack:etc")
			(dest (tackon AXsh_dest "etc"))
			(infos)	(all)
		)

		(complete 50)

		(copyfiles
			(source "AXshPack:home")
			(dest (tackon AXsh_dest "home"))
			(infos)	(all)
		)

		(copyfiles
			(source "AXshPack:usr")
			(dest (tackon AXsh_dest "usr"))
			(infos)	(all)
		)

		(copyfiles
			(source "AXshPack:info")
			(dest (tackon AXsh_dest "info"))
			(infos)	(all)
		)

		(copyfiles
			(source "AXshPack:storage")
			(dest (tackon AXsh_dest "storage"))
			(infos)	(all)
		)
		(copyfiles
			(source "AXshPack:AXsh.info")
			(dest AXsh_dest)
		)
	)
)

(complete 80)

(if	(in whichfiles 1)
	(
		(copyfiles
			(source "AXshPack:man")
			(dest (tackon AXsh_dest "man"))
			(infos)	(all)
		)
		(copyfiles
			(source "AXshPack:AXshUpdates1.3")
			(dest AXsh_dest)
			(infos)
		)
	)
)

(if	(in whichfiles 2)
	(
		(copyfiles
			(source "AXshPack:storage/AX-Sysghost.info")
			(dest "SYS:WBStartup")
		)
		(copyfiles
			(source "AXshPack:storage/AX-Server.info")
			(dest "SYS:WBStartup")
		)
		(copyfiles
			(source "AXshPack:Storage/DosDrivers")
			(dest "DEVS:DosDrivers")
			(all) (infos)
		)
		(copyfiles
			(source "AXshPack:Storage/Locale/Catalogs")
			(dest "LOCALE:Catalogs")
			(all) (infos)
		)
		(copyfiles
			(source "AXshPack:Storage/Presets/AXsh.locale")
			(dest "SYS:Prefs/Presets")
			(infos)
		)
		(copyfiles
			(source "AXshPack:bin/AXAUX-Handler")
			(dest "L:")
		)
	)
)


(complete 95)

	; modify S:User-Startup

(startup "AXsh"
	(prompt
		"I need to add \"assign AXsh: " AXsh_dest "\" to the \"S:user-startup\" "
		"so that your system will be properly configured to use AXsh.")
	(help "Do this or AXsh won't work!!")
	(command "ASSIGN AXsh: \"" AXsh_dest "\"\n"
	)
)


	; reinitialize assigns

(if (not @pretend)
	(makeassign "AXsh" AXsh_dest)
)

(complete 100)

	; cleanup
(makeassign "AXshPack" (safe))

	; this is not strictly necessary, but doesn't hurt
(exit)
