]> git.pld-linux.org Git - packages/fetchmail.git/blob - fetchmail.init
57d7bb7b58bc3315fb702f855e65ec545325748d
[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                 busy
70                 killproc fetchmail -HUP
71                 RETVAL=$?
72                 [ $RETVAL -eq 0 ] && ok || died
73         else
74                 msg_not_running fetchmail
75                 exit 1
76         fi
77         ;;
78   force-reload)
79         # if program allows reloading without stopping
80         $0 reload
81         exit $?
82
83         # or if it doesn't
84         $0 stop && $0 start
85         exit $?
86         ;;
87   status)
88         status fetchmail
89         exit $?
90         ;;
91   *)
92         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
93         exit 1
94 esac
95
96 exit $RETVAL
This page took 0.070145 seconds and 2 git commands to generate.