]> git.pld-linux.org Git - packages/fetchmail.git/blob - fetchmail.init
- updated to 6.2.2
[packages/fetchmail.git] / fetchmail.init
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 ]; 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 # See how we were called.
37 case "$1" in
38   start)
39         if [ ! -f /var/lock/subsys/fetchmail ]; then
40                 msg_starting "fetchmail"
41
42                 is_yes $VERBOSE_LOGGING && OPTIONS="-v"
43
44                 daemon fetchmail -d "$POLL_INTERVAL" $OPTIONS -f /etc/fetchmailrc
45                 RETVAL=$?
46                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail
47         else
48                 msg_already_running fetchmail
49                 exit 1
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                 exit 1
60         fi      
61         ;;
62   restart)
63         $0 stop
64         $0 start
65         ;;
66   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
73                 exit 1
74         fi
75         ;;
76   force-reload)
77         # if program allows reloading without stopping
78         $0 reload
79         exit $?
80
81         # or if it doesn't
82         $0 stop && $0 start
83         exit $?
84         ;;
85   status)
86         status fetchmail
87         exit $?
88         ;;
89   *)
90         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
91         exit 1
92 esac
93
94 exit $RETVAL
This page took 0.170694 seconds and 3 git commands to generate.