(if (= appsize 0) 
    (set appsize 512000))

(if (= Language "english")
    (set lanid 0))
(if (= Language "dansk")
    (set lanid 1))
(if (= Language "deutsch")
    (set lanid 2))
(if (= Language "español")
    (set lanid 3))
(if (= Language "français")
    (set lanid 4))
(if (= Language "italiano")
    (set lanid 5))
(if (= Language "netherlands")
    (set lanid 6))
(if (= Language "norsk")
    (set lanid 7))
(if (= Language "protugês")
    (set lanid 8))
(if (= Language "svenska")
    (set lanid 9))
	
(if (= lanid 0)
    ((set yes-word "Yes")
     (set no-word "No")
     (set yesboot-word "Reboot Now")
     (set noboot-word "Do Not Reboot")
     (set oldwb (cat "ENLAN-DFS Requires AmigaDOS Version 2.04 or higher.  Please "
		     "contact your local dealer, or Interworks, for information on "
		     "upgrading your machine to the current operating system.\n\n"
		     "Interworks: (909) 699-8120"))
     (set ask-savenodelist (cat "I have found a NodeList on this system.\n\n"
				"Shall I save this Nodelist for you so you will not need "
				 "to enter the Node names and Node addresses again? "))
     (set help-savenodelist (cat "If you select the \"Yes\" button, the NodeList "
				 "will be saved to your Sys: partition with under the name of NodeList.old.\n\n"
				 "If you select the \"No\" button, the NodeList will be deleted from your system "
				 "and you will either have to create a new one, or use the default NodeList that "
				 "the installation script will create for you."))
     (set ask-usenodelist (cat "There is a master NodeList on this Install disk.\n\n"
			       "Would you like to use it for this machine's NodeList?"))
     (set help-usenodelist (cat "If you select the \"Yes\" button, all of the information "
				"in the saved NodeList will be transferred to this systems NodeList.  "
				"This is a tremendous time saver.  You will not have to enter "
				 "the Node names and Node addresses again.\n\nNodeLists no longer need to "
				 "be edited using a text editor.  This install procedure will "
				 "create a default NodeList if one does not already exist, and the IConfig "
				 "program can be used to do all of the updates and changes."))
     (set ask-master (cat "Shall I save this machine's NodeList to the Install disk "
			  "as the master NodeList to be used for other installations?"))
     (set help-master (cat "If you select the \"Yes\" button, this NodeList will be "
			   "saved to the Install disk, where it can placed on all of the "
			   "other systems on the network.\n\n"
			   "If you select the \"No\" button, the NodeList will not be copied onto "
			   "the install disk and you will have to enter the information using the "
			   "IConfig program, or just use the default NodeList."))
     (set novice-sys-toosmall (cat "There is insufficient space left on Sys: "
				    "Please select an alternate place for me to install ENLAN-DFS."))
     (set dev-toosmall (cat "There is insufficient space left in the directory "
			     "you selected.  Please select an alternative."))
     (set ask-whichdir (cat "Please select a Device or Directory where I may "
			    "create the ENLAN drawer and then install the software."))
     (set help-whichdir (cat "This installation program will create a drawer named "
			     "ENLAN, and will install the ENLAN-DFS version 2 software "
			     "inside it.\n\nENLAN-DFS can be installed on other drives or inside "
			     "other drawers (sub-directories) if you wish.  Once the software has "
			     "been installed, the S:User-Startup will have a few lines added to it, "
			     "so the software will know where to find its support files.\n\n"
			     "Interworks recommends installing the ENLAN drawer to your "
			     "System:, or Sys: partition."))
     (set ask-modstartup (cat "May I modify your S:User-Startup to add the necessary "
			      "Assign and Path statements? "))
     (set help-modstartup (cat "If you select the \"Proceed\" button, a few lines, "
			       "like the ones below, will be added to your S:User-Startup file.\n\n"
				"    ;BEGIN ENLAN\n"
				"    If Exists \"Sys:Enlan\"\n"
				"    Assign Enlan: \"Sys:Enlan\"\n"
				"    Path Enlan: Add\n"
				"    Endif\n"
				"    ;END ENLAN\n\n"
				"This will make it much easier to access the ENLAN-DFS programs "
				"from the CLI or SHELL.\n\n"
				"If you select the \"Skip This Part\" button, these lines will not "
				"be added to the S:User-Startup file.  Whenever you want to use any "
				"of the network commands from the CLI or SHELL, you will need to "
				"CD (change directory) to where the software is installed."))
     
     (set ask-deleteall (cat "None of the older ENLAN-DFS Version 1.0 files are compatible "
			     "with the new ENLAN-DFS version 2.0.\n\nShall I delete these old files now?"))
     (set alt-ask-deleteall (cat "There are already version 2.0 files present.  "
			     "Shall I delete these files before re-installing the software?\n\n"
			     "This is the recommended procedure"))
     (set help-deleteall (cat "****************************************************\n"
			      "Interworks suggests that you make a backup of your system "
			      "files before installing or upgrading any new software onto "
			      "your network.  You should make regular back-ups of your "
				 "data to prevent any possible data-loss.  \n\n"
				 "If you would like to stop this installation so you may "
				 "make your backup now,  select the \"Abort Install\" button.  Once "
				 "you have finished with your backup, you may re-start this "
				 "installation program again.\n"
				 "****************************************************\n\n"
				 "If you select the \"Yes\" button, this install program will look "
				 "for these older files and then delete them from your system.\n\n"
				 "This install program will only look for the old software on your Sys: partition, "
				 "which was the default installation location.\n\n"
				 "If you did not install ENLAN-DFS version 1.0 on your Sys: partition, "
				 "this procedure may not be able to locate all of the old network software.  "
				 "This could cause a conflict with the new software.\n\n"
				 "If you select the \"No\" button, the new software will be installed without "
				 "deleting any of the old software.\n\nThis could cause a great number of compatibility "
				 "problems.  We do not recommend this!\n\n"))
     (set ask-installdisk "Please Insert the ENLAN-DFS Install disk labeled \"Master\".")
     (set ask-diskcopy "Starting the diskcopy process.")
     (set help-diskcopy (cat "This procedure uses the Sys:System/Diskcopy program to copy "
			     "the disk.  Once Diskcopy is finished, the new disk will be "
			     "named \"Install\", and be configured as the Working Install Disk.  This "
			     "is the disk which will be used for installing ENLAN-DFS onto the other "
				"systems in the network.\n\nCreating this \"Install\" disk will help prevent "
				"your original ENLAN-DFS disk from getting damaged.\n\n"))
     (set ask-workingdisk "Please Insert the ENLAN-DFS disk labeled \"Install\"")
     (set help-workingdisk "The copy is done, and we need to prepare it for use.")
     (set ask-makedir "Creating the new ENLAN directory")
     (set help-makedir (cat "If you have old software the directory was deleted.  This "
			    "procedure creates a new home directory for the ENLAN-DFS files."))
     (set ask-text "Marking \"Install\" as a working disk.") 
     (set help-text (cat "We need to differentiate between the \"Master\" and the "
			 "\"Install\" disk."))
     (set msg-ready  (cat "Please be ready with a blank disk to create the "
			   "working Install disk.  This is a REQUIRED PROCESS."
			   "\n\nYou may wish to use the label named \n\"ENLAN-DFS Version 2 Working Install Disk\"\n"
			   "which we have provided for you."))
     (set msg-earlyexit (cat "Set-up for the Working Install Disk complete.  Please close all windows "
			      "open on the Workbench and then double-click on the disk icon "
			      "labeled \"Install\" to continue the installation process.  "
			      "Use this Working Install Disk for all subsequent system installations "
			      "or re-installations."))
     (set starticonfig (cat "Would you like to run the IConfig program now?\n"
				"\nThe IConfig program creates and modifies the script "
				"files necessary for ENLAN-DFS to run properly."))
	(set help-starticonfig (cat "The IConfig program will allow you to easily create and modify "
				"your system's configuration.  \nIConfig will help you:\n\n"
				"·  Configure your SANA-II driver with a mouse click\n"
				"·  Create, modify and edit your NodeList file\n"
				"·  Manage resources to be Exported on start-up\n"
				"   · and ·\n"
				"·  Manage resources to be Imported on start-up\n"
				"\nNo more need to work with complicated text editors!!\n"))
     (set warn-reboot (cat "Please remove the Install disk from the drive now.\n\n"
     		   "If you select the \"Reboot Now\" button, your system will reboot and "
     		   "start running the network software.\n\n"
     		   "If you select the \"Do Not Reboot\" button, the installation program will exit "
     		   "and your system will not reboot.\n"))
     (set help-reboot (cat "If you choose not to reboot your system at this time, please note "
			     "that you may not be able to start-up the network until you do reboot.\n\n"
			     "If there was already an older version of ENLAN-DFS running, it is very "
			     "important that you reboot the computer.  This will clear the memory and "
			     "unload any old software which might have been made resident.\n"))
     (set press-whendone "Please select the \"Proceed\" button only after the diskcopy is complete.")
     (set ask-finalcopy "Copying the reboot program to Ram:")
     (set prompt-cardtype "Please select which SANA-II Ethernet device(s) to install")
     (set help-cardtype (cat "\n\nThese are the SANA-II Ethernet devices currently supported. "
			     "If your device is not listed, then please select \"Other\".\n\n"
			     "The Ethernet adapter you purchased should have come with a SANA-II "
			     "compatable device driver.  If it did not, please contact the "
			     "manufacurer of that card, to obtain the proper SANA II driver.\n\n\n"
			     "\n\n****************************************************\n\n"
			     "Interworks would like to thank the following companies for "
			     "giving us permission to distribute their SANA-II driver with "
			     "our software.\n\n"
			     "ASDG for the eb920 (LanRover) driver\n"
			     "Commodore Business Machines for the a2065 driver\n"
			     "and Hydra Systems for the hydra driver.\n\n"
			     "****************************************************\n"))
     (set nodriver-msg (cat "You have chosen \"Other.\"  No driver will be installed "
			    "for this option.  ENLAN-DFS Version 2 requires a SANA-II "
			    "Ethernet driver.  One should have come with the Ethernet adapter "
			    "you purchased.  If not, please contact the manufacturer of that "
				"card, and ask them to supply you with one."))
     (set prompt-interrupt (cat "Please select the which interrupt you wish to use with "
     			 "the ASDG eb920 (LanRover)"))
     (set help-interrupt (cat "The default is interrupt 6.\n\nThe ASDG eb920 (LANRover) "
			      "allows the user to select the relative interrupt priority, by changing "
				 "a jumper on the Ethernet card.\n\n"
			      "Interworks suggests that you use this default setting.  If, however; "
			      "you have a device which requires a higher priority (higher interrupt), "
				 "then please  refer to the eb920 manual for specific instructions on "
			      "how to set the jumper for interrupt level 2.\n\n"
				 "Once you have made these changes, simply reinstall ENLAN-DFS "
				 "and when prompted, select interrupt level 2 from this menu."))
     (set dearchive-now (cat "Please press \"Proceed\" to begin decompressing the ENLAN-DFS "
			     "archive to the ENLAN drawer.\n\n(This may take a couple minutes)"))))

