Upgrading sendmail

If you have already built and installed sendmail on your system, it is easy to upgrade to the latest version provided you saved the sendmail source tree from the previous version.

In this example, I show how to upgrade open source sendmail version 8.13.5 to version 8.13.6 on a Solaris system. These steps should work when upgrading other sendmail 8.12.x and sendmail 8.13.x releases, although you should read sendmail's RELEASE_NOTES and INSTALL files for any special configuration and installation steps.

1. Uncompress the new sendmail tarball.
$ gzip -cd sendmail.8.13.6.tar.gz | tar xvf -

2. Copy site.config.m4 (if applicable) and the MTA and MSP sendmail macro configuration (.mc) files from your previous sendmail source tree. In this example, the name of the sendmail macro configuration file is sendmail.mc.
$ cp sendmail-8.13.5/devtools/Site/site.config.m4 sendmail-8.13.6/devtools/Site/site.config.m4
$ cp sendmail-8.13.5/cf/cf/sendmail.mc sendmail-8.13.6/cf/cf/sendmail.mc
$ cp sendmail-8.13.5/cf/cf/submit.mc sendmail-8.13.6/cf/cf/submit.mc


3. Build sendmail.
$ cd sendmail-8.13.6
$ ./Build -c


4. Backup the old sendmail mail transport agent (MTA) and mail submission program (MSP) files; build the new sendmail configuration files.
# cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.`date +%Y.%m.%d`
# cp /etc/mail/submit.cf /etc/mail/submit.cf.`date +%Y.%m.%d`
# cd cf/cf

# ./Build install-cf
# cd ../..

5. Install sendmail, install the new configuration file, and restart sendmail. For minimal sendmail downtime, run the following chain of commands. Each command will proceed only if the previous command was successful (i.e. the previous command returned an exit status of 0).

# /etc/init.d/sendmail stop && ./Build install && cp cf/cf/config.cf /etc/mail/sendmail.cf && cp cf/cf/submit.cf /etc/mail/submit.cf && /etc/init.d/sendmail stop && /etc/init.d/sendmail start


Note: you may want to rebuild your sendmail database files, although they are likely compatible between minor and patch releases.

Here is a shell script I wrote named upgrade_sendmail to automate the process. Note that I include a check for Smart Table, as I use it on many of our mail servers. You should only use a similar process once you are comfortable upgrading sendmail manually.

Script usage:
$ upgrade_sendmail path_to_old_sendmail_source_tree path_to_new_sendmail_source_tree

Example:
$ upgrade_sendmail /usr/src/sendmail-8.12.10 /usr/src/sendmail-8.12.11

#!/bin/sh

printUsage() {
   echo "  Usage: `basename $0` old_source_tree new_source_tree"
   echo "Example: `basename $0` sendmail-8.13.5 sendmail-8.13.6"
   exit 1
}

compareVersions() {
   OLD_VERSION=`echo $OLD_SENDMAIL | sed 's/.*sendmail-//'`
   NEW_VERSION=`echo $NEW_SENDMAIL | sed 's/.*sendmail-//'`
   OLD_VERSION_MAJOR=`echo $OLD_VERSION | cut -d\. -f1`
   OLD_VERSION_MINOR=`echo $OLD_VERSION | cut -d\. -f2`
   OLD_VERSION_PATCH=`echo $OLD_VERSION | cut -d\. -f3`
   NEW_VERSION_MAJOR=`echo $NEW_VERSION | cut -d\. -f1`
   NEW_VERSION_MINOR=`echo $NEW_VERSION | cut -d\. -f2`
   NEW_VERSION_PATCH=`echo $NEW_VERSION | cut -d\. -f3`
   if [ "$NEW_VERSION_MAJOR" -gt "$OLD_VERSION_MAJOR" ] ; then
      :
   elif [ "$NEW_VERSION_MAJOR" -eq "$OLD_VERSION_MAJOR" ] && \
        [ "$NEW_VERSION_MINOR" -gt "$OLD_VERSION_MINOR" ] ; then
      :
   elif [ "$NEW_VERSION_MAJOR" -eq "$OLD_VERSION_MAJOR" ] && \
        [ "$NEW_VERSION_MINOR" -eq "$OLD_VERSION_MINOR" ] && \
        [ "$NEW_VERSION_PATCH" -gt "$OLD_VERSION_PATCH" ] ; then
      :
   elif [ "$NEW_VERSION_MAJOR" -eq "$OLD_VERSION_MAJOR" ] && \
        [ "$NEW_VERSION_MINOR" -eq "$OLD_VERSION_MINOR" ] && \
        [ "$NEW_VERSION_PATCH" -eq "$OLD_VERSION_PATCH" ] ; then
      echo "Version $OLD_VERSION is the same as ${NEW_VERSION}.\n"
      printUsage
   else
      echo "Version $OLD_VERSION is newer than ${NEW_VERSION}.\n"
      printUsage
   fi
}

