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
# 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

View File

@ -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 <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
- 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
- obsoleting compat-openldap properly again :)