diff --git a/time/apply.cgi b/time/apply.cgi index d9397a82f..517187d72 100755 --- a/time/apply.cgi +++ b/time/apply.cgi @@ -52,9 +52,17 @@ if ($in{'action'} eq $text{'action_sync'}) { } elsif ($in{'action'} eq $text{'index_sync'} || $in{'mode'} eq 'ntp') { # Sync with a time server $access{'ntp'} || &error($text{'acl_nontp'}); - $in{'timeserver'} =~ /\S/ || &error($text{'error_etimeserver'}); + if (!$time_is_chrony) { + $in{'timeserver'} =~ /\S/ || &error($text{'error_etimeserver'}); + } $err = &sync_time($in{'timeserver'}, $in{'hardware'}); - &error("
".&html_escape($err)."
") if ($err); + if ($err) { + my $err_ = "
".&html_escape($err)."
"; + if ($time_out_no_cmd) { + $err_ = $err; + } + &error($err_); + } # Save settings in module config &lock_file($module_config_file); diff --git a/time/index.cgi b/time/index.cgi index 530674012..fdd42af2d 100755 --- a/time/index.cgi +++ b/time/index.cgi @@ -3,7 +3,7 @@ use strict; use warnings; require './time-lib.pl'; -our (%in, %text, %config, %access, $base_remote_user, $get_hardware_time_error); +our (%in, %text, %config, %access, $base_remote_user, $get_hardware_time_error, $time_is_chrony); my ($rawdate, $rawhwdate, %system_date, $rawtime, %hw_date, $txt); $txt = ""; @@ -159,16 +159,23 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } & print &ui_hidden("mode", "ntp"); print &ui_table_start(&hlink($text{'index_timeserver'}, "timeserver"), "width=100%", 2, [ "width=30%" ]); - - print &ui_table_row($text{'index_addresses'}, - &ui_textbox("timeserver", $config{'timeserver'}, 60)); - - # Show hardware time checkbox - if (&support_hwtime()) { - print &ui_table_row(" ", - &ui_checkbox("hardware", 1, $text{'index_hardware2'}, - $config{'timeserver_hardware'})); + if (!$time_is_chrony) { + print &ui_table_row($text{'index_addresses'}, + &ui_textbox("timeserver", $config{'timeserver'}, 60)); + + # Show hardware time checkbox + if (&support_hwtime()) { + print &ui_table_row(" ", + &ui_checkbox("hardware", 1, $text{'index_hardware2'}, + $config{'timeserver_hardware'})); + } } + else { + if (&support_hwtime()) { + print &ui_table_row($text{'action_sync_s'}, + &ui_yesno_radio("hardware", $config{'timeserver_hardware'})); + } + } # Show boot-time checkbox my $job = &find_webmin_cron_job(); diff --git a/time/time-lib.pl b/time/time-lib.pl index dd4d6b254..7c0551587 100755 --- a/time/time-lib.pl +++ b/time/time-lib.pl @@ -11,6 +11,8 @@ our ($timezones_file, $currentzone_link, $currentzone_file, $timezones_dir, $sysclock_file); our ($get_hardware_time_error); our $cron_cmd = "$module_config_directory/sync.pl"; +our $time_is_chrony = &has_command("chronyc"); +our $time_out_no_cmd = 0; if ($config{'zone_style'}) { do "$config{'zone_style'}-lib.pl"; } @@ -40,14 +42,18 @@ my ($server, $hwtoo) = @_; my @servs = split(/\s+/, $server); my $servs = join(" ", map { quotemeta($_) } @servs); my $out; -if (&has_command("ntpdate")) { +if ($time_is_chrony) { + $out = &backquote_logged("chronyc -a makestep 2>&1"); + } +elsif (&has_command("ntpdate")) { $out = &backquote_logged("ntpdate -u $servs 2>&1"); } elsif (&has_command("sntp")) { $out = &backquote_logged("sntp -s $servs 2>&1"); } else { - $out = "Missing ntpdate and sntp commands"; + $out = "Missing chronyc or ntpdate and sntp commands"; + $time_out_no_cmd = 1; $? = 1; } if ($? && $config{'ntp_only'}) {