;
; $VER: IOBlix installation 1.7 (07.02.2000)
;
; Copyright (c) 1998-2000 Thore Böckelmann and RBM Computertechnik
;

;****************************************************************************
;
; English texts
;
(if (not (= @language "deutsch"))
    (
        (set #bad-kick      "You must have AmigaOS 2.0 (V37) or newer to be able to use the IOBlix I/O board.")
        (set #bad-cpu       "You must have at least an MC68020 to use the IOBlix software.")
        (set #cantremove    (cat "Cannot remove old ioblix.resource! "
                                 "Please quit any software using the IOBlix before installing the new drivers!"))
        (set #cantinit      (cat "Cannot initialize ioblix.resource! "
                                 "Please quit any software using the IOBlix before installing the new drivers!"))
        (set #noioblix      (cat "You have no IOBlix board installed! "
                                 "Please install the board first, before you install the software!"))
        (set #selectboard   (cat "You have an IOBlixZ2 board and an IOBlix1200 module installed!\n"
                                 "For which hardware do you want to install the software?"))
        (set #installz2     "\n\nI will now install the software for the IOBlixZ2 board.")
        (set #install1200   "\n\nI will now install the software for a IOBlix1200 module.")
        (set #selectdevs    "\nWhere to install the device drivers?\n")
        (set #selectl       "\nWhere to install the IOBlix-Handler?\n")
        (set #selecttool    "\nWhere to install the additional tools (a new drawer will be created automatically)?\n")
        (set #copyserdev    "\nCopying serial device driver...\n")
        (set #copypardev    "\nCopying parallel device driver...\n")
        (set #copyhandler   "\nCopying IOBlix-Handler...\n")
        (set #copydosdriver "\nCopying DOSDrivers...\n")
        (set #copytools     (cat "\nCopying Tools...\n"
                                 "For information about the AutoMounter read the help page.\n"))
        (set #tools-help    (cat "The AutoMounter makes mount files for ZIP media nearly obsolete, as long as you use ZIP media with an "
                                 "Amiga compliant RDB. The RDB is written by programms like HDToolbox or any other program to prepare a "
                                 "harddisk. The AutoMounter checks for every ZIP drive connected to a parallel port in case of a media change "
                                 "if the inserted media is already mounted. If not, the AutoMounter tries to mount it, similar if you entered "
                                 "\"mount <device>\" in a shell.\n"
                                 "If you use a new FileSystem with the media the AutoMounter also will try to load that FileSystem from the RDB.\n"
                                 "If all that could be done successfully the media will be ready ca. 5 seconds after insertion.\n"
                                 "\n"
                                 "The AutoMounter will NOT work for PC-formatted media, because these have no RDB! If you wish to work with "
                                 "PC-formatted media you will have to use mount files, just as before!"))
        (set #createtest    "\nCreating \"Test_Board\" script...\n")
        (set #ssmodify      "\nAdding some command to S:User-Startup...\n")
        (set #nsdinfo       (cat "\n"
                                 "\n"
                                 "If don't want to use IOBlix' own drivers SERxx: and PARxx: "
                                 "but the original drivers instead, then you also have to install the NSDPatch software!\n"
                                 "\n"
                                 "NSDPatch can be found in the drawer \"Goodies\""))
    )
)

;****************************************************************************
;
; Deutsche Texte
;
(if (= @language "deutsch")
    (
        (set #bad-kick      "Sie müssen AmigaOS 2.0 (V37) oder höher installieren, um die IOBlix-Karte zu benutzen.")
        (set #bad-cpu       "Sie brauchen mindestens einen MC68020, um die IOBlix-Software zu benutzen.")
        (set #cantremove    (cat "Kann alte ioblix.resource nicht aus dem System entfernen!\n"
                                 "Bitte beenden Sie alle Programme, die den IOBlix benutzen, bevor Sie die neue Software installieren!"))
        (set #cantinit      (cat "Kann ioblix.resource nicht initialisieren!\n"
                                 "Bitte beenden Sie alle Programme, die den IOBlix benutzen, bevor Sie die neue Software installieren!"))
        (set #noioblix      (cat "Sie haben keine IOBlix-Karte in Ihrem Rechner installiert! "
                                 "Bitte bauen Sie erst die Karte ein, bevor Sie die Software installieren!"))
        (set #selectboard   (cat "Sie haben ein IOBlixZ2-Karte und ein IOBlix1200-Modul installiert!\n"
                                 "Für welche Hardware wollen Sie die Software installieren?"))
        (set #installz2     "\n\nEs wird jetzt die Software für die IOBlixZ2-Karte installiert.")
        (set #install1200   "\n\nEs wird jetzt die Software für ein IOBlix1200-Modul installiert.")
        (set #selectdevs    "\nWohin sollen die Gerätetreiber kopiert werden?\n")
        (set #selectl       "\nWohin soll der IOBlix-Handler kopiert werden?\n")
        (set #selecttool    "\nWohin sollen die Zusatzprogramme kopiert werden (eine neue Schublade wird automatisch angelegt)?\n")
        (set #copyserdev    "\nKopiere seriellen Gerätetreiber...\n")
        (set #copypardev    "\nKopiere parallelen Gerätetreiber...\n")
        (set #copyhandler   "\nKopiere IOBlix-Handler...\n")
        (set #copydosdriver "\nKopiere DOSDrivers...\n")
        (set #copytools     (cat "\nKopiere Zusatzprogramme...\n"
                                 "Für Informationen über den AutoMounter lesen Sie bitte die Hilfeseite.\n"))
        (set #tools-help    (cat "Mit dem AutoMounter werden Mount-Dateien so gut wie unnötig, solange Sie mit ZIP-Medien arbeiten, "
                                 "die einen Amiga-kompatiblen RDB besitzen. Der RDB wird von Programmen wie der HDToolbox oder ähnlichen "
                                 "Programmen zum Partitionieren von Festplatten geschrieben. Der AutoMounter überprüft für jedes in ein "
                                 "am Parallel-Port angeschlossenes ZIP-Drive bei einem Medienwechsel, ob das Medium bereits angemeldet ist, "
                                 "und wenn nicht, so wird versucht es anzumelden, genauso als wenn Sie in einer Shell \"mount <device>\" "
                                 "eingegeben hätten.\n"
                                 "Wird ein FileSystem benutzt, daß bisher nicht im System verwendet wird, so wird ebenfalls versucht das "
                                 "FileSystem aus dem RDB des Mediums zu laden.\n"
                                 "Ist das alles erfolgreich abgelaufen, so steht Ihnen nach ca. 5 Sekunden das Medium zur Arbeit bereit.\n"
                                 "\n"
                                 "Dieses Verfahren funktioniert NICHT bei PC-formatierten Medien, da diese keinen RDB besitzen! Um mit "
                                 "PC-formatierten Medien zu arbeiten müssen Sie also auch weiterhin eine Mount-Datei benutzen!"))
        (set #createtest    "\nErstelle \"Test_Board\" Skript...\n")
        (set #ssmodify      "\nFüge Befehle in S:User-Startup ein...\n")
        (set #nsdinfo       (cat "\n"
                                 "\n"
                                 "Wenn Sie statt der IOBlix-eigenen Treibern SERxx: und PARxx: "
                                 "lieber weiterhin die originalen Treiber benutzen wollen, dann müssen Sie noch die NSDPatch-Software installieren!\n"
                                 "\n"
                                 "NSDPatch finden Sie in der Schublade \"Goodies\""))
    )
)

;****************************************************************************
;
; Setup
;

(complete 0)

(if (< (/ (getversion) 65536) 37)
    (abort #bad-kick)
)

(if (patmatch "68000|68010" (database "cpu"))
    (abort #bad-cpu)
)

;****************************************************************************
;
; Welcome
;

(welcome)

(complete 10)

;****************************************************************************
;
; Check for IOBlix board
;

(set #setupcheck (run "C/SetupIOBlix remove" (safe)))
(if (< 0 #setupcheck)
    (abort #cantremove)
)

(set #setupcheck (run "C/SetupIOBlix reinit" (safe)))
(if (< 0 #setupcheck)
    (abort #cantinit)
)

(set #ioblixz2
    (+
        (run "C/Look4IOBlix hw=ser" (safe))
        (run "C/Look4IOBlix hw=par" (safe))
    )
)
(set #ioblix1200
    (+
        (run "C/Look4IOBlix a1200 hw=ser" (safe))
        (run "C/Look4IOBlix a1200 hw=par" (safe))
    )
)

(if (> 2 @user-level)
    (
        (if (and (= 0 #ioblixz2) (= 0 #ioblix1200))
            (abort #noioblix)
        )
    )
    (
        (set #ioblixz2 5)
        (set #ioblix1200 5)
    )
)

(if (and (< 0 #ioblixz2) (< 0 #ioblix1200))
    (
        (set #ioblixboard
            (askchoice
                (prompt #selectboard)
                (help @askchoice-help)
                (choices "IOBlixZ2" "IOBlix1200")
                (default 0)
            )
        )
    )
    (
        (if (< 0 #ioblixz2)
            (
                (set #ioblixboard 0)
            )
            (
                (set #ioblixboard 1)
            )
        )
    )
)

(if (= 0 #ioblixboard)
    (
        (message #installz2)
    )
    (
        (message #install1200)
    )
)

(complete 20)

;****************************************************************************
;
; Setup directory
;

(set #destdevs
    (askdir
        (prompt #selectdevs)
        (help @askdir-help)
        (default "DEVS:")
    )
)

(set #destl
    (askdir
        (prompt #selectl)
        (help @askdir-help)
        (default "L:")
    )
)

(set #desttool
    (askdir
        (prompt #selecttool)
        (help @askdir-help)
        (default "SYS:IOBlix")
        (newpath)
    )
)

(set @default-dest #desttool)

(complete 30)

(makedir #desttool
    (prompt "")
    (help @makedir-help)
    (infos)
)

(complete 40)

;****************************************************************************
;
; Install devices
;

(if (= 0 #ioblixboard)
    (
        (set #file "Devs/IOBlixZ2/ioblixser.device")
    )
    (
        (set #file "Devs/IOBlix1200/ioblix12ser.device")
    )
)
(copylib
    (help @copylib-help)
    (prompt #copyserdev)
    (source #file)
    (dest #destdevs)
    (confirm)
)

(if (= 0 #ioblixboard)
    (
        (set #file "Devs/IOBlixZ2/ioblixpar.device")
    )
    (
        (set #file "Devs/IOBlix1200/ioblix12par.device")
    )
)
(copylib
    (help @copylib-help)
    (prompt #copypardev)
    (source #file)
    (dest #destdevs)
    (confirm)
)

(copylib
    (help @copylib-help)
    (prompt #copyhandler)
    (source "l/IOBlix-Handler")
    (dest #destl)
    (confirm)
)

(if (= 0 #ioblixboard)
    (
        (copyfiles
            (help @copyfiles-help)
            (prompt #copydosdriver)
            (source "Devs/IOBlixZ2/DOSDrivers")
            (choices "PAR00" "PAR01" "SER00" "SER01" "SER02" "SER03")
            (dest "SYS:Storage/DOSDrivers")
            (infos)
            (confirm)
        )
    )
    (
        (copyfiles
            (help @copyfiles-help)
            (prompt #copydosdriver)
            (source "Devs/IOBlix1200/DOSDrivers")
            (choices "PAR00" "PAR01" "SER00" "SER01" "SER02" "SER03")
            (dest "SYS:Storage/DOSDrivers")
            (infos)
            (confirm)
        )
    )
)

(complete 60)

;****************************************************************************
;
; Install tools
;

(copyfiles
    (help #tools-help)
    (prompt #copytools)
    (source "C")
    (choices "SetupIOBlix" "QueryIOBlix" "ResetQuaddddroPort" "AutoMount.demon" "SetParMode")
    (dest #desttool)
    (confirm)
)

(if (<> 0 #ioblixboard)
    (
        (if (<> 0 (run "search S:User-Startup ResetQuaddddroPort >nil:" (safe)))
            (
                (textfile
                    (dest "S:User-Startup.old")
                    (prompt "")
                    (help "")
                    (include "S:User-Startup")
                )
                (textfile
                    (dest "S:User-Startup")
                    (prompt "")
                    (help "")
                    (append (cat (tackon #desttool "ResetQuaddddroPort") "\n"))
                    (include "S:User-Startup.old")
                )
            )
        )
    )
)

(startup "IOBlix I/O Board"
    (help @startup-help)
    (prompt #ssmodify)
    (command (cat (tackon #desttool "SetupIOBlix") " automounter >NIL:"))
)

(complete 80)

(copyfiles
    (help @copyfiles-help)
    (prompt #createtest)
    (dest #desttool)
    (source "Test_Board")
    (infos)
)

(textfile
    (dest (tackon #desttool "Test_Board"))
    (prompt #createtest)
    (help "")
    (append (tackon #desttool "QueryIOBlix >t:queryioblix{$$}\n"))
    (append "more t:queryioblix{$$}\n")
    (append "delete t:queryioblix{$$} >nil:\n")
)

(complete 90)

(if (not (= @language "english"))
    (
        (set #src_name (tackon "catalogs/" @language))
        (set #dst_name (tackon "LOCALE:" #src_name))

        (set #src_name (tackon #src_name "ioblix.catalog"))

        (if (exists #src_name (noreq))
            (
                (copyfiles
                        (help @copyfiles-help)
                        (source #src_name)
                        (dest #dst_name)
                )
            )
            (
                (message "Sorry, there is no " @language " catalog available at the moment!")
            )
        )
    )
)

(message #nsdinfo)

;****************************************************************************
;
; Exit
;

(complete 100)
(exit)

