From d5c0e6ac02bd4bb1832434ef3fa502a21ac48432 Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Sat, 21 Mar 2015 18:40:28 +0100 Subject: Bootstrap-related files get it's own directory --- bootstrap/make-named.pl | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 bootstrap/make-named.pl (limited to 'bootstrap/make-named.pl') diff --git a/bootstrap/make-named.pl b/bootstrap/make-named.pl new file mode 100755 index 0000000..a9ea02d --- /dev/null +++ b/bootstrap/make-named.pl @@ -0,0 +1,129 @@ +#!/usr/bin/perl -I /root/tgmanage +use strict; + +BEGIN { + require "include/config.pm"; + eval { + require "include/config.local.pm"; + }; +} + + +use Net::IP; +use Net::IP qw(:PROC); + +unless ( (($#ARGV == 0 ) || ( $#ARGV == 1)) + && (( $ARGV[0] eq "master" ) || ( $ARGV[0] eq "slave" )) ) +{ + print STDERR "Invalid usage!\ncat netnames.txt | $0 [basedir]\n"; + exit 1; +} + +my $role = $ARGV[0]; + +my $base = "/etc"; +$base = $ARGV[1] if $#ARGV == 1; +$base .= "/" if not $base =~ m/\/$/ and not $base eq ""; + +my $bind_base = $base . "bind/"; +my $named_file = $bind_base . "named.conf"; + +if ( -f $named_file ) +{ + print STDERR $named_file . " already exists. Cowardly refusing to continue.\n"; + exit; +} + +my $run = `date +%Y%m%d-%H%M`; + +open NFILE, ">" . $named_file or die ( $! . " " . $named_file ); + +chomp $run; +print NFILE <