;;----------------------------------------------------------------------------
;;
;; Remove-OpaqueMove - OpaqueMove removal script for Installer
;;
;; Copyright © 1996 Steve Koren, All Right reserved.
;;
;; Use following Icon tooltypes / Command line options:
;; APPNAME=OpaqueMove
;; MINUSER=AVERAGE
;;----------------------------------------------------------------------------

(complete 0)

(set locale 0)

(set #welcome           (cat "Welcome to the " @app-name " removal process."))
(set #removing          (cat "Removing " @app-name " files..."))
(set #notfound          (cat "Unable to find install directory."))
(set #userstop          (cat "User stopped removal."))
(set #danger            (cat "WARNING: This process will remove " @app-name
                             " from your system.  Do you wish to proceed?\n\n"
                             "NOTE: If you have OpaqueMove drawers open in "
                             "workbench or otherwise locked, this script "
                             "will not be able to remove them."))

(set #delwbs            (cat "Deleting OpaqueMove.info from WBStartup."))
(set #delenv            (cat "Deleting OpaqueMove from env: and envarc:"))
(set #deldir            (cat "Deleting %s directory."))
(set #delenvprompt      (cat "Do you wish to delete the ENVARC:OpaqueMove "
                             "directory?  NOTE: If you have not backed up "
                             "your keyfile and preferences settings, you "
                             "will lose them permanently if you proceed!!"))

;=============================================================================
; Removal procedure
;=============================================================================

; -- check for existance of MUI: ---------------------------------------------

(welcome #welcome)

; -- select our install dir --------------------------------------------------

(set LastDir "")
(set OM-Dir  "")

(if (exists "ENV:OpaqueMove/OM-Dir")
    ((set LastDir (getenv "OpaqueMove/OM-Dir"))
     (if (not (exists (tackon LastDir "OpaqueMove/OpaqueMove")))
         (set LastDir ""))))

(complete 10)
(set Reuse 0)
(if (= LastDir "") (abort #notfound))

(set OM-Dir (tackon LastDir "OpaqueMove"))

(if (not (exists (tackon OM-Dir "OpaqueMove")))
    (abort #notfound))


; -- ask user whether to stop ------------------------------------------------

(complete 20)

(if (not (askbool (prompt #danger)
                  (help @askbool-help)
                  (default 1)))
    (abort #userstop))


; -- really remove stuff -----------------------------------------------------

(set @execute-dir "ram:")

(run (prompt #delwbs)
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" "SYS:WBStartup/OpaqueMove#?")

(run (prompt (#deldir OM-Dir))
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" OM-Dir (cat OM-Dir ".info") "ALL")

(complete 80)

(if (not (askbool (prompt #delenvprompt)
                  (help @askbool-help)
                  (default 1)))
    (abort #userstop))

(run (prompt #delenv)
     (help @run-help)
     (confirm)
     "c:delete" ">nil:" "ENV:OpaqueMove" "ENVARC:OpaqueMove" "ALL")

(complete 100)

(exit)
