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 $? }
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.