(if (= lanid 2)
    ((set yes-word "Ja")
     (set no-word "Nein")
	(set yesboot-word "Reboot Now")
	(set noboot-word "Do Not Reboot")
     (set oldwb (cat ""
		      ""
		      ""
		      ""))
     (set ask-savenodelist (cat ""
				 ""
				 ""))
     (set help-savenodelist (cat ""
				  ""))
     (set ask-usenodelist (cat ""
			       ""))
     (set help-usenodelist (cat ""
				""
				""))
     (set ask-master (cat ""
			  ""))
     (set help-master (cat ""
			   ""
			   ""))
     (set novice-sys-toosmall (cat ""
				    ""))
     (set dev-toosmall (cat ""
			     ""))
     (set ask-whichdir (cat ""
			 	""))
	(set help-whichdir (cat ""
				""
				""
				""
				""
				""
				""))
     (set ask-modstartup (cat ""
			     ""))
     (set help-modstartup (cat ""
				""
				""
				""
				""
				""
				""))
     (set ask-deleteall (cat ""
			      ""))
     (set alt-ask-deleteall (cat ""
			      ""))
     (set help-deleteall (cat ""
			      ""
			      ""
				 ""
				 ""
				 ""
			      ""
			      ""))
     (set ask-installdisk "")
     (set ask-diskcopy "")
     (set help-diskcopy (cat ""
				    ""
				    ""))
     (set ask-workingdisk "")
     (set help-workingdisk "")
     (set ask-makedir "")
     (set help-makedir (cat ""
			    ""))
     (set ask-text "") 
     (set help-text (cat ""
			  ""))
     (set msg-ready  (cat ""
			   ""
			   ""
			   ""))
     (set msg-earlyexit (cat ""
			      ""
			      ""
			      ""
			      ""))

     (set starticonfig (cat ""
				""
				""))
	(set help-starticonfig (cat ""
				""
				""
				""
				""
				""
				""
				""))
     (set warn-reboot (cat "" 
			   ""
			   ""
			   ""
			   ""
			   ""
			   ""))
     (set help-reboot (cat ""
				""
			   	""
				""
			     ""))
     (set press-whendone    "")
     (set ask-finalcopy "")
     (set prompt-cardtype "")
     (set help-cardtype (cat ""
			     ""
			     ""
			     ""
			     ""
			     ""))
     (set nodriver-msg (cat ""
			    ""
			    ""
			    ""
			    ""
			    ""))
     (set prompt-interrupt "")
     (set help-interrupt (cat ""
			      ""
			      ""
			      ""
			      ""
			      ""
			      ""
				 ""
				 ""))
     (set dearchive-now (cat ""
			     ""
			     ""))
))

