/[smecontribs]/rpms/mailman/contribs7/mailman-2.1-mailmanctl-status.patch
ViewVC logotype

Contents of /rpms/mailman/contribs7/mailman-2.1-mailmanctl-status.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Tue Nov 25 16:20:13 2008 UTC (16 years ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
Error occurred while calculating annotation data.
Restore

1 diff -r -u mailman-2.1.5.orig/bin/mailmanctl mailman-2.1.5/bin/mailmanctl
2 --- mailman-2.1.5.orig/bin/mailmanctl 2004-02-03 17:26:08.000000000 -0500
3 +++ mailman-2.1.5/bin/mailmanctl 2004-09-10 18:23:34.000000000 -0400
4 @@ -35,7 +35,7 @@
5 pid directly. The `start', `stop', `restart', and `reopen' commands handle
6 everything for you.
7
8 -Usage: %(PROGRAM)s [options] [ start | stop | restart | reopen ]
9 +Usage: %(PROGRAM)s [options] [ start | stop | restart | reopen | status ]
10
11 Options:
12
13 @@ -89,6 +89,9 @@
14
15 reopen - This will close all log files, causing them to be re-opened the
16 next time a message is written to them
17 +
18 + status - This returns a string indicating the status of the master
19 + qrunner
20 """
21
22 import sys
23 @@ -189,6 +192,52 @@
24 return 0
25 return 1
26
27 +def mailman_status():
28 + # return status, pid
29 + #
30 + # These status values match the /etc/init.d status values
31 + # (at least on Red Hat), try to return equivalent status if possible
32 + # status is 0 if running,
33 + # status is 1 if dead but pid file exists
34 + # status is 2 if dead but subsys locked
35 + # status is 3 if stopped (pid returned will be 0)
36 + #
37 + #
38 + # We want any user to be able to query the status and this presents
39 + # few interesting permission problems and is why we don't use
40 + # qrunner_state(). The pidfile is only readable by the mailman owner
41 + # and group, however the lockfile is world readable. So we will
42 + # get the master pid from the lockfile. We try to determine if the
43 + # master process exists by sending it a signal. If we don't have
44 + # permission to signal the process, but the process exists we'll
45 + # get a EPERM error, if the process does not exist then we'll get
46 + # a ESRCH error.
47 +
48 + try:
49 + hostname, pid, tempfile = get_lock_data()
50 + except IOError, e:
51 + if e.errno == errno.ENOENT:
52 + # Lock file didn't exist, can't be running
53 + return 3, 0
54 + else:
55 + raise
56 + if hostname <> socket.gethostname():
57 + # not running on this host
58 + return 3, 0
59 + # Find out if the process exists by calling kill with a signal 0.
60 + try:
61 + os.kill(pid, 0)
62 + except OSError, e:
63 + if e.errno == errno.ESRCH:
64 + # process does not exist
65 + return 1, pid
66 + elif e.errno == errno.EPERM:
67 + # we don't have permission signal the process but it exists
68 + return 0, pid
69 + else:
70 + raise
71 + return 0, pid
72 +
73
74 def acquire_lock_1(force):
75 # Be sure we can acquire the master qrunner lock. If not, it means some
76 @@ -336,13 +385,15 @@
77 command = COMMASPACE.join(args)
78 usage(1, _('Bad command: %(command)s'))
79
80 + command = args[0].lower()
81 +
82 if checkprivs:
83 check_privs()
84 else:
85 - print _('Warning! You may encounter permission problems.')
86 + if command != 'status':
87 + print _('Warning! You may encounter permission problems.')
88
89 # Handle the commands
90 - command = args[0].lower()
91 if command == 'stop':
92 # Sent the master qrunner process a SIGINT, which is equivalent to
93 # giving cron/qrunner a ctrl-c or KeyboardInterrupt. This will
94 @@ -361,6 +412,14 @@
95 if not quiet:
96 print _('Re-opening all log files')
97 kill_watcher(signal.SIGHUP)
98 + elif command == 'status':
99 + status, pid = mailman_status()
100 + if not quiet:
101 + if status == 0:
102 + print _("mailman (pid %(pid)d) is running...")
103 + else:
104 + print _("mailman is stopped")
105 + sys.exit(status)
106 elif command == 'start':
107 # First, complain loudly if there's no site list.
108 check_for_site_list()
109 diff -u -r mailman-2.1.5.orig/misc/mailman.in mailman-2.1.5/misc/mailman.in
110 --- mailman-2.1.5.orig/misc/mailman.in 2003-09-25 18:13:26.000000000 -0400
111 +++ mailman-2.1.5/misc/mailman.in 2005-02-15 10:48:26.445983000 -0500
112 @@ -36,19 +36,70 @@
113 MAILMANHOME=@prefix@
114 MAILMANCTL=$MAILMANHOME/bin/mailmanctl
115
116 +# Source function library.
117 +. /etc/rc.d/init.d/functions
118 +
119 +RETVAL=0
120 +prog="mailman"
121 +
122 +function start()
123 +{
124 + echo -n $"Starting $prog: "
125 + daemon $PYTHON $MAILMANCTL -s -q start
126 + RETVAL=$?
127 + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
128 + echo
129 + return $RETVAL
130 +}
131 +
132 +function stop()
133 +{
134 + echo -n $"Shutting down $prog: "
135 + daemon $PYTHON $MAILMANCTL -q stop
136 + RETVAL=$?
137 + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
138 + echo
139 + return $RETVAL
140 +}
141 +
142 +function restart()
143 +{
144 + stop
145 + start
146 + RETVAL=$?
147 + return $RETVAL
148 +}
149 +
150 case "$1" in
151 'start')
152 - #rm -f $MAILMANHOME/locks/*
153 - $PYTHON $MAILMANCTL -s -q start
154 + start
155 + RETVAL=$?
156 ;;
157
158 'stop')
159 - $PYTHON $MAILMANCTL -q stop
160 + stop
161 + RETVAL=$?
162 ;;
163
164 'restart')
165 - $PYTHON $MAILMANCTL -q restart
166 + restart
167 + RETVAL=$?
168 + ;;
169 +
170 +'condrestart')
171 + $PYTHON $MAILMANCTL -q -u status
172 + retval=$?
173 + if [ $retval -eq 0 ]
174 + then
175 + restart
176 + RETVAL=$?
177 + fi
178 + ;;
179 +
180 +'status')
181 + $PYTHON $MAILMANCTL -u status
182 + RETVAL=$?
183 ;;
184
185 esac
186 -exit 0
187 +exit $RETVAL

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed