PageRenderTime 101ms CodeModel.GetById 41ms app.highlight 2ms RepoModel.GetById 28ms app.codeStats 0ms

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