(set vernum (getversion "libs:version.library"))
(set ver (/ vernum 65536))

(set is_update 0)
(set apt-dest (getassign "APT" "a"))
(complete 0)

(if apt-dest
   (
      (set @default-dest apt-dest)
      (set is_update 
         (askbool
            (prompt 
               "Your current APT assignment appears to be located in the drawer named \""
               apt-dest
               "\".\n\n  Do you want these update files installed in that drawer?"
            )
            (help
               "The logical assignment \"APT:\" is present on your system"
               "If you would like this version placed elsewhere, please select"
               "NO.  Otherwise, select YES to install APT there."
            )
            (default 1)
         )
      )
   )
)

(if (= is_update 0)
   (
      (set apt-dest
         (tackon 
            (askdir
               (prompt "In which disk or drawer should APT be installed?")
               (help @askdir-help)
               (default @default-dest)
            )
            "APT"
         )
      )
      (makedir apt-dest (infos))
      (set @default-dest apt-dest)
      (makeassign "APT" apt-dest)

      (copyfiles
         (source "APT")
         (dest apt-dest)
         (all)
      )
   )
)

(complete 90)

(if (not (exists "Devs:ApT-Mountlist"))
   (copyfiles
      (source "Devs/ApT-Mountlist")
      (dest "DEVS:")
   )
   (copyfiles
      (source "Devs/ApT-Mountlist")
      (dest "DEVS:")
      (prompt "ApT-Mountlist already exists!  - Overwrite it?")
      (help "Unless you have modified your old ApT-Mountlist file, it is ok to overwrite it.")
      (confirm)
   )

)

(complete 91)

(if (not (exists "L:ApT-Handler"))
   (copyfiles
      (source "L/ApT-Handler")
      (dest "L:")
   )
   (copyfiles
      (source "L/ApT-Handler")
      (dest "L:")
      (prompt "ApT-Handler already exists!  - Overwrite it?")
      (help "If you are updating from an APT-BBS version earlier than 1.8"
      " you will have to overwrite it by proceeding with the copy.")
      (confirm)
   )

)

(complete 92)

(if (not (exists "Libs:aptbbs.library"))
   (copyfiles
      (source "Libs/aptbbs.library")
      (dest "LIBS:")
   )
   (copyfiles
      (source "Libs/aptbbs.library")
      (dest "LIBS:")
      (prompt "This library file already exists!\nOverwrite it?\n"
      "\nSelect the HELP button for more information.")
      (help "If you are updating from an APT-BBS version earlier than"
      " 1.8 then you SHOULD overwrite the old version.")
      (confirm)
   )
)

(complete 93)

(if (not (exists "Libs:ApTContext.library"))
   (copyfiles
      (source "Libs/ApTContext.library")
      (dest "LIBS:")
   )
   (copyfiles
      (source "Libs/ApTContext.library")
      (dest "LIBS:")
      (prompt "This library file already exists!\nOverwrite it?\n"
      "\nSelect the HELP button for more information.")
      (help "If you are updating from an APT-BBS version earlier than"
      " 1.8 then you SHOULD overwrite the old version.")
      (confirm)
   )
)

(complete 94)

(if (not (exists "Libs:ApTControl.library"))
   (copyfiles
      (source "Libs/ApTControl.library")
      (dest "LIBS:")
   )
   (copyfiles
      (source "Libs/ApTControl.library")
      (dest "LIBS:")
      (prompt "This library file already exists!\nOverwrite it?\n"
      "\nSelect the HELP button for more information.")
      (help "If you are updating from an APT-BBS version earlier than"
      " 1.8 then you SHOULD overwrite the old version.")
      (confirm)
   )
)

(complete 95)

(if (not (exists "Libs:ApTGlobal.library"))
   (copyfiles
      (source "Libs/ApTGlobal.library")
      (dest "LIBS:")
   )
   (copyfiles
      (source "Libs/ApTGlobal.library")
      (dest "LIBS:")
      (prompt "This library file already exists!\nOverwrite it?\n"
      "\nSelect the HELP button for more information.")
      (help "If you are updating from an APT-BBS version earlier than"
      " 1.8 then you SHOULD overwrite the old version.")
      (confirm)
   )
)

(complete 96)

(if (not (exists "Libs:ApTMap.library"))
   (copyfiles
      (source "Libs/ApTMap.library")
      (dest "LIBS:")
   )
   (copyfiles
      (source "Libs/ApTMap.library")
      (dest "LIBS:")
      (prompt "This library file already exists!\nOverwrite it?\n"
      "\nSelect the HELP button for more information.")
      (help "If you are updating from an APT-BBS version earlier than"
      " 1.8 then you SHOULD overwrite the old version.")
      (confirm)
   )
)

(complete 97)

(if (not (exists "S:startAPT"))
   (copyfiles
      (source "S/startAPT")
      (dest "S:")
   )
   (copyfiles
      (source "S/startAPT")
      (dest "S:")
      (prompt "Your S:startAPT script already exists!\n  - Overwrite it?\n"
      "Select HELP button for more info.")
      (help "You probably should not overwrite your pre-existing startAPT"
      " script as you will lose whatever changes you made to any device "
      "assignments or similar personal modifications.\n\nHowever you are strongly"
      " urged to compare the new startAPT script with your old one and modify"
      " your original script wherever necessary to get full functionality from"
      " APT-BBS V1.8")
      (confirm)
   )
)

(if (exists "S:startAPT")
  (protect "S:startAPT"
      ("+s")
  )
)

(if (not (exists "S:FMan.Config"))
   (copyfiles
      (source "S/FMan.Config")
      (dest "S:")
   )
   (copyfiles
      (source "S/FMan.Config")
      (dest "S:")
      (prompt "Your S:FMan.Config script already exists!\n  - Overwrite it?\n"
      "Select HELP button for more info.")
      (help "You probably should not overwrite your pre-existing FMan.Config"
      " script as you will lose whatever changes you made to any device "
      "assignments or similar personal modifications.\n\nHowever you are strongly"
      " urged to check out your Fmanager settings and check that File Paths"
      " and similar details suit this APT-BBS set-up.\n\n"
      "NOTE: This installation is intended for NEW ApT-BBS Sysops. People running"
      " older versions of ApT-BBS should contact a support site for updates "
      "to the main executables only.")
      (confirm)
   )

)

(complete 98)

(copyfiles
   (source "Fonts")
   (dest "Fonts:")
   (all)
)

(complete 100)

(exit)
