;;
;; Installer for Demon Internet Demon users
;;
;; set up variables

(set
	myuser		"fred"
	myname		"Frederick P Bloggs"
	mypass		"blivet"
	mynode		"frammis"
	myorg			"Demon Internet Dial-Up"
	myeditor		"Ed"
	myserdev		"serial.device"
	myserunit	"0"
	modeminit	"ATZ0"
	modemdial	"ATDT"
	popno			"0645-123666"

	source-dir	(if (= 1 (exists @icon))
						(pathonly (expandpath @icon))
						(expandpath @icon)
					)
	pkgname		"AmiTCP"
	pkgdir		(cat pkgname ":")
	bindir		(tackon pkgdir "bin")
	sbindir		(tackon source-dir "bin")
	dbdir			(tackon pkgdir "db")
	sdbdir		(tackon source-dir "db")
	docdir		(tackon pkgdir "doc")
	helpdir		(tackon pkgdir "help")
	servdir		(tackon pkgdir "serv")
	ldir			(tackon pkgdir "l")
	libsdir		(tackon pkgdir "libs")
	usrdir		(tackon pkgdir "usr")
	susrdir		(tackon source-dir "usr")
	usrsp			(tackon usrdir "spool")
	maildir		(tackon usrdir "mail")
	newsdir		(tackon usrdir "news")
	uudir			(tackon usrdir "lib")
	suudir		(tackon susrdir "lib")
	envdir		"envarc:"
	senvdir		(tackon pkgdir "env")
	sanadir		(tackon envdir "sana2")
	devdir		(tackon pkgdir "devs")
	netsdir		(tackon "devs:" "networks")

	checkok		5

)

(procedure get-user-info
	(message
		"\nFirst we need to know some things about you and your Demon account.\n"
	)
	
	(set myuser
		(askstring
			(prompt "Please enter your username, this will be used as part of your email address.")
			(help "The username makes up part of your email address. If your username was 'fred' your address might be \n\n'fred@frammis.demon.co.uk'.")
			(default myuser)
		)
	)
	(set myname
		(askstring
			(prompt "Please enter your real name, this will be used when you send mail and news.")
			(help "The real name is shown after your email address. If your real name was 'Frederick P Bloggs' your address might be \n\n'fred@frammis.demon.co.uk (Fred P Bloggs)'.")
			(default myname)
		)
	)
	(set mynode
		(askstring
			(prompt "Please enter your node name, this will be used as part of your email address.")
			(help "The node name makes up part of your email address. It is the name you chose when you set up your account. If your node name was 'frammis' your address might be \n\n'fred@frammis.demon.co.uk'.")
			(default mynode)
		)
	)
	(set myorg
		(askstring
			(prompt "Please enter your Organisation, this will be used when you send mail and news.")
			(help "The Organisation is shown in your mail and news postings.")
			(default myorg)
		)
	)
	(set mypass
		(askstring
			(prompt "Please enter your password, this will be used when you log on.")
			(help "The password is used when you log on. You should not tell anybody your password.")
			(default mypass)
		)
	)
	
	(set checkok
		(askbool
			(prompt
				"You entered the following -\n\n"
				"Username: " myuser "\n"
				"Realname: " myname "\n"
				"Nodename: " mynode "\n"
				"Password: " mypass "\n"
				"Organisation: " myorg 
			)
			(help @askchoice-help)
			(choices "No, that's wrong" "Okay")
			(default 1)
		)
	)
)

