;
;  MERCURY mailer installation script
;
;

; This is for english

(set #where-mercury-dir
        (cat "Where shall I put the Mercury-Mailer directory ?\n"
             "(A new drawer will be created)"))
(set #inst-exec
        (cat "Installing Mercury executable..."))
(set #inst-doc
        (cat "Installing Mercury documentation..."))
(set #inst-cfg-ex
        (cat "Installing Mercury configuration file example..."))
(set #inst-lib1
        (cat "Installing the xprzedzap.library..."))
(set #cfg-ask-help
        (cat "If you want to let this script "
              "configure the mailer for you, select yes. "
              "If you are a beginner, you should select Yes"))
(set #cfg-ask
        (cat "Do you wish to let this script "
              "semi-automatically configure the Mercury mailer ?"))
(set #cfg-ask-netname
        (cat "Please enter a short name for your system\n"
             "(please just one word, with no space)"))
(set #cfg-ask-netname-help
        (cat "\n\nThis name will be used on the command line,"
             " so it should be shorty and with no space."))
(set #cfg-ask-username
        (cat "Please enter your full name"))
(set #cfg-ask-username-default
        (cat "John Smith"))
(set #cfg-ask-username-help
        (cat "\n\nYou must insert in the string gadget "
              "your firstname and your lastname.\n"
              "\nexample: John Smith"))
(set #cfg-ask-sysname
        (cat  "What is the name of your point system ?"))
(set #cfg-ask-sysname-help
        (cat  "\nThis is the full name of your point. This line will "
              "be sent to the remote system each time it handshakes "
              "with your system.\nThis name can contain spaces and "
              "any standart character (ascii <128)\n\n"
              "example: \"My Point of View - Rodrigo Reyes\""))

(set #cfg-ask-boss
        (cat "What is the address of your BOSS"))
(set #cfg-ask-boss-help
        (cat "This shall be the address of the remote system "
             "you will call. Normally, this is a fidonet-style "
             "address, such as 1:89/45 or 2:320/104.\n"
             "Please note that there should not be any trailing "
             "point-zero suffix (it is 1:89/45, not 1:89/45.0)\n"
             "This is just for this script, as 1:89/45.0 is a "
             "valid boss address for the Mercury parser."))

(set #cfg-ask-otherboss
        (cat "Have your boss any other address ?\n"
             "If you select yes, the script will prompt you for a "
             "BOSS-AKA (Also Known As)"))
(set #cfg-ask-otherboss-help
        (cat "If your boss has more than one phone line, "
             "it probably has more than one node address. "
             "The reason is that on a Fidonet-like network, "
             "each line is a node, and each node has an "
             "address.\n\n"
             "So, if you want the program to be able to call "
             "all the available lines of a BBS, you must "
             "define all the addresses for the boss nodes.\n"
             "\nIf your BBS has only one phone line, there are "
             "no such problems.\n\n"
             "However, if you wish to define more than one network "
             "for your boss, you also need to define all the "
             "address you will use. This means that if your boss "
             "feeds you with FidoNet and AmigaNet networks, you "
             "must give the two networks' addresses to the "
             "program to allow him to correctly pickup the "
             "mail."))

(set #cfg-ask-bossaka
        (cat "Please give an AKA for your boss"))
(set #cfg-ask-bossaka-help
        (cat "\nJust give an address for your boss. This may be "
             "another line's address, or another network's address."))

(set #cfg-ask-sysaka
        (cat "What is YOUR address for the following node : "))
(set #cfg-ask-sysaka-help
        (cat "\nYou have defined an address for your boss, you "
             "must now precise what is YOUR point address for "
             "this node.\n"
             "If your boss' address is 2:320/104, and if your "
             "boss gave you the point number 16, then YOUR "
             "address is 2:320/104.16. You must type this address "
             "in the string gadget."))

(set #cfg-ask-call
        (cat "What is the call number for address : "))
(set #cfg-ask-call-help
        (cat "There shall be one node per line for a boss.\n"
             "Just type in the phone number which correspond to "
             "the given address."))

(set #cfg-ask-password
        (cat "What is your password for this system ?"))
(set #cfg-ask-call-help
        (cat "\nThis password was given to you by your"
             "sysop, and shouldn't be longer than 8-char to be "
             "fidonet-compliant.\n"))


(set #cfg-ask-inbound
        (cat "please select your inbound directory..."))
