blob: aff193ac930ab30df6765b697dd32a8fcf394b17 (
plain) (
blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#!/bin/sh
#
# mta.sh - start multiple MTA instances, e.g. for MailScanner
# PROVIDE: mta
# REQUIRE: LOGIN cleanvar
# BEFORE:
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable mta at boot-up time:
# mta_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable mta
# mta_type (str): Type of MTA (sendmail, exim, unknown), defaults to "sendmail"
# mta_profiles (string): Undefined by default. Define your profiles here.
# mta_flags (str): Set to "" by default.
# Extra flags passed to start command.
# mta_program (str): Path to program, defaults depending on $mta_type
# either to "/usr/sbin/sendmail" or "/usr/local/sbin/exim"
# mta_configfile (str): Config file, defaults depending on $mta_type either
# to "/etc/mail/sendmail.cf" or "/usr/local/etc/exim/configure"
# mta_pidfile (str): PID file, defaults depending on $mta_type either
# to "/var/run/sendmail.pid" or "/var/run/exim.pid"
#
#
# Examples:
#
# Exim, 2 instances (for MailScanner):
#
# mta_enable="YES"
# mta_type="exim"
# mta_profiles="incoming outgoing"
# mta_incoming_configfile="/usr/local/etc/exim/configure.in"
# mta_incoming_flags="-bd"
# mta_incoming_pidfile="/var/run/exim_in.pid"
# mta_outgoing_configfile="/usr/local/etc/exim/configure.out"
# mta_outgoing_flags="-q15m"
# mta_outgoing_pidfile="/var/run/exim_out.pid"
#
# Sendmail, 3 instances (for MailScanner):
#
# mta_enable="YES"
# mta_type="sendmail"
# mta_profiles="incoming outgoing submitqueue"
# mta_incoming_flags="-L sm-mta-in -bd -OPrivacyOptions=noetrn -OQueueDirectory=/var/spool/mqueue.in -ODeliveryMode=queueonly"
# mta_incoming_pidfile="/var/run/sendmail_in.pid"
# mta_outgoing_flags="-L sm-mta-out -q15m"
# mta_outgoing_pidfile="/var/run/sendmail_out.pid"
# mta_submitqueue_flags="-L sm-msp-queue -Ac -q15m"
# mta_submitqueue_pidfile="/var/spool/clientmqueue/sm-client.pid"
#
. %%RC_SUBR%%
name="mta"
rcvar=`set_rcvar`
load_rc_config $name
: ${mta_enable="NO"}
: ${mta_type="sendmail"}
: ${mta_flags=""}
case "${mta_type}" in
sendmail)
_mta_program="/usr/sbin/sendmail"
_mta_configfile="/etc/mail/sendmail.cf"
_mta_pidfile="/var/run/sendmail.pid"
;;
exim)
_mta_program="/usr/local/sbin/exim"
_mta_configfile="/usr/local/etc/exim/configure"
_mta_pidfile="/var/run/exim.pid"
;;
esac
: ${mta_program=${_mta_program}}
: ${mta_configfile=${_mta_configfile}}
: ${mta_pidfile=${_mta_pidfile}}
# support SIGHUP to reparse configuration file
extra_commands="reload"
# command and arguments
command="${mta_program}"
if [ -n "${2}" -o -n "$profile" ]; then
profile=${profile-$2}
export profile
if [ "x${mta_profiles}" != "x" ]; then
eval mta_configfile=\${mta_${profile}_configfile}
[ "x${mta_configfile}" = "x" ] && {
echo "You must define a configuration file (mta_${profile}_configfile)"
exit 1
}
eval mta_enable=\${mta_${profile}_enable:-YES}
eval mta_flags=\${mta_${profile}_flags:-${mta_flags}}
eval mta_configfile=\${mta_${profile}_configfile:-${mta_configfile}}
eval mta_pidfile=\${mta_${profile}_pidfile:-${mta_pidfile}}
pidfile="${_pidprefix}.${profile}.pid"
else
echo "$0: extra argument ignored"
fi
else
if [ "x${mta_profiles}" != "x" ]; then
for profile in ${mta_profiles}; do
echo "===> mta profile: ${profile}"
$0 $1 $profile
retcode=$?
if [ "$?" -ne 0 ]; then
failed="${profile} ({$retcode}) ${failed}"
else
success="${profile} ${success}"
fi
done
exit 0
fi
fi
pidfile=${mta_pidfile}
required_files="${mta_configfile}"
# select correct command arguments
case "${mta_type}" in
sendmail)
command_args="-C'${mta_configfile}' -OPidFile='${pidfile}'"
;;
exim)
command_args="-C '${mta_configfile}' -oP '${pidfile}'"
;;
*)
command_args=""
;;
esac
run_rc_command "$1"
|