aboutsummaryrefslogtreecommitdiffstats
path: root/main/opensmtpd/smtpd.initd
blob: ae55a7a73dbc8d38261aba3acb68505ef8cfb77d (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
#!/sbin/openrc-run

name="OpenSMTPD"
extra_commands="checkconfig"
description_checkconfig="Check configuration file for errors"

command=/usr/sbin/smtpd
[ "$use_pam" = yes ] && command=/usr/sbin/smtpd-pam

command_args="-F ${command_args:-$SMTPD_OPTS}"  # SMTPD_OPTS is deprecated
command_background=yes

pidfile=/run/$RC_SVCNAME.pid
required_files=/etc/smtpd/smtpd.conf

depend() {
	need net localmount
	after bootmisc firewall
	use logger dns
	provide mta
}

start_pre() {
	checkconfig
}

checkconfig() {
	if [ "$use_pam" = yes ] && [ ! -x "$command" ]; then
		eerror "\$use_pam=yes, but opensmtpd-pam is not installed"
		return 1
	fi

	ebegin "Checking $name configuration"

	# Don't output anything unless something is *not* ok.
	local out; out=$($command -n 2>&1)
	local ret=$?

	[ "$ret" -eq 0 ] || printf '%s\n' "$out" >&2
	eend $?
}