Friday, June 27, 2014

Devops need no words but code: How to forward all Solaris user emails to an external email account

Devops need no words but code.
smarthost=mail.sample.com
user=me
alertlist=alert@mail.sample.com
/opt/csw/bin/gsed -i "s/^DS[\s]*.*/DS $smarthost/g" /etc/mail/submit.cf
/opt/csw/bin/gsed -i "s/^DS[\s]*.*/DS $smarthost/g" /etc/mail/sendmail.cf
/opt/csw/bin/gsed -i "/$user:/d" /etc/mail/aliases
echo "$user:$alertlist" >> /etc/mail/aliases
/opt/csw/bin/gsed -i "/root:/d" /etc/mail/aliases
echo "root:$alertlist" >> /etc/mail/aliases
newaliases
svcadm restart sendmail
echo "So that we never miss again an important communication from servers" | mailx -s "`hostname` As a sysadmin I want to receive my user mail notifications in my personal email address" me
echo "So that we never miss again an important communication from servers" | mailx -s "`hostname` As a sysadmin I want to receive root mail notifications in my personal email address" root

No comments:

Followers