summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_any.pm5
-rw-r--r--perl-install/install_steps.pm2
-rw-r--r--perl-install/install_steps_interactive.pm15
-rw-r--r--perl-install/timezone.pm22
4 files changed, 41 insertions, 3 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 6fb0f38d2..b8c2f9251 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -308,7 +308,10 @@ sub preConfigureTimezone {
add2hash($o->{timezone}, { timezone::read($o->{prefix}) }) if $o->{isUpgrade};
$o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang}));
- add2hash_($o->{timezone}, { UTC => $::expert && !grep { isFat($_) || isNT($_) } @{$o->{fstab}} });
+
+ my $utc = $::expert && !grep { isFat($_) || isNT($_) } @{$o->{fstab}};
+ my $ntp = timezone::ntp_server($o->{prefix});
+ add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp });
}
sub setPackages {
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 1817466d3..2725f4934 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -523,6 +523,8 @@ sub configureTimezone {
my ($o) = @_;
install_any::preConfigureTimezone($o);
+ $o->pkg_install('ntp') if $o->{timezone}{ntp};
+
require timezone;
timezone::write($o->{prefix}, $o->{timezone});
}
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 6a020f0e6..4fda58db6 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -775,7 +775,19 @@ sub configureTimezone {
require timezone;
$o->{timezone}{timezone} = $o->ask_from_treelist('', _("Which is your timezone?"), '/', [ timezone::getTimeZones($::g_auto_install ? '' : $o->{prefix}) ], $o->{timezone}{timezone});
$o->set_help('configureTimezoneGMT');
- $o->{timezone}{UTC} = $o->ask_yesorno('', _("Is your hardware clock set to GMT?"), $o->{timezone}{UTC}) if $::expert || $clicked;
+
+ my $ntp = bool($o->{timezone}{ntp});
+ $o->ask_from_entries_refH('', '', [
+ { text => _("Hardware clock set to GMT"), val => \$o->{timezone}{UTC}, type => 'bool' },
+ { text => _("Automatic time synchronization (using NTP)"), val => \$ntp, type => 'bool' },
+ ]) or goto &configureTimezone
+ if $::expert || $clicked;
+ if ($ntp) {
+ $o->ask_from_entries_refH('', '',
+ [ { label => _("NTP Server"), val => \$o->{timezone}{ntp} } ]) or goto &configureTimezone;
+ } else {
+ $o->{timezone}{ntp} = '';
+ }
install_steps::configureTimezone($o);
}
@@ -789,6 +801,7 @@ sub configureServices {
sub summary {
my ($o, $first_time) = @_;
+ require pkgs;
if ($first_time) {
#- auto-detection
diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm
index 35622d2b5..16b888e6e 100644
--- a/perl-install/timezone.pm
+++ b/perl-install/timezone.pm
@@ -3,7 +3,7 @@ package timezone; # $Id$
use diagnostics;
use strict;
-use common qw(:common :system);
+use common qw(:common :system :file);
use commands;
use log;
@@ -25,9 +25,29 @@ sub read {
(timezone => $t{ZONE}, UTC => text2bool($t{UTC}));
}
+sub ntp_server {
+ my ($prefix, $server) = @_;
+
+ my $f = "$prefix/etc/ntp.conf";
+ -e $f or return;
+
+ if (@_ > 1) {
+ substInFile {
+ if (/^#?\s*server\s+(\S*)/ && $1 ne '127.127.1.0') {
+ $_ = $server ? "server $server\n" : "#server $1\n";
+ }
+ } $f;
+ } else {
+ ($server) = grep { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($f);
+ }
+ $server;
+}
+
sub write {
my ($prefix, $t) = @_;
+ ntp_server($prefix, $t->{ntp});
+
eval { commands::cp("-f", "$prefix/usr/share/zoneinfo/$t->{timezone}", "$prefix/etc/localtime") };
$@ and log::l("installing /etc/localtime failed");
setVarsInSh("$prefix/etc/sysconfig/clock", {