; $VER: Install_hserv 9.1 (13.3.99)

(procedure selDest
 (if (exists "hserv:" (noreq))
  (
   (set #old-hserv-assign 1)
   (set #old-hserv-assign-location (expandpath "hserv:"))
   (set #installDir
    (askdir
     (prompt "Select the directory where you want to "
      "install hserv 9.1. You already have a 'hserv:' "
      "assign on your system, so it is assumed that this "
      "is the location of an older version of hserv that "
      "you want to upgrade.")
     (help "Select the directory where you want to "
      "install hserv 9.1. Since you already have a 'hserv:' "
      "assign on your system you should probably accept "
      "the default.")
     (default "hserv:")
    )
   )
  )
  (
   (set #old-hserv-assign 0)
   (if (exists "Work:" (noreq))
    (set #installDir "Work:")
    (set #installDir "SYS:")
   )
   (set #installDir
    (askdir
     (prompt "Select the directory where you want to "
      "install hserv 9.1. An additional directory "
      "will *NOT* be created at the location you specify.")
     (help "Select the directory where you want to "
      "install hserv 9.1. All necessary files will be copied "
      "to that directory during installation. A new directory "
      "will *NOT* be created at the location you specify. "
      "This means if you want hserv to be installed in its "
      "own directory then you need to create that directory "
      "yourself first.")
     (default #installDir)
    )
   )
  )
 )
)

(procedure copyLibs
 (set #copyLibsHelp "Copying the libraries needed by hserv and hconf")
 (copylib
  (prompt "Installing rxsocket.library to LIBS:" )
  (help #copyLibsHelp)
  (source (tackon #source-dir "LIBS/rxsocket.library"))
  (dest "LIBS:")
  (confirm)
  (optional "askuser" "force")
 )
 (copylib
  (prompt "Installing rmh.library to LIBS:" )
  (help #copyLibsHelp)
  (source (tackon #source-dir "LIBS/rmh.library"))
  (dest "LIBS:")
  (confirm)
  (optional "askuser" "force")
 )
 (copylib
  (prompt "Installing rxwiz.library to LIBS:" )
  (help #copyLibsHelp)
  (source (tackon #source-dir "LIBS/rxwiz.library"))
  (dest "LIBS:")
  (confirm)
  (optional "askuser" "force")
 )
 (copylib
  (prompt "Installing rxasl.library to LIBS:" )
  (help #copyLibsHelp)
  (source (tackon #source-dir "LIBS/rxasl.library"))
  (dest "LIBS:")
  (confirm)
  (optional "askuser" "force")
 )
)

(welcome "Welcome to the hserv 9.1 installation.\n")

(set @app-name "hserv 9.1")

(complete 0)

(set #source-dir (if (= 1 (exists @icon)) (pathonly (expandpath @icon))
 (expandpath @icon))
)

(selDest)
(set @default-dest #installDir)

(complete 20)

; start actual installation

; delete obsolete files from older hserv versions
(delete (tackon #installDir "main/gethostname.rexx") (optional force))
(delete (tackon #installDir "main/errlog.rexx") (optional force))
(delete (tackon #installDir "main/transferlog.rexx") (optional force))
(delete (tackon #installDir "main/readconfig.rexx") (optional force))
(delete (tackon #installDir "main/sorryTermite.rexx") (optional force))
(delete (tackon #installDir "main/checkIP.rexx") (optional force))
(delete (tackon #installDir "main/checkAuth.rexx") (optional force))
(delete (tackon #installDir "main/getIdentify.rexx") (optional force))

;copy libraries
(copyLibs)

;copy rxs
(copylib
 (prompt "Installing rxs to C:")
 (help "This will install rxs to C:")
 (source (tackon #source-dir "c/rxs"))
 (dest "C:")
 (confirm)
 (optional "askuser" "force")
)

(complete 30)

;copy root
(copyfiles
 (source (tackon #source-dir "temp"))
 (dest (#installDir))
 (optional force)
 (all)
)

; delete Install files
(delete (tackon #installDir "Install") (optional force))
(delete (tackon #installDir "Install.info") (optional force))

(complete 40)

; copy main
(if (not (exists (tackon #installDir "main")))
 (makedir (tackon #installDir "main"))
)
(copyfiles
 (source (tackon #source-dir "main"))
 (dest (tackon #installDir "main"))
 (optional force)
 (all)
)

(complete 50)

; copy htdocs
(if (not (exists (tackon #installDir "htdocs")))
 (makedir (tackon #installDir "htdocs"))
)
(copyfiles
 (source (tackon #source-dir "htdocs"))
 (dest (tackon #installDir "htdocs"))
 (optional force)
 (all)
)

(complete 60)

; copy conf
(if (not (exists (tackon #installDir "conf")))
 (makedir (tackon #installDir "conf"))
)
(copyfiles
 (source (tackon #source-dir "conf"))
 (dest (tackon #installDir "conf"))
 (optional force)
 (all)
)

(complete 70)

; copy cgi-bin
(if (not (exists (tackon #installDir "cgi-bin")))
 (makedir (tackon #installDir "cgi-bin"))
)
(copyfiles
 (source (tackon #source-dir "cgi-bin"))
 (dest (tackon #installDir "cgi-bin"))
 (optional force)
 (all)
)

(complete 80)

; copy log
(if (not (exists (tackon #installDir "logs")))
 (makedir (tackon #installDir "log"))
)

(complete 90)

(complete 100)
