; Install-Script for Diavolo-Backup
;
; © 1993-1997 Martin Korndörfer
;
; $VER:DiavoloInstall 3.x (01-Mar-97)
;
;  
;
; Initial Release


; ** "Locale" Section. For each supported language, all texts must be set correctly
; **
;

(if (= @language "deutsch")
    (
        (set @abort-button "Installation abbrechen"
        )

        (set @app-name "Diavolo Backup 3.x"
        )

        (set #welcome "Diavolo Backup 3.x Installation"
        )

        (set #get-destination-prompt "Bitte wählen Sie, wo das Diavolo Verzeichnis erstellt werden soll"
        )

        (set #get-destination-help (cat "Bitte wählen Sie in diesem Dialog auf welcher Partition oder in welchem "
                                        "Verzeichnis die Diavolo Schublade eingerichtet werden soll.\n\n"
                                        @askdir-help
                                   )
        )

        (set #copying-archive "Kopiere Haupt-Archiv ..."
        )

        (set #copying-install-script "Kopiere Installscript ..."
        )

        (set #Unpack-Main "Entpacke Haupt-Archiv ..."
        )

        (set #Unpack-MWBDemo "Entpacke MagicWB-Demo ..."
        )

        (set #unpack-error (cat "Konnte Archiv nicht entpacken! Bitte machen Sie auf Ihrem Laufwerk Platz oder "
                                "wählen Sie ein anderes Ziel und starten Sie die Installation neu."
                           )
        )

        (set #mwb-detected-prompt (cat "MagicWB 2.0 gefunden.\nSie können entweder MWB-kompatible 8-Farb-Icons "
                                       "oder die standard System-Icons für Diavolo verwenden."
                                  )
        )

        (set #mwb-detected-help (cat "Das Installationsprogramm hat festgestellt, daß die MagicWB 2.0 auf Ihrem "
                                     "Rechner installiert ist. Sie sollten deshalb auch für Diavolo die Icons im "
                                     "MagicWB-Stil verwenden. Wenn Sie wollen, können Sie aber auch die normalen "
                                     "4-farb Icons installieren lassen.\n\n"
                                     @askchoice-help
                                )
        )

        (set #mwb-notdetected-prompt (cat "MagicWB 2.0 ist nicht installiert.\nUnter bestimmten Umständen können Sie "
                                          "dennoch die 8-farb Icons verwenden (siehe Hilfe), in aller Regel werden Sie "
                                          "aber die Standard System-Icons installieren müssen."
                                  )
        )

        (set #mwb-notdetected-help (cat "Das Installationsprogramm konnte die MagicWB 2.0 nicht auf Ihrem System finden. "
                                     "Die mitgelieferten 8-farb Icons funktionieren nur mit der MagicWB 2.0 korrekt. "
                                     "Ausser Sie verwenden einen Screen mit exakt 8 Farben und der MagicWB 1.x Palette, "
                                     "in diesem Fall können Sie ebenfalls die 8-farb Icons installieren.\nIn allen anderen "
                                     "Fällen sollten Sie auf die Standard System-Icons zurückgreifen.\n\n"
                                     @askchoice-help
                                )
        )

        (set #mwb-0 "8-farb MWB Icons")

        (set #mwb-1 "4-farb Standard Icons")

        (set #Unpack-StdIcons "Entpacke Standard-Icon Archiv ..."
        )

        (set #Unpack-MWBIcons "Entpacke MagicWB-Icon Archiv ..."
        )

        (set #prompt-MWB (cat"Diavolo Backup verwedet die Optik der MagicWB von Martin Huttenloher. "
                             "Um einen Eindruck von diesem Produkt zu bekommen, sollten Sie einen Blick "
                             "auf die Demo der neuesten Version werfen. Es werden dabei keinerlei Veränderungen "
                             "an Ihrem System vorgenommen."
                         )
        )

        (set #label-MWB "MagicWB 2.0 Demo kopieren"
        )

        (set #help-MWB (cat "Das Aussehen von Diavolo Backup orientiert sich stark am MagicWB-Stil. MagicWB ist "
                            "ein Programm zur optischen Aufwertung der Oberfläche des Amigas (Workbench). Falls "
                            "Sie MagicWB noch nicht kennen oder noch nicht registriert sind, sollten Sie einen "
                            "Blick auf diese Demonstration werfen. Sie enthält alle aktuellen Informationen über "
                            "die neueste Version von MagicWB.\n\nDie Demo (etwa 300k) wird in einem extra Verzeichnis "
                            "innerhalb der Diavolo-Schublade installiert ohne irgendwelche anderen Daten oder Bereiche in "
                            "Ihrem System zu beeinflussen. Um die Demo zu entfernen, brauchen Sie lediglich das "
                            "Verzeichnis zu löschen.\n\n"
                            @askoptions-help
                        )
        )

        (set #Update-Lib-Prompt "Die Library\n%s\nist in diesem System bereits installiert. Soll sie ausgetauscht werden?"
        )

        (set #Update-Lib-Help (cat "Es ist nicht notwendig die von Diavolo benötigten Libraries im globalen LIBS: "
                                   "Verzeichnis zu installieren, da sie auch in Diavolos eigenem libs Verzeichnis "
                                   "gefunden werden.\n"
                                   "Aber diese Library ist in Ihrem System bereits installiert. Um zu vermeiden, "
                                   "daß eine veraltete Version dieser Library verwendet wird, sollten Sie prüfen, "
                                   "ob die Version, die bei Diavolo mitgeliefert wird, aktueller ist und sie in "
                                   "diesem Fall erneuern lassen.\n\n"
                                   @copylib-help
                              )
        )

        (set #Update-XPK-Lib-Prompt (cat "The XPK Kompressions-Library\n%s\nist in diesem System bereits installiert. Soll sie "
                                     "ausgetauscht werden?"
                                )
        )

        (set #Create-Dirs "Erstelle Verzeichnisse ...")

        (set #Checking-Libs "Prüfe auf veraltete Libraries im System ...")

        (set #Correcting-Icons "Korrigiere Einträge in den Icon-Informationen ...")

        (set #copy-scheddaemon-prompt (cat "Wenn Sie automatische Sicherungen zu bestimmten Zeiten mit Hilfe des "
                                           "'DBScheduler's ausführen lassen wollen, so muß dazu das Programm "
                                           "'DBSchedDaemon' in Ihre WBStartup Schublade kopiert werden.\n\n"
                                           "DBSchedDaemon in die WBStartup Schublade kopieren?"
                                      )
        )

        (set #copy-scheddaemon-help (cat "Das Programm 'DBSchedDaemon' kümmert sich darum, daß die Zeiteinträge, "
                                         "die Sie mit 'DBScheduler' erstellen können, überwacht werden und rechtzeitig "
                                         "die gewünschten Sicherungen ausgeführt werden.\n\n Für weitere Informationen "
                                         "beachten Sie bitte das Kapitel 'automatische Sicherungen' im Handbuch.\n\n"
                                         @askbool-help
                                    )
        )

        (set #create-emergency-disk-prompt (cat "Soll eine Not-Bootdiskette erstellt werden?\n\n"
                                                "(Sehr zu empfehlen!)"
                                           )
        )

        (set #create-emergency-disk-help (cat "Damit Sie auch dann noch Ihre Daten restaurieren können, wenn Ihr "
                                              "System nicht mehr selbständig startet, muß eine Not-Bootdiskette "
                                              "erstellt werden. Mit dieser Diskette können Sie immer Ihr System "
                                              "und Diavolo Backup starten, um so z.B. ein Backup zu restaurieren.\n\n"
                                              @askbool-help
                                         )
        )

        (set #emergency-yes "Ja"
        )

        (set #emergency-no "Nein"
        )

        (set #format-select-prompt (cat "Für die Not-Bootdiskette wird eine leere Diskette benötigt.\n"
                                        "Soll die Diskette formatiert werden?"
                                   )
        )

        (set #format-select-help (cat "Das Installprogramm formatiert auf Wunsch eine Diskette. Neue Disketten, "
                                      "oder Disketten, die mit einem Fremdformat formatiert sind, müssen "
                                      "vollständig formatiert werden. Disketten, die bereits für den Amiga "
                                      "formatiert wurden, können mit 'Schnell formatieren' gelöscht werden. "
                                      "Sollten Sie bereits eine leere, formatierte Diskette bereithalten, "
                                      "können Sie das Formatieren auch vollständig überspringen.\n\n"
                                      @askchoice-help
                                 )
        )

        (set #format-full "Vollständig formatieren"
        )

        (set #format-quick "Schnell formatieren"
        )

        (set #format-none "Nicht formatieren"
        )

        (set #Ok-To-Format-prompt "Bitte legen Sie die zu formatierende Diskette in Laufwerk DF0 ein!"
        )

        (set #Ok-To-Format-Help @askbool-help
        )

        (set #format-yes "Formatieren"
        )

        (set #format-no "Zurück"
        )

        (set #formatting "Formatiere ..."
        )

        (set #format-failed "Das Formatieren schlug fehl!"
        )

        (set #install-failed "INSTALL df0: fehlgeschlagen"
        )

        (set #copy-monitors-prompt "Welchen Monitortyp verwendet Ihr System?\n(Siehe Hilfe!!)"
        )

        (set #copy-monitors-help (cat "Das Installationsprogramm versucht auf der Boot-Diskette den selben "
                                      "Workbench-Screenmode einzustellen wie er in Ihrem System konfiguriert ist. "
                                      "Das ist vorallem dann wichtig, wenn Ihr System die Standard-Amiga Screenmodi "
                                      "nicht darstellen kann, weil Ihr Monitor z.B. erst ab 30 kHz synchronisiert.\n\n"
                                      "Damit der Screenmodus auf der Bootdiskette funktioniert, muß die zugehörige "
                                      "Monitordatei auf die Disk kopiert werden. Wählen Sie bitte *NUR* diesen einen "
                                      "'Monitor' aus der Liste an. Mehr als einer wird wahrscheinlich nicht auf die "
                                      "Diskette passen! Wenn Sie sich nicht sicher sind, welchen 'Monitor' Ihr System "
                                      "verwendet, starten Sie bitte das ScreenMode-Prefs Programm. Das Kürzel vor dem "
                                      "Doppelpunkt in der hervorgehobenen Zeile ist der Monitorname.\n\n"
                                      "Anmerkung für CyberGraphics Benutzer: Das Installationsprogramm erkennt die "
                                      "CyberGraphics Treiber und kopiert diese selbstständig. Bitte wählen Sie aus "
                                      "der Liste der Monitore den entsprechenden CyberGraphics Monitor aus.\n\n"
                                      "Anmerkung für Anwender anderer Grafikkartensysteme: Das Installationsprogramm "
                                      "erkennt derzeit NUR die Cybergraphics Software. Die meisten anderen Emulationen "
                                      "benötigen zudem zu viel Platz und passen nicht auf die Bootdiskette. Bitte stellen "
                                      "Sie nach Möglichkeit einen Amiga-Screenmodus auf Ihrer Workbench ein, den Ihr "
                                      "Monitor anzeigen kann, starten Sie dann das Installationsprogramm neu und geben "
                                      "dann diesen Monitor bei der Abfrage an.\n\n"
                                      @copyfiles-help
                                 )
        )

        (set #prefs-available (cat "Ihre aktuelle Diavolo Backup Konfiguration wurde auf die Bootdisk kopiert.\n\n"
                                   "Wenn Sie auf Streamer sichern, beachten Sie bitte folgendes:\n\n"
                                   "Beim Start von der Bootdiskette können Sie auf keine Kataloge zugreifen und auch "
                                   "keine Kataloge (wieder-)herstellen, da auf der Diskette kein Platz dafür ist.\n"
                                   "Sie können jedoch den Katalog-Pfad in den SCSI-Einstellungen auf die Festplatte "
                                   "umlenken. Näheres ist im Handbuch beschrieben."
                              )
        )

        (set #prefs-not-available (cat "Es ist keine Konfiguration für Diavolo Backup vorhanden.\n\n"
                                       "Wenn Sie auf Streamer sichern sollten Sie zunächst Diavolo Backup "
                                       "konfigurieren und dann das Installationsprogramm erneut aufrufen um "
                                       "eine aktualisierte Notbootdiskette zu erstellen."

                                  )
        )

        (set #emergency-disk-finished "Die Diavolo Backup Not-Bootdiskette wurde erfolgreich erstellt."
        )
    )
)

