summaryrefslogtreecommitdiffstats
path: root/main/postfix/postfix.initd
blob: e578431f7df44dc651bb83ab52812012c06e9759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-mta/postfix/files/postfix.rc6.2.6,v 1.3 2011/10/24 12:52:32 eras Exp $

# Please read http://www.postfix.org/MULTI_INSTANCE_README.html for multi instance support

CONF_DIR="/etc/postfix"
CONF_OPT="${SVCNAME##*.}"
if [ -n ${CONF_OPT} -a ${SVCNAME} != "postfix" ]; then
	CONF_DIR="${CONF_DIR}.${CONF_OPT}"
fi
if [ "${CONF_DIR}" = "/etc/postfix" ]; then
	CONF_PARAM=""
	CONF_MESSAGE=""
else
	CONF_PARAM="-c ${CONF_DIR}"
	CONF_MESSAGE="(${CONF_DIR})"
fi

extra_started_commands="reload abort flush"

description_reload="Re-read configuration files. Running processes terminate at their earliest convenience."
description_abort="Stop the Postfix mail system abruptly. Running processes are signaled to stop immediately."
description_flush="Force delivery: attempt to deliver every message in the deferred mail queue."

depend() {
	use logger dns ypbind amavisd antivirus postfix_greylist net saslauthd
	after firewall
	if [ "${SVCNAME}" = "postfix" ]; then
		provide mta
	fi
}

start() {
	if [ ! -z "${CONF_PARAM}" ]; then
		einfo "Please consider updating your config for postmulti support."
	fi
	ebegin "Starting postfix ${CONF_MESSAGE}"
	if [ ! -d ${CONF_DIR} ]; then
		eend 1 "${CONF_DIR} does not exist"
		return 1
	fi
	/usr/sbin/postfix ${CONF_PARAM} start >/dev/null 2>&1
	eend $?
}

stop() {
	ebegin "Stopping postfix ${CONF_MESSAGE}"
	/usr/sbin/postfix ${CONF_PARAM} stop >/dev/null 2>&1
	eend $?
}

reload() {
	ebegin "Reloading postfix ${CONF_MESSAGE}"
	/usr/sbin/postfix ${CONF_PARAM} reload >/dev/null 2>&1
	eend $?
}

abort() {
	ebegin "Aborting postfix ${CONF_MESSAGE}"

	if service_started "${SVCNAME}"; then
		mark_service_stopped "${SVCNAME}"
	fi
	/usr/sbin/postfix ${CONF_PARAM} abort >/dev/null 2>&1
	eend $?
}

flush() {
	ebegin "Flushing postfix ${CONF_MESSAGE}"
	/usr/sbin/postfix ${CONF_PARAM} flush >/dev/null 2>&1
	eend $?
}