PageRenderTime 70ms CodeModel.GetById 65ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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