(procedure get-comp-info
	(message
		"\nNow we need to know some things about your computer and modem setup.\n"
	)
	
	(set myeditor
		(askstring
			(prompt "Please enter the command which calls your editor. You must include any command line switches if they are required.")
			(help "This is the command that runs your text editor for composing mail and news posts.")
			(default myeditor)
		)
	)
	
	(set myserdev
		(askstring
			(prompt "Please enter the name of the serial device driver that you intend to use.")
			(help "This is the name of your serial device driver that you will be running your modem on.")
			(default myserdev)
		)
	)
	
	(set myserunit
		(askstring
			(prompt "Please enter the unit number of your serial device.")
			(help "This is the unit number of the serial device driver that you will be running your modem on. It will be 0 if you are using the internal port, but may be different if you are using an I/O interface.")
			(default myserunit)
		)
	)
	
	(set baudnum
		(askchoice
			(prompt "Please choose a baud rate.\n NOTE the Amigas internal port *can not* do 57600 on 68000 driven systems.")
			(help "This is the speed at which the computer will communicate with the modem.")
			(choices "1200" "2400" "9600" "19200" "38400" "57600" "115200")
			(default 3)
		)
	)

	(set modembaud
		(select baudnum
			"1200" 
			"2400" 
			"9600" 
			"19200" 
			"38400" 
			"57600" 
			"115200"
		)
	)

	(set modeminit
		(askstring
			(prompt "Please enter your modem initialisation string.")
			(help "This is the command which initialises or resets your modem into a ready state. It is usually ATZ or ATZ0.")
			(default modeminit)
		)
	)
	
	(set modemdial
		(askstring
			(prompt "Please enter your modem dial string.")
			(help "This is the command the modem will use to dial, but without the number.")
			(default modemdial)
		)
	)

	(set popno
		(askstring
			(prompt "Please enter the telephone number of your local Point of Presence.\nSee POP.txt for a list of numbers.")
			(help "This is the phone number of the Point of Presence you wish to connect to. See POP.txt for a list of numbers.")
			(default popno)
		)
	)

	(set checkok
		(askbool
			(prompt
				"You entered the following -\n\n"
				"Editor: " myeditor "\n"
				"Serial Device: " myserdev "\n"
				"Serial Unit: " myserunit "\n"
				"Baud: " modembaud "\n"
				"Modem Init String: " modeminit "\n"
				"Modem Dial String: " modemdial "\n"
				"PoP number: " popno 
			)
			(help @askchoice-help)
			(choices "No, that's wrong" "Okay")
			(default 1)
		)
	)
)

