2015-10-13 19:06:37 +02:00
|
|
|
package interface::bind9;
|
|
|
|
use v5.14;
|
|
|
|
use Moo;
|
|
|
|
use configuration ':all';
|
|
|
|
use remotecmd ':all';
|
|
|
|
|
|
|
|
has [ qw/mycfg tmpdir primarydnsserver secondarydnsserver/ ] => qw/is ro required 1/;
|
|
|
|
|
|
|
|
sub reload {
|
|
|
|
my ($self, $domain) = @_;
|
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
my $cmd = "rndc reload $domain";
|
2015-11-20 20:13:59 +01:00
|
|
|
say "CMD: $cmd";
|
2015-10-14 00:50:23 +02:00
|
|
|
qx/$cmd/;
|
|
|
|
$cmd = "rndc notify $domain";
|
2015-11-20 20:13:59 +01:00
|
|
|
say "CMD: $cmd";
|
2015-10-14 00:50:23 +02:00
|
|
|
qx/$cmd/;
|
2015-10-13 19:06:37 +02:00
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#my $cmd = "rndc reload $domain ";
|
|
|
|
#my $user = get_user_from_cfg($$self{mycfg});
|
|
|
|
#my $host = get_host_from_cfg($$self{mycfg});
|
|
|
|
#my $port = get_port_from_cfg($$self{mycfg});
|
2015-10-13 19:06:37 +02:00
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#remotecmd $user, $host, $port, $cmd;
|
2015-10-13 19:06:37 +02:00
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#$cmd = "rndc notify $domain ";
|
|
|
|
#remotecmd $user, $host, $port, $cmd;
|
2015-10-13 19:06:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub primary_addzone {
|
|
|
|
my ($self, $domain, $opt) = @_;
|
|
|
|
|
|
|
|
my $cmd = "rndc addzone $domain ";
|
|
|
|
|
|
|
|
if(defined $opt) {
|
|
|
|
$cmd .= "'$opt'";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $dir = get_zonedir_from_cfg($$self{mycfg});
|
|
|
|
$cmd .= "\"{ type master; file \\\"$dir/$domain\\\"; allow-transfer { ";
|
|
|
|
|
|
|
|
my $sec = $$self{secondarydnsserver};
|
|
|
|
for(@$sec) {
|
|
|
|
my $v4 = get_v4_from_cfg($_);
|
|
|
|
my $v6 = get_v6_from_cfg($_);
|
|
|
|
|
|
|
|
$cmd .= $v4 . '; ' if $v4;
|
|
|
|
$cmd .= $v6 . '; ' if $v6;
|
|
|
|
}
|
|
|
|
$cmd .= " }; notify yes; };\"";
|
|
|
|
}
|
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
# if remote rndc
|
|
|
|
#my $user = get_user_from_cfg($$self{mycfg});
|
|
|
|
#my $host = get_host_from_cfg($$self{mycfg});
|
|
|
|
#my $port = get_port_from_cfg($$self{mycfg});
|
2015-10-13 19:06:37 +02:00
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#remotecmd $user, $host, $port, $cmd;
|
|
|
|
|
|
|
|
qx/$cmd/;
|
2015-10-13 19:06:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub reconfig {
|
|
|
|
my ($self, $domain) = @_;
|
|
|
|
|
|
|
|
my $cmd = "rndc reconfig ";
|
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#my $user = get_user_from_cfg($$self{mycfg});
|
|
|
|
#my $host = get_host_from_cfg($$self{mycfg});
|
|
|
|
#my $port = get_port_from_cfg($$self{mycfg});
|
2015-10-13 19:06:37 +02:00
|
|
|
|
2015-10-14 00:50:23 +02:00
|
|
|
#remotecmd $user, $host, $port, $cmd;
|
|
|
|
|
|
|
|
qx/$cmd/;
|
2015-10-13 19:06:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub delzone {
|
|
|
|
my ($self, $domain) = @_;
|
|
|
|
|
2015-11-20 20:13:59 +01:00
|
|
|
my $cmd = "rndc delzone $domain ";
|
2015-10-13 19:06:37 +02:00
|
|
|
|
|
|
|
my $user = get_user_from_cfg($$self{mycfg});
|
|
|
|
my $host = get_host_from_cfg($$self{mycfg});
|
|
|
|
my $port = get_port_from_cfg($$self{mycfg});
|
|
|
|
|
2015-11-20 20:13:59 +01:00
|
|
|
#remotecmd $user, $host, $port, $cmd;
|
|
|
|
qx/$cmd/;
|
2015-10-13 19:06:37 +02:00
|
|
|
|
|
|
|
my $file = get_zonedir_from_cfg($$self{mycfg});
|
|
|
|
$file .= "/$domain";
|
|
|
|
|
|
|
|
$cmd = "rm $file";
|
|
|
|
|
|
|
|
remotecmd $user, $host, $port, $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|