Friday, July 25, 2008

Sendmail support - sendmailreload script

I have made this simple script you can use for your mail server when you need to activate any changes you have made to any of the config files inside the /et/mail directory. I know I have made a posting before with the script in it, but this one is a bit better, and this post is dedicated to it ;-)

Here is the script:

#!/bin/bash
MAILDIR="/etc/mail"
cd /etc/mail
makemap hash $MAILDIR/virtusertable.db < $MAILDIR/virtusertable
makemap hash $MAILDIR/mailertable.db < $MAILDIR/mailertable
makemap hash $MAILDIR/access.db < $MAILDIR/access
makemap hash $MAILDIR/aliases.db < $MAILDIR/aliases
makemap hash $MAILDIR/domaintable.db < $MAILDIR/domaintable
newaliases > /dev/null 2> /dev/null
wait
ps auxw grep sendmail grep accepting awk '{print "kill -HUP "$2}' sh
echo "Rebuild aliases run now - "`date` >> /var/log/maillog


The reason why it is better to use this script is that when you start to get a very busy mail server, with huge amount of mail in the mail queue, you don't want to restart the sendmail service everytime you made a change, rather run this script.

No comments: