From: <sar...@us...> - 2010-09-17 23:17:48
|
Update of /cvsroot/ceps/scripts In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv15752 Modified Files: Tag: RHEL5U8_Migration dnsregister.sh Log Message: Bug fixex related to restore of the original names in DNS Index: dnsregister.sh =================================================================== RCS file: /cvsroot/ceps/scripts/Attic/dnsregister.sh,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** dnsregister.sh 17 Sep 2010 07:30:31 -0000 1.1.2.3 --- dnsregister.sh 17 Sep 2010 23:17:39 -0000 1.1.2.4 *************** *** 16,19 **** --- 16,20 ---- TUPD_SCRIPT=/tmp/upd.$$ AMPROG=/usr/ceps/bin/eman-am + RM="rm -f" # Check for correct command line arguments if [ $# -ne 2 ] *************** *** 35,73 **** AMARGS="-username=$scr_username -password=$scr_password" ! # Construct DHCP IP notation may registered in DNS, if it is DHCP convertIP=`echo ${pIPaddr} | sed -e 's/\./-/g'` - dhcpDnsName=dhcp-${convertIP}.cisco.com - - # Construct BOOTP scropt IP name, if it is from BOOTP pool - locc=`pradmin gate ${pIPaddr} sh | grep "Location Code" | awk '{ print $4 }' | tr [A-Z] [a-z]` - bootpDnsName=printer-${locc}-${convertIP}.cisco.com # Check whether it is BOOTP IP? ! isBootp=0 ! pradmin gate ${pIPaddr} sh | grep ${pIPaddr} | while read IP BOOTP AVIAL ! do ! if [ "${BOOTP}" = "Y" ] ! then ! isBootp=1 ! fi ! done # Check the device is already registered in DNS using nslookup nsl_result=`nslookup ${prnName} | egrep "Name|Address" | grep -v "#" | awk -F: '{ print $2 }' | sed 's/[ |\t]//g'` ! # if the result is nothing. The hostname is not registered in DNS. We need to register now if [ -z "$nsl_result" ] then echo "# This is new Printer \"$pName\", not yet registered in DNS" >> ${LOG_FILE} ! if [ "$isBootp" = "1" ] then echo "# -f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" >> ${TREG_SCRIPT} else echo "# -f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" >> ${TREG_SCRIPT} fi echo "# -f=int-add -name=${prnName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-add -name=${prnName} -ipaddress=${pIPaddr}" > ${TREG_SCRIPT} # Register in DNS --- 36,73 ---- AMARGS="-username=$scr_username -password=$scr_password" ! # Convert the IP with "-" to use it in the dhcp / bootp name construction convertIP=`echo ${pIPaddr} | sed -e 's/\./-/g'` # Check whether it is BOOTP IP? ! sddbIP=`pradmin gate ${pIPaddr} sh | grep ${pIPaddr} | awk '{if ($2 ~ /Y/) print $1}'` ! if [ ! -z $sddbIP ] ! then ! ipType="bootp" ! # Construct BOOTP scrope IP name ! locc=`pradmin gate ${pIPaddr} sh | awk '/Location Code/ {print tolower($4)}'` ! bootpDnsName=printer-${locc}-${convertIP}.cisco.com ! else ! ipType="dhcp" ! # Construct default DHCP IP host name, that may registered in DNS ! dhcpDnsName=dhcp-${convertIP}.cisco.com ! fi # Check the device is already registered in DNS using nslookup nsl_result=`nslookup ${prnName} | egrep "Name|Address" | grep -v "#" | awk -F: '{ print $2 }' | sed 's/[ |\t]//g'` ! # if the result is nothing. The hostname is not registered in DNS. We need to register now as new device if [ -z "$nsl_result" ] then echo "# This is new Printer \"$pName\", not yet registered in DNS" >> ${LOG_FILE} ! if [ "$ipType" = "bootp" ] then echo "# -f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" > ${TREG_SCRIPT} else echo "# -f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" > ${TREG_SCRIPT} fi echo "# -f=int-add -name=${prnName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-add -name=${prnName} -ipaddress=${pIPaddr}" >> ${TREG_SCRIPT} # Register in DNS *************** *** 88,105 **** # Construct DHCP IP notation may registered in DNS, if it is DHCP old_convertIP=`echo ${ipaddr} | sed -e 's/\./-/g'` ! old_dhcpDnsName=dhcp-${convertIP}.cisco.com # Check whether it is BOOTP IP? ! oldIsBootp=0 ! pradmin gate ${ipaddr} sh | grep ${ipaddr} | while read IP Bootp Avial ! do ! if [ "${Bootp}" = "Y" ] ! then ! oldIsBootp=1 ! # Construct BOOTP IP name ! locc=`pradmin gate ${ipaddr} sh | grep "Location Code" | awk '{ print $4 }' | tr [A-Z] [a-z]` ! old_bootpDnsName=printer-${locc}-${convertIP}.cisco.com ! fi ! done if [ "${device}" = "${prnName}" ] --- 88,104 ---- # Construct DHCP IP notation may registered in DNS, if it is DHCP old_convertIP=`echo ${ipaddr} | sed -e 's/\./-/g'` ! old_dhcpDnsName=dhcp-${old_convertIP}.cisco.com # Check whether it is BOOTP IP? ! isSddbIP=`pradmin gate ${ipaddr} sh | grep ${ipaddr} | awk '{if ($2 ~ /Y/) print $1}'` ! if [ ! -z $isSddbIP ] ! then ! oldIpType="bootp" ! # Construct BOOTP IP name ! locc=`pradmin gate ${ipaddr} sh | grep "Location Code" | awk '{ print $4 }' | tr [A-Z] [a-z]` ! old_bootpDnsName=printer-${locc}-${old_convertIP}.cisco.com ! else ! oldIpType=dhcp ! fi if [ "${device}" = "${prnName}" ] *************** *** 114,118 **** echo "# -f=int-del -name=${prnName} -ipaddress=${ipaddr}" >> ${LOG_FILE} echo "-f=int-del -name=${prnName} -ipaddress=${ipaddr}" > ${TUPD_SCRIPT} ! if [ "$oldIsBootp" = "1" ] then echo "# -f=int-add -name=${old_bootpDnsName} -ipaddress=${ipaddr}" >> ${LOG_FILE} --- 113,117 ---- echo "# -f=int-del -name=${prnName} -ipaddress=${ipaddr}" >> ${LOG_FILE} echo "-f=int-del -name=${prnName} -ipaddress=${ipaddr}" > ${TUPD_SCRIPT} ! if [ "$oldIpType" = "bootp" ] then echo "# -f=int-add -name=${old_bootpDnsName} -ipaddress=${ipaddr}" >> ${LOG_FILE} *************** *** 124,134 **** echo "# Register with new interface : $pIPaddr" >> ${LOG_FILE} ! if [ "$isBootp" = "1" ] then ! echo "# -f=int-del -name=${bootpDnsName} -ipaddress=${ipaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${bootpDnsName} -ipaddress=${ipaddr}" > ${TUPD_SCRIPT} else ! echo "# -f=int-del -name=${dhcpDnsName} -ipaddress=${ipaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${dhcpDnsName} -ipaddress=${ipaddr}" > ${TUPD_SCRIPT} fi echo "# -f=int-add -name=${prnName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} --- 123,133 ---- echo "# Register with new interface : $pIPaddr" >> ${LOG_FILE} ! if [ "$ipType" = "bootp" ] then ! echo "# -f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${bootpDnsName} -ipaddress=${pIPaddr}" >> ${TUPD_SCRIPT} else ! echo "# -f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} ! echo "-f=int-del -name=${dhcpDnsName} -ipaddress=${pIPaddr}" >> ${TUPD_SCRIPT} fi echo "# -f=int-add -name=${prnName} -ipaddress=${pIPaddr}" >> ${LOG_FILE} *************** *** 153,156 **** --- 152,158 ---- # $Id$ # $Log$ + # Revision 1.1.2.4 2010/09/17 23:17:39 saravanc + # Bug fixex related to restore of the original names in DNS + # # Revision 1.1.2.3 2010/09/17 07:30:31 saravanc # Taken care to restore the previous dns name registration |