Mageia Bugzilla – Attachment 4290 Details for
Bug 11092
chrony as default ntp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
svn diff of svn/soft/perl-install with changes needed for chrony
chrony.diff (text/plain), 8.89 KB, created by
David Walser
on 2013-08-27 22:07:51 CEST
(
hide
)
Description:
svn diff of svn/soft/perl-install with changes needed for chrony
Filename:
MIME Type:
Creator:
David Walser
Created:
2013-08-27 22:07:51 CEST
Size:
8.89 KB
patch
obsolete
>Index: install/steps.pm >=================================================================== >--- install/steps.pm (revision 8725) >+++ install/steps.pm (working copy) >@@ -692,7 +692,15 @@ > my ($o) = @_; > install::any::preConfigureTimezone($o); > >- $o->pkg_install('ntp') if $o->{timezone}{ntp}; >+ if $o->{timezone}{ntp} { >+ my $pkg = install::pkgs::packageByName($o->{packages}, 'ntp'); >+ unless ($pkg && $pkg->flag_installed) { >+ $pkg = install::pkgs::packageByName($o->{packages}, 'chrony'); >+ unless ($pkg && $pkg->flag_installed) { >+ $o->pkg_install('chrony'); >+ } >+ } >+ } > > require timezone; > timezone::write($o->{timezone}); >Index: services.pm >=================================================================== >--- services.pm (revision 8725) >+++ services.pm (working copy) >@@ -23,6 +23,7 @@ > atd => N_("Runs commands scheduled by the at command at the time specified when > at was run, and runs batch commands when the load average is low enough."), > 'avahi-deamon' => N_("Avahi is a ZeroConf daemon which implements an mDNS stack"), >+chronyd => N_("An NTP client/server"), > cpufreq => N_("Set CPU frequency settings"), > crond => N_("cron is a standard UNIX program that runs user-specified programs > at periodic scheduled times. vixie cron adds a number of features to the basic >Index: standalone/drakclock >=================================================================== >--- standalone/drakclock (revision 8725) >+++ standalone/drakclock (working copy) >@@ -23,9 +23,9 @@ > > $ugtk2::wm_icon = "/usr/share/mcc/themes/default/time-mdk.png"; > >-my $ntpfile = '/etc/ntp.conf'; >-my $ntpdlock = '/var/lock/subsys/ntpd'; >-my $ntpdsystemdlock = '/sys/fs/cgroup/systemd/system/ntpd.service'; >+my $ntpd = timezone::ntp . 'd'; >+my $ntpfile = '/etc/' . timezone::ntp . '.conf'; >+my $ntpdlock = '/sys/fs/cgroup/systemd/system/' . $ntpd . '.service'; > > my $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings")); > >@@ -77,9 +77,13 @@ > 0, gtksignal_connect(gtkset_active($check_ntp = gtknew('CheckButton', text => N("Enable Network Time Protocol")), $mode), clicked => sub { > $mode = !$mode; > $hb_ntp->set_sensitive($mode); >- if ($mode == 1 && !$in->do_pkgs->is_installed('ntp')) { >+ if ($mode == 1 && !$in->do_pkgs->is_installed('ntp') && !$in->do_pkgs->is_installed('chrony')) { > install_ntp(); > } >+ # also install ntp-client for ntpdate command used below >+ if ($mode == 1 && !$in->do_pkgs->is_installed('ntp-client')) { >+ install_ntp_client(); >+ } > }), > 0, $hb_ntp = gtknew('HBox', border_width => 5, children => [ > 0, gtknew('Label', text => N("Server:")), >@@ -116,15 +120,13 @@ > return; > } > timezone::set_ntp_server($choosed_serv); >- system(qw(/sbin/chkconfig --level 35 ntpd on)); >- # FIXME: Change to use systemctl when will not support old iniscript anymore >- system(qw(service ntpd stop)); >+ system(split(' ', "systemctl enable $ntpd.service")); >+ system(split(' ', "systemctl stop $ntpd.service")); > #verify that we have a valid hostname (thx sam) > $choosed_serv =~ s/[^-a-zA-Z0-9.]//g; > if (!system("/usr/sbin/ntpdate", $choosed_serv)) { > update_time(); #- get the new time before updating the hwclock >- # FIXME: Change to use systemctl when will not support old iniscript anymore >- system(qw(service ntpd start)); >+ system(split(' ', "systemctl start $ntpd.service")); > $need_date = 0; > } else { > $in->ask_from_no_check({ >@@ -135,14 +137,10 @@ > }, []) or return; > } > } else { >- if (-e $ntpdlock) { >- system(qw(service ntpd stop)); >- system(qw(/sbin/chkconfig --level 35 ntpd off)); >+ if (-e $ntpdlock) { >+ system(split(' ', "systemctl stop $ntpd.service")); >+ system(split(' ', "systemctl disable $ntpd.service")); > } >- elsif (-e $ntpdsystemdlock) { >- system(qw(systemctl stop ntpd.service)); >- system(qw(systemctl disable ntpd.service)); >- } > } > if ($need_date) { > my ($year, $month, $day) = $calendar->get_date; >@@ -174,7 +172,7 @@ > > my $servers = get_server(); > $combo_ntpserver->set_popdown_strings(@$servers); >-if (-e $ntpfile && (-e $ntpdsystemdlock || -e $ntpdlock)) { >+if (-e $ntpfile && -e $ntpdlock) { > $ntp = timezone::ntp_server(); > $ntp and ntp_widget_state(1); > my $fullntp = $ntp; >@@ -238,9 +236,14 @@ > } > sub install_ntp() { > $my_win->{window}->set_sensitive(0); >- $in->do_pkgs->ensure_is_installed('ntp') or ntp_widget_state(0); >+ $in->do_pkgs->ensure_is_installed('chrony') or ntp_widget_state(0); > $my_win->{window}->set_sensitive(1); > } >+sub install_ntp_client() { >+ $my_win->{window}->set_sensitive(0); >+ $in->do_pkgs->ensure_is_installed('ntp-client') or ntp_widget_state(0); >+ $my_win->{window}->set_sensitive(1); >+} > sub get_server() { > my $servs = timezone::ntp_servers(); > [ map { "$servs->{$_}: $_" } sort { $servs->{$a} cmp $servs->{$b} || $a cmp $b } keys %$servs ]; >Index: standalone/finish-install >=================================================================== >--- standalone/finish-install (revision 8725) >+++ standalone/finish-install (working copy) >@@ -75,7 +75,11 @@ > $timezone->{timezone} = timezone::bestTimezone($locale->{country}) if $locale->{country}; > any::configure_timezone($in, $timezone, 'ask_gmt', lc(get_conf('TIMEZONE')) eq 'simplified'); > >- $in->do_pkgs->ensure_is_installed('ntp') if $timezone->{ntp}; >+ if ($timezone->{ntp}) { >+ unless ($in->do_pkgs->is_installed('ntp') || $in->do_pkgs->is_installed('chrony')) { >+ $in->do_pkgs->ensure_is_installed('chrony'); >+ } >+ } > timezone::write($timezone); > > #- reload sys clock from hc once we know the real timezone >Index: timezone.pm >=================================================================== >--- timezone.pm (revision 8725) >+++ timezone.pm (working copy) >@@ -24,15 +24,18 @@ > { timezone => $t{ZONE}, UTC => text2bool($t{UTC}) }; > } > >-my $ntp_conf_file = "/etc/ntp.conf"; >+my $ntp = "chrony"; >+unless (-f $::prefix . "/etc/" . $ntp . ".conf") { >+ $ntp = "ntp"; >+} > > sub ntp_server() { >- find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . $ntp_conf_file); >+ find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . "/etc/" . $ntp . ".conf"); > } > > sub set_ntp_server { > my ($server) = @_; >- my $f = $::prefix . $ntp_conf_file; >+ my $f = $::prefix . "/etc/" . $ntp . ".conf"; > -f $f or return; > > my $pool_match = qr/\.pool\.ntp\.org$/; >@@ -45,10 +48,12 @@ > $added = 1; > } > } $f; >- output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers)); >+ if ($ntp eq "ntp") { >+ output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers)); >+ } > > require services; >- services::set_status('ntpd', to_bool($server), $::isInstall); >+ services::set_status($ntp . 'd', to_bool($server), $::isInstall); > } > > sub write {
Index: install/steps.pm =================================================================== --- install/steps.pm (revision 8725) +++ install/steps.pm (working copy) @@ -692,7 +692,15 @@ my ($o) = @_; install::any::preConfigureTimezone($o); - $o->pkg_install('ntp') if $o->{timezone}{ntp}; + if $o->{timezone}{ntp} { + my $pkg = install::pkgs::packageByName($o->{packages}, 'ntp'); + unless ($pkg && $pkg->flag_installed) { + $pkg = install::pkgs::packageByName($o->{packages}, 'chrony'); + unless ($pkg && $pkg->flag_installed) { + $o->pkg_install('chrony'); + } + } + } require timezone; timezone::write($o->{timezone}); Index: services.pm =================================================================== --- services.pm (revision 8725) +++ services.pm (working copy) @@ -23,6 +23,7 @@ atd => N_("Runs commands scheduled by the at command at the time specified when at was run, and runs batch commands when the load average is low enough."), 'avahi-deamon' => N_("Avahi is a ZeroConf daemon which implements an mDNS stack"), +chronyd => N_("An NTP client/server"), cpufreq => N_("Set CPU frequency settings"), crond => N_("cron is a standard UNIX program that runs user-specified programs at periodic scheduled times. vixie cron adds a number of features to the basic Index: standalone/drakclock =================================================================== --- standalone/drakclock (revision 8725) +++ standalone/drakclock (working copy) @@ -23,9 +23,9 @@ $ugtk2::wm_icon = "/usr/share/mcc/themes/default/time-mdk.png"; -my $ntpfile = '/etc/ntp.conf'; -my $ntpdlock = '/var/lock/subsys/ntpd'; -my $ntpdsystemdlock = '/sys/fs/cgroup/systemd/system/ntpd.service'; +my $ntpd = timezone::ntp . 'd'; +my $ntpfile = '/etc/' . timezone::ntp . '.conf'; +my $ntpdlock = '/sys/fs/cgroup/systemd/system/' . $ntpd . '.service'; my $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings")); @@ -77,9 +77,13 @@ 0, gtksignal_connect(gtkset_active($check_ntp = gtknew('CheckButton', text => N("Enable Network Time Protocol")), $mode), clicked => sub { $mode = !$mode; $hb_ntp->set_sensitive($mode); - if ($mode == 1 && !$in->do_pkgs->is_installed('ntp')) { + if ($mode == 1 && !$in->do_pkgs->is_installed('ntp') && !$in->do_pkgs->is_installed('chrony')) { install_ntp(); } + # also install ntp-client for ntpdate command used below + if ($mode == 1 && !$in->do_pkgs->is_installed('ntp-client')) { + install_ntp_client(); + } }), 0, $hb_ntp = gtknew('HBox', border_width => 5, children => [ 0, gtknew('Label', text => N("Server:")), @@ -116,15 +120,13 @@ return; } timezone::set_ntp_server($choosed_serv); - system(qw(/sbin/chkconfig --level 35 ntpd on)); - # FIXME: Change to use systemctl when will not support old iniscript anymore - system(qw(service ntpd stop)); + system(split(' ', "systemctl enable $ntpd.service")); + system(split(' ', "systemctl stop $ntpd.service")); #verify that we have a valid hostname (thx sam) $choosed_serv =~ s/[^-a-zA-Z0-9.]//g; if (!system("/usr/sbin/ntpdate", $choosed_serv)) { update_time(); #- get the new time before updating the hwclock - # FIXME: Change to use systemctl when will not support old iniscript anymore - system(qw(service ntpd start)); + system(split(' ', "systemctl start $ntpd.service")); $need_date = 0; } else { $in->ask_from_no_check({ @@ -135,14 +137,10 @@ }, []) or return; } } else { - if (-e $ntpdlock) { - system(qw(service ntpd stop)); - system(qw(/sbin/chkconfig --level 35 ntpd off)); + if (-e $ntpdlock) { + system(split(' ', "systemctl stop $ntpd.service")); + system(split(' ', "systemctl disable $ntpd.service")); } - elsif (-e $ntpdsystemdlock) { - system(qw(systemctl stop ntpd.service)); - system(qw(systemctl disable ntpd.service)); - } } if ($need_date) { my ($year, $month, $day) = $calendar->get_date; @@ -174,7 +172,7 @@ my $servers = get_server(); $combo_ntpserver->set_popdown_strings(@$servers); -if (-e $ntpfile && (-e $ntpdsystemdlock || -e $ntpdlock)) { +if (-e $ntpfile && -e $ntpdlock) { $ntp = timezone::ntp_server(); $ntp and ntp_widget_state(1); my $fullntp = $ntp; @@ -238,9 +236,14 @@ } sub install_ntp() { $my_win->{window}->set_sensitive(0); - $in->do_pkgs->ensure_is_installed('ntp') or ntp_widget_state(0); + $in->do_pkgs->ensure_is_installed('chrony') or ntp_widget_state(0); $my_win->{window}->set_sensitive(1); } +sub install_ntp_client() { + $my_win->{window}->set_sensitive(0); + $in->do_pkgs->ensure_is_installed('ntp-client') or ntp_widget_state(0); + $my_win->{window}->set_sensitive(1); +} sub get_server() { my $servs = timezone::ntp_servers(); [ map { "$servs->{$_}: $_" } sort { $servs->{$a} cmp $servs->{$b} || $a cmp $b } keys %$servs ]; Index: standalone/finish-install =================================================================== --- standalone/finish-install (revision 8725) +++ standalone/finish-install (working copy) @@ -75,7 +75,11 @@ $timezone->{timezone} = timezone::bestTimezone($locale->{country}) if $locale->{country}; any::configure_timezone($in, $timezone, 'ask_gmt', lc(get_conf('TIMEZONE')) eq 'simplified'); - $in->do_pkgs->ensure_is_installed('ntp') if $timezone->{ntp}; + if ($timezone->{ntp}) { + unless ($in->do_pkgs->is_installed('ntp') || $in->do_pkgs->is_installed('chrony')) { + $in->do_pkgs->ensure_is_installed('chrony'); + } + } timezone::write($timezone); #- reload sys clock from hc once we know the real timezone Index: timezone.pm =================================================================== --- timezone.pm (revision 8725) +++ timezone.pm (working copy) @@ -24,15 +24,18 @@ { timezone => $t{ZONE}, UTC => text2bool($t{UTC}) }; } -my $ntp_conf_file = "/etc/ntp.conf"; +my $ntp = "chrony"; +unless (-f $::prefix . "/etc/" . $ntp . ".conf") { + $ntp = "ntp"; +} sub ntp_server() { - find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . $ntp_conf_file); + find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($::prefix . "/etc/" . $ntp . ".conf"); } sub set_ntp_server { my ($server) = @_; - my $f = $::prefix . $ntp_conf_file; + my $f = $::prefix . "/etc/" . $ntp . ".conf"; -f $f or return; my $pool_match = qr/\.pool\.ntp\.org$/; @@ -45,10 +48,12 @@ $added = 1; } } $f; - output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers)); + if ($ntp eq "ntp") { + output_p("$::prefix/etc/ntp/step-tickers", join('', map { "$_\n" } @servers)); + } require services; - services::set_status('ntpd', to_bool($server), $::isInstall); + services::set_status($ntp . 'd', to_bool($server), $::isInstall); } sub write {
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 11092
: 4290