Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conf name #108

Merged
merged 8 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions package/yast2-ntp-client.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-------------------------------------------------------------------
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 who own it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"who own it" or "which package owns it" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or "which package belongs to" ?

- 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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,
Copy link
Member

@kobliha kobliha Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea, ... but probably too late: Could we have a comment here (in file) that this is created by us and that the user should run YaST to re/configure it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, such comment probably makes good sense. This one is already merged, but I can open new one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please :)

"-*/#{@sync_interval} * * * * root /usr/sbin/chronyd -q &>/dev/null\n"
)
else
SCR.Execute(
path(".target.bash"),
"test -e #{@cron_file} && rm #{@cron_file};"
"test -e #{CRON_FILE} && rm #{CRON_FILE};"
Copy link
Member

@lslezak lslezak Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: there is a trailing ; and maybe simple rm -f #{CRON_FILE} (without the test) would be better (even could be replaced by native Ruby)

)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/ntp_client_test.rb
Original file line number Diff line number Diff line change
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