(set is-installed
	(exists "WWBBS:" (noreq))
)

(if is-installed
	(abort "You must remove any old installations of WWBBS.  You should also reset before installing WWBBS, or at least perform an `Avail Flush'.")
	(
		(set default-dest
			(askdir
				(prompt "Where would you like to install World Wide BBS?\n(A directory will be created)")
				(help @askdir-help)
				(default @default-dest)
			)
		)

		(set @default-dest default-dest)

		(set @default-dest
			(tackon @default-dest "WWBBS")
		)
	)
)

(message "Installing World Wide BBS in\n" @default-dest)

(set wwbbs-dir @default-dest)

(makedir wwbbs-dir
	(prompt "Create new directory\n" wwbbs-dir)
	(help @makedir-help)
	(infos)
)

(makeassign "WWBBS" wwbbs-dir)

(copylib
	(prompt "Copy wwbbs.library to LIBS:")
	(help @copylib-help)
	(source "Libs/wwbbs.library")
	(dest "LIBS:")
	(confirm)
)

(copyfiles
	(prompt "Copy handler")
	(help @copyfiles-help)
	(source "L/wwbbsaux-handler")
	(dest "L:")
	(confirm)
)

(copyfiles
	(prompt "Copy DOS driver")
	(help @copyfiles-help)
	(source "DOSDrivers/WWBBSAUX")
	(dest "DEVS:DOSDrivers")
	(infos)
	(confirm)
)

(copyfiles
	(prompt "Copy binaries")
	(help @copyfiles-help)
	(source "Bin")
	(dest "WWBBS:")
	(all)
	(infos)
	(confirm)
)

(copyfiles
	(prompt "Copy config files")
	(help @copyfiles-help)
	(source "Config")
	(dest "WWBBS:")
	(all)
	(confirm)
)

(copyfiles
	(prompt "Copy REXX files")
	(help @copyfiles-help)
	(source "Rexx")
	(dest "WWBBS:Rexx")
	(all)
	(confirm)
)

(makedir "WWBBS:Users"
	(prompt "Create new directory\nWWBBS:Users")
	(help @makedir-help)
)

(makedir "WWBBS:Logs"
	(prompt "Create new directory\nWWBBS:Logs")
	(help @makedir-help)
)

(makedir "WWBBS:Menus"
	(prompt "Create new directory\nWWBBS:Menus")
	(help @makedir-help)
)

(if
	(exists "WWBBS:BBSRx")
	(protect "WWBBS:BBSRx" "+P")
)

(startup "World Wide BBS"
	(prompt "Add assign to S:User-startup")
	(help @startup-help)
	(command "Assign WWBBS: \"" wwbbs-dir "\"\n")
	(command "Resident WWBBS:BBSRx")
)

(run "Resident WWBBS:BBSRx")
