1 |
On Sun, 24 May 2009 15:37:51 +0200 |
2 |
Jarry <mr.jarry@×××××.com> wrote: |
3 |
|
4 |
> Mike Kazantsev wrote: |
5 |
> |
6 |
> > Looks like there's a line in "stop" section that kills the script |
7 |
> > itself. Try looking for a lines like these: |
8 |
> > pkill MailScanner |
9 |
> > killall MailScanner |
10 |
> > start-stop-daemon --stop --name MailScanner |
11 |
> |
12 |
|
13 |
... |
14 |
|
15 |
> depend() { |
16 |
> need net mta |
17 |
> use logger dns } |
18 |
|
19 |
|
20 |
That's what probably starts sendmail as a dependency (mta), so if you |
21 |
want to stop both MailScanner and sendmail you can just use |
22 |
|
23 |
/etc/init.d/sendmail stop |
24 |
|
25 |
...or something like that (I'm not sure about initscript name for |
26 |
sendmail) - it should stop everything that depends on sendmail |
27 |
(including MailScanner) then the sendmail itself. |
28 |
|
29 |
|
30 |
> stop() { |
31 |
> ebegin "Stopping MailScanner" |
32 |
|
33 |
And here's the killer line: |
34 |
|
35 |
> killall -15 MailScanner |
36 |
|
37 |
|
38 |
I'd still suggest looking through available docs to see if the app can |
39 |
create pidfile for itself and replacing that line with following: |
40 |
|
41 |
start-stop-daemon --stop -p /path/to/pidfile |
42 |
|
43 |
It'll give error code if it won't find the process, just as killall |
44 |
does. |
45 |
"-15" is SIGTERM (I guess that's true for all gentoo platforms) and is |
46 |
default for nearly all kill-like commands, so there's little need to |
47 |
specify it explicitly in gentoo. |
48 |
|
49 |
|
50 |
And if you want a faster solution, I see at least two options: |
51 |
|
52 |
1. Looking at "ps aux | grep MailScanner" output to see exact |
53 |
invocation line and using one of the following: |
54 |
|
55 |
start-stop-daemon --stop --exec /path/to/bin/MailScanner |
56 |
pkill -f /path/to/bin/MailScanner |
57 |
|
58 |
I'd prefer first one, for consistency. |
59 |
|
60 |
2. Just rename init.d script to something w/o MailScanner in it's name. |
61 |
It might break something only if any other scripts depend on this |
62 |
one, but it sure looks like the easiest way to me ;) |
63 |
|
64 |
|
65 |
> RETVAL=$? |
66 |
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner |
67 |
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off |
68 |
> eend ${RETVAL} |
69 |
> } |
70 |
|
71 |
... |
72 |
|
73 |
> Don't know exactly how sendmail is started, but according to |
74 |
> MailScanner install messages, I had to remove it from default |
75 |
> runlevel. MailScanner itself takes care of starting sendmail... |
76 |
|
77 |
|
78 |
That seems strange, since sendmail should be already started as a |
79 |
dependency anyway, so it shouldn't hurt to have it at any runlevel. |
80 |
|
81 |
But since there's a check on killall and you've mentioned |
82 |
self-restarting mechanism, I guess it might indeed restart itself and |
83 |
sendmail independently of init-scripts, so removing sendmail from |
84 |
runlevel serves exactly one purpose: it's init-script won't fail if the |
85 |
process won't be there. |
86 |
|
87 |
Also it looks like leaving sendmail running after MailScanner itself |
88 |
was closed is expected behaviour or app (not initscript) bug, since |
89 |
there's no mention of sendmail stopping in the script (unless it checks |
90 |
that /var/lock paths) and MailScanner didn't close it upon receiving |
91 |
SIGTERM, which seem to be expected way to stop it. |
92 |
|
93 |
|
94 |
All in all, I think there's no reason to worry about why and how |
95 |
sendmail is started as long as it works, so bogus killall line should |
96 |
be the only wrong thing here. |
97 |
|
98 |
|
99 |
-- |
100 |
Mike Kazantsev // fraggod.net |