(procedure create-files
	(working "Generating Configuration Files...")

	(working "Creating db/AmiTCP.Config...")

	(set file (tackon sdbdir "AmiTCP.Config"))
	(delete file)
	(textfile
		(dest file)
		(append 
			(cat 
				"#	AmiTCP/IP configuration file.\n"
				"#\n"
				"useloopback=YES\n"
				"debugsana=NO\n"
				"usens=SECOND\n"
				"gateway=YES\n"
				"hostname=" mynode ".demon.co.uk\n"
			)
		)
	)

	(working "Creating db/Hosts...")

	(set file (tackon sdbdir "Hosts"))
	(delete file)
	(textfile
		(dest file)
		(append 
			(cat 
				"#\n"
				"#	The hosts database file for AmiTCP/IP.\n"
				"#\n"
				"127.0.0.1 localhost \n"
				my-ip " " my-host " " my-node "\n"
				"; \n"
			)
		)
	)

	(working "Creating db/passwd...")

	(set file (tackon sdbdir "passwd"))
	(textfile
		(dest file)
		(append (cat "root||0|0|" my-name "|sys:|shell\n"))
		(append (cat myuser "||100|100|" myname "|usr:" myuser "|shell\n"))
	)

	(working "Creating UULIB:Sitename...")

	(set file (tackon suudir "sitename"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				mynode ".demon.co.uk"
			)
		)
	)

	(working "Creating UULIB:Aliases...")

	(set file (tackon suudir "Aliases"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				"# Following alias is required by the new mail protocol, RFC 822\n"
				"postmaster: " myuser "\n"
				"\n"
				"# Aliases to handle mail to msgs and news\n\n\n"
				"# System\n"
				"manager: " myuser "\n"
				"operator: " myuser "\n"
				"staff: " myuser "\n"
				"nobody: " myuser "\n"
				"root: " myuser "\n"
				"uucp: " myuser "\n"
				"daemon: " myuser "\n"
				"lp: " myuser "\n"
				"#\n"
				"#   User\n"
				"#\n\n"
				"# End of file\n"
			)
		)
	)

	(working "Creating ENV:dialer0.config...")

	(set file (tackon senvdir "dialer0.config"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
			"#   dialer.device config file \n"
			"# Most config commands are optional \n"
			"# keywords are case-insensitive \n"
			" \n"
			"# default: \"serial.device\"\n"
			"DEVICE " myserdev "\n"
			" \n"
			"# default: 0 \n"
			"UNIT " myserunit "\n"
			" \n"
			"# default: Prefs setting \n"
			"BAUD " modembaud "\n"
			" \n"
			"# default: ATZ \n"
			"INITSTRING " modeminit "\n"
			" \n"
			"# default: ATDT \n"
			"DIALSTRING " modemdial "\n"
			" \n"
			"# You can have as many phone numbers as you like, including none. They will \n"
			"# be dialled in turn until you get a CONNECT. Dialling will be aborted on \n"
			"# 'ERROR' or 'NO DIALTONE'.  If there are no phone numbers, no modem \n"
			"# initialisation will be done. \n"
			"#PHONE 0123-456789 \n"
			"PHONE " popno "\n"
			" \n"
			"# default: 60 \n"
			"DIALTIMEOUT 100 \n"
			" \n"
			"# You can have as many Conversations as you like, including none. \n"
			"# we wait for the first string, then send the second, with a CR appended \n"
			"# they will be actioned in the order encountered \n"
			"CONVERSE ogin: " mynode "\n"
			"CONVERSE sword: " mypass "\n"
			"CONVERSE rotocol: PPP\n"
			"CONVERSE HELLO\n"
			" \n"
			"# The time we wait in a Conversation for the expected string \n"
			"# default: 30 \n"
			"#TIMEOUT 20 \n"
			" \n"
			"# default: 320 11 320 100 \n"
			"#WINDOWSIZE 320 11 320 100 \n"
			" \n"
			"# default: 320 11 320 11 \n"
			"#ZOOMSIZE 320 11 320 11 \n"
			)
		)
	)

	(working "Creating Startnet...")

	(set file (tackon sbindir "StartNet"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				"; Startnet Script for Demon Internet \n"
				" \n"
				"; Assigns and Env settings \n"
				" \n"
				"assign AmiTCP:    " source-dir " \n"
				" \n"
				"path >Nil: AmiTCP:bin remove \n"
				"path AmiTCP:bin add \n"
				" \n"
				"Assign APIPE: Exists >NIL: \n"
				"IF Warn \n"
				"  Mount APIPE: from AmiTCP:devs/APipe-Mountlist \n"
				"EndIf \n"
				" \n"
				"assign INet:      AmiTCP: \n"
				"assign usr:       AmiTCP:usr \n"
				"assign uumail:    usr:mail \n"
				"assign uulib:     usr:lib \n"
				"assign uuspool:   usr:spool \n"
				"assign uunews:    usr:news \n"
				"assign etc:       AmiTCP:db \n"
				" \n"
				"path AmiTCP:bin usr: uumail: uulib: uuspool: uunews: etc: add \n"
				" \n"
				"; Environmental variables \n"
				" \n"
				"setenv NODENAME      " mynode "\n"
				"setenv HOST          " mynode ".demon.co.uk\n"
				"setenv HOSTNAME      " mynode ".demon.co.uk\n"
				"setenv DOMAINNAME    .demon.co.uk\n"
				"setenv REALNAME      " myname " \n"
				"setenv ORGANIZATION  " myorg " \n"
				"setenv NEWSSERVER    distort.demon.co.uk\n"
				"setenv SENDMAIL		AmiTCP:bin/Sendmail %s\n"
				"setenv POSTNEWS		AmiTCP:bin/Postnews\n"
				"setenv TIN_MAIL		AmiTCP:bin/SendMail\n"
				"setenv TIN_POST		AmiTCP:bin/Postnews %s\n"
				"setenv LOGFILE			uuspool:LOGFILE\n"
				"setenv USERNAME   	" myuser " \n"
				"setenv AMITCPDIR  	" source-dir " \n"
				"setenv EDITOR     	" myeditor " \n"
				"setenv NNTPSERVER 	distort.demon.co.uk \n"
				"setenv CURSESTYPE		SCREEN \n"
				" \n"
				"setenv SOCKETCONFIG  \"UID=100 GID=100 USER=" myuser " DOMAIN=demon.co.uk UMASK=022\" \n"
				" \n"
				"; Create ppp configuration file-must be 'ppp0.config for ppp.device' \n"
				"echo \"dialer.device 0 " modembaud " 0.0.0.0 7WIRE\" >ENV:Sana2/ppp0.config  \n"
				" \n"
				"; Set default user \n"
				"; \n"
				"AmiTCP:bin/login -f $USERNAME \n"
				"AmiTCP:bin/umask 022 \n"
				" \n"
				"; Invoke AmiTCP \n"
				"; \n"
				"AmiTCP:AmiTCP \n"
				"WaitForPort AMITCP \n"
				" \n"
				"; Configure loop-back device \n"
				"AmiTCP:bin/ifconfig lo0 localhost \n"
				" \n"
				"Assign >NIL: TCP: EXISTS \n"
				"IF WARN \n"
				"  Mount TCP: FROM AmiTCP:devs/inet-mountlist \n"
				"EndIF \n"
				" \n"
				"; Start the internet `super server' \n"
				"Run <NIL: >NIL: AmiTCP:bin/inetd \n"
				" \n"
				"cd $HOME \n"
				" \n"
				";EOF \n"
				" \n"
			)
		)
	)

	(working "Creating Link...")

	(set file (tackon sbindir "Link"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				"/*rx \n"
				" * AmiTCP DIS v4 Amiga Installation \n"
				" * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n"
				" * \n"
				" * NAME \n"
				" *   link -- Control the state of the AmiTCP connection \n"
				" * USAGE \n"
				" *   link up|down [news|autonews|automail] \n"
				" * PURPOSE \n"
				" *   This script makes using AmiTCP on a dialup to Demon much easier. You \n"
				" *   can connect/disconnect by entering LINK UP or LINK DOWN. \n"
				" */ \n"
				" \n"
				"if ~exists('libs:rexxsupport.library') then  \n"
				"do \n"
				"	say 'Cannot find rexxsupport.library, aborting..' \n"
				"   exit \n"
				"end \n"
				" \n"
				"if ~show('L','rexxsupport.library') then  \n"
				"do \n"
				"	addlib('rexxsupport.library',0,-30,0) \n"
				"end \n"
				" \n"
				"CALL PRAGMA('priority',3) \n"
				" \n"
				"/* VARIABLES - Modify these for your setup */ \n"
				"mynode = \"" mynode "\"				/* My node name */ \n"
				"fingercmd = \"AmiTCP:bin/finger\" \n"
				"mailhost = \"@post.demon.co.uk\" \n"
				"DISmail = 1 \n"
				"THISmail = 1 \n"
				" \n"
				"address command \n"
				"arg which news \n"
				" \n"
				"/* THE SCRIPT PROPER */ \n"
				" \n"
				"if which='' then \n"
				"do\n"
				"	say '' \n"
				"	say 'Usage: Link Up|Down [News|Autonews|Automail]' \n"
				"	say '' \n"
				"	exit \n"
				"end \n"
				"if which~='UP' & which~='DOWN' then \n"
				"do \n"
				"	say '' \n"
				"	say 'Invalid command: ' || which || ' - try Up or Down' \n"
				"	say '' \n"
				"	exit \n"
				"end \n"
				"if news~='NEWS' & news~='AUTONEWS' & news~='AUTOMAIL' & news~='' then \n"
				"do \n"
				"	say 'Invalid parameter: ' || news || ' - try News, Autonews or Automail' \n"
				"end \n"
				"else  \n"
				"do \n"
				"	if which='UP' then  \n"
				"	do \n"
				"		'AmiTCP:bin/online devs:networks/ppp.device 0' \n"
				"		if RC=10 then  \n"
				"		do \n"
				"			say '' \n"
				"			say 'Connection/Dial Error' \n"
				"			exit \n"
				"		end \n"
				"		'AmiTCP:bin/ifconfig lo0 localhost' \n"
				"		'AmiTCP:bin/ifconfig ppp0 $ppp0IPLocal $ppp0IPRemote netmask 255.255.0.0' \n"
				"		'AmiTCP:bin/route add default $ppp0IPRemote' \n"
				"		if ~open(log,'uuspool:link.log','A') then  \n"
				"		do \n"
				"			if open(log,'uuspool:link.log','W') then \n"
				"			do \n"
				"				call WriteLog('Connection Opened') \n"
				"			end \n"
				"		end \n"
				"		else \n"
				"		do \n"
				"			call WriteLog('Connection Opened') \n"
				"		end \n"
				"		'AmiTCP:bin/mailkick post.demon.co.uk handletos logsends' \n"
				"		if exists('AmiTCP:db/LinkMacro') then\n"
				"		do\n"
	      	"			'execute AmiTCP:db/LinkMacro' \n"
				"		end\n"
				"		if news='NEWS' then  \n"
				"		do \n"
				"			say 'Slurping news...' \n"
				"			'execute AmiTCP:bin/nntptransfer mode news' \n"
				"		end \n"
				"		if news='AUTONEWS' then  \n"
				"		do \n"
				"			say 'Slurping news with auto link down...' \n"
				"			'execute AmiTCP:bin/nntptransfer mode news' \n"
				"			do while DISmail = 1 | THISmail = 1 \n"
				"				call checkDISmail \n"
				"				call checkTHISmail \n"
				"			end \n"
				"			'wait 5' \n"
				"			'AmiTCP:bin/link down' \n"
				"		end \n"
				"		if news='AUTOMAIL' then  \n"
				"		do \n"
				"			do while DISmail = 1 | THISmail = 1 \n"
				"				call checkDISmail \n"
				"				call checkTHISmail \n"
				"			end \n"
				"			'wait 5' \n"
				"			'AmiTCP:bin/link down' \n"
				"		end \n"
				" \n"
				"	end \n"
				"	else  \n"
				"	do \n"
				"		if which='DOWN' then  \n"
				"		do \n"
				"			'AmiTCP:bin/mailkick quit' \n"
				"			'AmiTCP:bin/ifconfig ppp0 down' \n"
				"			'AmiTCP:bin/offline ppp.device 0' \n"
				"			'AmiTCP:bin/route delete $ppp0IPLocal' \n"
				"			'AmiTCP:bin/route delete default' \n"
				"			if ~open(log,'uuspool:link.log','A') then  \n"
				"			do \n"
				"				if open(log,'uuspool:link.log','W') then \n"
				"				do \n"
				"					call WriteLog('Connection Closed') \n"
				"				end \n"
				"			end \n"
				"			else \n"
				"			do \n"
				"				call WriteLog('Connection Closed') \n"
				"			end \n"
				"		end \n"
				"	end \n"
				"end \n"
				"exit \n"
				" \n"
				"checkDISmail: \n"
				"	say \"Checking for incoming mail...\" \n"
				"	DISmail = 0 \n"
				"	fingercmd mynode || mailhost \">t:linktmp\" \n"
				"	if (exists('t:linktmp')>0) then  \n"
				"	do \n"
				"		result = open('fingerout', 't:linktmp', read) \n"
				"		do while ~eof('fingerout') \n"
				"			ln = readln('fingerout') \n"
				"			ln = strip(ln) \n"
				"			if index(ln,'[')=0 & index(ln,']')=0 & ln~='' then  \n"
				"			do \n"
				"				if find(ln,'no')=0 then  \n"
				"				do \n"
				"					DISmail = 1 \n"
				"				end \n"
				"			end \n"
				"		end \n"
				"		result = close('fingerout') \n"
				"		result = delete('t:linktmp') \n"
				"	end \n"
				"	if DISmail = 1 then \n"
				"	do  \n"
				"		say \"Found incoming mail, waiting...\" \n"
				"		\"wait 5\" \n"
				"	end \n"
				"	else \n"
				"	do \n"
				"		say \"No incoming mail.\" \n"
				"	end \n"
				"return \n"
				" \n"
				"checkTHISmail: \n"
				"	say \"Checking for outgoing mail...\" \n"
				"	THISmail = 0 \n"
				"	\"list nohead uuspool: >t:spooltmp\" \n"
				"	if (exists('t:spooltmp')>0) then  \n"
				"	do \n"
				"		result = open('spoolout', 't:spooltmp', read) \n"
				"		do while ~eof('spoolout') \n"
				"			ln = readln('spoolout') \n"
				"			ln = strip(ln) \n"
				"			if index(ln,'C.')~=0 | index(ln,'D.')~=0 |index(ln,'X.')~=0 then  \n"
				"			do \n"
				"				THISmail = 1 \n"
				"			end \n"
				"		end \n"
				"		result = close('spoolout') \n"
				"		result = delete('t:spooltmp') \n"
				"	end \n"
				"	if THISmail = 1 then \n"
				"	do  \n"
				"		say \"Found outgoing mail, waiting...\" \n"
				"		\"wait 5\" \n"
				"	end \n"
				"	else \n"
				"	do \n"
				"		say \"No outgoing mail.\" \n"
				"	end \n"
				"return \n"
				" \n"
				"WriteLog: procedure EXPOSE mynode \n"
				"	logmsg = Arg(1) \n"
				"	logline = Date(E) || '-' || Time() || ' ' || mynode || ' ' || logmsg \n"
				"	call writeln(log,logline) \n"
				"	call close(log) \n"
				"return \n"
				" \n"
			)
		)
	)

	(working "Creating ADMail.config...")

	(set file (tackon (tackon usrdir myuser) "ADMail.config"))
	(delete file)
	(textfile
		(dest file)
		(append
			"# ADMail example config file \n"
			"# The settings below represent the available settings in ADMail. \n"
			"# Uncomment and fill in the appropriate ones, as detailed in \n"
			"# the ADMail documentation. \n"
			" \n"
			"#Sendmail \n"
			"#UUDecode \n"
			"Salute Hi $FIRSTNAME \n"
			"#ForwardIntro \n"
			"#IndentPrefix \n"
			"#SaveDir \n"
			"#SigDir \n"
			"#SigFile  \n"
			"#RandSigHook \n"
			"#Editor \n"
			"#MBoxDir \n"
			"# \n"
			"ToReceived never \n"
			"#LogOutgoing \n"
			"#LogEncoded \n"
			"#IncludeFrom \n"
			"#RandomSigs \n"
			"#SigDashes \n"
			"#ShowDeleted \n"
			"#SkipDeleted \n"
			"#ReloadOnResize \n"
			"#PubScreen \n"
			"ShowButtons yes \n"
			"# \n"
			"#MsgListLeft 4 \n"
			"#MsgListTop 2 \n"
			"#MsgListWidth 700 \n"
			"#MsgListHeight 128 \n"
			"# \n"
			"#MsgLeft 4 \n"
			"#MsgTop 130 \n"
			"#MsgWidth 700 \n"
			"#MsgHeight 128 \n"
			"# \n"
			"#SelectLeft \n"
			"#SelectTop \n"
			"#SelectWidth \n"
			"#SelectHeight \n"
			"# \n"
			"#TextWidth \n"
		)
	)

	(working "Creating UULIB:.Signature...")

	(set file (tackon suudir ".Signature"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				" " myname " - " myuser "@" mynode ".demon.co.uk (" myorg ")\n\n"
				" Connecting via Demon Internet Ltd\n"
			)
		)
	)
	(copyfiles (source suudir) (dest (tackon usrdir myuser)) (files) (pattern ".Signature"))

	(working "Creating UULIB:Config...")

	(set file (tackon suudir "Config"))
	(delete file)
	(textfile
		(dest file)
		(append
			(cat
				"#   Config file sample \n"
				"# \n"
				"#   Config may exist as 'UULIB:Config' or 'S:UUConfig', but not in \n"
				"#   any overide directory for UULIB: since that is listed in the config \n"
				"#   file and we have to find it first, eh? \n"
				"# \n"
				"UserName			" myuser "\n"
				"RealName			" myname "\n"
				"NodeName			" mynode "\n"
				"HostName			" mynode ".demon.co.uk\n"
				"Organization		" myorg "\n"
				"TimeZone			GMT\n"
				"DefaultNode		post.demon.co.uk\n"
				"NNTPServer			distort.demon.co.uk\n"
				" \n"
				"#   These may be used to specify explicit paths to auto-run programs. \n"
				"#   Example paths are shown.  If not specified, the programs in question \n"
				"#   are assumed to exist in your command path. \n"
				"# \n"
				"MailEditor		" myeditor "\n"
				"NewsEditor		" myeditor "\n"
				"RMail			amitcp:bin/rmail \n"
				"SendMail		amitcp:bin/sendmail \n"
				"PostNews		amitcp:bin/postnews \n"
			)
		)
	)
)