(if (= @language "english")
    (
        (set @abort-button "Cancel installation"
        )

        (set @app-name "Diavolo Backup 3.x"
        )

        (set #welcome "Diavolo Backup 3.x installation"
        )

        (set #get-destination-prompt "Please select a destination for the Diavolo drawer"
        )

        (set #get-destination-help (cat "Use this dialogue to select the partition or the directory where you "
                                        "want the Diavolo drawer to be created.\n\n"
                                        @askdir-help
                                   )
        )

        (set #copying-archive "Copying main archive ..."
        )

        (set #copying-install-script "Copying install script ..."
        )

        (set #Unpack-Main "Unpacking main archive ..."
        )

        (set #Unpack-MWBDemo "Unpacking MagicWB demo ..."
        )

        (set #prompt-MWB (cat"Diavolo Backup uses the look and feel of Martin Huttenloher's MagicWB. "
                             "To get an impression of this product you should take a look at this "
                             "presentation of the latest version of MagicWB. Your system will remain unchanged "
                             "when installing the demo."
                         )
        )

        (set #label-MWB "Install MagicWB 2.0 demo"
        )

        (set #help-MWB (cat "MagicWB's graphical style plays an important part in the layout of Diavolo Backup. "
                            "MagicWB is a product to enhance the appearance of your workbench screen. If you don't "
                            "know MagicWB or if you haven't yet registered, then take a look at this demonstration. "
                            "It provides you with all the latest information about the new version of MagicWB.\n\n"
                            "The demo (about 300k) will be installed into a seperate drawer in the Diavolo directory, "
                            "without interfering with any other data or parts of your system. To remove the demo you "
                            "would just have to delete the drawer. \n\n"
                            @askoptions-help
                       )
        )

        (set #unpack-error (cat "Could not unpack archive! Make some room on your drive or choose another destination "
                                "and try again."
                           )
        )

        (set #mwb-detected-prompt (cat "MagicWB 2.0 detected.\nYou can use either MWB-compatible 8-color icons "
                                       "or the system standard 4-color icons for Diavolo"
                                  )
        )

        (set #mwb-detected-help (cat "MagicWB 2.0 was detected by the install program. You should use the MagicWB-Style "
                                     "icons for Diavolo, too. But you can also install the standard system look icons, "
                                     "if you wish.\n\n".
                                     @askchoice-help
                                )
        )

        (set #mwb-notdetected-prompt (cat "MagicWB 2.0 not detected.\nThough you might be able to use the 8-color icons "
                                          "(see help for details) it's more likely that you have to install the "
                                          "standard system look icons instead.\n\n"
                                  )
        )

        (set #mwb-notdetected-help (cat "MagicWB 2.0 could not be found by the install program. The 8-color icons in this "
                                        "package are designed for MagicWB 2.0, but they also work with MagicWB 1.x if you "
                                        "use a screen with 8 colors exactly. In all other cases you will have to install "
                                        "the standard system look icons.\n\n"
                                        @askchoice-help
                                )
        )

        (set #mwb-0 "8-color MWB icons")

        (set #mwb-1 "4-color standard icons")

        (set #Unpack-StdIcons "Unpacking standard icon archive ..."
        )

        (set #Unpack-MWBIcons "Unpacking MagicWB icon archive ..."
        )

        (set #Update-Lib-Prompt "The Library\n%s\nis already installed in your system. Do you want to replace it?"
        )

        (set #Update-Lib-Help (cat "It's not neccessary to install Diavolo's libraries in your global LIBS: directory, "
                                   "as they will also be found in Diavolo's own libs directory.\n"
                                   "But this library is already installed in your system. To avoid using an "
                                   "obsolete version of that library, you should check if the version supplied "
                                   "with Diavolo is newer and, in that case, choose to replace your old version.\n\n"
                                   @copylib-help)
        )

        (set #Update-XPK-Lib-Prompt "The XPK compression Library\n%s\nis already installed in your system. Do you want to replace it?"
        )

        (set #Create-Dirs "Creating subdirectories ...")

        (set #Checking-Libs "Checking for obsolete libraries in the system ...")

        (set #Correcting-Icons "Correcting entries in the icon info pages ...")

        (set #copy-scheddaemon-prompt (cat "If you want backups to be created automatically at given times using the "
                                           "'DBScheduler' it's neccessary to copy the program 'DBSchedDaemon' into "
                                           "your WBStartup drawer.\n\n"
                                           "Copy DBSchedDaemon into the WBStartup drawer?"
                                      )
        )

        (set #copy-scheddaemon-help (cat "The program 'DBSchedDaemon' takes scansc the event entries created by "
                                         "'DBScheduler' and takes care that the requested backups are created on time.\n\n"
                                         "See the chapter 'automatic backups' in the manual for detailed information.\n\n"
                                         @askbool-help
                                    )
        )

        (set #create-emergency-disk-prompt (cat "Do you want to create a emergency boot disk?\n\n"
                                                "(Recommended!)"
                                           )
        )

        (set #create-emergency-disk-help (cat "To be able to restore your data even when your system does not start "
                                              "itself anymore, it's neccessary to create a emergency boot disk. "
                                              "With this disk you can start your system anytime and start Diavolo "
                                              "to restore a backup for example.\n\n"
                                              @askbool-help
                                         )
        )

        (set #emergency-yes "Yes"
        )

        (set #emergency-no "No"
        )

        (set #format-select-prompt (cat "For the emergency boot disk a blank disk is required.\n"
                                        "Do you want a disk to be formatted?"
                                   )
        )

        (set #format-select-help (cat "The install program can format a disk if you want to. New disks or "
                                      "disks formatted with an alien format must be fully formated. Disks that "
                                      "are already formatted for the Amiga can be cleared using the quick format. "
                                      "If you have a blank, formatted disk ready you can skip the format procedure "
                                      "entirely.\n\n"
                                      @askchoice-help
                                 )
        )

        (set #format-full "Full format"
        )

        (set #format-quick "Quick format"
        )

        (set #format-none "Don't format"
        )

        (set #Ok-To-Format-prompt "Please insert the disk to be formatted into drive DF0!"
        )

        (set #Ok-To-Format-Help @askbool-help
        )

        (set #format-yes "Format"
        )

        (set #format-no "Back"
        )

        (set #formatting "Formatting ..."
        )

        (set #format-failed "The format procedure failed!"
        )

        (set #install-failed "INSTALL df0: failed!"
        )

        (set #copy-monitors-prompt "Which Monitor is used in your System?\n(See Help!!)"
        )

        (set #copy-monitors-help (cat "The install program tries to configure the same screen mode on the boot disk "
                                      "that is currently set in your system. This is especially important if your "
                                      "system can't display standard amiga screenmodes, perhaps because your monitor "
                                      "only synchronises with 30 kHz or more.\n\n"
                                      "To make the screen mode work on your boot disk, it's neccessary to copy the "
                                      "respective monitor file onto the disk. Please choose *ONLY* this one 'monitor' "
                                      "from the list. More than one would probably not fit onto the disk! If you're "
                                      "not sure which 'monitor' is used by your system, start the screen mode prefs "
                                      "program. The name before the colon in the hilighted line is the name of your "
                                      "'monitor'.\n\n"
                                      "Note for CyberGraphics user: The install program recognizes the CyberCraphics "
                                      "drivers and copies them automatically. Please choose the correct CyberGFX "
                                      "monitor from the list.\n\n"
                                      "Note for users of other graphic expansions: The install program currently "
                                      "recognizes ONLY the CyberGraphics software. Most other emulations wouldn't even "
                                      "fit on the boot disk anyhow. Please set the workbench screen mode to a native "
                                      "Amiga mode that you can display on your monitor, restart the install program "
                                      "and select this monitor from the list.\n\n"
                                      @copyfiles-help
                                 )
        )

        (set #prefs-available (cat "Your current Diavolo Backup configuration was copied to the boot disk.\n\n"
                                   "If you use a streamer device, please note that when you're starting with the "
                                   "boot disk, you cannot access tape catalogs nor can you (re)create them, "
                                   "because there's not enough space on the disk.\n"
                                   "However, you can redirect the catalog path in the SCSI settings to your harddrive. "
                                   "See the manual for details."
                              )
        )

        (set #prefs-not-available (cat "Diavolo Backup it not yet configured.\n\n"
                                       "If you use a streamer device, you should first configure Diavolo Backup "
                                       "and then start the installation program again to create a updated emergency "
                                       "boot disk."
                                  )
        )

        (set #emergency-disk-finished "The Diavolo Backup emergency boot disk has been successfully created."
        )
    )
)


