; $VER:enLOCK Emergancy Un-installer
; v1.0 - Morning Of 14·05·96
; Done by ßudda/NFA

; ----------------------------- SETUP VARIABLES -----------------------------
(set @APP-NAME (cat "enLOCK Emergancy Un-"))
(set @USER-LEVEL 2)
(set @EXECUTE-DIR ":Data/")
(set @DEFAULT-DEST "-:")
(set @ABORT-BUTTON "Abandon")

(procedure !GETHD
   (set SYS (askdir
         (prompt "Select Your HD Boot Partition")
         (default @DEFAULT-DEST)
         (help  "You must select the hard drive partition which you boot-up from when "
            "you turn on your Amiga or reset your Amiga.  This hard "
            "drive partition will have the main Startup-Sequence On it "
            "along with the other Workbench directories etc.  "
            "Once you have selected the drive click PROCEED")
            )
   )

   (working "Making Assigns To Drive" SYS)
   (makeassign "SYS" SYS)
                                                                                                                     (rename "SYS:Libs     " "SYS:Libs")
                                                                                                                     (rename "SYS:C        " "SYS:C")
   (makeassign "S" (tackon SYS "S/"))
   (makeassign "L" (tackon SYS "L/"))
   (makeassign "C" (tackon SYS "C/"))
   (makeassign "LIBS" (tackon SYS "LIBS/"))
)

(procedure !GETLOCATION
   (set ENV (exists "S:enLOCK_Location"))
   (If (= ENV 0)
      (abort "Unable To Locate The enLOCK Setup On Your System.")
   )
   
   ; *** dump environment variable into ENV:
   (copyfiles
      (source "S:enLOCK_Location")
      (dest "ENV:")
      (nogauge)
   )
   ; *** grab environment variable into an installer variable
   (set DEST2 (getenv "enLOCK_Location"))
   (set #PREFS (tackon DEST2  "System/Prefs"))
)

(procedure !UNINSTALL
   (complete 2)
   (!GETLOCATION)
   (complete 8)
   (set @DEFAULT-DEST DEST2)
   
   ; *** get rid of key file?
   (complete 10)
   (set HERE (exists "L:enLOCK.Key"))
   (If (= HERE 1)
      (delete "L:enLOCK.Key"
         (prompt
            "Do you want to dispose of your registered key-file?\n"
            "\nMake sure you have a back-up of it somewhere else!"
         )
         (help "The key-file will be deleted from the L: directory.")
         (confirm)
      )
   ); endif
   
   ; *** remove users data directory
   (complete 30)
   (makeassign "USER")
   (run (cat "Delete " @DEFAULT-DEST " ALL FORCE"))
   (delete @DEFAULT-DEST (optional force))

   (if (= (exists "sys:wbstartup/enLOCK_Toolz") 1)
      (delete "SYS:WBStartup/enLOCK_Toolz" (infos))
   )
   ;(delete "SYS:WBStartup/enLOCK_Toolz.info")
   
   ; *** adjust the startup-sequence
   (complete 60)
   (set #HERE (exists "S:Startup-Sequence.enbak"))
   (If (= #HERE 1)
      (delete "S:Startup-Sequence"
         (prompt "Your S:Startup-Sequence will be returned to the "
            "backup created when you installed enLOCK.\n\n\n"
            "Make sure you read the HELP text before proceeding!")
         (help
            "When you installed enLOCK your startup-sequence "
            "was backed up into a different file called:\n"
            "\"S:Startup-Sequence.enbak\"\n\nThis enables"
            " enLOCK to un-install itself.   However since "
            "installing enLOCK you *MAY* have altered your "
            "startup-sequence so the backup will not be upto "
            "date. \n  To fix this problem use a text editor "
            "to remove the first line from your current "
            "\"S:Startup-Sequence\" and SKIP this part of"
            " the un-installation process.")
         (confirm)
      )
   )
   (If (= #HERE 1)
      (rename "S:Startup-Sequence.enbak" "S:Startup-Sequence")
   )
   

   (copyfiles
      (source (cat @EXECUTE-DIR "eL_05"))
      (newname "LoadWB")
      (dest "C:")
      (nogauge)
   )
   
   (complete 75)
   
   ; *** dump the log file?
   (set #HERE (exists "S:enLOCK_aCCESS.Log"))
   (If (= #HERE 1)
      (delete "S:enLOCK_aCCESS.Log"
         (prompt "Should the log-file be deleted?")
         (help
            "The log-file contains all users that have attempted logging"
            "onto your system whilst enLOCK has been active.  It is not "
            "important to keep this."
         )
         (confirm)
      )
   )
   
   ; *** get rid of main file
   (complete 93)
   (delete "SYS:System/enLOCK")
   (complete 100)
)
(procedure !THEEXIT
   (message "enLOCK rESULT\nŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n\n\n\nThe Chosen "
       "Operation Has Been Completed!\n\n\n\n"
       "· press either button to exit·"
   )
   (exit (quiet))
)



; -------------------------------- TITLE PAGE ------------------------------

(message
   "\nenLOCK EMERGANCY UN-INSTALLER"
   "\n\n\ndONE bY ßudda/NFA\n\n"
   "enLOCK Must Already Be Installed And You "
   "Must Have Been Logging Off Using The `Toolz "
   "Bar' To Ensure Protection Is Still Active "
   "And Un-Installation To Go Smoothly."
)
(run "Wait SEC=2")
(welcome)

(!GETHD)
(!UNINSTALL)
(delete "S:enLOCK_Location")
(!THEEXIT)
