#! /bin/sh
certfiles=$(postconf -n | awk -F " = " '$1 ~ /(cert|key)_file/ {print $2}' | sort -u)
reload=false
for f in $certfiles; do
  if [ -f "$f" ]; then
    if [ /var/spool/postfix/pid/master.pid -ot "$f" ]; then
      reload=true
    fi
  fi
done
if $reload; then
  echo "postfix master.pid file older than certificates; restart required!"
  service postfix restart
fi