; ** Start of Installation
;
;

(user 1)

; ** Check if Diavolo is already installed. If not, install the compressed
; ** archives
;

(set Installed (exists "Diavolo")
)

(if (not Installed)
    (
        (welcome)

        (set newdest (askdir (prompt #get-destination-prompt)
                             (help #get-destination-help)
                             (default @default-dest)
                     )
        )

        (set @default-dest newdest
        )

        (set DBDest (tackon @default-dest "Diavolo")
        )

        (if (not (= (exists DBDest) 2))
            (
                (makedir DBDest
                )
            )
        )

        (foreach DBDest "~(#?.prefs)"
                 (
                    (if (< @each-type 0)
                        (
                            (delete (tackon DBDest @each-name)
                                    (optional askuser)
                            )
                        )
                    )
                 )
        )

        (copyfiles (prompt #copying-archive)
                   (source "InstallData.run")
                   (dest DBDest)
        )

        (complete 50)

        (set @execute-dir DBDest
        )

        (working #Unpack-Main)

        (set Fail (run (tackon DBDest "InstallData.run"
                       )
                  )
        )

        (delete (tackon DBDest "InstallData.run"
                )
        )

        (complete 70)

        (if (exists "LOCALE:" (noreq))
            (
                (copyfiles (source (tackon DBDest "catalogs"))
                           (dest "Locale:catalogs")
                           (all)
                           (optional force)
                )
            )
        )

        (if Fail
            (
                (abort #unpack-error
                )
            )
        )

        (if (exists "env:MagicWB")
            (
                (set UseStdIcons (askchoice (prompt #mwb-detected-prompt)
                                            (help #mwb-detected-help)
                                            (choices #mwb-0 #mwb-1)
                                            (default 0)
                                 )
                )
            )
            (
                (set UseStdIcons (askchoice (prompt #mwb-notdetected-prompt)
                                            (help #mwb-notdetected-help)
                                            (choices #mwb-0 #mwb-1)
                                            (default 1)
                                 )
                )
            )
        )

        (if UseStdIcons
            (
                (working #Unpack-StdIcons)

                (set Fail (run (tackon DBDest "StandardIcons.run"
                               )
                          )
                )
            )
            (
                (working #Unpack-MWBIcons)

                (set Fail (run (tackon DBDest "MWBIcons.run"
                               )
                          )
                )
            )
        )

        (if Fail
            (
                (abort #unpack-error
                )
            )
        )

        (delete (tackon DBDest "StandardIcons.run"
                )
        )

        (delete (tackon DBDest "MWBIcons.run"
                )
        )

        (if (exists "MagicWB-Demo.run")
            (
                (if (askoptions (prompt #prompt-MWB)
                                (help #help-MWB)
                                (choices #label-MWB)
                    )
                    (
                        (copyfiles (source "MagicWB-Demo.run")
                                   (dest DBDest)
                        )

                        (complete 80)

                        (working #Unpack-MWBDemo)

                        (set Fail (run (tackon DBDest "MagicWB-Demo.run"
                                       )
                                  )
                        )

                        (delete (tackon DBDest "MagicWB-Demo.run"
                                )
                        )
                    )
                    (
                        (delete (tackon DBDest "MagicWB-Demo.info"
                                )
                        )
                    )
                )
            )
        )

        (complete 90)

        (copyfiles (prompt #copying-install-script)
                   (source "Install Diavolo")
                   (dest DBDest)
        )

        (copyfiles (source "Installer")
                   (dest DBDest)
        )

        (complete 92)

        ; ** Create all directories if not already there
        ;

        (working #Create-Dirs)

        (if (not (exists (tackon DBDest "Tape Catalogs")
                 )
            )
            (
                (makedir (tackon DBDest "Tape Catalogs")
                         (prompt #create-dir)
                )
            )
        )

        (if (exists (tackon DBDest "DBScheduler"))
            (if (not (exists (tackon DBDest "SchedulerEvents")
                     )
                )
                (
                    (makedir (tackon DBDest "SchedulerEvents")
                             (prompt #create-dir)
                    )
                )
            )
        )

        (if (not (exists (tackon DBDest "SelectFilters")
                 )
            )
            (
                (makedir (tackon DBDest "SelectFilters")
                         (prompt #create-dir)
                )
            )
        )

        (if (not (exists (tackon DBDest "DefIcons")
                 )
            )
            (
                (makedir (tackon DBDest "DefIcons")
                         (prompt #create-dir)
                )
            )
        )

        (complete 93)

        ; ** Check if catalogs are installed in LOCALE: and delete them
        ; ** (they should only be located in the DB directory and nowhere else!)
        ;

        (working #Checking-libs)

        (if (exists "Locale:catalogs/deutsch/Diavolo.catalog"
                    (noreq)
            )
            (
                (delete "Locale:catalogs/deutsch/Diavolo.catalog"
                        (prompt #Delete-German-Catalog)
                )
            )
        )

        (if (exists "Locale:catalogs/français/Diavolo.catalog"
                    (noreq)
            )
            (
                (delete "Locale:catalogs/français/Diavolo.catalog"
                        (prompt #Delete-French-Catalog)
                )
            )
        )

        (complete 95)

        ; ** Check if libraries are installed, if yes replace old versions
        ;
        ;

        (set LibDir (tackon DBDest "libs")
        )

        (if (exists (tackon LibDir "movieshop.library")
            )
            (
                (copylib (prompt (#Update-Lib-Prompt @each-name))
                         (help #Update-Lib-Help)
                         (source (tackon LibDir "movieshop.library"))
                         (dest "LIBS:")
                         (optional nofail askuser)
                         (confirm)
                )

                (delete (tackon LibDir "movieshop.library") (optional force)
                )
            )
        )

        (if (exists (tackon LibDir "pfile.library")
            )
            (
                (copylib (prompt (#Update-Lib-Prompt @each-name))
                         (help #Update-Lib-Help)
                         (source (tackon LibDir "pfile.library"))
                         (dest "LIBS:")
                         (optional nofail askuser)
                         (confirm)
                )

                (delete (tackon LibDir "pfile.library") (optional force)
                )
            )
        )

        (foreach LibDir "~(asl|locale).library"
            (
                (if (exists (tackon "LIBS:" @each-name)
                    )
                    (
                        (copylib (prompt (#Update-Lib-Prompt @each-name))
                                 (help #Update-Lib-Help)
                                 (source (tackon LibDir @each-name))
                                 (dest "LIBS:")
                                 (optional nofail askuser)
                                 (confirm)
                        )
                    )
                )
            )
        )

        (set LibDir (tackon LibDir "compressors")
        )

        (foreach LibDir "#?.library"
            (
                (if (exists (tackon "LIBS:compressors" @each-name)
                    )
                    (
                        (copylib (prompt (#Update-XPK-Lib-Prompt @each-name))
                                 (help #Update-Lib-Help)
                                 (source (tackon LibDir @each-name))
                                 (dest "LIBS:compressors")
                                 (optional nofail askuser)
                                 (confirm)
                        )
                    )
                )
            )
        )

        (complete 97)

        ; ** Set Icon tool types and default tools
        ;

        (working #Correcting-Icons)

        (set IconDir (tackon DBDest "deficons")
        )

        (copyfiles (source (tackon IconDir "DiavoloRoot.info"))
                   (dest @default-dest)
                   (newname "Diavolo.info")
        )

        (tooltype (dest DBDest)
                  (noposition)
        )

        (tooltype (dest (tackon DBDest "MakeBootDisk"))
                  (setdefaulttool "Installer")
                  (settooltype "SCRIPT" "Install Diavolo")
                  (settooltype "MINUSER" "AVERAGE")
                  (settooltype "DEFUSER" "AVERAGE")
                  (settooltype "PRETEND" "FALSE")
                  (settooltype "APPNAME" "Diavolo Backup 3.x")
                  (settooltype "LANGUAGE" @language)
                  (setstack 10000)
        )

        (tooltype (dest (tackon IconDir "Def_Filter"))
                  (setdefaulttool (tackon DBDest "Diavolo"))
                  (setstack 10000)
                  (noposition)
        )

        (if (exists (tackon IconDir "Def_Event.info")
            )
            (
                (tooltype (dest (tackon IconDir "Def_Event"))
                          (setdefaulttool (tackon DBDest "DBScheduler"))
                          (settooltype "DIAVOLODIR" DBDest)
                          (settooltype "EVENTDIR" "SchedulerEvents")
                          (setstack 10000)
                          (noposition)
                )
            )
        )

        (tooltype (dest (tackon DBDest "Diavolo"))
                  (settooltype "TOOLPRI" "0")
                  (settooltype "LANGUAGE_2.0" @language)
                  (settooltype "LANGUAGE_2.1" "auto")
                  (settooltype "REFRESHDELAY" "5")
        )

        (if (exists (tackon DBDest "DBSchedDaemon.info")
            )
            (
                (tooltype (dest (tackon DBDest "DBSchedDaemon"))
                          (settooltype "LANGUAGE_2.0" @language)
                          (settooltype "LANGUAGE_2.1" "auto")
                          (settooltype "DIAVOLODIR" DBDest)
                          (settooltype "EVENTDIR" "SchedulerEvents")
                          (settooltype "DONOTWAIT" "1")
                          (settooltype "STARTPRI" "-10")
                          (setstack 10000)
                )

                (if (askbool (prompt #copy-scheddaemon-prompt)
                             (help #copy-scheddaemon-help)
                             (default 1)
                    )
                    (
                        (copyfiles (source (tackon DBDest "DBSchedDaemon"))
                                   (dest "sys:WBStartup")
                                   (infos)
                        )
                    )
                )
            )
        )

        (if (exists (tackon DBDest "DBScheduler.info")
            )
            (
                (tooltype (dest (tackon DBDest "DBScheduler"))
                          (settooltype "LANGUAGE_2.0" @language)
                          (settooltype "LANGUAGE_2.1" "auto")
                          (settooltype "DIAVOLODIR" DBDest)
                          (settooltype "EVENTDIR" "SchedulerEvents")
                          (setstack 10000)
                )
            )
        )

        (complete 100)
    )

    (
        (set DBDest "")
    )
)


; ** Part II: Create emergency disk
;


(set emergency (askbool (prompt #create-emergency-disk-prompt)
                        (help #create-emergency-disk-help)
                        (default 1)
                        (choices #emergency-yes #emergency-no)
               )
)

(if emergency
    (
        (user 2)

        (set SysVersion (getversion))

        (set SysVer (/ SysVersion 65536))

        (complete 0)


        ; ** Format disk
        ;


        (until Ok
            (
                (set Format (askchoice (prompt #format-select-prompt)
                                       (help #format-select-help)
                                       (choices #format-full #format-quick #format-none)
                                       (default 0)
                            )
                )

                (if (< Format 2)
                    (
                        (set Ok (askbool (prompt #Ok-To-Format-prompt)
                                         (help #Ok-to-format-help)
                                         (default 0)
                                         (choices #Format-yes #Format-no)
                                )
                        )

                        (if Ok
                            (
                                (working #formatting)

                                (if (= Format 0)
                                    (
                                        (set Fail (run "sys:system/format drive df0: name \"Diavolo Emergency Disk\" ffs noicons")
                                        )
                                    )
                                    (
                                        (set Fail (run "sys:system/format drive df0: name \"Diavolo Emergency Disk\" ffs noicons quick")
                                        )
                                    )
                                )

                                (if Fail
                                    (
                                        (message #format-failed)
                                        (set Ok 0)
                                    )
                                )
                            )
                        )
                    )
                    (
                        (set Ok 1)
                    )
                )
            )
        )

        (complete 10)

        (set Fail (run "c:install df0:")
        )

        (if Fail
            (
                (abort #install-failed)
            )
        )

        (working #create-dirs)

        (makedir "df0:c")

        (makedir "df0:libs")

        (makedir "df0:fonts")

        (makedir "df0:devs")

        (if (>= SysVer 39)
            (makedir "df0:devs/Monitors")
        )

        (makedir "df0:devs/Keymaps")

        (makedir "df0:s")

        (makedir "df0:Prefs")

        (makedir "df0:Prefs/Env-Archive")

        (makedir "df0:Tape Catalogs")

        (complete 15)

        (copyfiles (source "c:SetPatch")
                   (dest "df0:c")
        )

        (if (exists "c:loadwb_old")
            (
                (copyfiles (source "c:loadwb_old")
                           (dest "df0:c")
                           (newname "loadwb")
                )
            )
            (
                (copyfiles (source "c:loadwb")
                           (dest "df0:c")
                )
            )
        )

        (copyfiles (source "c:copy")
                   (dest "df0:c")
        )

        (copyfiles (source "c:IPrefs")
                   (dest "df0:c")
        )

        (copyfiles (source "c:Assign")
                   (dest "df0:c")
        )

        (copyfiles (source "c:MakeDir")
                   (dest "df0:c")
        )

        (if (exists "libs:68040.library")
            (
                (copyfiles (source "libs:68040.library")
                           (dest "df0:libs")
                )
            )
        )

        (copyfiles (source "libs:diskfont.library")
                   (dest "df0:libs")
        )

        (copyfiles (source "libs:iffparse.library")
                   (dest "df0:libs")
        )

        (copyfiles (source "libs:asl.library")
                   (dest "df0:libs")
        )

        ; ** Just in case my asl is newer

        (copylib (source (tackon DBDest "libs/asl.library"))
                 (dest "df0:libs")
        )

        (copyfiles (source (tackon DBDest "libs/xpkmaster.library"))
                   (dest "df0:libs")
        )

        (copyfiles (source (tackon DBDest "libs/compressors"))
                   (dest "df0:libs/compressors")
                   (pattern "xpk(FEAL|FAST|NUKE).library")
        )

        (copyfiles (source (tackon DBDest "fonts"))
                   (dest "df0:fonts")
                   (all)
        )

        (complete 30)

        (copyfiles (source (tackon DBDest "Diavolo"))
                   (dest "df0:")
                   (infos)
        )

        (complete 70)

        (if (>= SysVer 39)
            (
                (copyfiles (prompt #copy-monitors-prompt)
                           (help #copy-monitors-help)
                           (source "devs:monitors")
                           (dest "df0:devs/monitors")
                           (pattern "~(#?.info|VGAOnly)")
                           (confirm)
                )

                (if (exists "libs:cybergraphics.library")
                    (
                        (copyfiles (source "libs:")
                                   (dest "df0:libs")
                                   (pattern "Cyber(graphics|layers|intuition).library")
                        )

                        (if (exists "env:CyberGraphics")
                            (copyfiles (source "env:CyberGraphics")
                                       (dest "df0:prefs/Env-Archive/CyberGraphics")
                                       (all)
                            )
                        )

                        (copyfiles (source "libs:datatypes.library")
                                   (dest "df0:libs")
                        )
                    )
                )
            )
        )

        (complete 80)

        (if (exists "env:sys/ScreenMode.prefs")
            (
                (copyfiles (source "env:sys/ScreenMode.prefs")
                           (dest "df0:prefs/Env-Archive/sys")
                )
            )
        )

        (if (exists "env:sys/Palette.prefs")
            (
                (copyfiles (source "env:sys/Palette.prefs")
                           (dest "df0:prefs/Env-Archive/sys")
                )
            )
        )

        (if (exists "env:sys/input.prefs")
            (
                (copyfiles (source "env:sys/input.prefs")
                           (dest "df0:prefs/Env-Archive/sys")
                )
            )
        )

        (set Monitors "")

        (if (>= SysVer 39)
            (
                (foreach "df0:devs/monitors" "~(#?.info)"
                    (
                        (set Monitors (cat Monitors
                                           "  DEVS:Monitors/"
                                           @each-name
                                           "\n"
                                      )
                        )
                    )
                )
            )
        )

        (textfile (dest "df0:s/startup-sequence")
                  (append (cat "c:SetPatch > nil:\n"
                               "makedir ram:env\n"
                               "assign env: ram:env\n"
                               "copy envarc: env: all quiet\n"
                               "assign locale: sys:\n"
                               "assign KEYMAPS: DEVS:Keymaps\n"
                               "if exists DEVS:Monitors\n"
                               Monitors
                               "endif\n"
                               "iprefs\n"
                               "loadwb\n"
                               "endcli > nil:\n"
                          )
                  )
        )

        (complete 90)

        (if (exists (tackon DBDest "DiavoloStandard.prefs"))
            (
                (copyfiles (source (tackon DBDest "DiavoloStandard.prefs"))
                           (dest "df0:")
                )

                (message #Prefs-available)
            )
            (
                (message #Prefs-not-available)
            )
        )

        (copyfiles (source "Devs:Keymaps")
                   (dest "df0:Devs/Keymaps")
                   (pattern "~(#?.info)")
        )

        (complete 100)

        (message #emergency-disk-finished)
    )
)

(if Installed
    (exit (quiet))
    (exit)
)

