[Exim] queryprogram problem

Etusivu
Poista viesti
Vastaa
Lähettäjä: Chris Keane
Päiväys:  
Vastaanottaja: exim-users
Aihe: [Exim] queryprogram problem
Hi. Sorry if this is covered in the archives/FAQ, but I had a look and
couldn't find it anywhere.

I have exim-3.13 installed on a laptop, where I'd like to route all
outgoing mail via a smart host, but where the smart host changes depending
on which interfaces are active at the time (eth0 when I'm at work, ppp0
when I'm dialled up from home, etc.)

I reckon I should be able to achieve this with a queryprogram router thus:

  queryprog:
    driver = queryprogram
    command = /path/to/mail-route


where /path/to/mail-route contains the following:

#!/bin/sh
#
# Script to help exim decide where to route outgoing mail.
#

  addrcheck() {
    ipaddr="`echo $2 | /bin/sed 's/\./\\\./g'`"
    /sbin/ifconfig $1 2>/dev/null | /bin/egrep "inet addr:$ipaddr[     ]" >/dev/null
  }


addrcheck eth0 1.2.3.4 && echo "OK some_transport" && exit 0
addrcheck ppp0 5.6.7.8 && echo "OK remote_smtp smtp.host.ispA bydns_a" && exit 0
addrcheck ppp0 9.8.7.6 && echo "OK remote_smtp smtp.host.ispB bydns_a" && exit 0
echo "DEFER no external link at present"
exit 0

Unfortunately this doesn't work. Running with -d9 shows that
/path/to/mail-route is giving the output I'd expect, and exim says that
the message passed okay, but it seems to ignore the transport being given,
and goes on to fail with "xxx unrouteable". Unless I explicitly set the
"transport =" option in the router config, in which case that transport
always gets run, regardless of the transport output by the script.

I'm sure I must be doing something wrong - but I dunno what!
Thanks for any suggestions,

Chris.