initscript: replaced spaces with tabs

This commit is contained in:
Jan Vcelak 2010-11-01 10:32:22 +01:00
parent 60cf0d9290
commit 96238a3a52

178
ldap.init
View File

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