(set olduser @user-level)


(set wbversion (/ (getversion) 65536))
(if (< wbversion 37)
    (abort oldwb))
					; probe existance of old installation.
					; start by getting the assigns for certain directories

(if (exists "ENLAN:" (noreq))
    (set dfsdir (getassign "ENLAN"))
  (set dfsdir ""))
(set devdir (getassign "Devs"))
(set libsdir (getassign "Libs"))
(set ldir (getassign "L"))
					; check for an old NodeList.
(if (not (exists "df0:WorkingDisk"))
    ((user 2)
     (message msg-ready)
     (askdisk (prompt ask-installdisk)
	      (help @askdisk-help)
	      (dest "MASTER"))
     (textfile (dest "t:ENLAN_install.tmp")
	       (append "Sys:System/Diskcopy from df0: to df0: name Install\n")
	       (append "endcli\n"))
     (run "newcli CON:100/100/475/100/Diskcopy_Process t:ENLAN_Install.tmp"
	  (prompt ask-diskcopy)
	  (help help-diskcopy))

     (message press-whendone)
     
     (askdisk (prompt ask-workingdisk)
	      (help help-workingdisk)
	      (dest "Install"))
     (textfile (prompt @ask-text)
	       (help @help-text)
	       (dest "Install:WorkingDisk")
	       (append "Valid"))
     (message msg-earlyexit)
;	(run "diskchange df0:")
     (exit (quiet))))