# Command-line arguments
# $1 is the path to the old sendmail source tree.
# $2 is the path to the new sendmail source tree.
OLD_SENDMAIL=$1
NEW_SENDMAIL=$2

# If two command-line arguments were not provided, print usage and exit
[ $# -ne 2 ] && printUsage

# If either of the source directories are not accessible, exit.
if [ ! -d "$1" ] || [ ! -d "$2" ] ; then
   echo "Problem accessing old or new sendmail source directory. Exiting."
   exit 1
fi

# Compare command-line arguments to ensure that $NEW_SENDMAIL
# is a newer version than $OLD_SENDMAIL
compareVersions

export NEW_VERSION

# Copy configuration information from previous sendmail version
[ -s ${OLD_SENDMAIL}/devtools/Site/site.config.m4 ] && \
cp ${OLD_SENDMAIL}/devtools/Site/site.config.m4 \
   ${NEW_SENDMAIL}/devtools/Site/site.config.m4

if [ ! -s ${OLD_SENDMAIL}/cf/cf/sendmail.mc ] ; then
   echo "${OLD_SENDMAIL}/cf/cf/sendmail.mc not found. Exiting."
   exit 1
fi

cp ${OLD_SENDMAIL}/cf/cf/sendmail.mc \
   ${NEW_SENDMAIL}/cf/cf/sendmail.mc

cp ${OLD_SENDMAIL}/cf/cf/submit.mc \
   ${NEW_SENDMAIL}/cf/cf/submit.mc

# Copy smarttable.m4 to ${NEW_SENDMAIL}, if applicable
[ -s ${OLD_SENDMAIL}/cf/feature/smarttable.m4 ] && \
cp ${OLD_SENDMAIL}/cf/feature/smarttable.m4 \
   ${NEW_SENDMAIL}/cf/feature/smarttable.m4

# Build sendmail
cd ${NEW_SENDMAIL}
echo "Building sendmail $NEW_VERSION...\n"
PATH=$PATH:/usr/ccs/bin ./Build -c
if [ $? -eq 1 ] ; then
   echo "\nsendmail $NEW_VERSION build failed. Exiting."
   exit 1
fi

# Build new sendmail.cf file
cd cf/cf
echo "\nBuilding sendmail $NEW_VERSION sendmail.cf configuration file...\n"
PATH=$PATH:/usr/ccs/bin ./Build sendmail.cf
if [ $? -eq 1 ] ; then
   echo "\nsendmail $NEW_VERSION sendmail.cf configuration file build failed. Ex
iting."
   exit 1
fi

# Build new submit.cf
echo "\nBuilding sendmail $NEW_VERSION submit.cf configuration file...\n"
PATH=$PATH:/usr/ccs/bin ./Build submit.cf
if [ $? -eq 1 ] ; then
   echo "\nsendmail $NEW_VERSION submit.cf configuration file build failed. Exit
ing."
   exit 1
fi

cd ../..

echo "\nThe root password is required to complete sendmail $NEW_VERSION \
installation."

/bin/su root -c 'echo "\nInstalling sendmail ${NEW_VERSION}...\n"; \
   /etc/init.d/sendmail stop && \
   PATH=$PATH:/usr/ccs/bin ./Build install && \
   cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.`date +%m.%d.%y` && \
   cp /etc/mail/submit.cf /etc/mail/submit.cf.`date +%m.%d.%y` && \
   cd cf/cf && \
   cp sendmail.cf /etc/mail/sendmail.cf && \
   cp submit.cf /etc/mail/submit.cf && \
   /etc/init.d/sendmail stop && \
   /etc/init.d/sendmail start'
[ $? -eq 1 ] && echo "\nsendmail $NEW_VERSION installation failed." && \
   exit 1

echo "\nUpgrade from sendmail $OLD_VERSION to sendmail $NEW_VERSION complete."
unset NEW_VERSION

Back to brandonhutchinson.com.
Last modified: 2006/03/22