]> git.pld-linux.org Git - packages/fetchmail.git/blobdiff - fetchmail.init
- updated to 5.8.11.
[packages/fetchmail.git] / fetchmail.init
index 25d4cf3820b10bb2f818e4348565d29f4fe4147e..987f78de17388dfa287ced5614543f20d0d8d4dd 100644 (file)
@@ -1,24 +1,30 @@
 #!/bin/sh
 #
 # chkconfig:   345 91 35
-# description: Starts and stops the fetchmail daemon used to retrive mail via
-#              various protocols (such as POP3 and IMAP4).
+# description: Starts and stops the fetchmail daemon used to retrive mail \
+#              via various protocols (such as POP3 and IMAP4).
 #
 # config:      /etc/fetchmailrc
 
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 # Source networking configuration.
-. /etc/sysconfig/network
+# Get service config - may override defaults
+[ -f /etc/sysconfig/fetchmail ] && . /etc/sysconfig/fetchmail
 
-# Demon specified configuration.
-. /etc/sysconfig/fetchmail
+# defaults
+[ -z "$POLL_INTERVAL" ] && POLL_INTERVAL=300
+
+# Get network config
+[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
 
 # Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 0
+if is_no "${NETWORKING}"; then
+       msg_Network_Down "fetchmail"
+       exit 1
+fi
 
 # Check that fetchmailrc exists.
 [ -f /etc/fetchmailrc ] || exit 0
@@ -26,24 +32,61 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 # See how we were called.
 case "$1" in
   start)
-       show Starting fetchmail
-       daemon $NICELEVEL fetchmail -f /etc/fetchmailrc
-       touch /var/lock/subsys/fetchmail
-       ;;
+       if [ ! -f /var/lock/subsys/fetchmail ]; then
+               msg_starting "fetchmail"
+
+               is_yes $VERBOSE_LOGGING && OPTIONS="-v"
+
+               daemon fetchmail -d "$POLL_INTERVAL" $OPTIONS -f /etc/fetchmailrc
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/fetchmail
+       else
+               msg_Already_Running fetchmail
+               exit 1
+       fi
+        ;;
   stop)
-       show Stopping fetchmail
-       killproc fetchmail
-       rm -f /var/lock/subsys/fetchmail
-       ;;
-  status)
-       status fetchmail
-       ;;
+       if [ -f /var/lock/subsys/fetchmail ]; then
+               msg_stopping "fetchmail"
+               killproc fetchmail
+               rm -f /var/lock/subsys/fetchmail >/dev/null 2>&1
+       else
+               msg_Not_Running "fetchmail"
+               exit 1
+       fi      
+        ;;
   restart)
-       $0 stop
+        $0 stop
        $0 start
+        ;;
+  reload)
+       if [ -f /var/lock/subsys/fetchmail ]; then
+               msg_reloading "fetchmail"
+               busy
+               killproc fetchmail -HUP
+               deltext
+               ok              
+       else
+               msg_Not_Running fetchmail
+               exit 1
+       fi
+       ;;
+  force-reload)
+       # if program allows reloading without stopping
+       $0 reload
+       exit $?
+
+       # or if it doesn't
+       $0 stop && $0 start
+       exit $?
        ;;
+  status)
+       status fetchmail
+       exit $?
+        ;;
   *)
-       echo "Usage: $0 {start|stop|restart|status}"
-       exit 1
+       msg_Usage "$0 {start|stop|status|restart|reload|force-reload}"
+        exit 1
 esac
 
+exit $RETVAL
This page took 0.071373 seconds and 4 git commands to generate.