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