modifications de dernière minute, mise en prod réussie \o/
parent
527313614c
commit
e94224b6f2
|
@ -4,6 +4,7 @@ use Moo;
|
|||
|
||||
use db;
|
||||
use zone;
|
||||
use configuration ':all';
|
||||
|
||||
has db => ( is => 'rw', builder => '_void');
|
||||
|
||||
|
@ -16,6 +17,9 @@ sub BUILD {
|
|||
my ($self) = @_;
|
||||
$$self{db} = db->new(data => $self);
|
||||
|
||||
my $tmpdir = get_tmpdir_from_uri($$self{tmpdir});
|
||||
-f $tmpdir || qx/mkdir -p $tmpdir/;
|
||||
|
||||
my $db = $$self{database};
|
||||
unless(exists $$db{sgbd} && exists $$db{name}
|
||||
&& exists $$db{host} && exists $$db{port}
|
||||
|
|
|
@ -16,6 +16,7 @@ get_v6_from_cfg
|
|||
get_host_from_cfg
|
||||
get_user_from_cfg
|
||||
get_port_from_cfg
|
||||
get_tmpdir_from_uri
|
||||
/;
|
||||
|
||||
# bundle of exports (tags)
|
||||
|
@ -30,6 +31,7 @@ get_v6_from_cfg
|
|||
get_host_from_cfg
|
||||
get_user_from_cfg
|
||||
get_port_from_cfg
|
||||
get_tmpdir_from_uri
|
||||
/] );
|
||||
|
||||
sub is_conf_file {
|
||||
|
@ -102,6 +104,14 @@ sub get_v4_from_cfg {
|
|||
$$cfg{domain}{v4} // get_v4_from_name($$cfg{domain}{name})
|
||||
}
|
||||
|
||||
sub get_tmpdir_from_uri {
|
||||
my $tmpdir = shift;
|
||||
unless($tmpdir) {
|
||||
die 'There is no tmpdir';
|
||||
}
|
||||
URI->new($tmpdir)->path;
|
||||
}
|
||||
|
||||
sub get_zonedir_from_cfg {
|
||||
my $cfg = shift;
|
||||
unless($$cfg{zonedir}) {
|
||||
|
|
|
@ -10,15 +10,19 @@ sub reload {
|
|||
my ($self, $domain) = @_;
|
||||
|
||||
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});
|
||||
|
||||
remotecmd $user, $host, $port, $cmd;
|
||||
|
||||
qx/$cmd/;
|
||||
$cmd = "rndc notify $domain";
|
||||
remotecmd $user, $host, $port, $cmd;
|
||||
qx/$cmd/;
|
||||
|
||||
#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});
|
||||
|
||||
#remotecmd $user, $host, $port, $cmd;
|
||||
|
||||
#$cmd = "rndc notify $domain ";
|
||||
#remotecmd $user, $host, $port, $cmd;
|
||||
}
|
||||
|
||||
sub primary_addzone {
|
||||
|
@ -44,11 +48,14 @@ sub primary_addzone {
|
|||
$cmd .= " }; notify yes; };\"";
|
||||
}
|
||||
|
||||
my $user = get_user_from_cfg($$self{mycfg});
|
||||
my $host = get_host_from_cfg($$self{mycfg});
|
||||
my $port = get_port_from_cfg($$self{mycfg});
|
||||
# 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});
|
||||
|
||||
remotecmd $user, $host, $port, $cmd;
|
||||
#remotecmd $user, $host, $port, $cmd;
|
||||
|
||||
qx/$cmd/;
|
||||
}
|
||||
|
||||
sub reconfig {
|
||||
|
@ -56,17 +63,19 @@ sub reconfig {
|
|||
|
||||
my $cmd = "rndc reconfig ";
|
||||
|
||||
my $user = get_user_from_cfg($$self{mycfg});
|
||||
my $host = get_host_from_cfg($$self{mycfg});
|
||||
my $port = get_port_from_cfg($$self{mycfg});
|
||||
#my $user = get_user_from_cfg($$self{mycfg});
|
||||
#my $host = get_host_from_cfg($$self{mycfg});
|
||||
#my $port = get_port_from_cfg($$self{mycfg});
|
||||
|
||||
remotecmd $user, $host, $port, $cmd;
|
||||
#remotecmd $user, $host, $port, $cmd;
|
||||
|
||||
qx/$cmd/;
|
||||
}
|
||||
|
||||
sub delzone {
|
||||
my ($self, $domain) = @_;
|
||||
|
||||
my $cmd = "rndc delzone $domain ";
|
||||
my $cmd = "sudo rndc delzone $domain ";
|
||||
|
||||
my $user = get_user_from_cfg($$self{mycfg});
|
||||
my $host = get_host_from_cfg($$self{mycfg});
|
||||
|
|
|
@ -15,8 +15,7 @@ sub reload_sec {
|
|||
|
||||
$self->_reload_conf($slavedzones);
|
||||
|
||||
my $cmd = "sudo nsdc rebuild && "
|
||||
. " sudo nsdc restart ";
|
||||
my $cmd = "sudo nsdc rebuild && sudo nsdc restart && sudo nsdc patch ";
|
||||
|
||||
my $user = get_user_from_cfg($$self{mycfg});
|
||||
my $host = get_host_from_cfg($$self{mycfg});
|
||||
|
@ -42,28 +41,36 @@ sub _reload_conf {
|
|||
copycat $remote, $f;
|
||||
|
||||
my $data = read_file $f;
|
||||
|
||||
# if it's the first time we get the configuration, fresh start
|
||||
$data .= "\n## BEGIN_GENERATED" if( $data !~ /BEGIN_GENERATED/);
|
||||
|
||||
my $v4 = get_v4_from_cfg($$self{primarydnsserver});
|
||||
my $v6 = get_v6_from_cfg($$self{primarydnsserver});
|
||||
|
||||
my $debut = "## BEGIN_GENERATED";
|
||||
|
||||
my $nouveau = '';
|
||||
my $dnsslavekey = get_dnsslavekey_from_cfg($$self{primarydnsserver});
|
||||
|
||||
for(@{$slavedzones}) {
|
||||
|
||||
$nouveau .= "zone:\n\n\tname: \"$_\"\n"
|
||||
. "\tzonefile: \"slave/$_\"\n\n";
|
||||
$nouveau .= "zone:\n\tname: \"$$_{domain}\"\n"
|
||||
. "\tzonefile: \"slave/$$_{domain}\"\n";
|
||||
|
||||
my $v4 = get_v4_from_cfg($$self{primarydnsserver});
|
||||
my $v6 = get_v6_from_cfg($$self{primarydnsserver});
|
||||
say "domain : $$_{domain}";
|
||||
|
||||
if($v4) {
|
||||
# allow notify & request xfr, v4 & v6
|
||||
$nouveau .= "\tallow-notify: $v4 $dnsslavekey \n"
|
||||
. "\trequest-xfr: $v4 $dnsslavekey \n\n";
|
||||
$nouveau .= "\tallow-notify: $v4 \"$dnsslavekey\" \n"
|
||||
. "\trequest-xfr: $v4 \"$dnsslavekey\" \n";
|
||||
}
|
||||
|
||||
if($v6) {
|
||||
$nouveau .= "\tallow-notify: $v6 $dnsslavekey \n"
|
||||
. "\trequest-xfr: $v6 $dnsslavekey \n\n";
|
||||
$nouveau .= "\tallow-notify: $v6 \"$dnsslavekey\" \n"
|
||||
. "\trequest-xfr: $v6 \"$dnsslavekey\" \n";
|
||||
}
|
||||
$nouveau .= "\n";
|
||||
}
|
||||
|
||||
$data =~ s/$debut.*/$debut\n$nouveau/gsm;
|
||||
|
@ -71,10 +78,9 @@ sub _reload_conf {
|
|||
write_file $f, $data;
|
||||
copycat $f, $remote;
|
||||
|
||||
my $cmd = "sudo nsdc patch && "
|
||||
. " sudo rm /var/nsd3/ixfr.db";
|
||||
my $cmd = "sudo nsdc patch && sudo rm /var/nsd3/ixfr.db";
|
||||
|
||||
remotecmd $user, $host, $port, $cmd;
|
||||
remotecmd $user, $host, $port, $cmd
|
||||
}
|
||||
|
||||
sub reconfig {
|
||||
|
|
Reference in New Issue