]> git.pld-linux.org Git - packages/spamassassin.git/blobdiff - spamassassin-spamd.init
- disable t/trust_path.t test
[packages/spamassassin.git] / spamassassin-spamd.init
index c25139659526d2a432d0a7e5959e3644afbf1852..07c17c019a795c08d6262a536d248499adedb22a 100644 (file)
@@ -8,7 +8,7 @@
 #              email messages for SPAM.  It is normally called by spamc \
 #              from a MDA.
 # processname: spamd
-# pidfile:     /var/run/spamassassin.pid
+# pidfile:     /var/run/spamd.pid
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -24,43 +24,76 @@ 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 -r /var/run/spamd.pid $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 spamd.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
+       status --pidfile spamd.pid spamd
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
        exit 1
 esac
 
This page took 0.05208 seconds and 4 git commands to generate.