(user 2)
(set nodelist_used "")
(if (exists ("Install:master_nodelist"))
    (if (askbool (choices yes-word no-word)
		 (prompt ask-usenodelist)
		 (help help-usenodelist))
	((set nodelist_used "disk")
	 (copyfiles (prompt "")
		    (help help-usenodelist)
		    (source "Install:master_nodeList")
		    (dest "sys:")
		    (newname "NodeList.old")))))
(if (= nodelist_used "")
    (if (exists (tackon devdir "NodeList"))
	(if (askbool (choices yes-word no-word)
		     (prompt ask-savenodelist)
		     (help help-savenodelist))
	    ((set nodelist_used "old")
	     (copyfiles (prompt "")
			(help "")
			(source (tackon devdir "NodeList"))
			(dest "Sys:")
			(newname "NodeList.old"))))))

(if (= nodelist_used "")
    (if (not (= dfsdir ""))
	(if (askbool (choices yes-word no-word)
		     (prompt ask-savenodelist)
		     (help help-savenodelist))
	    (if (exists (tackon (tackon dfsdir "devs") "NodeList"))
		((set nodelist_used "old")
		 (copyfiles (prompt "")
			    (help "")
			    (source (tackon (tackon dfsdir "devs") "NodeList"))
			    (dest "Sys:")
			    (newname "NodeList.old")))))))
  