(procedure copy-files
	(working "Copying Devices...")
	(copyfiles
		(prompt "Copying dialer device...")
		(help @copyfiles-help)
		(source "devs") (dest "devs:") (pattern "dialer.device") (confirm)
	)
	(copyfiles
		(prompt "Copying PPP device...")
		(help @copyfiles-help)
		(source "devs/networks") (dest "devs:networks") (all) (confirm)
	)
	(working "Copying Libraries...")
	(copylib	
		(prompt "Copying reqtools.library...")
		(help @copylib-help)
		(source "libs/reqtools.library") (dest "libs:") (confirm)
	)
	(copylib	
		(prompt "Copying rexxreqtools.library...")
		(help @copylib-help)
		(source "libs/rexxreqtools.library") (dest "libs:") (confirm)
	)
	(copylib	
		(prompt "Copying OwnDevUnit.library...")
		(help @copylib-help)
		(source "libs/OwnDevUnit.library") (dest "libs:") (confirm)
	)
	(copylib	
		(prompt "Copying socket.library...")
		(help @copylib-help)
		(source "libs/socket.library") (dest "libs:") (confirm)
	)
	(working "Copying Fonts...")
	(copyfiles (source "fonts") (dest "sys:fonts") (all))
	(working "Copying Environment...")
	(copyfiles (source "env") (dest "env:") (all))
	(copyfiles (source "env") (dest "envarc:") (all))
)

