]>
Commit | Line | Data |
---|---|---|
3681cede | 1 | #!/bin/sh |
2 | # | |
3 | # chkconfig: 345 91 35 | |
b91b49cd | 4 | # description: Starts and stops the fetchmail daemon used to retrive mail \ |
5 | # via various protocols (such as POP3 and IMAP4). | |
3681cede | 6 | # |
7 | # config: /etc/fetchmailrc | |
8 | ||
f307ac5f | 9 | |
3681cede | 10 | # Source function library. |
11 | . /etc/rc.d/init.d/functions | |
12 | ||
13 | # Source networking configuration. | |
b91b49cd | 14 | # Get service config - may override defaults |
15 | [ -f /etc/sysconfig/fetchmail ] && . /etc/sysconfig/fetchmail | |
3681cede | 16 | |
60aaf401 SZ |
17 | # defaults |
18 | [ -z "$POLL_INTERVAL" ] && POLL_INTERVAL=300 | |
19 | ||
f307ac5f | 20 | # Get network config |
21 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network | |
22 | ||
3681cede | 23 | # Check that networking is up. |
b91b49cd | 24 | if is_no "${NETWORKING}"; then |
f307ac5f | 25 | msg_Network_Down "fetchmail" |
b91b49cd | 26 | exit 1 |
27 | fi | |
3681cede | 28 | |
29 | # Check that fetchmailrc exists. | |
30 | [ -f /etc/fetchmailrc ] || exit 0 | |
31 | ||
32 | # See how we were called. | |
33 | case "$1" in | |
34 | start) | |
b91b49cd | 35 | if [ ! -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 36 | msg_starting "fetchmail" |
df30b99a | 37 | |
38 | is_yes $VERBOSE_LOGGING && OPTIONS="-v" | |
39 | ||
40 | daemon fetchmail -d "$POLL_INTERVAL" $OPTIONS -f /etc/fetchmailrc | |
b91b49cd | 41 | RETVAL=$? |
42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail | |
43 | else | |
b91b49cd | 44 | msg_Already_Running fetchmail |
45 | exit 1 | |
46 | fi | |
47 | ;; | |
3681cede | 48 | stop) |
1ad998f9 | 49 | if [ -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 50 | msg_stopping "fetchmail" |
b91b49cd | 51 | killproc fetchmail |
52 | rm -f /var/lock/subsys/fetchmail >/dev/null 2>&1 | |
53 | else | |
f307ac5f | 54 | msg_Not_Running "fetchmail" |
b91b49cd | 55 | exit 1 |
56 | fi | |
57 | ;; | |
3681cede | 58 | restart) |
b91b49cd | 59 | $0 stop |
3681cede | 60 | $0 start |
b91b49cd | 61 | ;; |
62 | reload) | |
63 | if [ -f /var/lock/subsys/fetchmail ]; then | |
e5c4b2fc | 64 | msg_reloading "fetchmail" |
b91b49cd | 65 | busy |
66 | killproc fetchmail -HUP | |
67 | deltext | |
68 | ok | |
69 | else | |
70 | msg_Not_Running fetchmail | |
71 | exit 1 | |
72 | fi | |
73 | ;; | |
74 | force-reload) | |
75 | # if program allows reloading without stopping | |
76 | $0 reload | |
77 | exit $? | |
78 | ||
79 | # or if it doesn't | |
80 | $0 stop && $0 start | |
81 | exit $? | |
3681cede | 82 | ;; |
b91b49cd | 83 | status) |
84 | status fetchmail | |
85 | exit $? | |
86 | ;; | |
3681cede | 87 | *) |
b91b49cd | 88 | msg_Usage "$0 {start|stop|status|restart|reload|force-reload}" |
89 | exit 1 | |
3681cede | 90 | esac |
91 | ||
b91b49cd | 92 | exit $RETVAL |