/network/if-up.d/postfix

http://github.com/brinkman83/bashrc · Shell · 43 lines · 28 code · 5 blank · 10 comment · 9 complexity · fccc53fc4eeeab46941ebcc95a71e766 MD5 · raw file

  1. #!/bin/sh -e
  2. # Called when a new interface comes up
  3. # Written by LaMont Jones <lamont@debian.org>
  4. # don't bother to restart postfix when lo is configured.
  5. if [ "$IFACE" = "lo" ]; then
  6. exit 0
  7. fi
  8. # If /usr isn't mounted yet, silently bail.
  9. if [ ! -d /usr/lib/postfix ]; then
  10. exit 0
  11. fi
  12. RUNNING=""
  13. # If master is running, force a queue run to unload any mail that is
  14. # hanging around. Yes, sendmail is a symlink...
  15. if [ -f /var/spool/postfix/pid/master.pid ]; then
  16. pid=$(sed 's/ //g' /var/spool/postfix/pid/master.pid)
  17. exe=$(ls -l /proc/$pid/exe 2>/dev/null | sed 's/.* //;s/.*\///')
  18. if [ "X$exe" = "Xmaster" ]; then
  19. RUNNING="y"
  20. fi
  21. fi
  22. # start or reload Postfix as needed
  23. if [ ! -x /sbin/resolvconf ]; then
  24. f=/etc/resolv.conf
  25. if ! cp $f $(postconf -h queue_directory)$f 2>/dev/null; then
  26. exit 0
  27. fi
  28. if [ -n "$RUNNING" ]; then
  29. /etc/init.d/postfix reload >/dev/null 2>&1
  30. fi
  31. fi
  32. # If master is running, force a queue run to unload any mail that is
  33. # hanging around. Yes, sendmail is a symlink...
  34. if [ -n "$RUNNING" ]; then
  35. if [ -x /usr/sbin/sendmail ]; then
  36. /usr/sbin/sendmail -q >/dev/null 2>&1
  37. fi
  38. fi