(set #cfg-ask-inbound-help
        (cat "Just select a directory where the program will "
             "put the incoming mail packets.\n\nThis should be"
             "different from the outbound directory."))

(set #cfg-ask-outbound
        (cat "please select your outbound directory..."))
(set #cfg-ask-outbound-help
        (cat "Just select a directory where the program will "
             "find the outgoing mail packets.\n\nThis should be"
             "different from the inbound directory."))

(set #cfg-autogen
        (cat ";\n"
             "; This config file has been semi-automatically\n"
             "; created by the Mercury mailer script.\n"
             ";\n"))

(set #writing-cfg
        (cat "Writing the config file..."))

(set #generated-cfg
        (cat "\n\nThe config file has been successfully generated.\n"
           "You can call the Mercury mailer with the following "
           "command line :\n"))


 ;
 ;   French translation...
 ;
 ;

(if (= @language "français")
(
(set #where-mercury-dir
        (cat "Où voulez-vous placer le répertoire de Mercury ?"
             "(Un nouveau répertoire nommé Mercury sera créé)"))
(set #inst-exec
        (cat "Installation de l'executable..."))

(set #inst-doc
        (cat "Installation de la documentation..."))
(set #inst-cfg-ex
        (cat "Installation du fichier d'exemple de configuration..."))
(set #inst-lib1
        (cat "Installation de la bibliothèque xprzedzap.library..."))

(set #cfg-ask-help
        (cat "Si vous désirez que ce script configure Mercury "
              "pour vous, choisissez OUI. Ce script vous "
              "posera certaine question sur votre système et "
              "créera automatiquement un fichier de configuration "
              "adapté. \n\n"
              "Vous devrez connaître au moins votre numéro de point et "
              "votre mot de passe pour ce point."))

(set #cfg-ask
        (cat "Désirez-vous que ce script configure semi-automatiquement "
              "le mailer pour vous ?"))

(set #cfg-ask-netname
        (cat "Entrez un nom pour cette configuration.\n"
             "(Appuyez sur AIDE pour plus d'information)."))
(set #cfg-ask-netname-help
        (cat "\n\nCe nom sera utilisé dans la ligne de commande "
             "pour spécifier quel BBS appeler. Donc, choisissez-le "
             "assez court si possible, et surtout sans espace."))
(set #cfg-ask-username
        (cat "Entrez votre nom complet, Prénom + Nom"))
(set #cfg-ask-username-default
        (cat "Jean Dupont"))
(set #cfg-ask-username-help
        (cat "\n\nInserez simplement dans le gadget de chaîne "
              "votre prénom et votre nom (dans cet ordre).\n"
              "\nexemple: Jean Dupont"))
(set #cfg-ask-sysname
        (cat  "Quel nom voulez-vous donner à votre point ?"))
(set #cfg-ask-sysname-help
        (cat  "Ceci doit être le nom complet de votre point. Cette ligne "
              "sera envoyée au BBS distant chaque fois que vous vous y "
              "connecterez, et c'est sous ce nom que vous apparaîtrez.\n\n"
              "Ce nom peut contenir des espaces et n'importe quel caractère "
              "ASCII (évitez les ascii > 128)"))
              "example: \"Point d'exclamation ! Rodrigo reyes !"

(set #cfg-ask-boss
        (cat "Quelle est l'adresse de votre \"boss\" ?"))
(set #cfg-ask-boss-help
        (cat "C'est normalement l'adresse du BBS qui héberge votre "
             "point. Normalement, c'est une adresse de type Fido, "
             "telle que 1:89/45 ou 2:320/104.\n\n"
             "Evitez de mettre un .0 final dans l'adresse du boss, "
             "cela permettra au script d'éviter de s'emmêler les "
             "pinceaux... Mercury comprend néanmoins parfaitement "
             "une adresse de type 2:320/104.0 pour un boss."))

(set #cfg-ask-otherboss
        (cat "Est-ce que votre boss possède une autre adresse electronique ?\n"
             "Si vous appuyez sur OUI, ce script vous demandera une autre "
             "adresse pour votre boss."))

(set #cfg-ask-otherboss-help
        (cat "Si votre BBS possède plus d'une ligne de téléphone, "
             "il est plus que probable qu'il ait également plusieurs "
             "adresse fidonet attribuée.\n En effet, sur les réseaux "
             "de type FidoNet, chaque ligne de téléphone est un noeud, "
             "et chaque noeud du réseau a une adresse propre.\n\n"
             "Donc, si vous désirez que le programme Mercury "
             "soit capable d'appeler chacune des lignes de téléphone "
             "de votre BBS, celui-ci doit connaître également chaque "
             "adresse.\n\n"
             "Si votre BBS ne possède qu'une seule ligne, il ne devrait "
             "pas y avoir de problème.\n".
             "Cependant, si vous désirez définir plusieurs réseaux pour "
             "votre BBS, vous devez aussi définir toutes les adresses "
             "de celui ci (une adresse pour chaque réseau et pour chaque "
             "ligne). Par exemple, si votre BBS vous transmet des conférences "
             "des réseaux FidoNet _ET_ AmigaNet, vous devez définir les deux "
             "entrée dans le fichier de configuration. Dans ce cas précis, "
             "vous mettrez l'adresse principale du BBS, et l'adresse du "
             "second réseau dans les AKAs (Also Known As), comme une autre "
             "adresse à part entière.\n"))


(set #cfg-ask-bossaka
        (cat "Donnez un AKA (Also Known As == Autre nom sous lequel il est "
             "connu) pour votre BBS.\n"))
(set #cfg-ask-bossaka-help
        (cat "\nEntrez simplement une des adresses de votre BBS. Cela "
             "peut aussi bien être l'adresse d'une autre ligne, que "
             "l'adresse d'un autre réseau qu'il vous transmet."))

(set #cfg-ask-sysaka
        (cat "Quelle est VOTRE adresse pour le noeud suivant :"))

(set #cfg-ask-sysaka-help
        (cat "Vous avez défini une adresse pour votre BBS, vous "
             "devez donc maintenant préciser quelle est VOTRE "
             "adresse pour ce node.\n"
             "Ainsi, si l'adresse de votre boss est 2:320/104, et "
             "que votre sysop vous a attribué le point numéro 16, "
             "alors votre adresse sur le réseau est 2:320/104.16.\n"
             "Vous devez entrer cette adresse complète."))

(set #cfg-ask-call
        (cat "Quelle est le numéro téléphonique d'appel pour le noeud : "))

(set #cfg-ask-call-help
        (cat "\nIl doit y avoir un noeud par ligne pour votre BBS (sauf "
             "s'il existe également des réseaux différents).\n"
             "Entrez simplement le numéro d'appel qui correspond à "
             "l'adresse qui vous est précisée.\n"
             "\nPar exemple : 45785328."))

(set #cfg-ask-password
        (cat "Quel est votre mot de passe pour ce BBS ? "))
(set #cfg-ask-call-help
        (cat "Ce mot de passe vous a été attribué par le sysop, "
             "et ne doit pas avoir une longueur de plus de huit "
             "caractères.\n"))

(set #cfg-ask-inbound
        (cat "Choisissez un répertoire pour la réception des "
             "paquets de courrier."))

(set #cfg-ask-inbound-help
        (cat "Choisissez simplement un répertoire dans lequel le "
             "programme stockera tous les paquets de courrier que "
             "vous enverra votre BBS.\n\nPrenez bien garde à choisir "
             "en répertoire différent de celui des paquets exportés."))

(set #cfg-ask-outbound
        (cat "Choisissez le répertoire dans lequel les paquets "
             "exportés devront se trouver."))
(set #cfg-ask-outbound-help
        (cat "Choisissez un répertoire dans lequel votre programme "
             "de gestion du courrier placera les paquets destinés à "
             "être exportés vers votre BBS."))

(set #cfg-autogen
        (cat ";\n"
             "; Ce fichier de configuration a été généré\n "
             "; semi-automatiquement par le script d'installation\n"
             "; de Mercury Mailer\n"
             ";\n"))

(set #writing-cfg
        (cat "Ecriture du fichier de configuration..."))

(set #generated-cfg
        (cat "Le fichier de configuration a été créé avec succès.\n"
             "Pour démarrer une session, double-cliquez sur votre icone "
             "Mercury, ou tapez la ligne de commande suivante depuis un "
             "shell : "))

))