(complete 5)	

(run "wait 1")

(copyfiles (prompt ask-finalcopy)
	   (help @copyfiles-help)
	   (source "Install:c/coldboot")
	   (dest "ram:"))

(run "wait 1")

;(message "version is" (/ (getversion "ENLAN:startENet") 65536))

(set t 0)
(if (exists "ENLAN:" (noreq))
    ((if (= 1 (/ (getversion "ENLAN:startENet") 65536))
	 (set ask-thisdelete ask-deleteall)
       (set ask-thisdelete alt-ask-deleteall))
     (if (askbool (choices yes-word no-word)
		  (prompt ask-thisdelete)
		  (help help-deleteall))
	 ((while (< t 16)
	    ((set choice (select t "Deport" "DTS" "Export" "Import" "NetCLI" 
				 "SetNodeName" "ShowHydra" "ShowLance" "ShowLinks"
				 "ShowNodes" "ShowRover" "Spawner" "StartENet"
				 "StopNet" "SyncTime" "XmitTest"))
	     (set t (+ t 1))
	     (if (exists (tackon dfsdir choice))
		 (delete (tackon dfsdir choice)
			 (optional "force")))))
	  (complete 10)
	  
	  (set t 0)
	  (while (< t 4)
	    ((set choice (select t "RemCLI" "DFS" "DTR" "TimeServer"))
	     (set t (+ t 1))
	     (if (exists (tackon (tackon dfsdir "Servers") choice))
		 (delete (tackon (tackon dfsdir "Servers") choice)
			 (optional "force")))))
	  (complete 15)
	  
	  (set t 0)
	  (while (< t 6)
	    ((set choice (select t "DLL.Ethernet.Device" "DLL.Hydra.device"
				 "DLL.Rover.Device" "NodeList" 
				 "Routing.DNA.Device" "Transport.NSP.Device"))
	     (set t (+ t 1))
	     (if (exists (tackon (tackon dfsdir "Devs") choice))
		 (delete (tackon (tackon dfsdir "Devs") choice)
			 (optional "force"))
	       (if (exists (tackon devdir choice))
		   (delete (tackon devdir choice)
			   (optional "force"))))))
	  
	  (complete 20)
	  
	  (set t 0)
	  (while (< t 3)
	    ((set choice (select t "ENLAN.Error.Library" "ENLAN.Network.Library"
				 "ENLAN.XDR.Library"))
	     (set t (+ t 1))
	     (if (exists (tackon (tackon dfsdir "libs") choice))
		 (delete (tackon (tackon dfsdir "libs") choice)
			 (optional "force"))
	       (if (exists (tackon libsdir choice))
		   (delete (tackon libsdir choice)
			   (optional "force"))))))
	  (complete 25)
	  
	  (if (exists (tackon (tackon dfsdir "l") "DFS-Handler"))
	      (delete (tackon (tackon dfsdir "l") "DFS-Handler")
		      (optional "force"))
	    (if (exists (tackon ldir "DFS-Handler"))
		(delete (tackon ldir "DFS-Handler")
			(optional "force"))))
	  
	  (complete 30)
	  
	  (if (exists "Sys:Readme-first")
	      (delete "Sys:Readme-first" (optional "force")))
	  (if (exists "Sys:Readme-first,info")
	      (delete "Sys:Readme-first.info" (optional "force")))
	  (if (exists "Sys:Start-DFS")
	      (delete "Sys:Start-DFS" (optional "force")))
	  (if (exists "Sys:Start-DFS.info")
	      (delete "Sys:Start-DFS.info" (optional "force")))
	  (if (exists "Sys:WBStartup/Start-DFS")
	      (delete "Sys:WBStartup/Start-DFS" (optional "force")))
	  (if (exists "Sys:WBStartup/Start-DFS.info")
	      (delete "Sys:WBStartup/Start-DFS.info" (optional "force")))))
     
     (makeassign "ENLAN")))

(complete 35)

(set defdir "Sys:")

(user 2)
(set dirnotok TRUE)
(while dirnotok 
  ((set defdir (askdir 
    	       (help help-whichdir)
	       (prompt ask-whichdir)
	       (default defdir)))
   (if (> (getdiskspace defdir) appsize)
       (set dirnotok FALSE)
     (message dev-toosmall))))

