; Installation script for CrashMail

(set reqtoolslib "libs/reqtools.library")
(set gtlayoutlib "libs/gtlayout.library")

; make sure we are running under at least Kickstart 2.04

(if (< (/ (getversion) 65536) 37)
(
    (abort "Sorry, you need at least Workbench 2.04 to use CrashMail")
))

(complete 0)

(message "\nWelcome to the CrashMail installation script.\n\n"
         "CrashMail is a mail processing utility ('tosser') "
         "for FidoNet and all other nets using the same technology.\n\n"
         "Please read CrashMail.guide for more information.\n\n"
         "CrashMail is Copyright 1995 Johan Billing.\n\n")


(copylib
	(prompt "Copying gtlayout.library...")
	(help "CrashPrefs needs this library for the "
	      "user interface. If you don't install "
	      "gtlayout.library, you will not be able "
	      "to use CrashPrefs. ")
	(source gtlayoutlib)
	(dest "Libs:")
	(confirm)
)

(complete 12)

(copylib
	(prompt "Copying reqtools.library...\n\n"
	        "Only the main library file is included in the CrashMail archive. "
	        "If you want to use ReqTools in your local language or use the "
	        "ReqTools settings program, you need to get the complete ReqTools "
	        "archive.")

	(help "CrashPrefs needs this library for the "
	      "requesters If you don't install "
	      "reqtools.library, you will not be able "
	      "to use CrashPrefs. ")

	(source reqtoolslib)
	(dest "Libs:")
	(confirm)
)

(complete 25)

; Ask for destination directory

(set destdir
   (askdir
      (prompt "Please select the directory where you want to install CrashMail. "
               "This script will not create a directory, the files will be put "
               "in the directory that you select here ")
      (help "")
      (default "RAM:")
   )
)

(set @default-dest destdir)

; Copy the main files

(set prgbitmap
  (askoptions
    (prompt "Which parts of the archive do you want to copy?")
    (help   "Just select the files you want to copy.\n\n"
            "CrashMail          Main program\n"
            "CrashMail.guide    Documentation\n"
            "CrashPrefs         Settings program\n"
            "AreaFixHelp.doc    Helpfile for the AreaFix\n"
            "StatsFormat.doc    Format of the statistics file\n")

    (choices "CrashMail"
             "CrashMail.guide"
             "CrashPrefs"
             "AreaFixHelp.doc"
             "StatsFormat.doc")

    (default 31)
  )
)

(if (BITAND prgbitmap 1)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashMail")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 2)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashMail.guide")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 4)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashPrefs")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 8)
   (copyfiles
      (prompt "")
      (help "")
	   (source "AreafixHelp.doc")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 16)
   (copyfiles
      (prompt "")
      (help "")
	   (source "StatsFormat.doc")
   	(dest destdir)
	   (infos)
   )
)

(complete 50)

; Copy the CrashMail tools

(set prgbitmap
  (askoptions
    (prompt "Which parts of the archive do you want to copy?")
    (help   "Just select the files you want to copy.\n\n"
            "CrashForward       Makes forward lists\n"
            "CrashHW            Shows and updates highwater marks\n"
            "CrashMaint         Maintains *.msg areas\n"
            "CrashStats         Shows statistics file\n"
            "CrashWrite         Generates messages\n")

    (choices "CrashForward"
             "CrashHW"
             "CrashMaint"
             "CrashStats"
             "CrashWrite")

    (default 31)
  )
)

(if (BITAND prgbitmap 1)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashForward")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 2)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashHW")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 4)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashMaint")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 8)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashStats")
   	(dest destdir)
	   (infos)
   )
)

(if (BITAND prgbitmap 16)
   (copyfiles
      (prompt "")
      (help "")
	   (source "CrashWrite")
   	(dest destdir)
	   (infos)
   )
)

(complete 75)

; Copy the tools drawer

(set prgbitmap
  (askoptions
    (prompt "Which additional tools do you want to copy?")
    (help   "Just select the files you want to copy.\n\n"
            "ExistsMail         Checks for mail in scripts\n"
            "ExistsTick         Checks for *.tic files in scripts\n"
            "CheckSpace10.lha   Checks for disk space in scripts\n")

    (choices "ExistsMail"
             "ExistsTick"
             "CheckSpace10.lha")

    (default 7)
  )
)

(if (BITAND prgbitmap 1)
   (copyfiles
      (prompt "")
      (help "")
	   (source "tools/ExistsMail")
   	(dest (tackon destdir "Tools") )
	   (infos)
   )
)

(if (BITAND prgbitmap 2)
   (copyfiles
      (prompt "")
      (help "")
	   (source "tools/ExistsTick")
   	(dest (tackon destdir "Tools") )
	   (infos)
   )
)

(if (BITAND prgbitmap 4)
   (copyfiles
      (prompt "")
      (help "")
	   (source "tools/CheckSpace10.lha")
   	(dest (tackon destdir "Tools") )
	   (infos)
   )
)

(if
	(askbool
		(prompt "Do you want to copy the included ARexx scripts?")
		(help "Several ARexx scripts are included with CrashMail. They "
		      "are small programs that might be useful to you...")
		(default 1)
	)
	(
		(copyfiles
			(source "Rexx")
			(dest (tackon destdir "Rexx"))
			(all)
         (infos)
		)
	)
)

(complete 100)

(message "CrashMail is now installed. Now you should "
         "start CrashPrefs to configure CrashMail")
