/network/if-down.d/postfix

http://github.com/brinkman83/bashrc · Shell · 34 lines · 21 code · 6 blank · 7 comment · 6 complexity · 52275dc23864f3bfca412c7558e28fe6 MD5 · raw file

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