Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 7cb52b531262a235bb2ac2b34cfe62b8 > files > 1

ndk-1.1-2mdk.noarch.rpm

#!/bin/sh
#
# ldap	This shell script takes care of starting and stopping
#	ldap servers (slapd and slurpd).
#
# chkconfig: 345 40 60
# description: LDAP stands for Lightweight Directory Access Protocol, used \
#              for implementing the industry standard directory services.
# processname: slapd
# config: /etc/openldap/slapd2.conf
# pidfile: /var/run/slapd/slapd2.pid
#

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# Source an auxiliary options file if we have one, and pick up OPTIONS,
# SLAPD_OPTIONS, and SLURPD_OPTIONS.
if [ -r /etc/sysconfig/ldap-ndk ] ; then
	. /etc/sysconfig/ldap-ndk
fi

slapd=/usr/sbin/slapd
slapdpid=/var/run/slapd/slapd2.pid
slurpd=/usr/sbin/slurpd
[ -x ${slapd} ] || exit 0
[ -x ${slurpd} ] || exit 0
[ -n $SLAPDCONFIG ]  || SLAPDCONFIG=/etc/openldap/slapd.conf

start() {
	local RETVAL=0
	local RETVAL2=0
	local ARGS=""


	# Start daemons.
	ARGS="-u ldap -g ldap"
	ARGS="$ARGS -f $SLAPDCONFIG"

	# Syslog 
	if [ -n "$SLAPDSYSLOGLOCALUSER" ] ; then
		ARGS="$ARGS -l $SLAPDSYSLOGLOCALUSER"
		if [ -n "$SLAPDSYSLOGLEVEL" ] ; then
			ARGS="$ARGS -s $SLAPDSYSLOGLEVEL"
		fi
	fi
	
	OUT="ldap"
	if [ -n "$SLAPDURLLIST" ] ; then
			ARGS="$ARGS -h \"$SLAPDURLLIST\""
		if gprintf "ldaps\n" && grep -q "^TLS" $SLAPDCONFIG  ; then
			OUT="ldap + ldaps"
			if [ ! -e /etc/openldap/ldap.pem ] ; then
				if [ -x /usr/share/openldap/gencert.sh ] ; then
						gprintf "Generating self-signed certificate\n"
						pushd /etc/openldap/ > /dev/null
						yes ""|/usr/share/openldap/gencert.sh >/dev/null 2>/dev/null
					    popd > /dev/null
				fi
			fi
			gprintf "\n To generate a self-signed certificate, you can use\n"
			gprintf " the utility /usr/share/openldap/gencert.sh ...\n\n"

			if ls /var/lib/ldap-netmeeting/*.gdbm > /dev/null 2>/dev/null || :  ; then
				gprintf " To convert a gdbm DB to a ldif file, you can use\n"
				gprintf " the utility /usr/sbin/slapcat-gdbm (actually openldap use \n"
				gprintf " Berkeley DB 3.x)...\n\n"
			fi

		fi
fi
			ARGS="$ARGS"

        gprintf "Starting slapd-ndk (%s): " "$OUT"
	initlog -c "${slapd} $ARGS" && success || failure
	RETVAL=$?
	if ! ls /var/lib/ldap-netmeeting/*.dbb > /dev/null 2>/dev/null ; then
			echo
			gprintf "Initializing ldap ndk base"
			echo
			[ -x /usr/sbin/initialize-ndk ] && /usr/sbin/initialize-ndk
	fi

	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ldap2 || RETVAL=1
	echo
        return $RETVAL
}

stop() {
	local RETVAL=0
	local RETVAL2=0

        # Stop daemons.
	gprintf "Stopping slapd: "
	pid=`cat $slapdpid`
	if checkpid $pid > /dev/null 2>&1; then
		kill -9 $pid
		RETVAL=$?
		[ $RETVAL -eq 0 ] && success "%s %s" $slapd $killlevel || failure "%s %s" $slapd $killlevel
	fi

        [ $RETVAL -eq 0  ] && rm -f /var/lock/subsys/ldap2 /var/run/slapd2.args
	echo
	return $RETVAL
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status ${slapd}
	;;
    restart)
	stop
	start
	;;
    reload)
    	killall -HUP ${slapd}
	RETVAL=$?
	;;
    condrestart)
        if [ -f /var/lock/subsys/ldap2 ] ; then
            stop
            start
        fi
	;;
    *)
	gprintf "Usage: %s {start|stop|restart|status|condrestart}\n" "$0"
	RETVAL=1
esac

exit $RETVAL