Owing to the ypbind unbound issues causing mail to be returned as no such address, I’ve created the following script which is run on all the mail servers out of crontab once a minute. The purpose of this script is to keep track of the status of ypbind, if unbound, shutdown postfix so sending mail will only get a temporary error and queue and resend. Then once a minute try to restart ypbind until it succeeds at which point restart postfix. This should prevent long outages if an update disables ypbind but forgets to re-enable when completed.
#!/bin/bash
if test -f /opt/status/ypmon.dat
then
YPSTAT_PRIOR=`cat /opt/status/ypmon.dat`
else
YPSTAT_PRIOR=”unknown”;
fi
if ypwhich > /dev/null
then
if [[ “$YPSTAT_PRIOR” == “bound” ]]
then
exit 0;
else
echo ‘Change from ypbind unbound to bound – starting postfix’
systemctl start postfix;
echo “bound” > /opt/status/ypmon.dat
exit 0;
fi
else
systemctl restart ypbind
if [[ “$YPSTAT_PRIOR” == “unbound” ]]
then
exit 0;
else
echo ‘unbound’ > /opt/status/ypmon.dat
echo ‘Change from ypbind to unbound.’
echo ‘Stopping postfix, restarting ypbind.’
systemctl stop postfix;
systemctl restart ypbind;
fi
Sorry for the formatting, the “code” option isn’t working on my copy of WordPress.