Okey, I've attached a new version of the lsb patch which reduces the verbose messages to be a bit more in line with what other init.d scripts print.

Hopefully you'll find this patch acceptable, otherwise I'm open to suggestions on how to add lsb logging to slapd...

--
David Härdeman
diff -ur ./openldap2.3-2.3.25.orig/debian/control 
./openldap2.3-2.3.25/debian/control
--- ./openldap2.3-2.3.25.orig/debian/control    2006-09-06 20:13:07.000000000 
+0200
+++ ./openldap2.3-2.3.25/debian/control 2006-09-06 20:13:37.000000000 +0200
@@ -12,7 +12,7 @@
 Priority: optional
 Architecture: any
 Pre-Depends: debconf (>= 0.5) | debconf-2.0
-Depends: ${shlibs:Depends}, coreutils (>= 4.5.1-1), psmisc, perl (>> 5.8.0) | 
libmime-base64-perl, libldap-2.3-0 (= ${Source-Version}), adduser
+Depends: ${shlibs:Depends}, coreutils (>= 4.5.1-1), psmisc, perl (>> 5.8.0) | 
libmime-base64-perl, libldap-2.3-0 (= ${Source-Version}), adduser, lsb-base (>= 
3.0-10)
 Recommends: db4.2-util, libsasl2-modules
 Suggests: ldap-utils
 Conflicts: umich-ldapd, ldap-server, libbind-dev, bind-dev, libltdl3 (= 
1.5.4-1)
diff -ur ./openldap2.3-2.3.25.orig/debian/slapd.init 
./openldap2.3-2.3.25/debian/slapd.init
--- ./openldap2.3-2.3.25.orig/debian/slapd.init 2006-09-06 20:13:07.000000000 
+0200
+++ ./openldap2.3-2.3.25/debian/slapd.init      2006-09-06 20:38:10.000000000 
+0200
@@ -9,6 +9,9 @@
 # Stop processing if slapd is not there
 [ -x /usr/sbin/slapd ] || exit 0
 
+# Use LSB logging functions
+. /lib/lsb/init-functions
+
 # Source the init script configuration
 if [ -f "/etc/default/slapd" ]; then
        . /etc/default/slapd
@@ -24,15 +27,8 @@
 
 # Stop processing if the config file is not there
 if [ ! -r "$SLAPD_CONF" ]; then
-  cat <<EOF >&2
-No configuration file was found for slapd at $SLAPD_CONF.
-If you have moved the slapd configuration file please modify
-/etc/default/slapd to reflect this.  If you chose to not
-configure slapd during installation then you need to do so
-prior to attempting to start slapd.
-An example slapd.conf is in /usr/share/slapd
-EOF
-  exit 0 # Should this be 1?
+       log_warning_msg "No configuration file was found for slapd at 
$SLAPD_CONF."
+       exit 1
 fi
 
 # Figure out some default settings
@@ -54,10 +50,7 @@
 # XXX: Breaks upgrading if there is no pidfile (invoke-rc.d stop will fail)
 # -- Torsten
 if [ -z "$SLAPD_PIDFILE" ]; then
-       cat <<EOF >&2
-The pidfile for slapd is neither specified in "$SLAPD_CONF" nor
-in /etc/default/slapd. Consequently, slapd will not be started.
-EOF
+       log_failure_msg "The pidfile for slapd has not been specified"
        exit 1
 fi
 
