updated on Thu Jan 12 08:01:00 UTC 2012
[aur-mirror.git] / sympa / sympa.rc
blob1ded8f6c3bd2ddf5a137b32ef777f5501bd1ffb2
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 # Sympa parameters
7 # Sympa binaries directory
8 sympadir="/srv/sympa/bin"
10 # Sympa config files directory
11 sympaconf="/srv/sympa/etc/sympa.conf"
12 wwsympaconf="/srv/sympa/etc/wwsympa.conf"
14 # Current state of the module
15 sympa_status() {
16 # First try "/u1/home/sympa/*.pid" files
17 if [ -f /srv/sympa/$1.pid ] ; then
18 pid=`head -1 /srv/sympa/$1.pid`
19 if [ "$pid" != "" ] ; then
20 running=`ps -A | sed 's/^ *//' | cut -d ' ' -f 1 | grep -x "$pid"`
21 if [ "$running" != "" ]; then
22 echo "$1 (pid $pid) is active..."
23 return 0
24 else
25 echo "$1 died, pid file remains."
26 return 1
30 echo "$1 is stopped."
31 return 3
34 # Start a module
35 sympa_module_start() {
36 $sympadir/$1.pl $startparam
37 return $?
40 # Test state of module before startup
41 sympa_start() {
42 sympa_status $1 > /dev/null
43 case "$?" in
45 stat_busy "Starting $1"
46 sympa_module_start $1 && stat_done || stat_fail
49 stat_busy "Starting $1, overwriting old pid file."
50 sympa_module_start $1 && stat_done || stat_fail
53 stat_fail
54 echo "$1 seems active. No action will be taken."
55 echo "Try \"/etc/rc.d/sympa status\" or \"/etc/rc.d/sympa restart"\".
57 esac
60 # Stop a module
61 sympa_stop() {
62 if [ -f /srv/sympa/$1.pid ]; then
63 stat_busy "Stopping module $1.pl"
64 pid=`head -1 /srv/sympa/$1.pid`
65 running=`ps -A | sed 's/^ *//' | cut -d ' ' -f 1 | grep -x "$pid"`
66 if [ $1 == 'bulk' ]; then
67 kill -TERM $pid && stat_done || stat_fail
68 else
69 if [ "$running" != "" ]; then
70 kill -TERM $pid && stat_done || stat_fail
71 else
72 stat_fail
75 else
76 echo "Module $1.pl not running"
80 # See how we were called.
81 case "$1" in
82 start)
83 if [ ! -f /srv/sympa/var/lock/subsys/sympa ]; then
84 echo "Starting Sympa subsystem: "
85 sympa_start sympa
86 sympa_start bulk
87 sympa_start archived
88 sympa_start bounced
89 sympa_start task_manager
90 touch /srv/sympa/var/lock/subsys/sympa
91 add_daemon sympa
92 else
93 echo "Sympa seems active. No action will be taken."
94 echo "Try \"sympa status\" or \"sympa restart"\".
97 stop)
98 echo "Stopping Sympa subsystem: "
99 sympa_stop bounced
100 sympa_stop archived
101 sympa_stop bulk
102 sympa_stop sympa
103 if [ -f /srv/sympa/sympa-distribute.pid ]; then
104 sympa_stop sympa-distribute
106 if [ -f /srv/sympa/sympa-creation.pid ]; then
107 sympa_stop sympa-creation
109 sympa_stop task_manager
110 if [ -f /srv/sympa/var/lock/subsys/sympa ]; then
111 rm -f /srv/sympa/var/lock/subsys/sympa
113 rm_daemon sympa
115 status)
116 echo "Status of Sympa subsystem: "
117 if [ -f /srv/sympa/var/lock/subsys/sympa ]; then
118 echo "Status file for subsystem found."
119 else
120 echo "Status file for subsystem NOT found."
122 sympa_status sympa
123 sympa_status bulk
124 sympa_status archived
125 sympa_status bounced
126 sympa_status task_manager
128 restart)
129 echo "Restarting Sympa subsystem: "
130 $0 stop
131 sleep 3
132 $0 start
133 echo
136 echo "usage: $0 {start|stop|status|restart}"
137 exit 1
139 esac