X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=spamassassin-spamd.init;h=404ea98be474f8df1cf98f2f07d068d626c1cdee;hb=5e2504f;hp=cf1aba9f5a028357d93f0036b28cb20187236626;hpb=55613dff1aed5f13fae960f266cb570d75c28611;p=packages%2Fspamassassin.git diff --git a/spamassassin-spamd.init b/spamassassin-spamd.init index cf1aba9..404ea98 100644 --- a/spamassassin-spamd.init +++ b/spamassassin-spamd.init @@ -7,7 +7,7 @@ # description: spamd is a daemon process which uses SpamAssassin to check \ # email messages for SPAM. It is normally called by spamc \ # from a MDA. -# processname: spamassassin +# processname: spamd # pidfile: /var/run/spamassassin.pid # Source function library. @@ -16,50 +16,84 @@ # Source networking configuration. . /etc/sysconfig/network +SPAMD_OPTS="-d -c" # Source configureation. -if [ -f /etc/sysconfig/spamassassin ] ; then - . /etc/sysconfig/spamassassin +if [ -f /etc/sysconfig/spamd ] ; then + . /etc/sysconfig/spamd fi # Check that networking is up. if is_no "${NETWORKING}"; then - msg_network_down SpamAssassin + msg_network_down "SpamAssassin" exit 1 fi -# See how we were called. -case "$1" in - start) +start() { # Start daemon. + if [ -f /var/lock/subsys/spamd ]; then + msg_already_running "SpamAssassin" + return + fi + + # Check if database is installed. + if [ "$(find /var/lib/spamassassin/ -name '*.cf' | head -n1 | wc -l)" -eq 0 ]; then + show 'Spamassassin database not found. Run sa-update first.'; fail + return 1 + fi + + msg_starting "SpamAssassin" + daemon /usr/bin/spamd $SPAMD_OPTS + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/spamd +} + +stop() { + # Stop daemons. + if [ ! -f /var/lock/subsys/spamd ]; then + msg_not_running "SpamAssassin" + return + fi + + msg_stopping "SpamAssassin" + killproc --pidfile spamassassin.pid spamd + RETVAL=$? + rm -f /var/lock/subsys/spamd +} + +condrestart() { if [ ! -f /var/lock/subsys/spamd ]; then - msg_starting SpamAssassin - daemon spamd $SPAMD_OPTS - RETVAL=$? - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/spamd - else - msg_already_running SpamAssassin + msg_not_running "SpamAssassin" + RETVAL=$1 + return fi + + stop + start +} + +# See how we were called. +case "$1" in + start) + start ;; stop) - # Stop daemons. - if [ -f /var/lock/subsys/spamd ]; then - msg_stopping SpamAssassin - killproc spamd - RETVAL=$? - rm -f /var/lock/subsys/spamd - else - msg_not_running SpamAssassin - fi + stop ;; restart) - $0 stop - $0 start + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 ;; status) status spamd ;; *) - msg_usage "$0 {start|stop|restart|status}" + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" exit 1 esac