(welcome "      Welcome to the Xenolink Install Utility\n")


(complete 0)
(set @default-dest "")


(if (= (getassign "t") "")
  (makeassign "t" "ram:")
)


(set OrigDir
	(askdir
		(prompt "Choose where to install Xenolink 1.90")

		(help "Xenolink will be completely installed within the directory you "
            "supply; many subdirectories will be made within the directory "
            "name you supply here.\n\n"

            "If the directory name supplied does not exist, it will be "
            "created for you.\n")

      (default "Work:Xenolink")
      (newpath 1)
      (disk 1)
	)
)


(set DirLength (strlen OrigDir))
(set DirLength (- DirLength 1))

(set LastChar (substr OrigDir DirLength))

(if (AND (<> LastChar "/") (<> LastChar ":")))
(
   (set BaseDir
      (cat OrigDir "/")
   )
)


(message ("The installer program will now create the required subdirectories ")
         ("within your Xenolink directory, and will copy the required files."))

(if (= (exists ("%sConfiguration" BaseDir)) 0)
   (makedir ("%sConfiguration" BaseDir))
)

(if (= (exists ("%sUtilities" BaseDir)) 0)
   (makedir ("%sUtilities" BaseDir))
)

(if (= (exists ("%sModules" BaseDir)) 0)
   (makedir ("%sModules" BaseDir))
)

(if (= (exists ("%sSystemData" BaseDir)) 0)
   (makedir ("%sSystemData" BaseDir))
)

(if (= (exists ("%sUpload" BaseDir)) 0)
   (makedir ("%sUpload" BaseDir))
)

(if (= (exists ("%sUpload/Resume" BaseDir)) 0)
   (makedir ("%sUpload/Resume" BaseDir))
)

(if (= (exists ("%sUpload/0" BaseDir)) 0)
   (makedir ("%sUpload/0" BaseDir))
)

(if (= (exists ("%sUpload/1" BaseDir)) 0)
   (makedir ("%sUpload/1" BaseDir))
)

(if (= (exists ("%sUsers" BaseDir)) 0)
   (makedir ("%sUsers" BaseDir))
)

(if (= (exists ("%sLog" BaseDir)) 0)
   (makedir ("%sLog" BaseDir))
)

(if (= (exists ("%sFileCat" BaseDir)) 0)
   (makedir ("%sFileCat" BaseDir))
)

(if (= (exists ("%sDoors" BaseDir)) 0)
   (makedir ("%sDoors" BaseDir))
)

(if (= (exists ("%sMenuSource" BaseDir)) 0)
   (makedir ("%sMenuSource" BaseDir))
)

(if (= (exists ("%sMenuObject" BaseDir)) 0)
   (makedir ("%sMenuObject" BaseDir))
)

(if (= (exists ("%sMenuText" BaseDir)) 0)
   (makedir ("%sMenuText" BaseDir))
)

(if (= (exists ("%sScripts" BaseDir)) 0)
   (makedir ("%sScripts" BaseDir))
)

(if (= (exists ("%sText" BaseDir)) 0)
   (makedir ("%sText" BaseDir))
)

(if (= (exists ("%sSystemText" BaseDir)) 0)
   (makedir ("%sSystemText" BaseDir))
)

(if (= (exists ("%sTemp" BaseDir)) 0)
   (makedir ("%sTemp" BaseDir))
)

(if (= (exists ("%sTemp/0" BaseDir)) 0)
   (makedir ("%sTemp/0" BaseDir))
)

(if (= (exists ("%sTemp/1" BaseDir)) 0)
   (makedir ("%sTemp/1" BaseDir))
)

(if (= (exists ("%sFileAttaches" BaseDir)) 0)
   (makedir ("%sFileAttaches" BaseDir))
)

(if (= (exists ("%sFidoNet" BaseDir)) 0)
   (makedir ("%sFidoNet" BaseDir))
)

(if (= (exists ("%sIn" BaseDir)) 0)
   (makedir ("%sIn" BaseDir))
)

(if (= (exists ("%sIn/Bad" BaseDir)) 0)
   (makedir ("%sIn/Bad" BaseDir))
)

(if (= (exists ("%sOut" BaseDir)) 0)
   (makedir ("%sOut" BaseDir))
)

(if (= (exists ("%sMsgs" BaseDir)) 0)
   (makedir ("%sMsgs" BaseDir))
)

(if (= (exists ("%sDownloading" BaseDir)) 0)
   (makedir ("%sDownloading" BaseDir))
)

(if (= (exists ("%sDownloading/Bad" BaseDir)) 0)
   (makedir ("%sDownloading/Bad" BaseDir))
)

(if (= (exists ("%sDownloading/UploadsToSysop" BaseDir)) 0)
   (makedir ("%sDownloading/UploadsToSysop" BaseDir))
)

(if (= (exists ("%sDownloading/Misc" BaseDir)) 0)
   (makedir ("%sDownloading/Misc" BaseDir))
)


(copyfiles (source "XENOLINK_DISK1:Xenolink.keyfile") (dest ("%s" BaseDir)))
(copyfiles (source "XENOLINK_DISK1:Misc/FileData.QDX") (dest ("%sFileCat" BaseDir)))
(copyfiles (source "XENOLINK_DISK1:Misc/NewFileData.QDX") (dest ("%sFileCat" BaseDir)))
(copyfiles (source "XENOLINK_DISK1:Misc/Start.0") (dest ("%s" BaseDir)))