(procedure add-startup
	(message
		"We will now add the Startnet command to your user-startup. If you do not want to run AmiTCP at boot-up simply remove the command."
	)
	(startup "Demon Internet"
		(prompt "Adding \nexecute " startnet-name "\nto your s:user-startup.\n\nThis assign may need to be commented out due to AmiTCP 4.0 demo having a nag requester.")
		(help "Adding StartNet command to user-startup")
		(
			(command (cat "execute " startnet-name "\n"))
		)
	)
)

(procedure fix-bits
	(protect (tackon bindir "StartNet") "+s")
	(protect (tackon bindir "StopNet") "+s")
	(protect (tackon bindir "link") "+s")
	(protect (tackon bindir "tin") "+s")
	(protect (tackon bindir "NNTPTransfer") "+s")
	(protect (tackon bindir "NetStat") "+s")
	(protect (tackon bindir "Telnetn") "+s")
	(protect (tackon bindir "SynClock") "+s")
	(protect (tackon bindir "TalkRequest.rx") "+s")
	(protect (tackon bindir "Postnews") "+s")
	(protect (tackon bindir "NGMan") "+s")
	(protect (tackon bindir "ALMan") "+s")
	(protect (tackon pkgdir "Connect") "+s")
	(protect (tackon pkgdir "Read_Mail") "+s")
	(protect (tackon pkgdir "Read_News") "+s")
	(protect (tackon pkgdir "WWW") "+s")
)

