]>
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. |
48e14cd7 | 24 | if is_yes "${NETWORKING}"; then |
25 | if [ ! -f /var/lock/subsys/network ]; then | |
26 | msg_network_down "fetchmail" | |
27 | exit 1 | |
28 | fi | |
29 | else | |
30 | exit 0 | |
b91b49cd | 31 | fi |
3681cede | 32 | |
33 | # Check that fetchmailrc exists. | |
34 | [ -f /etc/fetchmailrc ] || exit 0 | |
35 | ||
36 | # See how we were called. | |
37 | case "$1" in | |
38 | start) | |
b91b49cd | 39 | if [ ! -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 40 | msg_starting "fetchmail" |
df30b99a | 41 | |
42 | is_yes $VERBOSE_LOGGING && OPTIONS="-v" | |
43 | ||
44 | daemon fetchmail -d "$POLL_INTERVAL" $OPTIONS -f /etc/fetchmailrc | |
b91b49cd | 45 | RETVAL=$? |
46 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail | |
47 | else | |
eaf9e23f | 48 | msg_already_running fetchmail |
b91b49cd | 49 | exit 1 |
50 | fi | |
48e14cd7 | 51 | ;; |
3681cede | 52 | stop) |
1ad998f9 | 53 | if [ -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 54 | msg_stopping "fetchmail" |
b91b49cd | 55 | killproc fetchmail |
56 | rm -f /var/lock/subsys/fetchmail >/dev/null 2>&1 | |
57 | else | |
eaf9e23f | 58 | msg_not_running "fetchmail" |
b91b49cd | 59 | exit 1 |
60 | fi | |
48e14cd7 | 61 | ;; |
3681cede | 62 | restart) |
48e14cd7 | 63 | $0 stop |
3681cede | 64 | $0 start |
48e14cd7 | 65 | ;; |
b91b49cd | 66 | reload) |
67 | if [ -f /var/lock/subsys/fetchmail ]; then | |
e5c4b2fc | 68 | msg_reloading "fetchmail" |
b91b49cd | 69 | killproc fetchmail -HUP |
48e14cd7 | 70 | RETVAL=$? |
b91b49cd | 71 | else |
eaf9e23f | 72 | msg_not_running fetchmail |
b91b49cd | 73 | exit 1 |
74 | fi | |
75 | ;; | |
76 | force-reload) | |
48e14cd7 | 77 | # if program allows reloading without stopping |
b91b49cd | 78 | $0 reload |
79 | exit $? | |
80 | ||
81 | # or if it doesn't | |
82 | $0 stop && $0 start | |
83 | exit $? | |
3681cede | 84 | ;; |
b91b49cd | 85 | status) |
86 | status fetchmail | |
87 | exit $? | |
48e14cd7 | 88 | ;; |
3681cede | 89 | *) |
48e14cd7 | 90 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
91 | exit 1 | |
3681cede | 92 | esac |
93 | ||
b91b49cd | 94 | exit $RETVAL |