init script made LSB-compliant

Resolves: #247012
This commit is contained in:
Jan Šafránek 2008-01-28 11:45:46 +00:00
parent c5a2eb938e
commit 1447738ac4
2 changed files with 32 additions and 18 deletions

View File

@ -10,15 +10,22 @@
# config: /etc/openldap/slapd.conf # config: /etc/openldap/slapd.conf
# pidfile: /var/run/openldap/slapd.pid # 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. # Source function library.
. /etc/init.d/functions . /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 # Define default values of options allowed in /etc/sysconfig/ldap
SLAPD_LDAP="yes" SLAPD_LDAP="yes"
SLAPD_LDAPI="no" SLAPD_LDAPI="no"
@ -32,7 +39,8 @@ fi
slapd=/usr/sbin/slapd slapd=/usr/sbin/slapd
slaptest=/usr/sbin/slaptest slaptest=/usr/sbin/slaptest
[ -x ${slapd} ] || exit 1 lockfile=/var/lock/subsys/ldap
configfile=/etc/openldap/slapd.conf
RETVAL=0 RETVAL=0
@ -92,13 +100,14 @@ function checkkeytab() {
function configtest() { function configtest() {
local user= ldapuid= dbdir= file= local user= ldapuid= dbdir= file=
[ -f $configfile ] || exit 6
# Check for simple-but-common errors. # Check for simple-but-common errors.
user=ldap user=ldap
prog=`basename ${slapd}` prog=`basename ${slapd}`
ldapuid=`id -u $user` ldapuid=`id -u $user`
# Unaccessible database files. # Unaccessible database files.
slaptestflags="" 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 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 echo -n $"$file is not owned by \"$user\"" ; warning ; echo
done done
@ -116,7 +125,7 @@ function configtest() {
echo -n $"$file is not readable by \"$user\"" ; warning ; echo echo -n $"$file is not readable by \"$user\"" ; warning ; echo
fi fi
# Unaccessible TLS configuration files. # 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 for file in $tlsconfigs ; do
if ! testasuser $user -r $file ; then if ! testasuser $user -r $file ; then
echo -n $"$file is not readable by \"$user\"" ; warning ; echo 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 -n $"Checking configuration files for $prog: " ; failure ; echo
echo "$slaptestout" echo "$slaptestout"
if /sbin/runuser -m -s "$slaptest" -- "$user" "-u" > /dev/null 2> /dev/null ; then 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 for directory in $dirs ; do
if test -r $directory/__db.001 ; then if test -r $directory/__db.001 ; then
echo -n $"stale lock files may be present in $directory" ; warning ; echo echo -n $"stale lock files may be present in $directory" ; warning ; echo
fi fi
done done
fi fi
exit 1 exit 6
fi fi
} }
function start() { function start() {
[ -x $slapd ] || exit 5
configtest configtest
# Define a couple of local variables which we'll need. Maybe. # Define a couple of local variables which we'll need. Maybe.
user=ldap user=ldap
@ -168,7 +178,7 @@ function start() {
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
daemon --check=$prog ${slapd} -h "\"$harg\"" -u ${user} $OPTIONS $SLAPD_OPTIONS daemon --check=$prog ${slapd} -h "\"$harg\"" -u ${user} $OPTIONS $SLAPD_OPTIONS
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ldap [ $RETVAL -eq 0 ] && touch $lockfile
echo echo
return $RETVAL return $RETVAL
} }
@ -179,7 +189,7 @@ function stop() {
echo -n $"Stopping $prog: " echo -n $"Stopping $prog: "
killproc ${slapd} killproc ${slapd}
RETVAL=$? 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 echo
return $RETVAL return $RETVAL
} }
@ -201,12 +211,12 @@ case "$1" in
status ${slapd} status ${slapd}
RETVAL=$? RETVAL=$?
;; ;;
restart) restart|force-reload)
stop stop
start start
RETVAL=$? RETVAL=$?
;; ;;
condrestart) condrestart|try-restart)
if [ -f /var/lock/subsys/ldap ] ; then if [ -f /var/lock/subsys/ldap ] ; then
stop stop
start start
@ -214,8 +224,8 @@ case "$1" in
fi fi
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart|status|condrestart}" echo $"Usage: $0 {start|stop|restart|status|condrestart|configtest}"
RETVAL=1 RETVAL=2
esac esac
exit $RETVAL exit $RETVAL

View File

@ -9,7 +9,7 @@
Summary: The configuration files, libraries, and documentation for OpenLDAP Summary: The configuration files, libraries, and documentation for OpenLDAP
Name: openldap Name: openldap
Version: %{version} Version: %{version}
Release: 4%{?dist} Release: 5%{?dist}
License: OpenLDAP License: OpenLDAP
Group: System Environment/Daemons Group: System Environment/Daemons
Source0: ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-%{version}.tgz 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 %attr(0644,root,root) %{evolution_connector_libdir}/*.a
%changelog %changelog
* Mon Jan 28 2008 Jan Safranek <jsafranek@redhat.com> 2.4.7-5
- init script made LSB-compliant (#247012)
* Fri Jan 25 2008 Jan Safranek <jsafranek@redhat.com> 2.4.7-4 * Fri Jan 25 2008 Jan Safranek <jsafranek@redhat.com> 2.4.7-4
- fixed rpmlint warnings and errors - fixed rpmlint warnings and errors
- /etc/openldap/schema/README moved to /usr/share/doc/openldap
* Tue Jan 22 2008 Jan Safranek <jsafranek@redhat.com> 2.4.7-3 * Tue Jan 22 2008 Jan Safranek <jsafranek@redhat.com> 2.4.7-3
- obsoleting compat-openldap properly again :) - obsoleting compat-openldap properly again :)