forked from sympa-community/sympa
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsympa.generic
186 lines (175 loc) · 3.95 KB
/
sympa.generic
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh
#
#
# This script starts/stops Sympa.
#
# Harald Wilhelmi TNG Technology Consulting GmbH
#
# ATTENTION:
#
# This skript works only if the following variable is kept in sync
# with a explicit configuration of the pidfile (sympa.conf),
# bounced_pidfile and archived_pidfile (wwsympa.conf) parameters!
#
pidfilepath="/dist/sympa/run"
#
# It should be quite generic and work on most UNIX-Systems. Esspecially
# it's a vailid HPUX 10.x/11.x startup skript.
#
# Arguments: start, stop, verify_up, verify_down, restart
#
# Return values (start and verify_up/stop verify_down):
# 0: Success (all are up/all are down)
# 1: Failure (including partial)
# 2: Skipped
#
sympadir="--sbindir--"
sympaconf="--CONFIG--"
start_wait=3
stop_wait=5
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Gets a module name and check is it is up.
check_up() {
if [ -r $pidfilepath/$1.pid ]
then
ps -p `cat $pidfilepath/$1.pid` | grep -q $1.pl
if [ $? -ne 0 ]
then
echo " XXX $1.pl has crashed! (pidfile without proc)"
return 1
else
return 0
fi
else
echo " XXX $1.pl is down! (no pidfile)"
return 1
fi
}
# Gets a module name and check is it is down.
check_down() {
if [ -r $pidfilepath/$1.pid ]
then
ps -p `cat $pidfilepath/$1.pid` | grep -q $1.pl
if [ $? -ne 0 ]
then
echo " XXX $1.pl has crashed! (pidfile without proc)"
return 0;
else
echo " XXX $1.pl is still up!"
return 1;
fi
else
return 0;
fi
}
# See how we were called.
case "$1" in
start)
if [ ! -d $sympadir ]; then
echo "XXX $sympadir directory not found!"
exit 2
fi
if [ ! -f $sympaconf ]; then
echo "XXX $sympaconf not found!"
exit 2
fi
if [ ! -f $pidfilepath/sympa ]; then
echo "Starting Sympa subsystem: "
echo ' *** sympa_msg.pl...'
$sympadir/sympa_msg.pl
echo ' *** bulk.pl...'
$sympadir/bulk.pl
echo ' *** archived.pl...'
$sympadir/archived.pl
echo ' *** bounced.pl...'
$sympadir/bounced.pl
echo ' *** task_manager.pl...'
$sympadir/task_manager.pl
touch $pidfilepath/sympa
sleep $start_wait
else
echo " Sympa seems active. No action will be taken."
fi
$0 verify_up
exit $?
;;
stop)
echo "Stopping Sympa subsystem: "
if [ -f $pidfilepath/sympa ]; then
kill `cat $pidfilepath/sympa_msg.pid`
if [ -f $pidfilepath/sympa.pid ]; then
kill `cat $pidfilepath/sympa.pid`
fi
if [ -f $pidfilepath/sympa-creation.pid ]; then
kill `cat $pidfilepath/sympa-creation.pid`
fi
if [ -f $pidfilepath/sympa-distribute.pid ]; then
kill `cat $pidfilepath/sympa-distribute.pid`
fi
if [ -f $pidfilepath/sympa_automatic.pid ]; then
kill `cat $pidfilepath/sympa_automatic.pid`
fi
kill `cat $pidfilepath/bulk.pid`
kill `cat $pidfilepath/archived.pid`
kill `cat $pidfilepath/bounced.pid`
kill `cat $pidfilepath/task_manager.pid`
sleep $stop_wait
else
echo " Sympa seems down. No action will be taken."
fi
$0 verify_down
value=$?
if [ $value -eq 0 -a -r $pidfilepath/sympa ]
then
rm $pidfilepath/sympa
fi
exit $value
;;
restart)
$0 stop && $0 start
exit $?
;;
verify_up)
some_are_down=0
echo "Verifying Sympa is UP:"
check_up sympa_msg || some_are_down=1
check_up bounced || some_are_down=1
check_up bulk || some_are_down=1
check_up archived || some_are_down=1
check_up task_manager || some_are_down=1
if [ $some_are_down -eq 0 ]; then
echo " All fine."
exit 0
else
echo " *** FAILURE!"
exit 1
fi
;;
verify_down)
some_are_up=0
echo "Verifying Sympa is DOWN:"
check_down sympa_msg || some_are_up=1
check_down bounced || some_are_up=1
check_down bulk || some_are_up=1
check_down archived || some_are_up=1
check_down task_manager || some_are_up=1
if [ $some_are_up -eq 0 ]; then
echo " All is down."
exit 0
else
echo " *** FAILURE!"
exit 1
fi
;;
start_msg)
echo "Starting Sympa"
exit 0
;;
stop_msg)
echo "Stopping Sympa"
exit 0
;;
esac
echo "Usage: $0 start|stop|start_msg|stop_msg|verify_up|verify_down|restart"
exit 1