;
;  MERCURY mailer installation script
;
;


(set BBSname "Ramses")
(set BBSconfigname "RAMSES")

; 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-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-pointnb
        (cat "What is your point number for " BBSname " ?"))
(set #cfg-ask-pointnb-help
        (cat "This the point you were given by the sysop "
             "of " BBSname ".\n"))

(set #cfg-ask-password
        (cat "What is your password for this system ?"))
(set #cfg-ask-password-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-call-from
        (cat "Please, select the area you are calling from." ))

(set #cfg-call-from-help
        (cat "\nThis is needed by the installer to choose the "
             "correct phone number prefix." ))

(set #cfg-call-from-paris       "Paris" )
(set #cfg-call-from-province    "France (not Paris)" )
(set #cfg-call-from-other       "Out of France" )

(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-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-pointnb
        (cat "Quel est votre numéro de point pour " BBSname " ?"))
(set #cfg-ask-pointnb-help
        (cat "Entrez le numéro de point que vous a attribué le sysop "
             "de " BBSname ". Si vous ne l'avez pas, arrêtez "
             "la procédure d'installation, et demandez-lui."))

(set #cfg-ask-password
        (cat "Quel est votre mot de passe pour ce BBS ? "))
(set #cfg-ask-password-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-call-from
        (cat "Vous devez indiquer ici votre lieu de résidence "
             "(ou du moins le lieu à partir duquel vous allez appeler "
             BBSName ")."))

(set #cfg-call-from-help
        (cat "Cette information est nécessaire au programme d'installation "
             "pour lui permettre d'ajouter un préfixe à la numérotation "
             "si besoin est."
         ))

(set #cfg-call-from-paris       "depuis Paris ou sa région")
(set #cfg-call-from-province    "depuis la province" )
(set #cfg-call-from-other       "depuis l'étranger (hors de France)" )


(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 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 of " username))))


      (set pointnb (askstring (help #cfg-ask-pointnb-help)
                               (prompt #cfg-ask-pointnb)
                               (default "xx")))

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

      (select (askchoice (help #cfg-call-from-help)
              (prompt #cfg-call-from)
              (choices #cfg-call-from-Paris #cfg-call-from-Province #cfg-call-from-other)
              (default 0))
                   (set UsePrefix "")
                   (set UsePrefix "1")
                   (set UsePrefix "00331"))

      (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 \"" BBSconfigname "\"\n\n"
                             spc "LOCALNAME \"" systemname "\"\n"

                             ;
                             ;  All the nodes of the BBS
                             ;

                             spc "BOSS 2:320/104.0\n"
                             spc "BOSSAKA 39:180/1.0\n"
                             spc "BOSSAKA 2:320/105.0\n"
                             spc "BOSSAKA 2:320/106.0\n"
                             spc "BOSSAKA 2:320/101.0\n"
                             spc "BOSSAKA 2:320/100.0\n"
                            "\n"
                             spc "NODE 2:320/104." pointnb "\n"
                             spc "AKA 39:180/1." pointnb "\n"
                             spc "AKA 2:320/105." pointnb "\n"
                             spc "AKA 2:320/106." pointnb "\n"
                             spc "AKA 2:320/100." pointnb "\n"
                             spc "AKA 2:320/101." pointnb "\n"
                             "\n"

                             ;
                             ; All the nodes with their phone number
                             ;

                             spc "CALL 2:320/104.0 \"" UsePrefix "45845623\"\n"
                             spc "CALL 2:320/105.0 \"" UsePrefix "53791299\"\n"
                             spc "CALL 2:320/106.0 \"" UsePrefix "53791200\"\n"
                             spc "CALL 2:320/100.0 \"" UsePrefix "53791219\"\n"
                             spc "CALL 2:320/101.0 \"" UsePrefix "53791219\"\n"

                             spc "PASSWORD \"" password "\"\n"
                             spc "INBOUND \"" inbound "\"\n"
                             "\n"
                             "ENDNET\n\n"
                             "OUTBOUND \"" outbound "\"\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 \"\"\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"
                             )))

       (run (cat "copy .install/Call_Mercury.info \"" mercurydir "\""))

       (run (cat "rename \""
                 (tackon mercurydir "Call_Mercury.info" )
                 "\" \""
                 (tackon mercurydir (cat "CALL_" BBSconfigname ".info"))
                 "\""))

       (tooltype (dest (tackon mercurydir (cat "CALL_" BBSconfigname)))
                 (settooltype "CALL" "")
                 (settooltype "NET" BBSconfigname ))

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

    )
)



