On Sun, 24 May 2009 15:37:51 +0200
Jarry <[email protected]> wrote:

> Mike Kazantsev wrote:
> 
> > Looks like there's a line in "stop" section that kills the script
> > itself. Try looking for a lines like these:
> >   pkill MailScanner
> >   killall MailScanner
> >   start-stop-daemon --stop --name MailScanner
> 

...

> depend() {
>          need net mta
>          use logger dns }


That's what probably starts sendmail as a dependency (mta), so if you
want to stop both MailScanner and sendmail you can just use

  /etc/init.d/sendmail stop

...or something like that (I'm not sure about initscript name for
sendmail) - it should stop everything that depends on sendmail
(including MailScanner) then the sendmail itself.


> stop() {
>          ebegin "Stopping MailScanner"

And here's the killer line:

>          killall -15 MailScanner


I'd still suggest looking through available docs to see if the app can
create pidfile for itself and replacing that line with following:

  start-stop-daemon --stop -p /path/to/pidfile

It'll give error code if it won't find the process, just as killall
does.
"-15" is SIGTERM (I guess that's true for all gentoo platforms) and is
default for nearly all kill-like commands, so there's little need to
specify it explicitly in gentoo.


And if you want a faster solution, I see at least two options:

  1. Looking at "ps aux | grep MailScanner" output to see exact
    invocation line and using one of the following:

      start-stop-daemon --stop --exec /path/to/bin/MailScanner
      pkill -f /path/to/bin/MailScanner

    I'd prefer first one, for consistency.

  2. Just rename init.d script to something w/o MailScanner in it's name.
    It might break something only if any other scripts depend on this
    one, but it sure looks like the easiest way to me ;)


>          RETVAL=$?
>          [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
>          [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
>          eend ${RETVAL}
> }

...

> Don't know exactly how sendmail is started, but according to
> MailScanner install messages, I had to remove it from default
> runlevel. MailScanner itself takes care of starting sendmail...


That seems strange, since sendmail should be already started as a
dependency anyway, so it shouldn't hurt to have it at any runlevel.

But since there's a check on killall and you've mentioned
self-restarting mechanism, I guess it might indeed restart itself and
sendmail independently of init-scripts, so removing sendmail from
runlevel serves exactly one purpose: it's init-script won't fail if the
process won't be there.

Also it looks like leaving sendmail running after MailScanner itself
was closed is expected behaviour or app (not initscript) bug, since
there's no mention of sendmail stopping in the script (unless it checks
that /var/lock paths) and MailScanner didn't close it upon receiving
SIGTERM, which seem to be expected way to stop it.


All in all, I think there's no reason to worry about why and how
sendmail is started as long as it works, so bogus killall line should
be the only wrong thing here.


-- 
Mike Kazantsev // fraggod.net

Attachment: signature.asc
Description: PGP signature

Reply via email to