@@ -73,37 +66,25 @@
 # Tell the user that something went wrong and give some hints for
 # resolving the problem.
 report_failure() {
+       log_end_msg 1
        if [ -n "$reason" ]; then
-               echo " - failed: "
-               echo "$reason"
+               log_failure_msg "$reason"
        else
-               echo " - failed."
-               cat <<EOF
-The operation failed but no output was produced. For hints on what went
-wrong please refer to the system's logfiles (e.g. /var/log/syslog) or
-try running the daemon in Debug mode like via "slapd -d 16383" (warning:
-this will create copious output).
-EOF
+               log_failure_msg "The operation failed but no output was 
produced."
 
                if [ -n "$SLURPD_OPTIONS" -o \
                     -n "$SLAPD_OPTIONS" -o \
                     -n "$SLAPD_SERVICES" ]; then
-                       cat << EOF
-
-Below, you can find the command line options used by this script to 
-run slapd and slurpd. Do not forget to specify those options if you
-want to look to debugging output:
-EOF
                        if [ -z "$SLAPD_SERVICES" ]; then
                                if [ -n "$SLAPD_OPTIONS" ]; then
-                                       echo "  slapd $SLAPD_OPTIONS"
+                                       log_failure_msg "Command line used: 
slapd $SLAPD_OPTIONS"
                                fi
                        else
-                               echo "  slapd -h '$SLAPD_SERVICES' 
$SLAPD_OPTIONS"
+                               log_failure_msg "Command line used: slapd -h 
'$SLAPD_SERVICES' $SLAPD_OPTIONS"
                        fi
 
                        if [ "$SLURPD" = "yes" -a -n "$SLURPD_OPTIONS" ]; then
-                                       echo "  slurpd $SLURPD_OPTIONS"
+                                       log_failure_msg "Command line used: 
slurpd $SLURPD_OPTIONS"
                        fi
                fi
        fi
@@ -112,7 +93,6 @@
 # Start the slapd daemon and capture the error message if any to 
 # $reason.
 start_slapd() {
-       echo -n " slapd"
        if [ -z "$SLAPD_SERVICES" ]; then
                reason="`start-stop-daemon --start --quiet --oknodo \
                        --pidfile "$SLAPD_PIDFILE" \
@@ -127,10 +107,6 @@
 # Start the slurpd daemon and capture the error message if any to
 # $reason.
 start_slurpd() {
-       if [ "$SLURPD_START" != yes ]; then
-               return 0
-       fi
-       echo -n " slurpd"
        reason="`start-stop-daemon --start --quiet --oknodo \
                --exec /usr/sbin/slurpd -- $SLURPD_OPTIONS 2>&1`"
 }
@@ -138,7 +114,6 @@
 # Stop the slapd daemon and capture the error message (if any) to
 # $reason.
 stop_slapd() {
-       echo -n " slapd"
        reason="`start-stop-daemon --stop --quiet --oknodo --retry 10 \
                --pidfile "$SLAPD_PIDFILE" \
                --exec /usr/sbin/slapd 2>&1`"
@@ -147,32 +122,37 @@
 # Stop the slurpd daemon and capture the error message (if any) to
 # $reason.
 stop_slurpd() {
-       if [ "$SLURPD_START" != yes ]; then
-               return 0
-       fi
-       echo -n " slurpd"
        reason="`start-stop-daemon --stop --quiet --oknodo --retry 10 \
                --exec /usr/sbin/slurpd 2>&1`"
 }
 
 # Start the OpenLDAP daemons
 start() {
-       echo -n "Starting OpenLDAP:"
        trap 'report_failure' 0
+       log_daemon_msg "Starting OpenLDAP" "slapd"
        start_slapd
-       start_slurpd
+       if [ "$SLURPD_START" = "yes" ]; then
+               log_progress_msg "slurpd"
+               start_slurpd
+       fi
        trap "-" 0
-       echo .
+       log_end_msg 0
 }
 
 # Stop the OpenLDAP daemons
 stop() {
-       echo -n "Stopping OpenLDAP:"
        trap 'report_failure' 0
-       stop_slurpd
-       stop_slapd
+       if [ "$SLURPD_START" = "yes" ]; then
+               log_daemon_msg "Stopping OpenLDAP" "slurpd"
+               stop_slurpd
+               log_progress_msg "slapd"
+               stop_slapd
+       else
+               log_daemon_msg "Stopping OpenLDAP" "slapd"
+               stop_slapd
+       fi
        trap "-" 0
-       echo .
+       log_end_msg 0
 }
 
 case "$1" in

Reply via email to