;; main routine
;;
(message
	"\n"
	"Welcome to the Demon Internet AmiTCP 4.0 installer\n"
	"\n"
	"You will now be asked a number of questions in order\n"
	"to complete the installation successfully.\n"
	"\n"
	"This installer will configure your AmiTCP 4.0 and\n"
	"support files *in place*. Only libraries and devices\n"
	"will be copied."
)

(message
	"\n"
	"Installer and Documentation \n"
	"(c) 1995 James Savage / Gothsoft Developments II\n"
	"For\n"
	"Demons Unsupported Amiga Users\n"
	"\n"
	"Other copyrights held by their respective authors"
)

(makeassign "AmiTCP" source-dir)
(set checkok 5)
(while (<> checkok 0)
	(get-user-info)
)
(makedir (tackon usrdir myuser))
(set checkok 5)
(while (<> checkok 0)
	(get-comp-info)
)
(create-files)
(copy-files)
(set startnet-name (tackon (tackon (getassign pkgname) "bin") "StartNet"))
(add-startup)
(fix-bits)
(message
	"\n"
	"The installation of your Demon Internet suite has been completed successfully!\n"
	"\n"
	"Reboot, then simply click on Connect to take your first steps onto The Internet.\n"
	"\n"
	"Enjoy!\n"
	"\n"
	":-)"
)
