; Install_Phoenix -- Installer script for PhoEniX-AmIRC
; $VER: Install_Phoenix 1.17 (27.11.96) by |Paladin|
;
(set #ver "1.17"
     #app-name (cat @app-name " v"#ver"+")
)
(complete 0)
(welcome "\nWelcome to the "#app-name" installer.")
(if (< 39 (/ 65536 (getversion "exec.library" (resident))))
	(abort (#app-name" requires AmigaOS 3.0 (V39) or later."))
)
(message 
		"-- WARNING --\n\n"
     	"Existing files will be over-written.  If you wish to make a backup"
     	" of any of your old Phoenix installation abort now and do so.\n\n\n"
     	"This script was designed for use with:\n\nInstaller 43.3 (04/30/96)"
)
(set
	@copylib-help "Experts don't need help with this."
	@copyfiles-help (@copylib-help)
	#source-dir (if (= 1 (exists @icon)) (pathonly @icon) (@icon))
	#default-dir (if (= 2 (exists "AmiTCP:" (noreq))) ("AmiTCP:") ("DH0:"))
	@default-dest (askdir
		(prompt "Where is AmIRC installed?")
		(help "    Choose the directory where your existing install"
		      " of AmIRC is located.  This directory should contain"
		      " a rexx/ subdirectory."
		)
		(default #default-dir)
	)
	#dest-rexx (tackon @default-dest "rexx")
	#dest-snd (tackon @default-dest "Sounds")
	#dest-libs (if (= 2 @user-level)
		(askdir
			(prompt "Where should Libraries be installed?")
			(help "    Choose a directory to install the libraries used"
			      " by "@app-name".  Version numbers will be checked before"
			      " overwriting existing files."
			)
			(default "LIBS:")
		)
		("LIBS:")
	)
	#dest-mui (if (= 2 (exists "MUI:" (noreq))) ("MUI:")
		(askdir
			(prompt "Where is MUI installed?")
			(help "    Choose the root directory where MUI is installed."
			      " Normally there should be an assigned MUI:, but it is"
			      " not currently visible to this installer."
			)
			(default #default-dir)
		)
	)
)
(complete 12)
(foreach "Libs" "#?"
	(copylib
		(source (cat "Libs/" @each-name))
		(dest #dest-libs)
		(if (= 2 @user-level)
			(
				(prompt "Copying "@each-name"...")
				(help @copylib-help)
				(confirm)
			)
		)
	)
)
(complete 21)
(if (< 2 (exists #dest-snd (noreq)))
	(set #dest-snd
		(askdir
			(prompt "Where are your Sounds installed?")
			(help "    Select the same Sound directory that you have AmIRC"
			      " configured to use.  If you don't have a Sounds/ directory"
			      " then create one."
			)
			(default @default-dest)
		)
	)
)
(complete 25)
(copyfiles
	(source "bin/Sounds")
	(dest #dest-snd)
	(all)
)
(complete 30)
(copyfiles
	(source "bin/rexx")
	(dest #dest-rexx)
	(all)
)
(complete 42)
(if (= 1 (askbool
		(prompt "Install documentation?")
		(help "If you've never used "@app-name" before you'll be a typing"
		      " monkey without first reading the docs."
		)
	) )
	(copyfiles
		(source #source-dir)
		(dest @default-dest)
		(pattern "Phoenix.#?")
		(files)
		(infos)
		(noposition)
	)
)
(complete 52)
(copyfiles
	(source "bin")
	(dest @default-dest)
	(pattern "#?")
	(files)
	(infos)
	(noposition)
)
(complete 60)
(copyfiles
	(source "MUI")
	(dest #dest-mui)
	(all)
	(if (= 2 @user-level)
		(
			(prompt "MUI utilities")
			(help "    MUIRexx is required by "@app-name" for the "
			      "/CONFIG plus other GUI commands and is highly recommended."
			)
			(confirm)
		)
	)
)
(complete 68)
(copyfiles
	(source "WBStartup")
	(dest "SYS:WBStartup")
	(all)
	(infos)
	(noposition)
	(if (= 2 @user-level)
		(
			(prompt "Programs that need to start on bootup in WBStartup")
			(help "    RPStart is the RexxMast of RexxPlus, it is"
			      " required for "@app-name" to run."
			)
			(confirm)
		)
	)
)
(complete 70)
(if (= 2 @user-level)
	(
		(set
			#yes (askbool
				(prompt "Make changes to Phoenix.cfg?")
				(help "    This will overwrite the stock config with one"
				      " that uses the same directories that you selected"
				      " during this install."
				)
			)
		)
	)
	(set #yes 1)
)
(if (= 1 #yes)
	(
		(textfile
			(dest (tackon @default-dest ".phoenix.cfg"))
			(append
				(cat
					"/* Configuration file for PhoEniX-AmIRC v"#ver"  */\n"
					"/* (   *** Order & spacing are critical ***  ) */\n"
					"autoj=2;autop=1;delop=1;autobk=1;autoc=1;xdcc=1;xkick=0;xsnd=0;reqsnd=0\n"
					"floodp=1;cprot=1;nhp=0;chain=0;friendp=2;noscrew=0;revenge=0;war=0\n"
					"autoget=2;autom=0;sec=1;verb=1;sic=1;bseen=1;bgops=1;bmode=1\n"
					"xlimit=5;reset=4\n"
					"igtime=2;sens.PRIVMSG=15;sens.NOTICE=15;sens.CTCP=4;sens.DEOP=5;sens.KICK=8\n"
					"btype=\'N\';bkey=\'!\'\n"
					"phxdir=\""@default-dest"\"\n"
					"flist=\".phoenix.friend\";elist=\".phoenix.enemy\"\n"
                         "xlist=\".phoenix.xdcc\";alist=\".phoenix.away\";slist=\".phoenix.seen\"\n"
					"abkmsg=\"| Auto BKick |\";revmsg=\"| Re\\/enge |\";xkmsg=\"| XDCC Kick |\"\n"
					"frimsg=\"| Don\'t mess with my friends! |\";reqkmsg=\"| Requested Kick |\"\n"
					"cfmsg=\"| Flood |\"\n"
					"flmsg=\"You\'ve triggered my Flood Protection!  Ignoring you.\"\n"
					"wkmsg=\"| Wordkick |\"\n"
				)
			)
		)
	)
)
(complete 88)
(if (= 2 @user-level)
	(
		(set
			#yes (askbool
				(prompt "Make changes to Phoenix.amirx?")
				(help "    This will overwrite the stock communication script"
				      " with one that uses the same directories that you selected"
				      " during this install."
				)
			)
		)
	)
	(set #yes 1)
)
(if (= 1 #yes)
	(
		(textfile
			(dest (cat #dest-rexx "/Phoenix.amirx"))
			(append
				(cat
					"/*\\\n"
					" * Phoenix.amirx -- AmIRC to Phoenix interface\n"
					" * Usage  : change your Event ANY/JOIN/KICK/MODE/INVITE settings to\n"
					" *        : \"phoenix.amirx %p\" & edit .phoenix.cfg to suit your needs.\n"
					" * $VER: PhoEniX.amirx "#ver" (27.11.96) by |Paladin|\n"
					"\\*/\n"
					"options results;parse arg line;p=address();parse var p .'.'p2\n"
					"n=\'PHOENIX.\'p2\n"
					"if ~show(\'P\',n) then do;"
					"if ~show(\'L\',\'rexxsupport.library\') then if ~addlib(\'rexxsupport.library\',0,-30,0) then do;"
					"\'echo P=\'phx\' \'d2c(2)\'FATAL ERROR:\'d2c(2)\' Unable to load rexxsupport.library.\'\n"
					"exit;end;forbid();address command;\'run >nil: rexx/Phoenix >>ram:Phoenix.err \'p2\' "@default-dest"\'\n"
					"\'waitforport \'n\n"
					"address;if ~show(\'P\',n) then \'echo P=\'d2c(27)\'b«PhoEniX» Unable to start Phoenix\'\n"
					"permit();exit;end;address(n)\n"
					"p line\n"
				)
			)
		)
	)
)
(complete 100)
(exit
	"\nInstallation Complete!\n"
	@app-name" may be found in your "@default-dest" directory (or partition).\n\n"
	"Please read the docs for configuration instructions.\n\n"
	"A reboot will be required before "@app-name" will run correctly."
	(quiet)
)
