Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 278934 - mail-filter/MailScanner: Possible changes for the MailScanner startup script
Summary: mail-filter/MailScanner: Possible changes for the MailScanner startup script
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Markus Ullmann (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-24 15:15 UTC by Mauricio
Modified: 2010-03-16 19:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauricio 2009-07-24 15:15:35 UTC
When I try to quit mailscanner using /etc/init.d/MainScanner, it seems not to do it completely/cleanly. Among other things, it is not deleting /var/run/mailscanner.pid when it quits. So, when it tries to start, it sees the .pid file and assumes that it must be running. 

Reproducible: Always

Steps to Reproduce:
1.Install postfix and mailscanner using emerge
2.Start mailscanner as usual
3.Try to stop it

Actual Results:  
mail ~ # /etc/init.d/MailScanner stop
* Stopping MailScanner^[[K...
* MailScanner: caught SIGTERM, aborting^[[K
mail ~ # /etc/init.d/MailScanner status
* status: started
mail ~ # ps aux | grep -i MailScanner
root      6754  0.0  0.0   6092   596 pts/2    S+   10:54   0:00 grep --colour=auto -i MailScanner
main ~ # /etc/init.d/MailScanner start
* WARNING: MailScanner has already been started
main ~ # 


Expected Results:  
It should have quit postfix and itself, but it thinks it is still running.

I rewrote the startup script a bit so I can use it, and am including it below. It is not pretty code, but at least it may provide you with a few ideas. The reload function I have not touched; please modify it as needed. 

#!/sbin/runscript

opts="reload"
                                                                                
depend() {
        need net
        use logger dns
}
                                                                                
start() {
        ebegin "Starting postfix"
        /usr/sbin/postfix start &>/dev/null
        eend $?
        ebegin "Starting MailScanner"
        /sbin/start-stop-daemon --quiet \
                --start --startas /usr/sbin/check_MailScanner 
        [ -f /var/lock/subsys/MailScanner.off ] && { rm /var/lock/subsys/MailScanner.off ; touch /var/lock/subsys/MailScanner; }
        eend $?
}

stop() {
        ebegin "Stopping MailScanner"
        start-stop-daemon --quiet --stop --exec /usr/sbin/MailScanner \
                --pidfile /var/run/mailscanner.pid
        [ -f /var/lock/subsys/MailScanner ] && { rm /var/lock/subsys/MailScanner ; touch /var/lock/subsys/MailScanner.off; }
        eend $?
        ebegin "Stopping postfix"
        /usr/sbin/postfix stop &>/dev/null
        eend $?
}

reload() {
        ebegin "Reloading postfix"
                /usr/sbin/postfix reload &>/dev/null
        eend $?
        ebegin "Reloading MailScanner workers:"
                pid=`pidof -x MailScanner`
                if [ -n "$pid" ] ;
                then
                        /bin/kill -HUP $pid
                fi
        eend $?
}
Comment 1 Patrick Lauer gentoo-dev 2010-03-16 19:32:39 UTC
I don't see why it should stop postfix (and the way you do it is pretty much wrong as it sidesteps the postfix init script)
If you want that to handle postfix too you could add 
"use MailScanner"
to the depend() function of the postfix init script.

I've sanitized the startup/stop behaviour to be proper now, so at least that should make you happy.