; GenMailer Installer v1.11
(set ismail
    (askbool
        (prompt "Is the Shelter Archive extracted to MAIL: ?")
        (help "For proper operation, all of the files and drawers of the archive must be extracted with the command [LHA -xra x Shelter.LHA] IN MAIL:. Installer will create Assigns for certain of the drawers in Mail:")
        (default 1)
    )
)
(if (= ismail 0)
    (
        (message "Then please do it!")
        (exit)
    )
)
(if (= (getassign "MAIL") 0)
    (
        (message "MAIL: is NOT ASSIGNED, please do it\n")
        (exit)
    )
)
(set @default-dest (getassign "MAIL") )

(message "If your Startup-Sequence executes RexxMast or calls a script which executes RexxMast, please comment out that line.\n Also, if you have versions of wpl.library, xferq.library, xprzedzap.library, xprfts.library, or rexxdossupport.library already in your LIBS: directory, you should RENAME them to *.old and reboot.\nIf any of these are found in SYS:libs/, the version number will be displayed")
(set n 0)
(while (set thisfile (select n "SYS:LIBS/wpl.library" "SYS:LIBS/xferq.library" "SYS:LIBS/xprfts.library" "SYS:LIBS/xprzedzap.library" "SYS:LIBS/rexxdossupport.library" ""))
    ( (set n (+ n 1))
        ( 
            if (= (exists thisfile (noreq)) 1 )
            (
                (set vernum (getversion thisfile))
                (set ver (/ vernum 65536))
                (set rev (- vernum (* ver 65536) ) )
                (message ("Version %ld.%ld of %s may not be compatible with Shelter, please rename or delete it." ver rev thisfile))
            )
        )
    )
)

(copyfiles
    (source "Mail:bin/")
    (dest "Mail:")
    (all)
    (prompt "Copying /bin/#? to Mail:")
    (help "Executables are stored in Mail:bin in order to make a neat archive. During operation they are expected to be found in MAIL:. You may deleted the /bin drawer and its contents after, if you wish to conserve disk space")
    (confirm)
    (optional "nofail" "oknodelete" "askuser" "force")
)

(set cpu (database "cpu"))
(set xprsrc (tackon "Mail:xprs" cpu))
(copyfiles
    (source xprsrc)
    (dest "Mail:libsX")
    (all)
    (prompt "Copying "cpu" XPRs")
    (help "Copying versions of XPR's compilied for your CPU")
    (confirm)
    (optional "nofail" "oknodelete" "askuser" "force")
)


(set destfile "S:GenMailer-StartUp")
(textfile
    (prompt "Creating S:GenMailer-Startup. This creates a startup file that will be executed from your User-Startup.")
    (help "This creates a startup file that will be executed from your User-Startup. Assign ADD is used to allow AmigaDOs to access the various devices and libraries. Some directories are created and Paths defined. NEWAUX: and NULL: are mounted.")
    (confirm)
    (dest destfile)
    (append ";$VER: GenMailer User Startup Williamson 1.05\n")
    (append "IF ${SHELTER} EQ \"ROOF\"\n")
    (append "   EXIT\n")
    (append "ENDIF\n")
    (append "Assign >NIL: Mail: "@default-dest"\n")
    (append "Assign >NIL: LIBS: Mail:libsx ADD\n")
    (append "Assign >NIL: DEVS: Mail:devs ADD\n")
    (append "Assign >NIL: L: Mail:l ADD\n")
    (append "Assign >NIL: REXX: Mail:rexx ADD\n")
    (append "Assign >NIL: CFG: Mail:cfg\n")
    (append "Assign >NIL: INFO: Mail:cfg/info\n")
    (append "Assign >NIL: RexxC: SYS:rexxc\n")
    (append "MakeDir Mail:LOG\n")
    (append "Assign >NIL: LOG: Mail:LOG\n")
    (append "MakeDir >NIL: Mail:log/rfsacct\n")
    (append "MakeDir >NIL: Mail:log/rfsacct/h\n")
    (append "Path >NIL: ADD "@default-dest" "(tackon @default-dest "s")" "(tackon @default-dest "scripts")" "(tackon @default-dest "bin")"\n")
    (append "Mount NEWAUX: from Mail:devs/MountList.NewAux\n")
    (append "Mount NULL: from Mail:devs/MountList.NULL\n")
    (set loader (tackon @default-dest "bin/loadlib"))
    (append loader" Libs:mathieeedoubbas.library\n")
    (append loader" Libs:rexxsyslib.library\n")
    (append "IF ERROR\n")
    (append "   echo \"Couldn't load rexxsyslib.library\"\n")
    (append "   quit 20\n")
    (append "ENDIF\n")
    (append loader" Libs:rexxsupport.library\n")
    (append "IF ERROR\n")
    (append "   echo \"Couldn't load rexxsupport.library\"\n")
    (append "   quit 20\n")
    (append "ENDIF\n")
    (append loader" Libs:rexxdossupport.library\n")
    (append "IF ERROR\n")
    (append "   echo \"Couldn't load rexxdossupport.library\"\n")
    (append "   quit 20\n")
    (append "ENDIF\n")
    (append loader" Libs:hGRexxSupport.library\n")
    (append "IF ERROR\n")
    (append "   echo \"Couldn't load hGRexxSupport.library\"\n")
    (append "ENDIF\n")
    (append "RexxC:waitforport -i REXX\n")
    (append "IF WARN\n")
    (append "   Rexxmast >nil:\n")
    (append "   RexxC:waitforport REXX\n")
    (append "ENDIF\n")
    (append "RexxC:rxlib rexxsupport.library 0 -30 0\n")
    (append "RexxC:rxlib rexxdossupport.library 0 -30 2\n")
    (append "RexxC:rxlib hGRexxSupport.library 0 -30 0\n")
    (append "IF EXISTS REXXC:RPstart\n")
    (append "   Run RexxC:RPstart\n")
    (append "   RexxC:waitforport -i RPREXX\n")
    (append "   IF EXISTS RPDIR:\n")
    (append "       Path ADD RPDIR:\n")
    (append "   ENDIF\n")
    (append "ENDIF\n")
    (append "Run Mail:Sushi <>CON:0/20/640/100/Sushi/AUTO/WAIT/INACTIVE/CLOSE ON NOPROMPT ASKSAVE\n")
)
(execute destfile)

(startup "GENMAILER"
    (prompt "Modifying S:User-Startup")
    (help @startup-help)
    (command "IF ${SHELTER} NOT EQ \"ROOF\"\n")
    (command "  Makedir ENV:${SHELTER}\n")
    (command "  Copy >NIL: ENVARC:${SHELTER} ENV:${SHELTER} ALL\n")
    (command "  Execute S:GenMailer-Startup\n")
    (command "  Cd MAIL:\n")
;    (command "  Rx Mail:rexx/SHELTER START\n")
    (command "ENDIF\n")
)
(message "If your Startup-Sequence executes RexxMast or calls a script which executes RexxMast, please comment out that line.\n Also, if you have versions of wpl.library, xferq.library, xprzedzap.library, xprfts.library, rexxdossupport.library already in your LIBS: directory, you should RENAME them to *.old and then REBOOT.")
(exit)


