;**************************************************
;
;$VER: VitalConnectv2.0 (June 1998
;
; Title:
;    VitalConnect Installer
; 
; Description:
;    The Commodore Installer Script for VitalConnect
;
; Installer script by Pete Sullivan
;
;**************************************************

(set true 1)
(set false 0)
(set quote "\"")
(set nothing "")
(set WB2 (< 2293760 (getversion "exec.library" (resident)))) ; true if under 2.0

(set VitalConnect_dir (getassign "VitalConnect"))
(set c_dir (getassign "C"))
(set libs_dir (getassign "LIBS"))
(set fonts_dir (getassign "FONTS"))
(set devs_dir (getassign "DEVS"))
(set s_dir (getassign "S"))
(set wbstartup_dir (getassign "SYS:WBSTARTUP"))

(set Src_root "")
(set Src_c "c/")
(set Src_s "s/")
(set Src_libs "libs/")
(set Src_devs "devs/")
(set Src_rexx "rexx/")
(set Src_DATA "DATA/")
(set Src_Sullitech "/")
(set Src_docs "Docs/")
(set Src_fonts "Fonts/")
(set Src_WBStartup "WBStartup/")
(set Src_AmiFTP "AmiFTP/")
(set Temp_dir "ram:t/")

(set MSG_CopyDevs1 "\n\nCopying needed device ")
(set MSG_CopyDevs2 " to DEVS:")

; start with not updated software!

(set is_update false)

(if  (<> VitalConnect_dir nothing)
     (if  (askbool
               (prompt "\n\n\nAn earlier version of VitalConnect already exists in"
               " your drawer named: \n\n"
               quote VitalConnect_dir quote
               "\n\nDo you want the update installed over it?")
               (help
               "\n\n\nThe installer has determined that you already have a "
               "some version of the VitalConnect software installed "
               "on your system.  If this is wrong or you want the update "
               "installed elsewhere, select 'NO', otherwise select 'YES'."
               )
               (default 1)
          )
               (set is_update true) 

;else ask where to put software

               (
               (set VitalConnect_dir
               (askdir
                    (prompt "Where would you like the updated software "
                    "installed?\n"
                    "The directory 'VitalConnect' will be created automatically.\n")
                    (help @askdir-help)
                    (default @default-dest)
               )
               )

               (set VitalConnect_dir
               (tackon VitalConnect_dir "VitalConnect")
               )

               (makedir VitalConnect_dir
               (infos)
               )
          )
     )
)

; VitalConnect: was not previously assigned, so ask where to make it
(if  (= VitalConnect_dir nothing)
          (
          (set VitalConnect_dir
               (askdir
                    (prompt "Where would you like the software installed?\n"
                    "The directory 'VitalConnect' will be created automatically.\n")
                    (help @askdir-help)
                    (default @default-dest)
               )
          )

          (set VitalConnect_dir
          (tackon VitalConnect_dir "VitalConnect")
          )


          (makedir VitalConnect_dir
          (infos)
          )
     )
)

(set @default-dest VitalConnect_dir)

(complete 5)













   


(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied into your WBStartup: directory:")
     (help "\n\n\n\n\nThis will copy the NetStart facility to your WBStartup: "
     "directory.\n\n\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_root)
     (dest "SYS:WBStartup")
     (pattern "(IconDock|IconDock.info)")
     (confirm)
)
   
(complete 20)

(working omp "...Please Wait...")

;copy Cando.library

(copylib
   (source (tackon Src_libs "cando.library"))
   (dest "LIBS:")
   (prompt "Copying needed 'Cando.library' to LIBS:")
   (help @copylib-help)
   (confirm)
)

(complete 30)



; Copy SulliTech

(working omp "...Please Wait...")
   
(set VitalConnect_dir
     (copyfiles
          (prompt "These files will be copied to the VitalConnect: directory:")
          (help "\n\n\n\n\n\nThis will copy VitalConnect's main "
          "programs.\n\n\n\n\n\n\n"
          @copyfiles-help)
          (source Src_root)
          (dest VitalConnect_dir)
          (pattern "(#?IconDock|IconDock.info|Sullitech|IconVert|About|Sullot|ReadMe|Readme.info|VCInfo|QuickStart|QuickStart.info#?)")
          (confirm)
)


)


(complete 50)

;create Documentation directory

(set Docs_dir
(cat VitalConnect_dir)
)
(set Docs_dir
(tackon Docs_dir "Docs")
)

(makedir Docs_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied to the VitalConnect:Docs directory:")
     (help "\n\n\n\n\nThis will copy the HTML documentation for "
     "VitalConnect.  This documentation should reside in your "
     "'VitalConnect:Docs' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_Docs)
     (dest Docs_dir)
     (pattern "#?vc#?")
     (confirm)

)

(complete 60)

;create Rexx directory

(set Rexx_dir
(cat VitalConnect_dir)
)
(set Rexx_dir
(tackon Rexx_dir "Rexx")
)

(makedir Rexx_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "These file(s) must be copied into the Rexx directory:")
     (help "\n\n\n\nRexxMast MUST be running on your system for "
     "VitalConnect to use.  These AREXX scripts should reside in your "
     "'VitalConnect:Rexx' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_Rexx)
     (dest Rexx_dir)
     (pattern "#?rx#?")
     (confirm)
)

(complete 70)

; add assigns to User-Startup if this is not an update

(if  (= is_update false)
     (if  (askbool
               (prompt "\nIn order for VitalConnect to work correctly, "
               "Somewhere in the USER-STARTUP must be an assigment"
               " for 'VitalConnect:'\n\n"
               "These lines can be added for you automatically by this "
               "installer.  Would you like these lines added?\n\n")
               (help @askbool-help)
               )

               (
                    (if (= @pretend 0)
                    (
                        (
                        (if  (not  (exists "s:user-startup"))
                             (textfile
                             (dest "s:user-startup")
                             (append ";user-startup \n\n")
                         )
                    )
                    (textfile
                    (dest "ram:user-startup")
                    (include "s:user-startup")
                    (append ";BEGIN VitalConnect assignment\n")
                    (append "assign VitalConnect: " VitalConnect_dir)
                    (append "\n;END VitalConnect assignment\n")
                    )
                    (rename "s:user-startup" "s:user-startup.old")
                    (copyfiles
                    (help @copyfiles-help)
                    (source "ram:user-startup")
                    (dest "s:")
                    )
                    (delete "ram:user-startup")
               )
          )
          )
     )
     )
)

(complete 60)

(exit)
