initscript: replaced spaces with tabs
This commit is contained in:
parent
60cf0d9290
commit
96238a3a52
178
ldap.init
178
ldap.init
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# slapd This shell script takes care of starting and stopping
|
||||
# ldap servers (slapd).
|
||||
# slapd This shell script takes care of starting and stopping
|
||||
# ldap servers (slapd).
|
||||
#
|
||||
# chkconfig: - 27 73
|
||||
# description: LDAP stands for Lightweight Directory Access Protocol, used \
|
||||
@ -53,19 +53,19 @@ RETVAL=0
|
||||
# Pass commands given in $2 and later to "test" run as user given in $1.
|
||||
#
|
||||
function testasuser() {
|
||||
local user= cmd=
|
||||
user="$1"
|
||||
shift
|
||||
cmd="$@"
|
||||
if test x"$user" != x ; then
|
||||
if test x"$cmd" != x ; then
|
||||
/sbin/runuser -f -m -s /bin/sh -c "test $cmd" -- "$user"
|
||||
local user= cmd=
|
||||
user="$1"
|
||||
shift
|
||||
cmd="$@"
|
||||
if test x"$user" != x ; then
|
||||
if test x"$cmd" != x ; then
|
||||
/sbin/runuser -f -m -s /bin/sh -c "test $cmd" -- "$user"
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
false
|
||||
false
|
||||
fi
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
@ -73,34 +73,34 @@ function testasuser() {
|
||||
# If $3 is specified, the command is run if "klist" can't be found.
|
||||
#
|
||||
function checkkeytab() {
|
||||
local user= service= klist= default=
|
||||
user="$1"
|
||||
service="$2"
|
||||
default="${3:-false}"
|
||||
if test -x /usr/kerberos/bin/klist ; then
|
||||
klist=/usr/kerberos/bin/klist
|
||||
elif test -x /usr/bin/klist ; then
|
||||
klist=/usr/bin/klist
|
||||
fi
|
||||
KRB5_KTNAME="${KRB5_KTNAME:-/etc/krb5.keytab}"
|
||||
export KRB5_KTNAME
|
||||
if test -s "$KRB5_KTNAME" ; then
|
||||
if test x"$klist" != x ; then
|
||||
if LANG=C $klist -k "$KRB5_KTNAME" | tail -n 4 | awk '{print $2}' | grep -q ^"$service"/ ; then
|
||||
if ! testasuser "$user" -r ${KRB5_KTNAME:-/etc/krb5.keytab} ; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
$default
|
||||
local user= service= klist= default=
|
||||
user="$1"
|
||||
service="$2"
|
||||
default="${3:-false}"
|
||||
if test -x /usr/kerberos/bin/klist ; then
|
||||
klist=/usr/kerberos/bin/klist
|
||||
elif test -x /usr/bin/klist ; then
|
||||
klist=/usr/bin/klist
|
||||
fi
|
||||
KRB5_KTNAME="${KRB5_KTNAME:-/etc/krb5.keytab}"
|
||||
export KRB5_KTNAME
|
||||
if test -s "$KRB5_KTNAME" ; then
|
||||
if test x"$klist" != x ; then
|
||||
if LANG=C $klist -k "$KRB5_KTNAME" | tail -n 4 | awk '{print $2}' | grep -q ^"$service"/ ; then
|
||||
if ! testasuser "$user" -r ${KRB5_KTNAME:-/etc/krb5.keytab} ; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
$default
|
||||
fi
|
||||
else
|
||||
false
|
||||
fi
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
function configtest() {
|
||||
@ -112,16 +112,16 @@ function configtest() {
|
||||
# Unaccessible database files.
|
||||
slaptestflags=""
|
||||
dbdirs=""
|
||||
if [ -d $configdir ]; then
|
||||
for configfile in `ls -1 $configdir/cn\=config/olcDatabase*.ldif`; do
|
||||
dbdirs=$dbdirs"
|
||||
"`LANG=C egrep '^olcDbDirectory[[:space:]]*:[[:space:]]+[[:print:]]+$' $configfile | sed 's,^olcDbDirectory: ,,'`
|
||||
done
|
||||
elif [ -f $configfile ]; then
|
||||
dbdirs=`LANG=C egrep '^directory[[:space:]]+' $configfile | sed 's,^directory[[:space:]]*,,'`
|
||||
else
|
||||
exit 6
|
||||
fi
|
||||
if [ -d $configdir ]; then
|
||||
for configfile in `ls -1 $configdir/cn\=config/olcDatabase*.ldif`; do
|
||||
dbdirs=$dbdirs"
|
||||
"`LANG=C egrep '^olcDbDirectory[[:space:]]*:[[:space:]]+[[:print:]]+$' $configfile | sed 's,^olcDbDirectory: ,,'`
|
||||
done
|
||||
elif [ -f $configfile ]; then
|
||||
dbdirs=`LANG=C egrep '^directory[[:space:]]+' $configfile | sed 's,^directory[[:space:]]*,,'`
|
||||
else
|
||||
exit 6
|
||||
fi
|
||||
for dbdir in $dbdirs; do
|
||||
if [ ! -d $dbdir ]; then
|
||||
exit 6
|
||||
@ -143,7 +143,7 @@ function configtest() {
|
||||
echo -n $"$file is not readable by \"$user\"" ; warning ; echo
|
||||
fi
|
||||
# Unaccessible TLS configuration files.
|
||||
if [ -d $configdir ]; then
|
||||
if [ -d $configdir ]; then
|
||||
tlsconfigs=`LANG=C awk '/^olcTLS/ {
|
||||
while (/^olcTLS/) {
|
||||
if (/^olc(TLSCertificateKeyFile|TLSCertificateFile|TLSCACertificateFile)[ \t]*:[\t]*/) {
|
||||
@ -153,9 +153,9 @@ function configtest() {
|
||||
else break;
|
||||
}
|
||||
}' $configdir/cn\=config.ldif | awk '{print $2}'`
|
||||
elif [ -f $configfile ]; then
|
||||
tlsconfigs=`LANG=C egrep '^(TLSCACertificateFile|TLSCertificateFile|TLSCertificateKeyFile)[[:space:]]+' $configfile | awk '{print $2}'`
|
||||
fi
|
||||
elif [ -f $configfile ]; then
|
||||
tlsconfigs=`LANG=C egrep '^(TLSCACertificateFile|TLSCertificateFile|TLSCertificateKeyFile)[[:space:]]+' $configfile | awk '{print $2}'`
|
||||
fi
|
||||
for file in $tlsconfigs ; do
|
||||
if ! testasuser $user -r $file ; then
|
||||
echo -n $"$file is not readable by \"$user\"" ; warning ; echo
|
||||
@ -197,13 +197,13 @@ function start() {
|
||||
prog=`basename ${slapd}`
|
||||
harg="$SLAPD_URLS"
|
||||
if test x$SLAPD_LDAP = xyes ; then
|
||||
harg="$harg ldap:///"
|
||||
harg="$harg ldap:///"
|
||||
fi
|
||||
if test x$SLAPD_LDAPS = xyes ; then
|
||||
harg="$harg ldaps:///"
|
||||
harg="$harg ldaps:///"
|
||||
fi
|
||||
if test x$SLAPD_LDAPI = xyes ; then
|
||||
harg="$harg ldapi:///"
|
||||
harg="$harg ldapi:///"
|
||||
fi
|
||||
# Start daemons.
|
||||
echo -n $"Starting $prog: "
|
||||
@ -235,38 +235,38 @@ function stop() {
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
configtest)
|
||||
configtest
|
||||
;;
|
||||
start)
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status -p $pidfile ${slapd}
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart|force-reload)
|
||||
stop
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
status -p $pidfile ${slapd} > /dev/null 2>&1 || exit 0
|
||||
stop
|
||||
start
|
||||
;;
|
||||
usage)
|
||||
echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart|try-restart|configtest|usage}"
|
||||
RETVAL=0
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart|try-restart|configtest|usage}"
|
||||
RETVAL=2
|
||||
configtest)
|
||||
configtest
|
||||
;;
|
||||
start)
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status -p $pidfile ${slapd}
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart|force-reload)
|
||||
stop
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
status -p $pidfile ${slapd} > /dev/null 2>&1 || exit 0
|
||||
stop
|
||||
start
|
||||
;;
|
||||
usage)
|
||||
echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart|try-restart|configtest|usage}"
|
||||
RETVAL=0
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart|try-restart|configtest|usage}"
|
||||
RETVAL=2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
Loading…
Reference in New Issue
Block a user