forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qpsmtpd.initd
62 lines (57 loc) · 2.01 KB
/
qpsmtpd.initd
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
#!/sbin/openrc-run
pidfile=/var/run/qpsmtpd/qpsmtpd.pid
depend() {
use logger dns ypbind amavisd mysql postgresql antivirus postfix_greylist net saslauthd
provide mta
}
checkconfig() {
if ! [ -d "${QPSMTPD_CONFIG:-/etc/qpsmtpd}" ]; then
eerror "Configuration directory ${QPSMTPD_CONFIG:-/etc/qpsmtpd} does not exist."
return 1
fi
return 0
}
start() {
checkconfig || return 1
ebegin "Starting qpsmtpd [${QPSMTPD_SERVER_TYPE}] server"
HOME="/var/spool/qpsmtpd"
local QPSMTPD_SERVER_BIN=""
local myopts=""
export QPSMTPD_CONFIG=${QPSMTPD_CONFIG}
for foo in PERL_UNICODE LANG LC_TIME LC_ALL BASH_ENV ENV CDPATH IFS
do
unset ${foo}
done
case "${QPSMTPD_SERVER_TYPE}" in
prefork)
QPSMTPD_SERVER_BIN="/usr/bin/qpsmtpd-prefork"
QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:\-\-pid\-file[\t ]\{1,99\}[^ ]*::gI")"
# Option --pid-file is mentioned in the help of the prefork server
# but does not work when specified.
# QPSMTPD_OPTIONS="${QPSMTPD_OPTIONS} --pid-file ${pidfile}"
myopts="${myopts} --make-pidfile --pidfile ${pidfile}"
;;
async)
QPSMTPD_SERVER_BIN="/usr/sbin/qpsmtpd-async"
myopts="${myopts} --background --make-pidfile --pidfile ${pidfile}"
;;
forkserver|*)
QPSMTPD_SERVER_BIN="/usr/bin/qpsmtpd-forkserver"
QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:\-\-pid\-file[\t ]\{1,99\}[^ ]*::gI")"
QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:[\t ]\{0,99\}\-d[\t ]\{1,99\}|[\t ]\{1,99\}\-d[\t ]\{0,99\}::gI")"
QPSMTPD_OPTIONS="$(echo "${QPSMTPD_OPTIONS}" | sed "s:[\t ]\{0,99\}\-\detach[\t ]\{1,99\}|[\t ]\{1,99\}\-\-detach[\t ]\{0,99\}::gI")"
QPSMTPD_OPTIONS="${QPSMTPD_OPTIONS} --pid-file ${pidfile} --detach"
myopts="${myopts} --pidfile ${pidfile}"
;;
esac
start-stop-daemon --start --nicelevel ${QPSMTPD_NICELEVEL:-0} \
--quiet ${myopts} \
--exec ${QPSMTPD_SERVER_BIN} \
-- ${QPSMTPD_OPTIONS}
eend $?
}
stop() {
ebegin "Stopping qpsmtpd [${QPSMTPD_SERVER_TYPE}] server"
start-stop-daemon --stop --quiet --pidfile ${pidfile}
eend $?
}