; $VER: Install 1.1 (11.08.96)
;
; 1.0  (09.12.95)  first version
; 1.1  (11.08.96)  refer to the security chapter of the manual
;

(transcript "Installing EnvoyARexx...")

;
; Defaults
;

(set librarydest "LIBS:")
(set servicedest "SYS:")
(set clidest "C:")
(set rexxdest "REXX:")
(set docdest "SYS:")


;
; String-definitions
;

(set #WhichFiles    (cat "Which files of the EnvoyARexx-package do you want to "
                         "install on this Amiga? (Read the help-page for more "
                         "information)"))
(set #WhichFilesHlp (cat "envoyarexx.library: the client of the EnvoyARexx "
                         "package. Only needed on those machines which want "
                         "to connect to remote machines.\n\n"
                         "envoyarexx.service: the server of the package. "
                         "The server is required for machines which will "
                         "be connected from remote clients.\n\n"
                         "CLI commands: CLI equivalents of the envoyarexx.library's "
                         "rexx-functions. Useful for batch-files. CLI commands "
                         "require the envoyarexx.library.\n\n"
                         "Rexx example: simple example of EnvoyARexx.\n\n"
                         "Manual: documenation of EnvoyARexx."))
(set #Library            "envoyarexx.library")
(set #Service            "envoyarexx.service")
(set #CLICommands        "CLI commands")
(set #Example            "Rexx example script")
(set #Manual             "EnvoyARexx manual")
(set #DoNothing          "Thank you for using the EnvoyARexx installer... ;-)")
(set #CLIMessage    (cat "The CLI commands you chose to install require the "
                         "envoyarexx.library. Thus, the library will be "
                         "installed, too."))
(set #LibraryDest   (cat "Please select the path where to install "
                         "the envoyarexx.library. No new drawer will be created."))
(set #LibraryHelp   (cat "No new drawer will be created for the library.\n\n"
                         "Note that it's not absolutely required to place "
                         "the library to LIBS:, as long as your scripts and "
                         "applications are able to find this file somewhere else."))
(set #InstallLib         "Installing envoyarexx.library...")
(set #ServiceDest   (cat "Please select the path where the envoyarexx.service "
                         "should be installed. No new drawer will be created."))
(set #ServiceHelp   (cat "No new drawer will be created for the service.\n\n"
                         "You should copy the service into your Envoy/Services "
                         "directory."))
(set #InstallSvc         "Installing envoyarexx.service...")
(set #SvcMagicIcon       "Do you want to install the MagicWB-icon of the service?")
(set #CLIDest       (cat "Please select the path where the EnvoyARexx CLI commands "
                         "should be installed. No new drawer will be created."))
(set #InstallCH          "Installing CLI command 'ConnectHost'...")
(set #InstallDCH         "Installing CLI command 'DisConnectHost'...")
(set #RexxDest      (cat "Please select the path where the EnvoyARexx example "
                         "scripts should be installed. No new drawer will be created."))
(set #InstallRexx1       "Installing ARexx-script 'Example.earexx'...")
(set #WhichManuals       "Which documents should be installed?")
(set #ManGuide           "EnvoyARexx.guide")
(set #ManDVI             "EnvoyARexx.dvi")
(set #DocDest       (cat "Please select the path where the manual(s) "
                         "should be installed. No new drawer will be created."))
(set #DocWorking         "Installing manual(s)...")

(set #ByeTextSvc    (cat "Please refer the manual for more information "
                         "about EnvoyARexx.\n\nPlease read the chapter about "
                         "security in the manual!\n\nDon't forget to activate the "
                         "newly installed service using Envoy's Services Manager."))
(set #ByeText       (cat "Please refer the manual for more information "
                         "about EnvoyARexx.\n\nPlease read the chapter about "
                         "security in the manual!"))


;
; Select which files to install
;

(set cfiles (askoptions (prompt #WhichFiles)
                       (help #WhichFilesHlp)
                       (choices #Library
                                #Service
                                #CLICommands
                                #Example
                                #Manual
                       )
           )
)


;
; Exit if nothing was selected
;

(if (= cfiles 0)
  ((message #DoNothing) (exit (quiet)))
)


;
; Notify that CLI commands require the library (if selected)
;

(if (and (<> 0 (bitand cfiles 4)) (= 0 (bitand cfiles 1)))
  (message (#CLIMessage))
)


;
; Install the envoyarexx.library, if selected
;

(if (or (<> 0 (bitand cfiles 1)) (<> 0 (bitand cfiles 4)))
  (
    (set librarydest
      (askdir
        (prompt  #LibraryDest)
        (default librarydest)
        (help    #LibraryHelp)
      )
    )
    (copylib
      (prompt #InstallLib)
      (help @copylib-help)
      (source "libs/envoyarexx.library") (dest librarydest)
      (confirm)
    )
  )
)


;
; Install the service, if selected
;

(if (<> 0 (bitand cfiles 2))
  (
    (set servicedest
      (askdir
        (prompt  #ServiceDest)
        (default servicedest)
        (help    #ServiceHelp)
      )
    )
    (copylib
      (prompt #InstallSvc)
      (help @copylib-help)
      (source "services/envoyarexx.service") (dest servicedest)
      (confirm)
      (infos)
    )
    (set magicicon
      (askbool
        (prompt #SvcMagicIcon)
        (help   " ")
      )
    )
    (if (= 1 magicicon)
      (
        (copyfiles
          (source "icons/envoyarexx.service.info") (dest servicedest)
        )
      )
    )
  )
)


;
; Install the CLI command, if selected
;

(if (<> 0 (bitand cfiles 4))
  (
    (set clidest
      (askdir
        (prompt  #CLIDest)
        (default clidest)
        (help    @askdir-help)
      )
    )
    (copylib
      (prompt #InstallCH)
      (help @copylib-help)
      (source "c/ConnectHost") (dest clidest)
      (confirm)
    )
    (copylib
      (prompt #InstallDCH)
      (help @copylib-help)
      (source "c/DisConnectHost") (dest clidest)
      (confirm)
    )
  )
)


;
; Copy the example ARexx-script(s), if selected
;

(if (<> 0 (bitand cfiles 8))
  (
    (set rexxdest
      (askdir
        (prompt  #RexxDest)
        (default rexxdest)
        (help    @askdir-help)
      )
    )
    (copylib
      (prompt #InstallRexx1)
      (help @copylib-help)
      (source "rexx/Example.earx") (dest rexxdest)
      (confirm)
      (infos)
    )
  )
)


;
; Copy the manual, if selected
;

(if (<> 0 (bitand cfiles 16))
  (
    (set cman (askoptions (prompt #WhichManuals)
                          (help @askoptions-help)
                          (choices #ManGuide
                                   #ManDVI
                          )
                          (default 1)
              )
    )

    (if (<> cman 0)
      (
        (set docdest
          (askdir
            (prompt  #DocDest)
            (default docdest)
            (help    @askdir-help)
          )
        )

        (if (<> 0 (bitand cman 1))
          (copyfiles
            (prompt #DocWorking)
            (source "Docs/EnvoyARexx.guide") (dest docdest)
            (infos)
          )
        )

        (if (<> 0 (bitand cman 2))
          (copyfiles
            (prompt #DocWorking)
            (source "Docs/EnvoyARexx.dvi") (dest docdest)
            (infos)
          )
        )

      )
    )

  )
)


(if (<> 0 (bitand cfiles 2))
  (exit #ByeTextSvc)
  (exit #ByeText)
)