(until (AND (>= SysopNameLength 1) (< SysopNameLength 24))
   (set SysopName
      (askstring
         (prompt "Please enter the name you would like to use on the BBS (preferably "
                 "your real name).  You will be able to change it after you have "
                 "installed the BBS, if you wish.")

   		(help "The name you enter here will be the name of the sole user on "
               "the BBS, when it is initialised by the installation process.  "
               "The name you enter may be no more than 24 characters in length.")
      )
   )

   (set SysopNameLength (strlen SysopName))
)


(until (AND (>= PasswordLength 8) (< PasswordLength 15))
   (set Password
      (askstring
         (prompt ("Please enter the password you would like to use for the account '%s'.  " SysopName)
                  "Your password must be between 8 and 14 characters in length")

         (help ("The password you enter here will be the password of the user '%s' " SysopName)
                "for logging in to the BBS.")
      )
   )

   (set PasswordLength (strlen Password))

   (if (OR (< PasswordLength 8) (>= PasswordLength 15))
      (message "Your password must be between 8 and 14 characters in length")
   )
)


(message ("Xenolink's programs and data are stored on the Install disk in ")
         ("compressed format; they will now be decompressed"))

(makedir "t:Xenolink_Install_TempDir")
(copyfiles (source "XENOLINK_DISK1:Misc/LX") (dest "t:Xenolink_Install_TempDir"))

(message ("The installer program will now copy Xenolink's shared library ")
         ("(xenolink.library) and specialised external Zmodem protocol (xenoxprzmodem.library) ")
         ("to your LIBS: directory"))

(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Libs.LZH LIBS:"))


(if (= (exists ("FONTS:cleanibm/8")) 0)
   (message ("Xenolink requires cleanibm.font (size 8) to run, in its default setup.\n\n")
            ("This font will now be installed for you.\n"))

   (run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Fonts.LZH FONTS:"))
)

(if (= (exists ("FONTS:helvetica/11")) 0)
   (message ("Xenolink requires helvetica.font (size 11) to run.\n\n")
            ("You will have to install this font from your Workbench disks.\n\n"))
)


(message ("The Xenolink installer will now copy selected external protocol ")
         ("libraries to your LIBS: directory.\n\n")

         ("If the installer detects that you already have the latest version ")
         ("of a library, then it will not be copied and you will not be ")
         ("prompted; otherwise you will be prompted as to whether you wish to ")
         ("install the library.\n\n"))

(copylib
   (prompt "Copy Ymodem: xprymodem.library")
   (help "No help available at this point")
   (source "XENOLINK_DISK1:Misc/xprymodem.library")
   (dest "LIBS:")
   (optional "oknodelete" "askuser")
   (confirm)
)

(copylib
   (prompt "Copy Zmodem: xprzmodem.library")
   (help "No help available at this point")
   (source "XENOLINK_DISK1:Misc/xprzmodem.library")
   (dest "LIBS:")
   (optional "oknodelete" "askuser")
   (confirm)
)


(message ("Xenolink files will now be decompressed to subdirectories ")
         ("within your %s dir" BaseDir))

(working ("Decompressing files to %s" BaseDir))
(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Doors/GW2140.LHA %sDoors/GlobalWar/" BaseDir))
(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Doors/Nim.LZH %sDoors/Nim/" BaseDir))
(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Doors/Bomber.LZH %sDoors/Bomber/" BaseDir))
(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK1:Misc/Doors/Hello.LZH %sDoors/Hello/" BaseDir))
(run ("t:Xenolink_Install_TempDir/LX -a -m -q x XENOLINK_DISK2:Misc/Main.LZH %s" BaseDir))


(message ("Xenolink will now initialise its demo configuration"))

(run ("%sUtilities/InstInitBBS -! \"%sUsers/\" \"%s\" \"%s\" Somewhere" BaseDir BaseDir SysopName Password))

(makeassign "XENOLINK" ("%s" BaseDir))
(makeassign "XCONFIG" "XENOLINK:Configuration")
(makeassign "MSG" "XENOLINK:Msgs")
(makeassign "DOWNLOADING" "XENOLINK:Downloading")
(makeassign "DOORS" "XENOLINK:Doors")


(run ("%sUtilities/TextConfig" BaseDir))


(delete "t:Xenolink_Install_TempDir/LX")



(run "run XENOLINK_DISK1:Misc/more XENOLINK_DISK1:Misc/Xenolink.README")

(message ("The Install script has made three logical ASSIGN statements:\n\n")
         ("Assign XENOLINK: %s\n" BaseDir)
         ("Assign XCONFIG: %sConfiguration\n" BaseDir)
         ("Assign DOORS: %sDoors\n\n" BaseDir)
         ("You may wish to add these ASSIGN statements to your ")
         ("s:startup-sequence.  For now, the Install script has placed an ")
         ("executable script file named 'BBS' in the '%s' directory" BaseDir))

(execute ("XENOLINK_DISK1:Misc/MakeBBSScript >NIL: %s" BaseDir))

(execute "XENOLINK_DISK1:Misc/FirstStart")

(run "run XENOLINK_DISK1:Misc/more XENOLINK_DISK1:Misc/Xenolink2.README")
