Derek, I already took a shot at extending Andrew's script for use with Exim. Have a look at my updated version of "setmailrelay", it's not complete but works in my setup. We'll need to make it a bit more robust (handling the standard distributed config file of Exim in which the "queue_remote_domains" option isn't mentioned.
Auke On Wed, Oct 30, 2002 at 09:03:17AM -0400, Derek Broughton wrote: > From: "Andrew McMillan" <[EMAIL PROTECTED]> > > Unfortunately it isn't quite that straightforward. The setmailrelay > > script needs to update the configuration file for exim, make changes so > > that mail is relayed differently, and then restart it. > > > > It isn't _hard_ but Exim isn't compatible with sendmail at the > > configuration file level, unless I miss my guess. > > oh... 'fraid so. The Exim configuration is, imo, a whole lot simpler > - but that doesn't mean applying config changes for sendmail is going > to work :-) Having opened my mouth when I shouldn't, I'll take a look > at setmailrelay and see what it would need to work with Exim :-) > > derek -- PGP: 0x4A34DD6D, http://bunny.sourceforge.net/
#!/bin/bash # This script was written originally by Jos Visser http://www.josv.com/~josv/ # and I have modified it a little to make it slightly more generic # - Andrew McMillan 10 August 1999 # Postfix support by Chris Halls, August 2001 # # Usage: # setmailrelay none # - You have a permanent internet connection, do not use a mail relay # setmailrelay <relay> # - Relay to specified host # setmailrelay queue [<relay>] # - Do not send, place on the queue. When the queue is flushed, mail # will be relayed to <relay>, or $DEFAULT_RELAY if not specified # Where are the config files for your mailer? Can override in mail-relay.conf SENDMAIL_CONFFILE=/etc/mail/sendmail.cf POSTFIX_CONFFILE=/etc/postfix/main.cf EXIM_CONFFILE=/etc/exim/exim.conf . /etc/whereami/mail-relay.conf RELAY="$1" QUEUE_RELAY="${2:-${DEFAULT_RELAY}}" # check for a "parameter=" line in a file, add it if it does not exist # check_for_line(file, parameter) check_for_parameter() { FILE="$1" PARAM="$2" if egrep -q "^$PARAM *=" "$FILE" ; then : else echo "$PARAM=" >> "$FILE" fi } echo "Setting mail relay host ($RELAY)" if [ -f $SENDMAIL_CONFFILE ] ; then if [ -f /var/run/sendmail.pid ]; then pid=$(head -1 /var/run/sendmail.pid) kill $pid sleep 3 rm /var/run/sendmail.pid fi if [ "$RELAY" = "none" ]; then MODE=background QUEUE_RUN="-q5m" RELAY="" elif [ "$RELAY" = "queue" ]; then MODE=deferred QUEUE_RUN="" RELAY="smtp:${DEFAULT_RELAY}" else MODE=background QUEUE_RUN="-q5m" RELAY="smtp:$RELAY" fi sed -e "s/^DS.*\$/DS$RELAY/" \ -e "s/^O DeliveryMode=.*\$/O DeliveryMode=$MODE/" \ <$SENDMAIL_CONFFILE >$SENDMAIL_CONFFILE.N # Make a backup copy mv -f $SENDMAIL_CONFFILE $SENDMAIL_CONFFILE.whereami mv $SENDMAIL_CONFFILE.N $SENDMAIL_CONFFILE `which sendmail` -bd $QUEUE_RUN fi if [ -f $POSTFIX_CONFFILE ] ; then if [ "$RELAY" = "none" ]; then DEFER="" DISABLE_LOOKUPS="no" RELAY="" elif [ "$RELAY" = "queue" ]; then DEFER="smtp" DISABLE_LOOKUPS="yes" RELAY="$DEFAULT_RELAY" else DEFER="" DISABLE_LOOKUPS="yes" MODE=background RELAY="$RELAY" fi # Add paramters to config file if they do not exist check_for_parameter $POSTFIX_CONFFILE "defer_transports" check_for_parameter $POSTFIX_CONFFILE "disable_dns_lookups" check_for_parameter $POSTFIX_CONFFILE "relayhost" sed -e "s/^defer_transports *=.*\$/defer_transports=$DEFER/" \ -e "s/^disable_dns_lookups *=.*\$/disable_dns_lookups=$DISABLE_LOOKUPS/" \ -e "s/^relayhost *=.*\$/relayhost=$RELAY/" \ < $POSTFIX_CONFFILE > $POSTFIX_CONFFILE.N # Make a backup copy mv -f $POSTFIX_CONFFILE $POSTFIX_CONFFILE.whereami mv $POSTFIX_CONFFILE.N $POSTFIX_CONFFILE # Reload config /etc/init.d/postfix reload if [ "$RELAY" != "queue" ]; then # Run mail queue /etc/init.d/postfix flush fi fi if [ -f $EXIM_CONFFILE ] ; then if [ "$RELAY" = "none" ]; then DEFER="# queue_remote_domains = *" RELAY="$DEFAULT_RELAY" elif [ "$RELAY" = "queue" ]; then DEFER="queue_remote_domains = *" RELAY="$DEFAULT_RELAY" else DEFER="# queue_remote_domains = *" RELAY="$RELAY" fi # add parameters to configuration file if they do not exist #check_for_parameter $EXIM_CONFFILE "queue_remote_domains" #check_for_parameter $EXIM_CONFFILE "route_list" sed -e "s/^.*queue_remote_domains *=.*\$/$DEFER/" \ -e "s/route_list *=.*\$/route_list = \"* $RELAY bydns_a\"/" \ < $EXIM_CONFFILE > $EXIM_CONFFILE.N # make a backup copy of configuration file mv -f $EXIM_CONFFILE $EXIM_CONFFILE.whereami mv $EXIM_CONFFILE.N $EXIM_CONFFILE # reload configuration /etc/init.d/exim reload if [ "$RELAY" != "queue" ]; then # flush queued mails exim -qff fi fi
msg09270/pgp00000.pgp
Description: PGP signature