BASH   93
enslave sh
Guest on 16th March 2023 12:16:05 AM


  1. #!/bin/bash
  2.  
  3. #
  4. # This is sed to convert bind master "named.conf.local" into
  5. # slave "named.conf.local" for paired secondary server.
  6. #
  7. # Example from:
  8. # zone "example.com" {
  9. #        type master;
  10. #        file "/etc/bind/local-zones/example.com.zone";
  11. # };
  12. #
  13. # Example to:
  14. # zone "example.com" {
  15. #        type slave;
  16. #        file "/etc/bind/local-zones/example.com.zone";
  17. #        masters {
  18. #                10.10.3.21;
  19. #        };
  20. #};
  21. #
  22. # Script was written for a very specific set of input files, it may barf
  23. # if you try to use it on yours.  In particular you can't have more than one
  24. # instance of "};" other than the one terminating each block.
  25. #
  26. # Eli Fulkerson 2015
  27.  
  28. if [ -z "$1" ]; then
  29.         echo "Syntax:  enslave.sh inputfilename";
  30.     exit 1;
  31. fi
  32.  
  33. #@@set this as appropriate
  34. MASTERNS="8.8.8.8";
  35.  
  36. cat $1 | sed "s/type master\;/type slave\;/g" | sed "s/}\;/\tmasters {\n\t\t`echo $MASTERNS`;\n\t}\;\n}\;/g"

Raw Paste

Login or Register to edit or fork this paste. It's free.