]>
Commit | Line | Data |
---|---|---|
0af639ae JR |
1 | #!/bin/sh |
2 | # | |
3 | # spamassassin This script starts and stops the spamd daemon | |
4 | # | |
5 | # chkconfig: 2345 80 30 | |
6 | # | |
7 | # description: spamd is a daemon process which uses SpamAssassin to check \ | |
8 | # email messages for SPAM. It is normally called by spamc \ | |
9 | # from a MDA. | |
1d4bbe26 | 10 | # processname: spamd |
0af639ae JR |
11 | # pidfile: /var/run/spamassassin.pid |
12 | ||
13 | # Source function library. | |
14 | . /etc/rc.d/init.d/functions | |
15 | ||
16 | # Source networking configuration. | |
17 | . /etc/sysconfig/network | |
18 | ||
8644bd81 | 19 | SPAMD_OPTS="-d -c" |
0af639ae | 20 | # Source configureation. |
8644bd81 ER |
21 | if [ -f /etc/sysconfig/spamd ] ; then |
22 | . /etc/sysconfig/spamd | |
0af639ae JR |
23 | fi |
24 | ||
25 | # Check that networking is up. | |
26 | if is_no "${NETWORKING}"; then | |
9186730e | 27 | msg_network_down "SpamAssassin" |
0af639ae JR |
28 | exit 1 |
29 | fi | |
30 | ||
9302447f | 31 | start() { |
0af639ae | 32 | # Start daemon. |
9186730e ER |
33 | if [ -f /var/lock/subsys/spamd ]; then |
34 | msg_already_running "SpamAssassin" | |
35 | return | |
0af639ae | 36 | fi |
9186730e | 37 | |
25bcce3b | 38 | # Check if database is installed. |
4f24625c | 39 | if [ "$(find /var/lib/spamassassin/ -name '*.cf' | head -n1 | wc -l)" -eq 0 ]; then |
81e1251a | 40 | show 'Spamassassin database not found. Run sa-update first.'; fail |
25bcce3b | 41 | return 1 |
42 | fi | |
43 | ||
9186730e | 44 | msg_starting "SpamAssassin" |
16972a34 | 45 | daemon /usr/bin/spamd $SPAMD_OPTS |
9186730e ER |
46 | RETVAL=$? |
47 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/spamd | |
9302447f ER |
48 | } |
49 | ||
50 | stop() { | |
0af639ae | 51 | # Stop daemons. |
9186730e ER |
52 | if [ ! -f /var/lock/subsys/spamd ]; then |
53 | msg_not_running "SpamAssassin" | |
54 | return | |
0af639ae | 55 | fi |
9186730e ER |
56 | |
57 | msg_stopping "SpamAssassin" | |
5e2504fa | 58 | killproc --pidfile spamassassin.pid spamd |
9186730e ER |
59 | RETVAL=$? |
60 | rm -f /var/lock/subsys/spamd | |
9302447f ER |
61 | } |
62 | ||
0f81085a ER |
63 | condrestart() { |
64 | if [ ! -f /var/lock/subsys/spamd ]; then | |
65 | msg_not_running "SpamAssassin" | |
66 | RETVAL=$1 | |
67 | return | |
68 | fi | |
69 | ||
70 | stop | |
71 | start | |
72 | } | |
73 | ||
9302447f ER |
74 | # See how we were called. |
75 | case "$1" in | |
76 | start) | |
4f24625c | 77 | start |
9302447f ER |
78 | ;; |
79 | stop) | |
4f24625c | 80 | stop |
0af639ae JR |
81 | ;; |
82 | restart) | |
9302447f ER |
83 | stop |
84 | start | |
0af639ae | 85 | ;; |
0f81085a ER |
86 | try-restart) |
87 | condrestart 0 | |
88 | ;; | |
89 | force-reload) | |
90 | condrestart 7 | |
91 | ;; | |
0af639ae JR |
92 | status) |
93 | status spamd | |
94 | ;; | |
95 | *) | |
0f81085a | 96 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
0af639ae JR |
97 | exit 1 |
98 | esac | |
99 | ||
100 | exit $RETVAL |