#!/bin/sh # # chng-mail_relay.sh - Swap Postfix's default mail relay as Internet # connection goes up/down - Copyright (C) 1998 by James S. Seymour # (jseymour@jimsun.LinxNet.com) (See "License", below.) # # Usage: chng-mail_relay [smtp|uucp] # # Common application: # Place this script in a super-user bin directory (i.e.: # "/usr/local/sbin") as "chng-mail_relay" and make it # "root root 500". # # Edit the variables near the beginning of this script to # suit your host's setup. ("uucpRelay", "smtpRelay" for # sure, and maybe "configFileDir" and "pfBinDir" as well) # # Place a line like "/usr/local/sbin/chng-mail_relay smtp" # in your "/etc/ppp/ip-up" or "/etc/ppp/ip-up.local" file. # (Or equivalent.) # # Place a line like "/usr/local/sbin/chng-mail_relay uucp" # in your "/etc/ppp/ip-down" or "/etc/ppp/ip-down.local" file. # (Or equivalent.) # # When your IP connection comes up, your default mail relay # will automatically be changed to the specified SMTP relay # host. When your IP connection is down, the default will # be your designated UUCP mail relay. Obviously, incoming # mail relaying, being specified by your upstream provider(s), # is unaffected. Any customization of canonical, virtual, # or transport, etc. maps/tables is unaffected. # # Caveats: # Edits the "main.cf" file in place. Makes backup copies, but # keep this in mind. If this messes-up or is interrupted, it # could leave you with a non-functional MTA! # # Makes no effort to flush anything queued for the SMTP host # before making the change. Don't think it can, really. # Unless I'm mistaken: by the time this is run, the IP connection # will already have been taken down. # # Error checking and protecting one against oneself is really # rather minimal. It would be best if you knew what you're doing! # # License: # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You may have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # # An on-line copy of the GNU General Public License can be found # http://www.fsf.org/copyleft/gpl.html.