(set @default-dir defdir)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; I should have all the information that I need.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(user olduser)	    

;(set oldprotection (protect "S:User-Startup" ))
(if (exists "S:User-Startup")
    (set oldprotection (protect "S:User-Startup" ))
  (set oldprotection 0))

(startup "ENLAN" 
	 (prompt ask-modstartup)
	 (help help-modstartup)
	 (command (cat "If exists \"" (tackon @default-dir "Enlan") "\"\n"
	 "Assign Enlan: \"" (tackon @default-dir "Enlan") "\"\n"
	 "Path Enlan: add\n"
	 "Endif\n")))

(protect "S:User-Startup" oldprotection)
(protect "S:User-Startup" "-a")

(complete 40)

(set @default-dest (tackon @default-dir "ENLAN"))

(makedir @default-dest (prompt ask-makedir)
	 (help help-makedir)
	 (infos))
	 
(makeassign "ENLAN" @default-dest)

(message dearchive-now)

(run (cat "Install:c/lhex -fw=ENLAN: x Install:ENLAN.lha"))

(complete 90)

(if (exists "Sys:NodeList.old")
    ((copyfiles (prompt "")
		(help "")
		(source "Sys:NodeList.old")
		(dest "ENLAN:Devs/")
		(newname "NodeList"))
     (delete "Sys:NodeList.old" (optional "force")))
  (textfile (prompt "")
	    (help "")
	    (dest "ENLAN:Devs/NodeList")
	    (append "Amiga1\t1.1\nAmiga2\t1.2\nAmiga3\t1.3\n")
	    (append "Amiga4\t1.4\nAmiga5\t1.5\n")))

(complete 95)

(set other 4)
(set asdg 3)

(set cardmask (askoptions 
	      (prompt prompt-cardtype)
	      (help help-cardtype)
	      (default 0)
	      (choices "Commodore A2065" "Hydra Systems Network" "InterWorks ICard (PCMCIA)" 
		       "ASDG eb920 (LanRover)" "Other")))

(set loop 0)
(while (<= loop other)
  ((if (BITAND cardmask (shiftleft 1 loop))
       ((if (= loop other)
	    (message nodriver-msg)
	  ((if (= loop asdg)
	       ((set inum (askchoice
			   (prompt prompt-interrupt)
			   (help help-interrupt)
			   (choices "6 (default)" "2")))
		(set drivername (select inum "Install:SANA/eb920.device.6"
					"Install:SANA/eb920.device.2")))
	     (set drivername (select loop "Install:SANA/a2065.device"
				     "Install:SANA/hydra.device"
				     "Install:SANA/icard.device")))))
	  
	  
	  (if (not (= loop other))
	      ((if (not (exists "Devs:Networks"))
		   (makedir "Devs:Networks"))
	       (copylib (prompt "")
			(help "")
			(source drivername)
			(dest "Devs:Networks")) ; the driver is now installed.
	       (if (= loop asdg)
		   (if (= drivername "Install:SANA/eb920.device.6")
		       (rename "Devs:Networks/eb920.device.6" 
			       "Devs:Networks/eb920.device")
		     (rename "Devs:Networks/eb920.device.2" 
			     "Devs:Networks/eb920.device"))))))))
   (set loop (+ loop 1)))

(complete 98)

(if (askbool (choices yes-word no-word)
	     (prompt starticonfig)
	     (help help-starticonfig))
    (run "Install:c/IConfig"))

(if (not (= nodelist_used "disk"))
    (if (askbool (choices yes-word no-word)
		 (prompt ask-master)
		 (help help-master))
	((copyfiles (prompt "")
		    (help "")
		    (source "enlan:devs/nodelist")
		    (dest "Install:"))
	 (rename "Install:nodelist" "Install:master_nodelist"))))

(complete 100)
(if (askbool (choices yesboot-word noboot-word)
	     (prompt warn-reboot)
	     (help help-reboot))
    ((run "c:cpu nofastrom >nil:")
    	(run "wait 1")
    	(run "ram:coldboot"))
  (delete "ram:coldboot"))