;

(set mercurydest
     (askdir (prompt #where-mercury-dir)
             (help @askdir-help)
             (default "sys:")))

(set mercurydir (tackon mercurydest "Mercury"))
(set @default-dest mercurydir)

;
; Create the directory
;

(makedir mercurydir (infos))

;
; Copy all the files
;

(copyfiles (help @copyfiles-help)
           (source "/Mercury")
           (dest mercurydir)
           (prompt #inst-exec)
           (infos))

(copyfiles (help @copyfiles-help)
           (source "/Mercury.guide")
           (dest mercurydir )
           (prompt #inst-doc)
           (infos))

(copyfiles (help @copyfiles-help)
           (source "/Mercury.cfg.example")
           (dest mercurydir )
           (prompt #inst-cfg-ex)
           (infos))

;
;  Copy the needed library...
;

(copylib (help @copylib-help)
         (prompt #inst-lib1)
         (confirm)
         (source "/Libs/xprzedzap.library")
         (dest "LIBS:"))

;
;  Make a new config file
;

(if (askbool (help #cfg-ask-help)
             (prompt #cfg-ask)
             (default 1))

    (
      (set configfile (tackon mercurydir "Mercury.cfg"))

      (set netname (askstring (help #cfg-ask-netname-help)
                              (prompt #cfg-ask-netname)
                              (default "MYBBS")))

      (set username (askstring (help #cfg-ask-username-help)
                              (prompt #cfg-ask-username)
                              (default #cfg-ask-username-default)))

      (set systemname (askstring (help #cfg-ask-sysname-help)
                              (prompt #cfg-ask-sysname)
                              (default (cat "Amiga Point of VIEW - " username))))

      (set bossaddr (askstring (help #cfg-ask-boss-help)
                               (prompt #cfg-ask-boss)
                               (default "2:320/104")))

      (set bossaka1 "")
      (set bossaka2 "")
      (set bossaka3 "")
      (set bossaka4 "")

      (if (askbool (help #cfg-ask-otherboss-help)
                   (prompt #cfg-ask-otherboss)
                   (default 0))
              (
                (set bossaka1 (askstring (help #cfg-ask-bossaka-help)
                                    (prompt #cfg-ask-bossaka)
                                    (default bossaddr)))

                 (if (askbool (help #cfg-ask-otherboss-help)
                       (prompt #cfg-ask-otherboss)
                       (default 0))
                      (
                        (set bossaka2 (askstring (help #cfg-ask-bossaka-help)
                               (prompt #cfg-ask-bossaka)
                               (default bossaka1)))

                         (if (askbool (help #cfg-ask-otherboss-help)
                                   (prompt #cfg-ask-otherboss)
                                   (default 0))
                              (
                                (set bossaka3 (askstring (help #cfg-ask-bossaka-help)
                                       (prompt #cfg-ask-bossaka)
                                       (default bossaka2)))

                                 (if (askbool (help #cfg-ask-otherboss-help)
                                           (prompt #cfg-ask-otherboss)
                                           (default 0))
                                      (
                                        (set bossaka4 (askstring (help #cfg-ask-bossaka-help)
                                               (prompt #cfg-ask-bossaka)
                                               (default bossaka3)))
                                      )
                                 )
                              )
                         )


                      )
                 )

              )
           )


      (set sysaddr (askstring (help #cfg-ask-sysaka-help)
                               (prompt (cat #cfg-ask-sysaka bossaddr " ?")
                               (default (cat bossaddr ".xx")))))

      (if (<> bossaka1 "") (set sysaka1 (askstring (help #cfg-ask-sysaka-help)
                               (prompt (cat #cfg-ask-sysaka bossaka1 " ?")
                               (default (cat bossaka1 ".xx"))))))

      (if (<> bossaka2 "") (set sysaka2 (askstring (help #cfg-ask-sysaka-help)
                               (prompt (cat #cfg-ask-sysaka bossaka2 " ?")
                               (default (cat bossaka2 ".xx"))))))

      (if (<> bossaka3 "") (set sysaka3 (askstring (help #cfg-ask-sysaka-help)
                               (prompt (cat #cfg-ask-sysaka bossaka3 " ?")
                               (default (cat bossaka3 ".xx"))))))

      (if (<> bossaka4 "") (set sysaka4 (askstring (help #cfg-ask-sysaka-help)
                               (prompt (cat #cfg-ask-sysaka bossaka4 " ?")
                               (default (cat bossaka4 ".xx"))))))

      (set callboss (askstring (help #cfg-ask-call-help)
                                            (prompt (cat #cfg-ask-call)
                                                         bossaddr)
                                            (default "12345678")))

      (if (<> bossaka1 "") (set callaka1 (askstring (help #cfg-ask-call-help)
                               (prompt (cat #cfg-ask-call
                                         bossaka1))
                               (default "12345678"))))

      (if (<> bossaka2 "") (set callaka2 (askstring (help #cfg-ask-call-help)
                               (prompt (cat #cfg-ask-call
                                        bossaka2))
                               (default "12345678"))))

      (if (<> bossaka3 "") (set callaka3 (askstring (help #cfg-ask-call-help)
                               (prompt (cat #cfg-ask-call
                                        bossaka3))
                               (default "12345678"))))

      (if (<> bossaka4 "") (set callaka4 (askstring (help #cfg-ask-call-help)
                               (prompt (cat #cfg-ask-call
                                        bossaka4))
                               (default "12345678"))))

      (set password (askstring (help #cfg-ask-password-help)
                               (prompt #cfg-ask-password)
                               (default "8CARMAX")))

      (set inbound (askdir (help #cfg-ask-inbound-help)
                           (prompt #cfg-ask-inbound)
                           (default "Mail:Inbound")))

      (set outbound (askdir (help #cfg-ask-outbound-help)
                           (prompt #cfg-ask-outbound)
                           (default "Mail:Outbound")))

      (set spc "     ")


      (textfile (prompt #writing-cfg)
                (dest configfile)
                (append (cat #cfg-autogen
                             "\n\n"
                             "BAUD 38400\nMINBAUD 2400\n"
                             "\nSYSOP \"" username "\"\n"
                             "\nDEFNET \"" netname "\"\n\n"
                             spc "LOCALNAME \"" systemname "\"\n"
                             spc "BOSS " bossaddr "\n"
                             (if bossaka1 (cat spc "BOSSAKA " bossaka1 "\n"))
                             (if bossaka2 (cat spc "BOSSAKA " bossaka2 "\n"))
                             (if bossaka3 (cat spc "BOSSAKA " bossaka3 "\n"))
                             (if bossaka4 (cat spc "BOSSAKA " bossaka4 "\n"))
                             "\n"
                             spc "NODE " sysaddr "\n"
                             (if sysaka1 (cat spc "AKA " sysaka1 "\n"))
                             (if sysaka2 (cat spc "AKA " sysaka2 "\n"))
                             (if sysaka3 (cat spc "AKA " sysaka3 "\n"))
                             (if sysaka4 (cat spc "AKA " sysaka4 "\n"))
                             "\n"
                             spc "CALL " bossaddr " \""callboss "\"\n"
                             (if callaka1 (cat spc "CALL " bossaka1 " \"" callaka1 "\"\n"))
                             (if callaka2 (cat spc "CALL " bossaka2 " \"" callaka2 "\"\n"))
                             (if callaka3 (cat spc "CALL " bossaka3 " \"" callaka3 "\"\n"))
                             (if callaka4 (cat spc "CALL " bossaka4 " \"" callaka4 "\"\n"))
                             spc "PASSWORD \"" password "\"\n"
                             spc "INBOUND \"" inbound "\"\n"
                             spc "OUTBOUND \"" outbound "\"\n"
                             "\n"
                             "ENDNET\n\n"
                             "LOGFILE \"Sys:Mercury.log\"\n"
                             "MODEMINIT \"ATZ|\"\n"
                             "MODEMHANGUP \"^|+++~~~~ATH0|^\"\n"
                             "MODEMDIALPRE \"ATD\"\n"
                             "MODEMDIALPOST \"|\"\n"
                             "\n"
                             "SERIALNAME \"serial.device\"\n"
                             "SERIALUNIT 0\n"
                             "SERIALFLAGS 0\n"
                             "\n"
                             "SHARED OFF\n"
                             "DSRSUPPORT ON\n"
                             "7WIRE ON\n"
                             "AFTERSESSION \"ECHO ALL DONE !\"\n"
                             "LOCK ON\n"
                             "\n"
                             "MAXCALLS 10\n"
                             "CYCLEDELAY 5\n"
                             "CALLDELAY 30\n"
                             "WAITKEY ON\n"
                             "WINDOWSIZE 0/0/600/150\n"
                             "\n"
                             ";END OF SCRIPT\n"
                             )))

       (tooltype (dest (tackon mercurydir "Mercury"))
                 (settooltype "CALL" "")
                 (settooltype "NET" netname ))

      (message (cat #generated-cfg "Mercury CALL \""netname"\"\n"))

    )
)
