2 # Tis init script takes care of starting the MTA processes for use
5 opts="${opts} status reload startin startout stopin stopout restartin restartout"
8 ebegin "checking MTA availability for MailScanner"
9 if [ ${MTA} = 'sendmail' ]; then
10 if [ -f ${SENDMAIL} ]; then
14 echo "Cannot find sendmail, check /etc/conf.d/MailScanner-mta"
18 elif [ ${MTA} = "postfix" ]; then
19 if test -x ${POSTFIX} -a -f ${POSTFIXINCF}/main.cf \
20 -a -f ${POSTFIXOUTCF}/main.cf ; then
24 echo "Cannot find postfix and/or postfix configuration files,"
25 echo "Check /etc/conf.d/MailScanner-mta"
29 elif [ ${MTA} = "exim" ]; then
30 if test -x ${EXIM} -a -f ${EXIMINCF} -a -f ${EXIMSENDCF}; then
34 echo "Cannot find exim and/or exim configuration files,"
35 echo "Check /etc/conf.d/MailScanner-mta"
40 echo "Invalid MTA in /etc/conf.d/MailScanner-mta"
46 /usr/bin/newaliases > /dev/null 2>&1
48 if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then
52 for i in virtusertable access domaintable mailertable ; do
53 if [ -f /etc/mail/$i ] ; then
54 makemap hash /etc/mail/$i < /etc/mail/$i
63 if [ ${MTA} = "sendmail" ]; then
64 ( cd /var/spool/mqueue.in; rm -f xf*)
66 ${SENDMAIL} -bd -OPrivacyOptions=noetrn \
67 -ODeliveryMode=queueonly \
68 -OQueueDirectory=${INQDIR} \
72 chown ${MSPUSER}:${MSPGROUP} ${SMPID} 2> /dev/null
73 ${SENDMAIL} -L sm-msp-queue -Ac -q15m -OPidFile=${SMPID} 2> /dev/null
76 elif [ ${MTA} = "postfix" ]; then
77 ${POSTFIX} -c ${POSTFIXINCF} start 2> /dev/null
79 elif [ ${MTA} = "exim" ]; then
80 ${EXIM} -c ${EXIMINCF} start 2> /dev/null
86 if [ ${MTA} = "sendmail" ]; then
87 ${SENDMAIL} $([ -n "${QUEUETIME}" ] && echo -q${QUEUETIME}) \
90 elif [ ${MTA} = "postfix" ]; then
91 ${POSTFIX} -c ${POSTFIXOUTCF} start 2> /dev/null
93 elif [ ${MTA} = "exim" ]; then
94 ${EXIM} -c ${EXIMSENDCF} -q15m 2> /dev/null
100 if [ ${MTA} = "sendmail" ]; then
101 kill ${KILL_OPTS} `head -n 1 ${INPID}` 2> /dev/null
103 kill ${KILL_OPTS} `head -n 1 ${SMPID}` 2> /dev/null
106 elif [ ${MTA} = "postfix" ]; then
107 ${POSTFIX} -c ${POSTFIXINCF} stop 2> /dev/null
113 if [ ${MTA} = "sendmail" ]; then
114 kill ${KILL_OPTS} `head -n 1 ${OUTPID}` 2> /dev/null
116 elif [ ${MTA} = "postfix" ]; then
117 ${POSTFIX} -c ${POSTFIXOUTCF} stop 2> /dev/null
133 ebegin "Starting incoming ${MTA}"
137 if [ ${retval} -gt 0 ]; then
140 ebegin "Starting outgoing ${MTA}"
144 if [ ${retval} -gt 0 ]; then
145 echo "Will attempt to stop incoming ${MTA}"
152 if [ ${MTA} = "exim" ]; then
153 ebegin "Stopping exim"
154 killall ${KILL_OPTS} exim
157 ebegin "Stopping incoming ${MTA}"
160 ebegin "Stopping outgoing ${MTA}"
168 ebegin "Starting incoming ${MTA}"
175 ebegin "Starting outgoing ${MTA}"
182 if [ ${MTA} = "exim" ]; then
183 ebegin "Stopping incoming exim"
184 echo "It is not possible to stop only the incoming exim.";
185 echo "Please use the stop option, then use startin or startout to restart"
186 echo "the incoming or outgoing process."
189 ebegin "Stopping incoming ${MTA}"
197 if [ ${MTA} = "exim" ]; then
198 ebegin "Stopping outgoing exim"
199 echo "It is not possible to stop only the outgoing exim.";
200 echo "Please use the stop option, then use startin or startout to restart"
201 echo "the incoming or outgoing process."
204 ebegin "Stopping outgoing ${MTA}"
221 if [ ${MTA} = 'sendmail' ]; then
222 ebegin "Incoming Sendmail status"
223 pid=`head -n 1 ${INPID}`
224 alive=`ps ax | awk '{ print $1 }' | grep '^'$pid'$'`
225 if [ -z "${alive}" ]; then eend 1; else eend 0; fi
226 ebegin "Client submission Sendmail status"
227 pid=`head -n 1 ${SMPID}`
228 alive=`ps ax | awk '{ print $1 }' | grep '^'$pid'$'`
229 if [ -z "${alive}" ]; then eend 1; else eend 0; fi
230 ebegin "Outgoing Sendmail status"
231 pid=`head -n 1 ${OUTPID}`
232 alive=`ps ax | awk '{ print $1 }' | grep '^'$pid'$'`
233 if [ -z "${alive}" ]; then eend 1; else eend 0; fi
234 elif [ ${MTA} = 'postfix' ]; then
235 echo "Sorry: status is not supported for postfix"
236 elif [ ${MTA} = 'exim' ]; then
237 echo "Sorry: status is not supported for exim"
239 echo "Invalid MTA in /etc/conf.d/MailScanner-mta"
246 if [ ${MTA} = 'sendmail' ]; then
247 ebegin "Reloading Sendmail configuration"
250 elif [ ${MTA} = 'postfix' ]; then
251 ebegin "Reloading Incoming Postfix"
252 ${POSTFIX} -c ${POSTFIXINCF} reload > /dev/null
254 ebegin "Reloading Outgoing Postfix"
255 ${POSTFIX} -c ${POSTFIXOUTCF} reload > /dev/null
257 elif [ ${MTA} = 'exim' ]; then
258 echo "Sorry: reload is not supported for exim"
260 echo "Invalid MTA in /etc/conf.d/MailScanner-mta"