; $VER: hserv_Install 31.0 (24.5.01)

(procedure P_SetMessages
    (if (= "italiano" @language)
        (
            (set #AskInstallDirPromptMsg        "Scegli la directory dove installare hserv")
            (set #AskInstallDirHelpMsg          "Nella directory definita qui, sarà creato un cassetto di nome hserv ove saranno installati tutti i file necessari al corretto funzionamento di hserv.")

            (set #AskLibsDirPromptMsg           "Scegli la directory dove installare le librerie")
            (set #AskLibsDirHelpMsg             "Nella directory che sceglierai, verranno copiate varie librerie e verrà creata una directory chiamata RxMUI, contenente le classi esterne. Ovviamente la directory scelta, dovrà essere nell'assegnamento logico LIBS:")

            (set #AskMCCsDirPromptMsg           "Scegli la directory dove installare alcuni classi MUI")
            (set #AskMCCsDirHelpMsg             "Nella directory che sceglierai, verranno copiate alcune classi MUI. Ovviamente la directory scelta, dovrà essere nell'assegnamento logico LIBS:")

            (set #CopyingLibsMsg                "Sto copiando le librerie")
            (set #CopyingMCCsMsg                "Sto copiando le classi MUI")
            (set #CopyingHTDocsMsg              "Sto copiando i documenti HTML")
            (set #CopyingCGIMsg                 "Sto copiando gli script CGI")
            (set #CopyingConfigMsg              "Sto copiando i file di configurazione")
            (set #CopyingLogMsg                 "Sto copiando i file di log")
            (set #CopyingCoreMsg                "Sto copiando hserv")
        )
        (
            (set #AskInstallDirPromptMsg        "Select the drawer where you want to install hserv. A directory called hserv will be created there")
            (set #AskInstallDirHelpMsg          "In the drawer you supply here, there will be created a directory called hserv, where all the needed files will be copied")

            (set #AskLibsDirPromptMsg           "Select the drawer where you want to copy libraries and RxMUI external classes")
            (set #AskLibsDirHelpMsg             "In the drawer you supply here, there will be installed libraries and there will be created a drawer called rxmui, where external RxMUI classes reside. This drawer MUST BE in your LIBS: assignment")

            (set #AskMCCsDirPromptMsg           "Select the drawer where you want to copy some MUI classes")
            (set #AskMCCsDirHelpMsg             "In the drawer you supply here, there will be installed some MUI classes. This drawer MUST BE in your LIBS: assignment")

            (set #CopyingLibsMsg                "Copying or Updating libraries")
            (set #CopyingMCCsMsg                "Copying or Updating MUI classes")
            (set #CopyingHTDocsMsg              "Copying HTML documents")
            (set #CopyingCGIMsg                 "Copying CGI files")
            (set #CopyingConfigMsg              "Copying Configuration files")
            (set #CopyingLogMsg                 "Copying Log files")
            (set #CopyingCoreMsg                "Copying hserv core")
        )
    )
)

(procedure P_AskInstallDir
    (set #InstallDir (askdir (prompt #AskInstallDirPromptMsg)
                             (help #AskInstallDirHelpMsg)
                             (default "Ram:")
                     )
    )
)

(procedure P_AskLibsDir
    (set #libsDir
        (askdir
            (prompt #AskLibsDirPromptMsg)
            (help #AskLibsDirHelpMsg)
            (default "LIBS:")
        )
    )
)

(procedure P_AskMCCsDir
    (set #MCCsDir
        (askdir
            (prompt #AskMCCsDirPromptMsg)
            (help #AskMCCsDirHelpMsg)
            (default "MUI:LIBS/MUI/")
        )
    )
)

(procedure P_CopyLibs
    (working #CopyingLibsMsg)
    (set #localLibsDir (tackon #source-dir "LIBS/"))
    (foreach #localLibsDir "#?"
        (copylib
            (source (tackon #localLibsDir @each-name))
            (dest #libsDir)
        )
    )

    (set #localRxmecLibsDir (tackon #source-dir "LIBS/RXMUI/"))
    (set #installRxmecLibsDir (tackon #libsDir "RxMUI/"))
    (if (= (exists #installRxmecLibsDir) 0)
        (makedir #installRxmecLibsDir)
    )
    (foreach #localRxmecLibsDir "#?"
        (copylib
            (source (tackon #localRxmecLibsDir @each-name))
            (dest #installRxmecLibsDir) (optional "nofail")
        )
    )
)

(procedure P_CopyMCCs
    (working #CopyingMCCsMsg)
    (set #localMCCSDir (tackon #source-dir "MUI/"))
    (foreach #localMCCsDir "#?"
        (copylib
            (source (tackon #localMCCsDir @each-name))
            (dest #MCCsDir)
        )
    )
)

(procedure P_CopyCatalogs
    (set #catSourceDir (tackon #source-dir (tackon "Catalogs" @language)))
    (set #catDestDir (tackon "Locale:" (tackon "Catalogs" @language)))
    (if (= (and (= (exists (#catSourceDir)) 2) (= (exists (#catDestDir)) 2)) 1)
        (foreach #catSourceDir "#?"
            (copylib
                (source (tackon #catSourceDir @each-name))
                (dest #catDestDir)
            )
        )
    )
)

(procedure P_CopyCGI
    (working #CopyingCGIMsg)
    (copyfiles
        (source (tackon #source-dir "cgi-bin/"))
        (dest (tackon #installDir "cgi-bin"))
        (optional force askuser)
        (all)
    )
)

(procedure P_CopyConf
    (working #CopyingConfMsg)
    (copyfiles
        (source (tackon #source-dir "conf/"))
        (dest (tackon #installDir "conf"))
        (optional force askuser)
        (all)
    )
    (copyfiles
        (source (tackon #source-dir "mod/"))
        (dest (tackon #installDir "mod"))
        (optional force askuser)
        (all)
    )
)

(procedure P_CopyHTDocs
    (working #CopyingHTDocsMsg)
    (copyfiles
        (source (tackon #source-dir "htdocs/"))
        (dest (tackon #installDir "htdocs"))
        (optional force askuser)
        (all)
    )
)

(procedure P_CopyLog
    (working #CopyingLogMsg)
    (copyfiles
        (source (tackon #source-dir "log/"))
        (dest (tackon #installDir "log"))
        (optional force askuser)
        (all)
    )
)

(procedure P_CopyCore
    (working #CopyingCoreMsg)
    (copyfiles
        (source (tackon #source-dir "main/"))
        (dest #installDir)
        (optional force askuser)
        (all)
    )
    (copyfiles
        (source (tackon #source-dir "images/"))
        (dest (tackon #installDir "images"))
        (optional force askuser)
        (all)
    )
)

(procedure P_CopyIcons
    (copyfiles
        (source (tackon #source-dir "icons/hserv-dir.info"))
        (newname "hserv.info")
        (dest (tackon #installDir "/"))
        (optional force askuser)
    )
    (copyfiles
        (source (tackon #source-dir "icons/hserv-app.info"))
        (newname "hserv.info")
        (dest #installDir)
        (optional force askuser)
    )
)

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

(P_SetMessages)
(P_AskInstallDir)
(P_AskLibsDir)
(P_AskMCCsDir)
(set #InstallDir (tackon #InstallDir "hserv"))

(P_CopyLibs)
(complete 40)

(P_CopyMCCs)
(complete 45)

(P_CopyCore)
(complete 50)

(P_CopyIcons)

(P_CopyCGI)
(complete 60)

(P_CopyConf)
(complete 65)

(P_CopyHTDocs)
(complete 99)

(P_CopyLog)
(complete 100)
