#!/bin/ksh
#
# Sendmail configuration SOLARIS 9
# send all mail to mailhost alias "SMTP RELAY"
# run sendmail in non-demon mode
#
# [email protected]
# 18/01/04
#
#=========================================================================
# Backup files
#=========================================================================
cp /etc/mail/submit.cf /etc/mail/_submit.cf
#=========================================================================
# Disable daemon mode
#=========================================================================
print "MODE=" > /etc/default/sendmail
#=========================================================================
# edit /usr/lib/mail/cf/submit.mc
# Complie m4 macro
# replace
#=========================================================================
cd /usr/lib/mail/cf/
/usr/bin/sed 's/127.0.0.1/mailhost/g' submit.mc > submit-mailhost.mc
/usr/ccs/bin/m4 ../m4/cf.m4 submit-mailhost.mc > /etc/mail/submit.cf
cd - > /dev/null
#=========================================================================
# stop/start sendmail
#=========================================================================
/etc/init.d/sendmail stop
/etc/init.d/sendmail start
print "Mail setup complete"
#=========================================================================
# test for mailhost entry
#=========================================================================
print "Testing mail"
/usr/bin/getent hosts mailhost > /dev/null
if (( $? == 0 ))
then
print "MAILHOST alias OK"
else
print "MAILHOST alais not found"
print "Check DNS/resolv.conf/nsswitch.conf etc..."
fi
#=========================================================================
# send test mail ?
#=========================================================================
read MAILTEST?"Send test mail to [email protected] (y/n)"
if [[ $MAILTEST = [yY] ]]
then
/usr/bin/mailx -s "test-`uname -n`" [email protected] < /dev/null
fi