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=wagerware,dc=net'" #BINDPASSWORD="'LetMeIn1234'" BINDPASSWORD="'Augu5t2010'" SEARCHBASE="'cn=Test User,ou=People,dc=prod,dc=wagerware,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=wagerware,dc=net' -w 'LetMeIn1234' #-b cn=Test User,ou=People,dc=prod,dc=wagerware,dc=net -s base -h gy-asp-inet01.prod.wagerware.net description #Result:- # Test User, People, prod.wagerware.net #dn: cn=Test User,ou=People,dc=prod,dc=wagerware,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.wagerware.net description" ldapsearch -x -D ${BINDNAME} -w ${BINDPASSWORD} -b ${SEARCHBASE} -s ${SCOPE} -h gy-asp-inet01.prod.wagerware.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.wagerware.net gy-inet02.prod.wagerware.net gi-inet01.giprod.int.igt.com gi-inet01.giprod.int.igt.com ka-inet01.kaprod.int.igt.com ka-inet01.kaprod.int.igt.com