ive finally figured out how to get my qmail box to relay to different hosts
depending on wether it can ping them or not.. Its not pretty and I havent tested
it extensively yet, but it seems to work.. If anyone has any
suggestions/improvements, please let me know..
The thing is, you have 2 different smtproutes files, one that points to your
normal internal mail server, and one that points to your backup server.
Just put this into a file, chmod 755 it, and run it as a cron job every hour (or
whenever)..
It will also timestamp when it went to the backup server in
/var/log/redundant.log
put the ip address of the main host that you relay to in the host variable. You
also have to have 2 smtproutes files
smtproutes1 has the domains that you receive for and the main server that you
want to relay to.
smtproutes2 has the domains that you receive for and the backup server that you
want to relay to.
when it can ping the main server again, it will swap the smtproutes back. I
guess it would be better for it to test for an opening on port 25 instead of a
ping cause a server can obviously still be up (pingable) and not be running SMTP
services. If you know how to do that, please let me know.

regards,
Jason


#!/bin/sh
# script to test wether a host is alive or not
# Jason Welsh 7/27/99
# [EMAIL PROTECTED]
host="XXX.XXX.XXX.XXX"
today=`date`

ping -n -c 1 $host >/dev/null 2>&1
if (test $? -eq 0) then
#test is true (host is up)
   cp -f /var/qmail/control/smtproutes1 /var/qmail/control/smtproutes
else
#test is false (host is down)
   cp -f /var/qmail/control/smtproutes2 /var/qmail/control/smtproutes
   echo $today"  switched to backup mail host" >> /var/log/redundant.log
fi


Reply via email to