]>
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 | |
f307ac5f | 17 | # Get network config |
18 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network | |
19 | ||
3681cede | 20 | # Check that networking is up. |
b91b49cd | 21 | if is_no "${NETWORKING}"; then |
f307ac5f | 22 | msg_Network_Down "fetchmail" |
b91b49cd | 23 | exit 1 |
24 | fi | |
3681cede | 25 | |
26 | # Check that fetchmailrc exists. | |
27 | [ -f /etc/fetchmailrc ] || exit 0 | |
28 | ||
29 | # See how we were called. | |
30 | case "$1" in | |
31 | start) | |
b91b49cd | 32 | if [ ! -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 33 | msg_starting "fetchmail" |
1ad998f9 | 34 | daemon fetchmail -f /etc/fetchmailrc |
b91b49cd | 35 | RETVAL=$? |
36 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail | |
37 | else | |
b91b49cd | 38 | msg_Already_Running fetchmail |
39 | exit 1 | |
40 | fi | |
41 | ;; | |
3681cede | 42 | stop) |
1ad998f9 | 43 | if [ -f /var/lock/subsys/fetchmail ]; then |
f307ac5f | 44 | msg_stopping "fetchmail" |
b91b49cd | 45 | killproc fetchmail |
46 | rm -f /var/lock/subsys/fetchmail >/dev/null 2>&1 | |
47 | else | |
f307ac5f | 48 | msg_Not_Running "fetchmail" |
b91b49cd | 49 | exit 1 |
50 | fi | |
51 | ;; | |
3681cede | 52 | restart) |
b91b49cd | 53 | $0 stop |
3681cede | 54 | $0 start |
b91b49cd | 55 | ;; |
56 | reload) | |
57 | if [ -f /var/lock/subsys/fetchmail ]; then | |
e5c4b2fc | 58 | msg_reloading "fetchmail" |
b91b49cd | 59 | busy |
60 | killproc fetchmail -HUP | |
61 | deltext | |
62 | ok | |
63 | else | |
64 | msg_Not_Running fetchmail | |
65 | exit 1 | |
66 | fi | |
67 | ;; | |
68 | force-reload) | |
69 | # if program allows reloading without stopping | |
70 | $0 reload | |
71 | exit $? | |
72 | ||
73 | # or if it doesn't | |
74 | $0 stop && $0 start | |
75 | exit $? | |
3681cede | 76 | ;; |
b91b49cd | 77 | status) |
78 | status fetchmail | |
79 | exit $? | |
80 | ;; | |
3681cede | 81 | *) |
b91b49cd | 82 | msg_Usage "$0 {start|stop|status|restart|reload|force-reload}" |
83 | exit 1 | |
3681cede | 84 | esac |
85 | ||
b91b49cd | 86 | exit $RETVAL |