summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakclock
diff options
context:
space:
mode:
authorDavid Walser <luigiwalser@mageia.org>2013-11-17 19:00:07 +0000
committerColin Guthrie <colin@mageia.org>2013-11-17 20:41:41 +0000
commitd54857e5704e52bc93d810250732affc82e1d65f (patch)
treefbaccf45e44d72d4facdd803a1279baa66c14618 /perl-install/standalone/drakclock
parent6298fe9b2ec4be3c8845a0ab39c90ad76ea7a49e (diff)
downloaddrakx-d54857e5704e52bc93d810250732affc82e1d65f.tar
drakx-d54857e5704e52bc93d810250732affc82e1d65f.tar.gz
drakx-d54857e5704e52bc93d810250732affc82e1d65f.tar.bz2
drakx-d54857e5704e52bc93d810250732affc82e1d65f.tar.xz
drakx-d54857e5704e52bc93d810250732affc82e1d65f.zip
Add chrony support to drakclock mga#11092
v2 (by Colin Guthrie) * Fix external variable reference (my -> our + $ when using it) * Drop systemd cgroup filesystem check as the path has changed now (prefer "systemctl is-active foo.service" instead) * Add iburst to chrony config server definitions (triggers sync at startup) * Don't use ntpdate with chrony - rather chronyc waitsync * Don't bother checking for ntp in finish-install - just use chrony
Diffstat (limited to 'perl-install/standalone/drakclock')
-rwxr-xr-xperl-install/standalone/drakclock43
1 files changed, 24 insertions, 19 deletions
diff --git a/perl-install/standalone/drakclock b/perl-install/standalone/drakclock
index 0ca3c5b51..de60872f6 100755
--- a/perl-install/standalone/drakclock
+++ b/perl-install/standalone/drakclock
@@ -23,9 +23,8 @@ my $its_reset = 0;
$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 $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings"));
@@ -77,7 +76,7 @@ $my_win->{window}->add(gtknew('VBox', border_width => $::isEmbedded ? 0 : 5, chi
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();
}
}),
@@ -116,15 +115,22 @@ $my_win->{window}->add(gtknew('VBox', border_width => $::isEmbedded ? 0 : 5, chi
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('systemctl', 'enable', "$ntpd.service");
+ system('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)) {
+ my $sync_ok;
+ if ($ntpd == "chronyd") {
+ system('systemctl', 'start', "$ntpd.service");
+ # Wait up to 30s for sync
+ $sync_ok = !system('chronyc', 'waitsync', '30', '0.1');
+ system('systemctl', 'stop', "$ntpd.service") if (!$sync_ok);
+ } else {
+ $sync_ok = !system('/usr/sbin/ntpdate', $choosed_serv);
+ system('systemctl', 'start', "$ntpd.service") if ($sync_ok);
+ }
+ if ($sync_ok) {
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));
$need_date = 0;
} else {
$in->ask_from_no_check({
@@ -135,13 +141,9 @@ $my_win->{window}->add(gtknew('VBox', border_width => $::isEmbedded ? 0 : 5, chi
}, []) or return;
}
} else {
- if (-e $ntpdlock) {
- system(qw(service ntpd stop));
- system(qw(/sbin/chkconfig --level 35 ntpd off));
- }
- elsif (-e $ntpdsystemdlock) {
- system(qw(systemctl stop ntpd.service));
- system(qw(systemctl disable ntpd.service));
+ if (is_ntp_daemon_running()) {
+ system('systemctl', 'stop', "$ntpd.service");
+ system('systemctl', 'disable', "$ntpd.service");
}
}
if ($need_date) {
@@ -174,7 +176,7 @@ $time_box->set_direction('ltr');
my $servers = get_server();
$combo_ntpserver->set_popdown_strings(@$servers);
-if (-e $ntpfile && (-e $ntpdsystemdlock || -e $ntpdlock)) {
+if (-e $ntpfile && is_ntp_daemon_running()) {
$ntp = timezone::ntp_server();
$ntp and ntp_widget_state(1);
my $fullntp = $ntp;
@@ -238,9 +240,12 @@ sub ntp_widget_state {
}
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 is_ntp_daemon_running() {
+ !system("systemctl is-active $ntpd.service >/dev/null");
+}
sub get_server() {
my $servs = timezone::ntp_servers();
[ map { "$servs->{$_}: $_" } sort { $servs->{$a} cmp $servs->{$b} || $a cmp $b } keys %$servs ];