Forum Discussion

zhuqingedu's avatar
zhuqingedu
Level 4
9 years ago

How to use a script to update the client configuration?

In our environment,there is no dns server,so wo used the /etc/hosts to resovle server and client,now We have added four servers,We need to add the resolve to all of the 300 clients,who can provide me...
  • RiaanBadenhorst's avatar
    9 years ago

    Try this.

    Create bpstart_notify.updatehostfiles.bat on your master server. (I'm giving example for Windows but same can be done for Unix clients.) In this script put the code to update your hosts file. Or alternatively just call that script from bpstart_noifty (but then you need to backup and restore both files in the steps below)

    Back this file up to disk storage unit.

    Create a batch file to restore this file to each windows client (using bprestore)

    After the file is restores (deployed)

    Run a policy to backups anything on all clients and call that policy updatehostfiles so that it is the only policy that activates the script.

     

  • Genericus's avatar
    9 years ago

    To add it to the top, you can use the same process.

    1. access server

    2. copy existing /etc/hosts as before

    3. create NEW hosts file header using echo "line to add " > /etc/hosts.NEW (NOTE 1 > creates new file)

    4. add any new lines to top like     echo "new line to add at top" >> /etc/hosts.NEW (NOTE 2 >> updates file)

    5. cat /etc/hosts.YYMMDD | grep -v "old name" >> /etc/hosts.NEW (this excludes lines you do not want)

    at this point /etc/hosts.NEW should be what you want. 

    6, cp -p /etc/hosts.NEW /etc/hosts

    You should be able to use "grep -v " as many times as you need in line 5, like

    cat /etc/hosts.YYMMDD | grep -v bad.ip | grep -v "bad.name" | grep -v "anything to exclude" >> /etc/hosts.NEW

     

    Run a couple of tests to make sure you are getting what you want. 

     

    You can likely Google better detailed help on this, it is OS shell scripting, not so muich NetBackup related.