assistance needed to add 2 other routines to my script

Hello guys,

In my script, I need to add two other routines where I Manipulate the files with a 'x'

The routine looks at CLI named qip-getobjectprof that references a input file named hosts_list.txt

Then I use the CLI named qip-setobject to set the orignal name with an 'x'and move the orginal name to another IP.

All good.

Unfortunately, I also need the input file to also look in another section of the same record using another CLI named exportdnsrr
to do the same. Put an 'X' on the orginal records that are there then use another CLI enterdnsrr to move it based on the original input file.

Then of course where the option is selected Rollback to Orig. objects to do it all in reverse.

Can someone use the script I have provided and make the additions to make this all happen?

An example of the routine I want to add in the shell script:

[root@ESM1 bin]# ./exportdnsrr -f ( for filename, using the hosts_list.txt )
192.168.0.6,richie,IN,A,-1,200.200.200.1,F,,0,0,,

Then take the hostname richie and put an 'x' so it will look like richieX

then use enterdnsrr on the rollback routine to put it back

./enterdnsrr -f ( another variable since A & B are used already) to put all the changes back

Thanks

#########################################################################
#                                                                       #
# Input file to contain list of all Critical Servers with Corresponding #
# DR Servers in 2 columns eg. ip addresses only                         #
#                                                                       #
# Column 1 - Production server_1                                        #
# Column 2 - Disaster Recover dr_server_1 (failover system)             #
#                                                                       #
# 192.168.5.100 192.168.6.200                                           #
# 192.168.5.101 192.168.6.201                                           #
#                                                                       #
#                                                                       #
#########################################################################
. /opt/qip/etc/qiprc         # Source QIP Variables
. /opt/sybase/SYBASE.sh
#
# Variables Used
#
In_File="/home/ammuser/RICHARD-DR/host_list.txt"        # Input with above layout
Temp_Dir="/home/ammuser/RICHARD-DR/tmp/`date +%m_%d_%y`"    # Obect profile directory
Mod_Dir="${Temp_Dir}/modified"                 # Modified Object Profile directory
Host=1
Dns_Server="qipdrpinfs001.RICHARD.com.au" # Primary DNS Server
#
# Main Loop
#
while : {
do
clear
echo ""
#[ -f ${In_File} ] && echo "Current Input file :- ${In_File}"
[ -d ${Temp_Dir} ] && echo "Current Object Dir :- ${Temp_Dir}"
echo "==========================================================="
echo "Current Input file :- ${In_File}"
echo "Current Object Dir :- ${Temp_Dir}"
echo "==========================================================="
echo "==========================================================="
echo "(usuage) Must run as ROOT"
echo "(Must set reference qipman username and password in script"
echo ""
echo ""
echo "*********************************************************"
echo "*********************************************************"
echo "        DNS-DR Host processing - Main Menu RICHARD"
echo "*********************************************************"
echo "*********************************************************"
echo "Process DR hosts file .............a"
echo "Rollback to Orig. objects .........b"
echo "Update Primary DNS qipdrpinfs001...c"
echo "Quit...............................q"
echo "---------------------------------"
echo "Please make a selection:"
read ans
case ${ans} in
  a)
    [ -f ${In_File} ] || echo "Input file :- ${In_File} does not exist !!!"
    if [ -d ${Temp_Dir} ]
    then
    {
    echo "Destination Object Directory already Exist "
    echo "Are you sure you want to continue (y/n) ..."
    read a
        if [ "$a" = "y" ]
        then
        {
        echo "Backing up $Temp_Dir old dir ! ...."
        mv ${Temp_Dir} "${Temp_Dir}.`date +%T`" # Remove old directory
        #
        # Make Directories if does not exist
        #
        [ ! -d "${Temp_Dir}" ] && /bin/mkdir "${Temp_Dir}"
        [ ! -d "${Mod_Dir}" ] && /bin/mkdir "${Mod_Dir}"
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        echo "###########################"
        echo "Processing host file"
        cat "$In_File"
        echo "###########################"
        sleep 2
        while read a b
        do
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $a -f ${Temp_Dir}/${Host}.a.txt
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $b -f ${Temp_Dir}/${Host}.b.txt
           Host=`expr $Host + 1`
        done < ${In_File}
        #
        #
        cd ${Temp_Dir}
        #
        ###################################################################
        # Manipulate the files created above essentially renaming the
        # Production Object and creating an Alias for Prod Name to point
        # to Disaster Recovery Object
        ###################################################################
        #
        for i in `ls *.a.txt`
        do
                #
                # Store the Host name before we make changes to object profile
                # to later use as Alias to DR object
                #
           H_alias=`cat $i |grep ObjectName |awk -F= '{print $2}'`
                #
                # Append ObjectName with "x" to avoid name conflicts.
                #
           sed -e 's/^ObjectName.*/&x/' $i > ${Mod_Dir}/$i
                #
                # Work out corresponding file to the Changed Production Object
                #
           DR_File=`echo $i|awk -F. '{print $1".b."$3}'`
                #
                # Modify the matching DR Object files with Alias Entries
                #
           sed -e "s/^Aliases.*/& $H_alias/" $DR_File > $Mod_Dir/$DR_File
        done
                #
                # Commit changes to Database
                #
        cd $Mod_Dir
        for j in `ls`
        do
           qip-setobject -u qipman -p qipman -s QIPSYBASE -d $j
           echo "Setting $j ..."
        done
        }
        fi
     }
     else
     {
        #
        # Make Directories if does not exist
        #
        [ ! -d "${Temp-Dir}" ] && /bin/mkdir "${Temp_Dir}"
        [ ! -d "${Mod_Dir}" ] && /bin/mkdir "${Mod_Dir}"
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        while read a b
        do
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $a -f ${Temp_Dir}/${Host}.a.txt
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $b -f ${Temp_Dir}/${Host}.b.txt
           Host=`expr $Host + 1`
        done < ${In_File}
        #
        #
        cd ${Temp_Dir}
        #
        ###################################################################
        # Manipulate the file s created above essentially renaming the
        # Production Object and creating an Alias for Prod Name to point
        # to Disaster Recovery Object
        ###################################################################
        #
        for i in `ls *.a.txt`
        do
                #
                # Store the Host name before we make changes to object profile
                # to later use as Alias to DR object
                #
           H_alias=`cat $i |grep ObjectName |awk -F= '{print $2}'`
                #
                # Append ObjectName with "x" to avoid name conflicts.
                #
           sed -e 's/^ObjectName.*/&x/' $i > ${Mod_Dir}/$i
                #
                # Work out corresponding file to the Changed Production Object
                #
           DR_File=`echo $i|awk -F. '{print $1".b."$3}'`
                #
                # Modify the matching DR Object files with Alias Entries
                #
           sed -e "s/^Aliases.*/& $H_alias/" $DR_File > $Mod_Dir/$DR_File
        done
                #
                # Commit changes to Database
                #
        cd $Mod_Dir
        for j in `ls`
        do
           qip-setobject -u qipman -p qipman -s QIPSYBASE -d $j
           echo "Setting $j ..."
        done
     }
     fi
     sleep 2
     ;;
   b)
          {
            #cd Temp_Dir="$dir"
            echo "Rolling back objects to Original properties ..."
            cd ${Temp_Dir}
            for x in `ls *txt`
             do

               qip-setobject -u qipman -p qipman -s QIPSYBASE -d $x 2> /dev/nul
               echo "Setting $x ..."
             done
          }
        {
          echo "Rolling back objects to Original properties ..."
          cd ${Temp_Dir}
          for x in `ls *txt`
           do
             qip-setobject -u qipman -p qipman -s QIPSYBASE -d $x 2> /dev/null
             echo "Setting $x ..."
        echo "=============================================="
        echo "Objects from $x was safely reverted back !"
        echo "=============================================="
#       sleep 3
        echo "Done !"
        sleep 3
           done
        }
     ;;
   c)
     echo "Updating DNS Server ${Dns_Server} .."
     qip-dnsupdate -u qipman -p qipman -s QIPSYBASE -n ${Dns_Server}
     echo "... done."
     echo "Press any key to continue ."
     read dummy
     ;;
   q|Q)
     exit 0
     ;;
   *)
     echo "Invalid Selection ..."
     sleep 2
     ;;
esac
done

---------- Post updated at 06:24 PM ---------- Previous update was at 11:07 AM ----------

Hi,

Is this a tough one? do you need more information?

what have you attempted so far?

HI,
Well...I cant seem to grasp where the two additional routines need to go at the same time, modifying the original script to work together.

I am not an expert, but was handed this to fix. So I am seeking someone who can incorporate this.

Thank you kindly

Hi, Any luck with someone helping me?
Let me know if I can provide any more information.