; $VER: Install_MiamiDx 0.9f (21.04.99)
(procedure P-check-system-version
 (if (< (/ @installer-version 65536) 43)
  (abort "The Miami Deluxe installation script needs Installer\n"
   "version 43 or higher. It is available from Aminet\n"
   "and from www.nordicglobal.com")
 )
 (set #exec-version (/ (getversion) 65536))
 (if (< #exec-version 37)
  (abort "Miami Deluxe needs Kickstart 2.04 or higher.\n")
 )
)

(procedure P-select-destination-directory
 (if (exists "Miami:" (noreq))
  (
   (set #old-miami-assign 1)
   (set #old-miami-assign-location (expandpath "Miami:"))
   (set @default-dest
    (askdir
     (prompt "Select the directory where you want to "
      "install Miami Deluxe. You already have a 'Miami:' "
      "assign on your system, so it is assumed that this "
      "is the location of an older version of Miami that "
      "you want to upgrade to Miami Deluxe.")
     (help "Select the directory where you want to "
      "install Miami Deluxe. Since you already have a 'Miami:' "
      "assign on your system you should probably accept "
      "the default.")
     (default "Miami:")
    )
   )
  ) (
   (abort "You need to install Miami >= 3.0 before you can\n"
    "install Miami Deluxe.")
  )
 )
)

(procedure P-copy-file
 (copyfiles
  (source (tackon #source-dir #to-copy))
  (dest #dest-dir)
  (optional force)
 )
)

(welcome "Welcome to the Miami Deluxe installation.\n")

(set app-name "Miami Deluxe")

(P-check-system-version)

(if @pretend
  (abort "Pretend mode cannot be used with this\n"
   "installation script.")
)

(complete 0)

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

(P-select-destination-directory)

(complete 10)

; start actual installation

; create required directories

(if (not (exists (tackon @default-dest "SecureShell")))
 (makedir (tackon @default-dest "SecureShell"))
)

(if (not (exists (tackon @default-dest "MNI")))
 (makedir (tackon @default-dest "MNI"))
)

(if (not (exists (tackon @default-dest "Data")))
 (makedir (tackon @default-dest "Data"))
)

(complete 20)

; copy individual files
(set #dest-dir @default-dest)
(set #to-copy "CHANGES") (P-copy-file)
(set #to-copy "CHANGES.info") (P-copy-file)
(set #to-copy "MiamiAddr") (P-copy-file)
(set #to-copy "MiamiArp") (P-copy-file)
(set #to-copy "MiamiDiG") (P-copy-file)
(set #to-copy "MiamiDNSQuery") (P-copy-file)
(set #to-copy "MiamiDx.beta") (P-copy-file)

(complete 30)
(set #to-copy "MiamiFtp") (P-copy-file)
(set #to-copy "MiamiHost") (P-copy-file)
(set #to-copy "MiamiIPFW") (P-copy-file)
(set #to-copy "MiamiIPNatD") (P-copy-file)
(set #to-copy "MiamiNetStat") (P-copy-file)
(set #to-copy "MiamiRegister") (P-copy-file)
(set #to-copy "MiamiRemind") (P-copy-file)
(set #to-copy "MiamiResolve") (P-copy-file)
(set #to-copy "MiamiInit") (P-copy-file)
(set #to-copy "MiamiSecureShellKeygen") (P-copy-file)
(set #to-copy "MiamiSecureShellKill") (P-copy-file)

(complete 40)
(set #to-copy "MiamiSysCtl") (P-copy-file)
(set #to-copy "MiamiTCPDump") (P-copy-file)
(set #to-copy "MiamiTelnet") (P-copy-file)
(set #to-copy "MiamiTelnet.txt") (P-copy-file)
(set #to-copy "MiamiTelnet.txt.info") (P-copy-file)
(set #to-copy "MiamiTelnetFeatures.txt") (P-copy-file)
(set #to-copy "MiamiTelnetFeatures.txt.info") (P-copy-file)

(complete 50)
(set #to-copy "README") (P-copy-file)
(set #to-copy "README.info") (P-copy-file)
(set #to-copy "Secure-Shell.txt") (P-copy-file)
(set #to-copy "Secure-Shell.txt.info") (P-copy-file)
(set #to-copy "SanaMNI.txt") (P-copy-file)
(set #to-copy "SanaMNI.txt.info") (P-copy-file)

(if (not (exists "DEVS:Networks"))
 (makedir "DEVS:Networks")
)
(set #dest-dir "DEVS:Networks")
(set #to-copy "sanamni.device") (P-copy-file)

(set #dest-dir (tackon @default-dest "MNI"))
(set #to-copy "gg2-3c509.mni") (P-copy-file)
(set #to-copy "gg2-dp8390.mni") (P-copy-file)

(complete 60)
(set #to-copy "z2-am7990.mni") (P-copy-file)
(set #to-copy "z2-dp8390.mni") (P-copy-file)
(set #to-copy "z2-mb86950.mni") (P-copy-file)
(set #to-copy "z2-smc91c90.mni") (P-copy-file)

(complete 70)
(set #dest-dir (tackon @default-dest "Libs"))
(set #to-copy "miamibpf.library") (P-copy-file)
(set #to-copy "miamiipnat.library") (P-copy-file)
(set #to-copy "miamipanel.library") (P-copy-file)
(set #to-copy "miamipcap.library") (P-copy-file)
(set #to-copy "miamisecureshell.library") (P-copy-file)
(set #to-copy "miamisocks.library") (P-copy-file)

(complete 80)
(set #to-copy "miamisocksd.library") (P-copy-file)
(set #to-copy "MUI.MiamiDxGui") (P-copy-file)
(set #to-copy "MUI.MiamiToolsGui") (P-copy-file)

(if (exists (tackon @default-dest "MiamiDx.beta.info"))
 (if (exists (tackon @default-dest "MiamiDx.beta.info/Miami.info"))
  (
   (delete (tackon @default-dest "MiamiDx.beta.info/Miami.info"))
   (delete (tackon @default-dest "MiamiDx.beta.info"))
  )
 )
)

(if (not (exists (tackon @default-dest "MiamiDx.beta.info")))
 (if (exists (tackon @default-dest "Miami.info"))
  (
   (copyfiles
    (source (tackon @default-dest "Miami.info"))
    (dest @default-dest)
    (newname "MiamiDx.beta.info")
   )
   (tooltype
    (dest (tackon @default-dest "MiamiDx.beta"))
    (noposition)
   )
  )
 )
)
    
(complete 100)

(exit "The installation of Miami Deluxe is finished. "
 "Please shut down Miami or Miami Deluxe and execute the Shell "
 "command `avail flush' or reboot your computer before "
 "starting Miami Deluxe.")
