Created
July 31, 2011 03:55
-
-
Save deanet/1116366 to your computer and use it in GitHub Desktop.
Open LDAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# ldap This shell script takes care of starting and stopping | |
# ldap servers (slapd and slurpd). | |
# | |
# chkconfig: - 27 73 description: LDAP stands for Lightweight Directory Access Protocol, used \ | |
# for implementing the industry standard directory services. processname: slapd config: | |
# /etc/openldap/slapd.conf pidfile: /var/run/openldap/slapd.pid | |
# Source function library. | |
export PATH=/usr/local/openldap2.4/bin:/usr/local/openldap2.4/sbin:/usr/local/openldap2.4/libexec:$PATH | |
. /etc/init.d/functions | |
slapd=/usr/local/openldap2.4/libexec/slapd | |
slurpd=/usr/sbin/slurpd | |
slaptest=/usr/local/openldap2.4/sbin/slaptest | |
[ -x ${slapd} ] || exit 1 | |
RETVAL=0 | |
function start() { | |
# Define a couple of local variables which we'll need. Maybe. | |
user=ldap | |
prog=`basename ${slapd}` | |
# Start daemons. | |
echo -n $"Starting $prog: " | |
#ulimit $ULIMIT_SETTINGS > /dev/null 2>&1 | |
daemon --check=$prog ${slapd} | |
RETVAL=$? | |
echo | |
touch /var/lock/subsys/ldap | |
return $RETVAL | |
} | |
function stop() { | |
# Stop daemons. | |
echo -n $"Stopping $prog: " | |
killproc ${slapd} | |
RETVAL=$? | |
# echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ldap /usr/local/openldap2.4/var/run/slapd.pid | |
return $RETVAL | |
} | |
# See how we were called. | |
case "$1" in | |
configtest) | |
configtest | |
;; | |
start) | |
start | |
RETVAL=$? | |
;; | |
stop) | |
stop | |
RETVAL=$? | |
;; | |
status) | |
status ${slapd} | |
RETVAL=$? | |
if grep -q "^replogfile" /usr/local/openldap2.4/etc/openldap/slapd.conf ; then | |
status ${slurpd} | |
RET=$? | |
if [ $RET -ne 0 ] ; then | |
RETVAL=$RET; | |
fi | |
fi | |
;; | |
restart) | |
stop | |
start | |
;; | |
condrestart) | |
if [ -f /var/lock/subsys/ldap ] ; then | |
stop | |
start | |
RETVAL=$? | |
fi | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|status|condrestart}" | |
RETVAL=1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment