aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ManaTools/Shared
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2016-10-09 21:39:05 +0200
committerAngelo Naselli <anaselli@linux.it>2016-10-09 21:39:05 +0200
commit4b91d04b4228043cc2c77bf171683d10fa735f0c (patch)
tree05f65edeed079afcde7d1c0e3edbe7281099d1bd /lib/ManaTools/Shared
parentb0da9bf7734c0d0a9c2ec4464e0bb41dcbb4cc7f (diff)
downloadmanatools-4b91d04b4228043cc2c77bf171683d10fa735f0c.tar
manatools-4b91d04b4228043cc2c77bf171683d10fa735f0c.tar.gz
manatools-4b91d04b4228043cc2c77bf171683d10fa735f0c.tar.bz2
manatools-4b91d04b4228043cc2c77bf171683d10fa735f0c.tar.xz
manatools-4b91d04b4228043cc2c77bf171683d10fa735f0c.zip
First attempt to fix chrony pool configuration
Diffstat (limited to 'lib/ManaTools/Shared')
-rw-r--r--lib/ManaTools/Shared/TimeZone.pm29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/ManaTools/Shared/TimeZone.pm b/lib/ManaTools/Shared/TimeZone.pm
index cebf3d96..343c5e9f 100644
--- a/lib/ManaTools/Shared/TimeZone.pm
+++ b/lib/ManaTools/Shared/TimeZone.pm
@@ -836,7 +836,7 @@ sub ntpServers {
=head3 OUTPUT
- @servers: arrey of configured server
+ @servers: array of configured server
=head3 DESCRIPTION
@@ -856,6 +856,10 @@ sub ntpCurrentServers {
}
else {
@serv = map { MDK::Common::Func::if_(/^\s*server\s+(\S*)/, $1) } MDK::Common::File::cat_($configFile);
+ if (! scalar @serv) {
+ ## TODO manage as servers and pool
+ @serv = map { MDK::Common::Func::if_(/^\s*pool\s+(\S*)/, $1) } MDK::Common::File::cat_($configFile);
+ }
}
my @s = ();
@@ -927,7 +931,9 @@ sub isNTPRunning {
=head3 INPUT
- $servers: Array reference containing NTP server addresses
+ $NTP_servers: HASH reference containing:
+ servers => Array reference containing NTP server addresses
+ pool => ntp pool address if any
=head3 DESCRIPTION
@@ -939,11 +945,14 @@ sub isNTPRunning {
#=============================================================
sub setNTPConfiguration {
- my ($self, $servers) = @_;
+ my ($self, $NTP_servers) = @_;
- my $f = $self->ntp_configuration_file || $self->getNTPServiceConfig($self->ntp_program);;
+ my $f = $self->ntp_configuration_file || $self->getNTPServiceConfig($self->ntp_program);
-f $f or return;
+ my $servers = $NTP_servers->{servers};
+ my $pool = [ $NTP_servers->{pool} ];
+
die $self->loc->N("user does not have the rights to change configuration file, skipped")
if (!(-w $f));
@@ -955,10 +964,6 @@ sub setNTPConfiguration {
$added = 1;
}
} $f;
- if ($self->ntp_program eq "ntpd") {
- my $ntp_prefix = $self->ntp_conf_dir;
- MDK::Common::File::output_p("$ntp_prefix/step-tickers", join('', map { "$_\n" } @{$servers}));
- }
}
else {
my $added = 0;
@@ -969,6 +974,14 @@ sub setNTPConfiguration {
$added = 1;
}
} $f;
+ if ($pool) {
+ MDK::Common::File::substInFile {
+ if (/^#?\s*pool\s+(\S*)/ && $1 ne '127.127.1.0') {
+ $_ = $added ? "#pool $1\n" : join('', map { "pool $_$servername_config_suffix\n" } @{$pool});
+ $added = 1;
+ }
+ } $f;
+ }
if ($self->ntp_program eq "ntpd") {
my $ntp_prefix = $self->ntp_conf_dir;
MDK::Common::File::output_p("$ntp_prefix/step-tickers", join('', map { "$_\n" } @{$servers}));