sendmail
. Ensuring that all steps needed are performed
when making changes to sendmail is becoming more and more difficult,
necessitating this script.
Copy the following into a file named sendmail-restart
in
your /root/bin
dir. Be sure to chmod
it
executable.
If you'll be accessing it externally (I have a webpage that can allow
customers to manage their own email aliases, so www
needs
to be able to run this), you'll also need to set the suid sticky bit
with:
chmod u+s sendmail-restart
#!/usr/bin/perl use strict; # It looks like `sendmail -bi` is now smart enough to do the # the `newaliases` for you... # newaliases is only needed if you change the /etc/aliases file. # newaliases my @Cmds = ( "makemap -v hash /etc/mail/access.db</etc/mail/access", "makemap -v hash /etc/mail/mailertable.db</etc/mail/mailertable", "makemap -v hash /etc/mail/virtusertable.db</etc/mail/virtusertable", # I believe that '-bi' is really all that is needed, but I'm leaving # the old 'kill -HUP' just in case. "sendmail -bi", # kill is needed if you change the /etc/sendmail.cf file. # It may also be needed if you change virtusertable, but maybe not. "kill -HUP `head -1 /var/run/sendmail.pid`" ); foreach (@Cmds) { print "$_\n"; my @sysout = `$_`; my $err = 0; foreach (@sysout) { my $err = ($_ =~ /error/i); if ($err) { print "\"$_\"\n"; } } if ($err) { exit 1; } } # Note! 'newaliases' seems to be smart enough to take care of this # automatically for you... # makemap -v hash /usr/local/majordomo/aliases.majordomo</etc/mail/access