-
Notifications
You must be signed in to change notification settings - Fork 1
/
mailman3.service
53 lines (48 loc) · 1.9 KB
/
mailman3.service
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
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to use "override.conf" menthod
[Unit]
Description=GNU Mailing List Manager 3
After=syslog.target network.target postfix.service
ConditionFileNotEmpty=@ETCDIR@/settings.py
ConditionPathIsDirectory=@ETCDIR@
ConditionPathIsDirectory=@VARDIR@
[Service]
Type=forking
PIDFile=@RUNDIR@/master.pid
User=@MMUSER@
Group=@MMGROUP@
Environment="PYTHONPATH=@PYTHONPATH@"
ExecStart=@BINDIR@/mailman start --force
ExecReload=@BINDIR@/mailman restart
ExecStop=@BINDIR@/mailman stop
TimeoutStartSec=150
# wait until listening ports are up
ExecStartPost=/usr/bin/sh -c ' \
i=0; lmtp=0; restapi=0; timeout=120; \
echo "GNU Mailing List Manager 3 daemon started, waiting $timeout sec for port listen: LMTP(tcp/@LMTPPORT@) and RESTAPI(tcp/@RESTAPIPORT@)"; \
while [ $i -lt $timeout -a $[ $lmtp + $restapi ] -lt 2 ]; do \
if [ $lmtp -eq 0 ]; then \
if /usr/sbin/ss -H -t -l -n sport = :@LMTPPORT@ | grep -q "^LISTEN.*:@LMTPPORT@"; then \
echo "GNU Mailing List Manager 3 daemon started, port listen after $i sec: LMTP(tcp/@LMTPPORT@)"; \
lmtp=1; \
fi; \
fi; \
if [ $restapi -eq 0 ]; then \
if /usr/sbin/ss -H -t -l -n sport = :@RESTAPIPORT@ | grep -q "^LISTEN.*:@RESTAPIPORT@"; then \
echo "GNU Mailing List Manager 3 daemon started, port listen after $i sec: RESTAPI(tcp/@RESTAPIPORT@)"; \
restapi=1; \
fi; \
fi; \
sleep 1; i=$[ i + 1 ]; \
done ; \
if [ $lmtp -eq 0 ]; then \
echo "GNU Mailing List Manager 3 daemon started, missing port listen after $timeout sec: LMTP(tcp/@LMTPPORT@)"; \
fi; \
if [ $restapi -eq 0 ]; then \
echo "GNU Mailing List Manager 3 daemon started, missing port listen after $timeout sec: RESTAPI(tcp/@RESTAPIPORT@)"; \
fi; \
if [ $lmtp -eq 0 -o $restapi -eq 0 ]; then exit 1; fi; \
'
[Install]
WantedBy=multi-user.target