Skip to content

Commit

Permalink
Merge pull request #108 from yast/conf_na,e
Browse files Browse the repository at this point in the history
Conf name
  • Loading branch information
jreidinger committed Mar 7, 2018
2 parents 435e222 + b0b7c23 commit fa99807
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
11 changes: 11 additions & 0 deletions package/yast2-ntp-client.changes
@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Mar 7 10:57:36 UTC 2018 - jreidinger@suse.com

- change cron config file name to suse-ntp_synchronize
(bsc#1079122)
- convert old file to new one during upgrade, ensure that ntpd is
replaced by chrony (FATE#323432)
- ghost that config file, so it is easy to find which package owns
it
- 4.0.9

-------------------------------------------------------------------
Thu Feb 22 15:21:04 UTC 2018 - gsouza@suse.com

Expand Down
10 changes: 9 additions & 1 deletion package/yast2-ntp-client.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-ntp-client
Version: 4.0.8
Version: 4.0.9
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0+
Expand Down Expand Up @@ -61,6 +61,13 @@ rake test:unit
%install
rake install DESTDIR="%{buildroot}"

%post
# upgrade old name and convert it to chrony (bsc#1079122)
if [ -f /etc/cron.d/novell.ntp-synchronize ]; then
mv /etc/cron.d/novell.ntp-synchronize /etc/cron.d/suse-ntp_synchronize
sed -i 's:\* \* \* \* root .*:* * * * root /usr/sbin/chronyd -q \&>/dev/null:' /etc/cron.d/suse-ntp_synchronize
fi

%files
%defattr(-,root,root)
%dir %{yast_yncludedir}/ntp-client
Expand All @@ -72,6 +79,7 @@ rake install DESTDIR="%{buildroot}"
%{yast_ydatadir}/ntp_servers.yml
%{yast_schemadir}/autoyast/rnc/ntpclient.rnc
%{yast_dir}/lib
%ghost /etc/cron.d/suse-ntp_synchronize

%dir %{yast_docdir}
%doc %{yast_docdir}/COPYING
Expand Down
12 changes: 6 additions & 6 deletions src/modules/NtpClient.rb
Expand Up @@ -35,6 +35,9 @@ class NtpClientClass < Module

NTP_FILE = "/etc/chrony.conf".freeze

# The cron file name for the synchronization.
CRON_FILE = "/etc/cron.d/suse-ntp_synchronize".freeze

UNSUPPORTED_AUTOYAST_OPTIONS = [
"configure_dhcp",
"peers",
Expand Down Expand Up @@ -85,9 +88,6 @@ def main
# The interval of synchronization in minutes.
@sync_interval = DEFAULT_SYNC_INTERVAL

# The cron file name for the synchronization.
@cron_file = "/etc/cron.d/novell.ntp-synchronize"

# Service name of the NTP daemon
@service_name = "chronyd"

Expand Down Expand Up @@ -272,7 +272,7 @@ def ProcessNtpConf
# synchronize_time and sync_interval variables
# Return updated value of synchronize_time
def ReadSynchronization
crontab = SCR.Read(path(".cron"), @cron_file, "")
crontab = SCR.Read(path(".cron"), CRON_FILE, "")
log.info("NTP Synchronization crontab entry: #{crontab}")
cron_entry = (crontab || []).fetch(0, {}).fetch("events", []).fetch(0, {})
@synchronize_time = cron_entry["active"] == "1"
Expand Down Expand Up @@ -812,13 +812,13 @@ def update_cron_settings
if @synchronize_time
SCR.Write(
path(".target.string"),
@cron_file,
CRON_FILE,
"-*/#{@sync_interval} * * * * root /usr/sbin/chronyd -q &>/dev/null\n"
)
else
SCR.Execute(
path(".target.bash"),
"test -e #{@cron_file} && rm #{@cron_file};"
"rm -vf #{CRON_FILE}"
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/ntp_client_test.rb
Expand Up @@ -388,7 +388,7 @@
end

describe "#ReadSynchronization" do
let(:cron_job_file) { "/etc/cron.d/novell.ntp-synchronize" }
let(:cron_job_file) { "/etc/cron.d/suse-ntp_synchronize" }
let(:cron_entry) { [] }

before do
Expand Down

0 comments on commit fa99807

Please sign in to comment.