-
Notifications
You must be signed in to change notification settings - Fork 34
/
sympasoap
executable file
·170 lines (156 loc) · 4.28 KB
/
sympasoap
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh
#
# sympasoap Sympa SOAP Interface
#
# Written by IKEDA Soji 2011-10-20
#
# chkconfig: 345 95 05
# description: sympa is a powerful mailing lists management system.
if [ -f /etc/rc.d/init.d/functions ]; then
# Source function library.
. /etc/rc.d/init.d/functions
## Set a flag
use_functions=1
fi
# SympaSOAP parameters
# SympaSOAP binaries directory
sympafcgidir="/usr/libexec/sympa"
# Sympa config files directory
sympaconf="/etc/sympa/sympa.conf"
FCGI_CHILDREN=5
FCGI_USER=sympa
FCGI_GROUP=sympa
FCGI_PID_DIR=/var/run/sympa
FCGI_OPTS='-s /var/run/sympa/sympasoap.socket -M 0600 -U nginx'
if [ -e /etc/sysconfig/sympa ]; then
. /etc/sysconfig/sympa
fi
# Current state of SympaSOAP
sympasoap_status() {
if [ ${use_functions} ]; then
status sympasoap
else
if [ -f ${FCGI_PID_DIR}/sympasoap.pid ]; then
pid=`cat ${FCGI_PID_DIR}/sympasoap.pid | perl -pe0777 'chomp $_; s/\s+/|/g'`
if [ "$pid" != "" ]; then
running=`ps -A | egrep "$pid"`
if [ "$running" != "" ]; then
echo "$1 (pid(s) $pid) is active..."
return 0
else
echo "$1 died, pid file remains."
return 1
fi
fi
fi
echo "$1 is stopped."
return 3
fi
}
# Start SympaSOAP
sympasoap_start() {
sympasoap_status > /dev/null
rc=$?
case "$rc" in
3)
echo -n "Starting sympasoap: "
;;
1)
echo -n "Starting sympasoap, overwriting old pid file."
;;
0)
echo "SympaSOAP seems active. No action will be taken."
echo "Try \"sympasoap status\" or \"sympasoap restart"\".
return
esac
/usr/bin/spawn-fcgi -F ${FCGI_CHILDREN} -P ${FCGI_PID_DIR}/sympasoap.pid \
-u ${FCGI_USER} -g ${FCGI_GROUP} ${FCGI_OPTS} -- \
${sympafcgidir}/sympa_soap_server.fcgi
}
# Stop SympaSOAP
sympasoap_stop() {
if [ -f ${FCGI_PID_DIR}/sympasoap.pid ]; then
runcount=0
pids=`cat ${FCGI_PID_DIR}/sympasoap.pid`
if [ "$pids" != "" ]; then
for pid in "$pids"; do
killcount=0
running=`ps -A | grep "$pid ..* sympasoap"`
while [ "$running" != "" ]; do
if [ $killcount -gt 10 ]; then
if [ ${use_functions} ]; then
failure
else
echo 'failure'
fi
return 3
fi
kill -TERM $pid >/dev/null 2>&1
running=`ps -A | grep "$pid ..* $1\\.pl"`
if [ "$running" = "" ]; then
runcount=`expr $runcount + 1`
break
fi
sleep 2
running=`ps -A | grep "$pid ..* $1\\.pl"`
if [ "$running" = "" ]; then
runcount=`expr $runcount + 1`
break
fi
killcount=`expr $killcount + 1`
done
done
fi
if [ $runcount -gt 0 ]; then
if [ ${use_functions} ]; then
success
else
echo 'success'
fi
else
echo 'died'
fi
echo
else
echo "Module $1.pl not running"
fi
return 0
}
# Check config files
[ -d $sympafcgidir ] || exit 0
[ -f $sympaconf ] || exit 0
# See how we were called.
case "$1" in
start)
if [ ! -f /var/lock/subsys/sympasoap ]; then
echo "Starting SympaSOAP: "
sympasoap_start
touch /var/lock/subsys/sympasoap
echo
else
echo "SympaSOAP seems active. No action will be taken."
echo "Try \"sympasoap status\" or \"sympasoap restart"\".
fi
;;
stop)
echo "Stopping SympaSOAP: "
sympasoap_stop
if [ -f /var/lock/subsys/sympasoap ]; then
rm -f /var/lock/subsys/sympasoap
fi
;;
status)
echo "Status of SympaSOAP: "
sympasoap_status
;;
restart)
echo "Restarting SympaSOAP: "
$0 stop && $0 start
echo
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0