This is an old revision of the document!


ldapreplicationtest.sh

cat ldapreplicationtest.sh

#!/bin/bash
#Written Andrew Stringer, 25/03/2013 onwards to test ldap replication.
#This script will update value on master server and then check for updates on slave servers
#$1 should be update or check

#The attribute used to test replication is "description"

#turn on debugging, -x starts, +x stops
set +x

#Set up variables
BINDNAME="'cn=Andrew Stringer,ou=People,dc=prod,dc=domain,dc=net'"
BINDPASSWORD="'AugMent'"
SEARCHBASE="'cn=Test User,ou=People,dc=prod,dc=domain,dc=net'"
SCOPE='base'

echo "\${BINDNAME} is >${BINDNAME}<"
echo "\${SEARCHBASE} is >${SEARCHBASE}<"

#Example command to run:-
#ldapsearch -x -D 'cn=Test User,ou=People,dc=prod,dc=domain,dc=net' -w 'ChangeME'
#-b cn=Test User,ou=People,dc=prod,dc=domain,dc=net -s base -h gy-asp-inet01.prod.domain.net description

#Result:-
# Test User, People, prod.domain.net
#dn: cn=Test User,ou=People,dc=prod,dc=domain,dc=net
#description: 25-03-2013=11:45
# search result
#search: 2
#result: 0 Success
# numResponses: 2
# numEntries: 1



#set to 3 for testing, this forces sending mail, normally should be 0
SENDEMAIL=0

EMAIL=andrew.stringer@mycompany.com
LOGFILE=/usr/local/SiteScope/scripts/ldap/reploglog.txt
TMPLOG=/tmp/tmplog.txt-$$

DATE=`date +%b" "%d" "%Y`
DAY=`date +%a`
DATENUM=`date +%d`
echo " " >> ${LOGFILE}
echo -n "${DATE} - " >> ${LOGFILE}

#Test to force 1st of the month
#DATENUM=01
if [ $DATENUM == 01 ]
then
        MONTHTEST=" - 1st of the month test email."
        SENDEMAIL=2
fi




#Start of code
#=============

echo "LDAP replication test script" > ${TMPLOG}
echo "================================" >> ${TMPLOG}
echo "" >> ${TMPLOG}
echo "From /usr/local/SiteScope/scripts/ldap/ldapreplicationtest.sh on `hostname`" >> ${TMPLOG}
echo "" >> ${TMPLOG};
echo "" >> ${TMPLOG};


echo "ldapsearch -x -D ${BINDNAME} -w ${BINDPASSWORD} -b ${SEARCHBASE} -s ${SCOPE} -h gy-asp-inet01.prod.domain.net description"
ldapsearch -x -D ${BINDNAME} -w ${BINDPASSWORD} -b ${SEARCHBASE} -s ${SCOPE} -h gy-asp-inet01.prod.domain.net description







#Clean up any mess and finish
#============================
rm ${TMPLOG}

#exit with return status reflecting how it all went.
exit ${SENDEMAIL}
[scope@gy-mon01 ldap]$ cat ldapserverlist.txt
gy-inet01.prod.domain.net
gy-inet02.prod.domain.net
gi-inet01.giprod.int.domain.com
gi-inet02.giprod.int.domain.com
ka-inet01.kaprod.int.domain.com
ka-inet02.kaprod.int.domain.com

rb/openldapreplicationtest.1534376851.txt.gz · Last modified: 16/08/2018 00:47 by andrew