aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-bind-include.pl
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
committerJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
commit2a0c0a3dbbdf7fa5040953c0b0d88ad6f62c011e (patch)
tree92c7cbf54272466b46f64e5dc8d1ddb429858836 /tools/make-bind-include.pl
parentfe0be5960aac1f9bb600dbf853d862a9f4e60de8 (diff)
Initial commit. Source; TG13-goodiebag.
Diffstat (limited to 'tools/make-bind-include.pl')
-rwxr-xr-xtools/make-bind-include.pl51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/make-bind-include.pl b/tools/make-bind-include.pl
new file mode 100755
index 0000000..d688dec
--- /dev/null
+++ b/tools/make-bind-include.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -I /root/tgmanage
+
+# TODO: Port this to the "master|slave base" parameter syntax!
+
+use strict;
+
+unless ( (($#ARGV == 0 ) || ( $#ARGV == 1))
+ && (( $ARGV[0] eq "master" ) || ( $ARGV[0] eq "slave" )) )
+{
+ print STDERR "Invalid usage!\ncat netnames.txt | $0 <master|slave> [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 $masterinclude = $bind_base . "named.master-include.conf";
+my $slaveinclude = $bind_base . "named.slave-include.conf";
+
+my $glob;
+my @configs;
+
+if ( $role eq "master" )
+{
+ $glob = $bind_base . "conf-master/*.conf";
+ @configs = glob($glob);
+
+ open CONF, ">" . $masterinclude or die ( $! . " " . $masterinclude);
+ foreach my $config ( @configs )
+ {
+ print CONF "include \"" . $config . "\";\n";
+ }
+ close CONF;
+}
+
+if ( $role eq "slave" )
+{
+ $glob = $bind_base . "conf-slave/*.conf";
+ @configs = glob($glob);
+
+ open CONF, ">" . $slaveinclude or die ( $! . " " . $slaveinclude);
+ foreach my $config ( @configs )
+ {
+ print CONF "include \"" . $config . "\";\n";
+ }
+ close CONF;
+}