From 1447738ac42aec2fdcc0253fbe6c7aed6a760b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0afr=C3=A1nek?= Date: Mon, 28 Jan 2008 11:45:46 +0000 Subject: [PATCH] init script made LSB-compliant Resolves: #247012 --- ldap.init | 44 +++++++++++++++++++++++++++----------------- openldap.spec | 6 +++++- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/ldap.init b/ldap.init index 4ee201e..87afa30 100644 --- a/ldap.init +++ b/ldap.init @@ -10,15 +10,22 @@ # config: /etc/openldap/slapd.conf # pidfile: /var/run/openldap/slapd.pid +### BEGIN INIT INFO +# Provides: ldap +# Required-Start: $network $local_fs +# Required-Stop: $network $local_fs +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: +# Short-Description: starts and stopd OpenLDAP server daemon +# Description: LDAP stands for Lightweight Directory Access Protocol, used +# for implementing the industry standard directory services. +### END INIT INFO + # Source function library. . /etc/init.d/functions -# Source networking configuration and check that networking is up. -if [ -r /etc/sysconfig/network ] ; then - . /etc/sysconfig/network - [ ${NETWORKING} = "no" ] && exit 1 -fi - # Define default values of options allowed in /etc/sysconfig/ldap SLAPD_LDAP="yes" SLAPD_LDAPI="no" @@ -32,7 +39,8 @@ fi slapd=/usr/sbin/slapd slaptest=/usr/sbin/slaptest -[ -x ${slapd} ] || exit 1 +lockfile=/var/lock/subsys/ldap +configfile=/etc/openldap/slapd.conf RETVAL=0 @@ -92,13 +100,14 @@ function checkkeytab() { function configtest() { local user= ldapuid= dbdir= file= + [ -f $configfile ] || exit 6 # Check for simple-but-common errors. user=ldap prog=`basename ${slapd}` ldapuid=`id -u $user` # Unaccessible database files. slaptestflags="" - for dbdir in `LANG=C egrep '^directory[[:space:]]+[[:print:]]+$' /etc/openldap/slapd.conf | sed s,^directory,,` ; do + for dbdir in `LANG=C egrep '^directory[[:space:]]+[[:print:]]+$' $configfile | sed s,^directory,,` ; do for file in `find ${dbdir}/ -not -uid $ldapuid -and \( -name "*.dbb" -or -name "*.gdbm" -or -name "*.bdb" -or -name "__db.*" -or -name "log.*" -or -name alock \)` ; do echo -n $"$file is not owned by \"$user\"" ; warning ; echo done @@ -116,7 +125,7 @@ function configtest() { echo -n $"$file is not readable by \"$user\"" ; warning ; echo fi # Unaccessible TLS configuration files. - tlsconfigs=`LANG=C egrep '^(TLSCACertificateFile|TLSCertificateFile|TLSCertificateKeyFile)[[:space:]]' /etc/openldap/slapd.conf | awk '{print $2}'` + tlsconfigs=`LANG=C egrep '^(TLSCACertificateFile|TLSCertificateFile|TLSCertificateKeyFile)[[:space:]]' $configfile | awk '{print $2}'` for file in $tlsconfigs ; do if ! testasuser $user -r $file ; then echo -n $"$file is not readable by \"$user\"" ; warning ; echo @@ -138,18 +147,19 @@ function configtest() { echo -n $"Checking configuration files for $prog: " ; failure ; echo echo "$slaptestout" if /sbin/runuser -m -s "$slaptest" -- "$user" "-u" > /dev/null 2> /dev/null ; then - dirs=`LANG=C egrep '^directory[[:space:]]+[[:print:]]+$' /etc/openldap/slapd.conf | awk '{print $2}'` + dirs=`LANG=C egrep '^directory[[:space:]]+[[:print:]]+$' $configfile | awk '{print $2}'` for directory in $dirs ; do if test -r $directory/__db.001 ; then echo -n $"stale lock files may be present in $directory" ; warning ; echo fi done fi - exit 1 + exit 6 fi } function start() { + [ -x $slapd ] || exit 5 configtest # Define a couple of local variables which we'll need. Maybe. user=ldap @@ -168,7 +178,7 @@ function start() { echo -n $"Starting $prog: " daemon --check=$prog ${slapd} -h "\"$harg\"" -u ${user} $OPTIONS $SLAPD_OPTIONS RETVAL=$? - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ldap + [ $RETVAL -eq 0 ] && touch $lockfile echo return $RETVAL } @@ -179,7 +189,7 @@ function stop() { echo -n $"Stopping $prog: " killproc ${slapd} RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ldap /var/run/slapd.args + [ $RETVAL -eq 0 ] && rm -f $lockfile /var/run/slapd.args echo return $RETVAL } @@ -201,12 +211,12 @@ case "$1" in status ${slapd} RETVAL=$? ;; - restart) + restart|force-reload) stop start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f /var/lock/subsys/ldap ] ; then stop start @@ -214,8 +224,8 @@ case "$1" in fi ;; *) - echo $"Usage: $0 {start|stop|restart|status|condrestart}" - RETVAL=1 + echo $"Usage: $0 {start|stop|restart|status|condrestart|configtest}" + RETVAL=2 esac exit $RETVAL diff --git a/openldap.spec b/openldap.spec index d72322d..483b000 100644 --- a/openldap.spec +++ b/openldap.spec @@ -9,7 +9,7 @@ Summary: The configuration files, libraries, and documentation for OpenLDAP Name: openldap Version: %{version} -Release: 4%{?dist} +Release: 5%{?dist} License: OpenLDAP Group: System Environment/Daemons Source0: ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-%{version}.tgz @@ -605,8 +605,12 @@ fi %attr(0644,root,root) %{evolution_connector_libdir}/*.a %changelog +* Mon Jan 28 2008 Jan Safranek 2.4.7-5 +- init script made LSB-compliant (#247012) + * Fri Jan 25 2008 Jan Safranek 2.4.7-4 - fixed rpmlint warnings and errors + - /etc/openldap/schema/README moved to /usr/share/doc/openldap * Tue Jan 22 2008 Jan Safranek 2.4.7-3 - obsoleting compat-openldap properly again :)