After discussion on #pkg-sysvinit, I slightly changed the proposed
patch with a supposedly better LSB header.

Changes:

# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6

Do not start in "S" and "1". Stop in "1"


--- init.orig   2006-09-22 18:52:58.827721308 +0200
+++ init        2006-09-23 10:46:37.505139626 +0200
@@ -3,6 +3,14 @@
 # Fetchmail init script
 # Latest change: Mo Jul 31 20:23:54 CEST 2006
 #
+### BEGIN INIT INFO
+# Provides:          fetchmail
+# Required-Start:    $network $local_fs $remote_fs
+# Required-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+### END INIT INFO
+#
 # A fetchmailrc file containg hosts and passwords for all local users should be
 # placed in /etc/fetchmailrc.  Remember to make the /etc/fetchmailrc mode 600
 # to avoid disclosing the users' passwords.
@@ -34,10 +42,13 @@
 UIDL=/var/lib/fetchmail/.fetchmail-UIDL-cache
 
 test -f $DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
 if [ "$1" = "start" ]; then
     if [ ! -r $CONFFILE ] ; then
-        echo "$CONFFILE not found."
-        echo "can not start fetchmail daemon... consider disabling the script"
+        log_failure_msg "$CONFFILE not found."
+        log_failure_msg "can not start fetchmail daemon... consider disabling 
the script"
         exit 0
     fi
 fi
@@ -58,7 +69,7 @@
                chmod 700 /var/lib/fetchmail
                chown -h -R fetchmail:nogroup /var/lib/fetchmail
        else
-               echo "$0: $USER user does not exist!"
+               log_failure_msg "$0: $USER user does not exist!"
                exit 1
        fi
 fi
@@ -82,7 +93,7 @@
 
 # sanity check
 #if [ ! -d ${PIDFILE%/*} ]; then
-#      echo "$0: directory ${PIDFILE%/*} does not exist!"
+#      log_failure_msg "$0: directory ${PIDFILE%/*} does not exist!"
 #      exit 1
 #fi
 
@@ -108,45 +119,45 @@
                        pid=`cat $PIDFILE | sed -e 's/\s.*//'|head -n1`
                        PIDDIR=/proc/$pid
                    if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = 
"${DAEMON}" ]; then
-                               echo "fetchmail already started; not starting."
+                               log_failure_msg "fetchmail already started; not 
starting."
                                exit 0
                        else
-                               echo "Removing stale PID file $PIDFILE."
+                               log_warning_msg "Removing stale PID file 
$PIDFILE."
                                rm -f $PIDFILE
                        fi
                fi
-               echo -n "Starting mail retrieval agent: fetchmail"
+               log_begin_msg "Starting mail retriever agent" "fetchmail"
                if start-stop-daemon -S -o -q -p $PIDFILE -x $DAEMON -u $USER 
-a /bin/su -- -c "$DAEMON $OPTIONS" $USER; then
-                       echo "."
+                       log_end_msg 0
                else
-                       echo " (failed)."
+                       log_end_msg 1
                        exit 1
                fi
                ;;
        stop)
                if ! test -e $PIDFILE ; then
-                       echo "Pidfile not found! Is fetchmail running?"
+                       log_failure_msg "Pidfile not found! Is fetchmail 
running?"
                        exit 0
                fi
-               echo -n "Stopping mail retrieval agent: fetchmail"
+               log_begin_msg "Stopping mail retriever agent" "fetchmail"
                if start-stop-daemon -K -o -q -p $PIDFILE -x $DAEMON -u $USER; 
then
-                       echo "."
+                       log_end_msg 0
                else
-                       echo " (failed)."
+                       log_end_msg 1
                        exit 1
                fi
                ;;
        force-reload|restart)
-               echo -n "Restarting mail retrieval agent: fetchmail"
+               log_begin_msg "Restarting mail retriever agent" "fetchmail"
                if ! start-stop-daemon -K -o -q -p $PIDFILE -x $DAEMON -u 
$USER; then
-                       echo " (failed on stop)."
+                       log_end_msg 1
                        exit 1
                fi
                sleep 1
                if start-stop-daemon -S -q -p $PIDFILE -x $DAEMON -u $USER -a 
/bin/su -- -c "$DAEMON $OPTIONS" $USER; then
-                       echo "."
+                       log_end_msg 0
                else
-                       echo " (failed on start)."
+                       log_end_msg 1
                        exit 1
                fi
                ;;
@@ -162,13 +173,13 @@
                $0 start
                ;;
        awaken)
-               echo -n "Awakening mail retrieval agent: fetchmail"
+               log_begin_msg "Awakening mail retriever agent" "fetchmail"
                if [ -s $PIDFILE ]; then
                        start-stop-daemon -K -s 10 -q -p $PIDFILE -x $DAEMON
-                       echo "."
+                       log_end_msg 0
                        exit 0
                else
-                       echo " (not running)."
+                       log_end_msg 1
                        exit 1
                fi
                ;;
@@ -202,13 +213,13 @@
                exit 0
                ;;
        *)
-               echo "Usage: /etc/init.d/fetchmail 
{start|stop|restart|force-reload|awaken|debug-run}"
-               echo "  start - starts system-wide fetchmail service"
-               echo "  stop  - stops system-wide fetchmail service"
-               echo "  restart, force-reload - starts a new system-wide 
fetchmail service"
-               echo "  awaken - tell system-wide fetchmail to start a poll 
cycle immediately"
-               echo "  debug-run [strace [strace options...]] - start a debug 
run of the"
-               echo "    system-wide fetchmail service, optionally running it 
under strace"
+               log_warning_msg "Usage: /etc/init.d/fetchmail 
{start|stop|restart|force-reload|awaken|debug-run}"
+               log_warning_msg "  start - starts system-wide fetchmail service"
+               log_warning_msg "  stop  - stops system-wide fetchmail service"
+               log_warning_msg "  restart, force-reload - starts a new 
system-wide fetchmail service"
+               log_warning_msg "  awaken - tell system-wide fetchmail to start 
a poll cycle immediately"
+               log_warning_msg "  debug-run [strace [strace options...]] - 
start a debug run of the"
+               log_warning_msg "    system-wide fetchmail service, optionally 
running it under strace"
                exit 1
                ;;
 esac
--- control.ori 2006-09-22 20:38:24.834775816 +0200
+++ control     2006-09-22 20:38:44.234947736 +0200
@@ -9,7 +9,7 @@
 
 Package: fetchmail
 Architecture: any
-Depends: ${shlibs:Depends}, debianutils (>= 1.7), adduser (>= 3.34), gettext
+Depends: ${shlibs:Depends}, debianutils (>= 1.7), adduser (>= 3.34), gettext, 
lsb-base (>= 3.0-6)
 Conflicts: popclient, fetchmail-common, logcheck (<< 1.1.1-9), fetchmail-ssl 
(<= 6.2.5-12)
 Replaces: fetchmail-common, fetchmail-ssl
 Provides: fetchmail-ssl

Attachment: signature.asc
Description: Digital signature

Reply via email to