Hello !
First, I have to apologize, because it's a very, very long message
Second, I'm a total newbie with rexx, so in your reply, please give me the
exact lines of code, as I won't be able to deal with just advices, I'm too
short in time, as I have to leave home in 15 days.
This is the script I use to run my mail server, the questions are after it :
>==============================================================================
=========
/* REXX script for InetMail - Written by Paul Hethmon, and modify by many
people */
/*
* This program designed to control Inet.Mail in a dialup situation.
*
* Orignial Script available at:
* ftp://ftp.hethmon.com/hethmon/pub/scripts/dialup.zip
*
* This script depends on two external programs:
*
* etrn.exe -- Available from Hethmon Brothers
* ftp://ftp.hethmon.com/hethmon/pub/scripts/etrn.zip
*
* go.exe -- Available from Hethmon Brothers
* ftp://ftp.hethmon.com/hethmon/pub/scripts/go.zip
*
* When you start Inet.Mail, you must use 3 command line flags:
*
* -ready
* -queue
* -relay
*
* You must also create two files in the Inet.Mail main directory:
*
* noqueue
* norelay
*
* The file contents do not matter. A simple way of creating them is
* to redirect the output of the dir command: dir > noqueue
*
* These two files are used as flag files to communicate between this
* script and Inet.Mail.*/
/* ------------------------ Beginning of Variable declarations
-------------------------------- */
/* This section of variables must be set to local values. */
InetMailDir = 'f:\inetmail' /* Your InetMail directory */
DialerDir = 'e:\injoy' /* Your Dialer directory */
SemaforeDir = 'c:\fd\sem' /* The directory where you want a
semafore file to */
/* be created */
DialupLogFile = 'f:\inetmail\dialup.log' /* The logfile and its path */
SleepTime = (60 * 225 * 1) /* Amount of time between
connections in seconds */
/* template : seconds * minutes *
hours */
RemoteServer = 'relay.worldnet.net' /* Remote server to contact for mail
download */
/* Must be an ip name. */
MailDomains = 'celtes.com' /* The mail domain the remote server
is queueing for. */
/* This is the name of your mail
domain as in */
/* user@domain.com would be
domain.com. You may enter */
/* multiple ip names here as needed.
Every domain you */
/* have email queued for must be
listed. */
ImRelayFile = InetMailDir||'\norelay' /* Inet.Mail relay file. The file is
always called */
/* "norelay". Just add the full path
to it here. */
ImReadyFile = InetMailDir||'\ready' /* Inet.Mail ready file. The file is
always called */
/* "ready". Just add the full path
to it here. */
ImQueueFile = InetMailDir||'\noqueue' /* Inet.Mail queue file. The file is
always called */
/* "noqueue". Just add the full path
to it here. */
SpoolDir = InetMailDir||'\spool' /* Inet.Mail spool Directory. The
file is always */
/* *.spl. Just add the full path to
it here. */
Etrn = InetMailDir||'\etrn.exe' /* ETRN program */
DialerProg = 'In-joy.exe' /* Your Dialer Program */
DialIsp = DialerDir||'\in-joy.exe auto' /* If your dialer needs any command
line parameters to */
/* automatically dial, then place
them here */
KillDialer = DialerDir||'\killjoy.exe' /* Kill program to hangup the
dialer. If your dialer */
/* has a command which will cause it
to hang up. You */
/* may substitute it here*/
CheckIfRunning = 'go.exe -cp' /* Program to run to check if an
appli is running */
kill = 'go.exe -k' /* Kill program to kill The applis
that could run and */
/* need to be killed. */
SemaMailer = SemaforeDir||'\inetmail.sem' /* Name, Drive and Directory of the
semafore file you */
/* want the script to create once it
has run */
InetMail=inetmail /* define apps */
pop3d=pop3d /* define apps */
smtpd=smtpd /* define apps */
FireUpIM = InetMailDir||'\'||InetMail ' -l -vis -checkpoint -relay -ready
-queue -hops 30' /* How */
/* you fire up InetMail, and which
parameters do you */
/* need for it */
/* --------------------------- End of Variable declarations
----------------------------------- */
/* For non english speaking user : we change the day given in the log file
from english to french */
DayoftheWeek = date('W')
if DayoftheWeek = 'Sunday' then
JourdelaSemaine = 'Dimanche'
if DayoftheWeek = 'Monday' then
JourdelaSemaine = 'Lundi'
if DayoftheWeek = 'Tuesday' then
JourdelaSemaine = 'Mardi'
if DayoftheWeek = 'Wednesday' then
JourdelaSemaine = 'Mercredi'
if DayoftheWeek = 'Thursday' then
JourdelaSemaine = 'Jeudi'
if DayoftheWeek = 'Friday' then
JourdelaSemaine = 'Vendredi'
if DayoftheWeek = 'Saturday' then
JourdelaSemaine = 'Samedi'
/* End of the french translation */
CurDir = directory()
/* Set to 1 to enable debug output */
Debug = TRUE
/* Set to 1 to enable logging */
Log = TRUE
DialupVersion = 'v.1.6'
DialupRevision = '0.07'
DialupDate = '11 October 1999'
high = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
low = 'abcdefghijklmnopqrstuvwxyz'
Env = 'OS2ENVIRONMENT'
FALSE = 0
TRUE = 1
CRLF='0d0a'x
Start = 'start'
/* Rexx Socket variables */
domain = 'AF_INET'
server.!family = 'AF_INET'
server.!port = 25
server.!addr = RemoteServer
/* The external functions we need */
call RxFuncAdd 'SysCls', 'RexxUtil', 'SysCls'
call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
call RxFuncAdd 'SockLoadFuncs', 'rxSock', 'SockLoadFuncs'
rc = SockLoadFuncs()
rc = SockInit()
/* start main function, we ignore any arguments */
/* Endless loop */
do while 1
/* We start the dial process, so it's time to write the log file */
call LINEOUT DialupLogFile, ' '
call LINEOUT DialupLogFile, '------/' 'DialUp Script' DialupVersion
'rev.'DialupRevision ':' JourdelaSemaine date() '-' Time() '/------'
call LINEOUT DialupLogFile, ' '
call LINEOUT DialupLogFile, date() time() 'Started dialup up process ...'
/* lets attempt to shutdown dialer and mail server; in case it's running
already */
/* we should really test if it runs 1st... but, we'll just 'dumb kill all'
for now */
call SysCls
say '--------------------------------------------------------------------'
say '...we will try to shutdown dialer and mail server before we start...'
say '--------------------------------------------------------------------'
call LINEOUT DialupLogFile, date() time() ' dialer, if running, is
killed.'
KillDialer
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' inetmail, if running, is
killed.'
kill inetmail
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' pop3d process, if running, is
killed.'
kill pop3d
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' smtpd process, if running, is
killed.'
kill smtpd
call SysSleep(2) /* just give it a little time to shut down... */
/* Check for time of day - if outside business hours don't do anything */
/* Check for day of week - if Saturday or Sunday don't do anything */
/* IF (time('H') '22:00:00') | (date('Base')//7
> 4) then do
say "Outside working hours. Sleeping..."
call SysSleep(SleepTime)
iterate
end
else
*/
/* First we have to change to the Dialer directory */
newdir = directory(DialerDir)
/* Start the dialer */
call SysCls
say '--------------------------------------------------------------------'
say 'Starting dialer ... '
say '...starting InJoy dialer in another session... '
say '--------------------------------------------------------------------'
call LINEOUT DialupLogFile, date() time() '. Starting the Internet Dialer
...'
Start '"Internet Dialer" /C' DialIsp
/* return to script directory */
newdir = directory(CurDir)
/* We 're testing the server */
/* We give dialer some time to negotiate and complete connection, then, start
testing if TCP/IP is 'UP' */
say "...let's sit'n'wait till connection is established before we try
anything..."
say '...testing if a link has been established...'
DO ii=1 to 24 /* test for connection up to 24*5 = 120 seconds */
rc = SockGetHostByName(RemoteServer, "host.!")
if (rc = 1) then do
say '..we can resolve hostnames, connection is up...'
call LINEOUT DialupLogFile, date() time() ' We can resolve hostnames,
connection is up...'
call directory InetMailDir
call LINEOUT DialupLogFile, date() time() ' InetMail, Pop3d and Smtpd are
started...'
'@start ' FireUpIM /* We have to restart InetMail */
call SysSleep(1)
call directory CurDir
leave
end
say '...no connection yet, wait, then test again...'
call LINEOUT DialupLogFile, date() time() ' warning ! no connection yet,
wait, then test again...'
call SysSleep(5)
end /* do */
/* Check for a live connection */
say '--------------------------------------------------------------------'
say 'Check for a live connection, starting mail processing ... '
say '--------------------------------------------------------------------'
call LINEOUT DialupLogFile, date() time() '. Starting of the PingServer
procedure ...'
rc = PingServer()
/* a rc of 0 means we can connect, so start some stuff */
if (rc == 0) then do
/* We need to delete the queue file, otherwise smtpd will*/
/* never wake up and check the queue for mail to be sent */
say 'Deleting the outgoing mail queue flag file...'
call LINEOUT DialupLogFile, date() time() ' deleting the outgoing Mail
Queue Flag.'
rc = SysFileDelete(ImQueueFile);
/* Start the etrn program to pick up the new mail waiting */
say 'Starting etrn program ...'
call LINEOUT DialupLogFile, date() time() '. sending the ETRN signals ...'
do i = 1 to words(MailDomains)
TmpDomain = word(MailDomains, i)
etrn RemoteServer TmpDomain
end
/* We need to wait for at least the time between queue checks */
/* for the outgoing mail process to start delivering mail and */
/* delete the ready file before we check for its existence. */
call LINEOUT DialupLogFile, date() time() ' sleeping for 30 seconds ...'
Call SysSleep(30)
/* Now wait for Inet.Mail to tell us it is done sending the */
/* queued mail by checking for the existence of the ready file*/
say 'Waiting for queue delivery to complete ...'
call LINEOUT DialupLogFile, date() time() ' waiting for queue delivery to
complete ...'
Waiting = TRUE
do while (Waiting == TRUE)
rc = SysFileTree(ImReadyFile, "s.", 'F')
if (s.0 == 1) then Waiting = FALSE
end
say 'Queue delivery complete.'
call LINEOUT DialupLogFile, date() time() ' queue delivery complete ...'
/* Now we check that incoming mail delivery has completed.*/
/* by checking for the presence of *.spl in the spool directory.*/
/* Now we check that incoming mail delivery has completed.*/
/* by checking for the presence of *.spl in the spool directory.*/
Incoming = TRUE
call LINEOUT DialupLogFile, date() time() ' waiting for Incoming mail
delivery to complete ...'
do while (Incoming == TRUE)
rc = SysFileTree(SpoolDir'\*.spl', files., 'FO')
if (files.0 == 0) then Incoming = FALSE
call LINEOUT DialupLogFile, date() time() ' now waiting for 30 seconds
...'
call SysSleep(30) /* We wait a little bit for the server to send the mail
*/
end
say 'Incoming mail delivery complete.'
call LINEOUT DialupLogFile, date() time() ' incoming mail delivery
complete ...'
/* Recreate the queue file to put the queue check process */
/* back to sleep. */
call LINEOUT DialupLogFile, date() time() ' recreating the noqueue flag
file.'
rc = stream(ImQueueFile, 'c', 'open')
rc = lineout(ImQueueFile, 'noqueue')
rc = stream(ImQueueFile, 'c', 'close')
end
else do
call LINEOUT DialupLogFile, date() time() '. Warning : Unable to connect to
remote Sever. Skipping connection.'
say 'Unable to connect to remote server. Skipping connection.'
call LINEOUT DialupLogFile, date() time() ' and we go to sleep for a while
- 10 seconds.'
call SysSleep(10)
end
/* Now kill the dialer. Crude but necessary. */
say 'Hanging up the dialer...'
call LINEOUT DialupLogFile, date() time() '. Hanging up ...'
/* get current directory */
curdir = directory()
/* go stop injoy */
newdir = directory(DialerDir)
call LINEOUT DialupLogFile, date() time() ' we kill the Dialer, Crude but
necessary ...'
KillDialer
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' InetMail is killed.'
kill InetMail
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' Pop3d process is killed.'
kill pop3d
call SysSleep(2)
call LINEOUT DialupLogFile, date() time() ' Smtpd process is killed.'
kill smtpd
/* return to script directory */
newdir = directory(CurDir)
call LINEOUT DialupLogFile, date() time() '. Sleeping for' SleepTime
'seconds...'
call LINEOUT DialupLogFile, date() time() 'End of the script'
call LINEOUT DialupLogFile
/* And we will take some rest before working again */
say '--------------------------------------------------------------------'
say 'Sleeping for' SleepTime 'seconds at' time() 'on' date() '...'
say '--------------------------------------------------------------------'
call SysSleep(SleepTime)
/* Now it's time to create the semafore file your mailer is waiting */
rc = stream(SemaMailer, 'c', 'open')
rc = lineout(SemaMailer, 'inetmail semafore file')
---
* Origin: Island's BBS, a Node in the Atlantic Ocean (2:326/2)
|