From 143675198e9c0fcef3335affa224c6b9799a9a6b Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Wed, 25 Mar 2015 12:36:24 +0100 Subject: fixed isNTPRunning and its test --- lib/ManaTools/Shared/TimeZone.pm | 48 ++++++++++------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) (limited to 'lib/ManaTools') diff --git a/lib/ManaTools/Shared/TimeZone.pm b/lib/ManaTools/Shared/TimeZone.pm index d481bf2..121a123 100644 --- a/lib/ManaTools/Shared/TimeZone.pm +++ b/lib/ManaTools/Shared/TimeZone.pm @@ -165,7 +165,7 @@ sub _ntp_program_init { # looks for a running service from the configured ones, # if none is running chooses the first of the list my $list = $self->ntpServiceList(); - return $self->loc->N("No NTP services") if !$list; + return "" if !$list; my $ntpd; my $isRunning = 0; @@ -891,43 +891,19 @@ sub isNTPRunning { my $self = shift; my $ntpd = $self->ntp_program; - my $isRunning = $self->sh_services->is_service_running($ntpd); + my $isRunning = $ntpd ? $self->sh_services->is_service_running($ntpd) : 0; if (!$isRunning) { - my @ntp_service = ("chronyd", "ntpd"); - foreach ( @ntp_service ) { - $ntpd = $_; - $isRunning = $self->sh_services->is_service_running($ntpd); - last if $isRunning; - } - if ($isRunning) { - $self->ntp_program($ntpd); - if ($ntpd eq "chronyd") { - $self->ntp_configuration_file("/etc/chrony.conf"); - } - elsif ($ntpd eq "ntpd") { - $self->ntp_configuration_file("/etc/ntp.conf"); - } - } - else { - # fallback systemd-timesyncd - - if ($self->getEmbeddedNTP()) { - $ntpd = "systemd-timesyncd"; - $self->ntp_program($ntpd); - $self->ntp_configuration_file("/etc/systemd/timesyncd.conf"); - $isRunning = $self->sh_services->is_service_running($ntpd); - # if it is not started you cannot set time with NTP true - if (!$isRunning) { - Sys::Syslog::syslog( - 'info|local1', - $self->loc->N("%s enabled but stopped - disabling it", - $ntpd - ) - ); - $self->setEmbeddedNTP(0); - } - } + # NOTE fix systemd-timesyncd problem that prevents to set time + if ($self->getEmbeddedNTP()) { + $ntpd = "systemd-timesyncd"; + Sys::Syslog::syslog( + 'info|local1', + $self->loc->N("%s enabled but stopped - disabling it", + $ntpd + ) + ); + $self->setEmbeddedNTP(0); } } -- cgit v1.2.1