summaryrefslogtreecommitdiffstats
path: root/perl-install/timezone.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/timezone.pm')
-rw-r--r--perl-install/timezone.pm47
1 files changed, 29 insertions, 18 deletions
diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm
index b072dda3a..cfbaf98a1 100644
--- a/perl-install/timezone.pm
+++ b/perl-install/timezone.pm
@@ -1,4 +1,4 @@
-package timezone; # $Id$
+package timezone;
use diagnostics;
use strict;
@@ -6,8 +6,10 @@ use strict;
use common;
use log;
-sub get_timezone_prefix() {
- my $prefix = $::testing ? '' : $::prefix;
+sub get_timezone_prefix {
+ my ($b_use_system_prefix) = @_;
+
+ my $prefix = ($::testing || $b_use_system_prefix) ? '' : $::prefix;
$prefix . "/usr/share/zoneinfo";
}
@@ -24,15 +26,20 @@ sub read() {
{ timezone => $t{ZONE}, UTC => text2bool($t{UTC}) };
}
-my $ntp_conf_file = "/etc/ntp.conf";
+our $ntp = "ntp";
+my $servername_config_suffix = "";
+unless (-f $::prefix . "/etc/" . $ntp . ".conf") {
+ $ntp = "chrony";
+ $servername_config_suffix = " iburst";
+}
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$/;
@@ -41,14 +48,16 @@ sub set_ntp_server {
my $added = 0;
substInFile {
if (/^#?\s*server\s+(\S*)/ && $1 ne '127.127.1.0') {
- $_ = $added ? $_ =~ $pool_match ? undef : "#server $1\n" : join('', map { "server $_\n" } @servers);
+ $_ = $added ? $_ =~ $pool_match ? undef : "#server $1\n" : join('', map { "server $_$servername_config_suffix\n" } @servers);
$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 {
@@ -56,8 +65,8 @@ sub write {
set_ntp_server($t->{ntp});
- my $tz_prefix = get_timezone_prefix();
- eval { cp_af($tz_prefix . '/' . $t->{timezone}, "$::prefix/etc/localtime") };
+ my $tz_prefix = get_timezone_prefix(1);
+ eval { symlinkf($tz_prefix . '/' . $t->{timezone}, "$::prefix/etc/localtime") };
$@ and log::l("installing /etc/localtime failed");
setVarsInSh("$::prefix/etc/sysconfig/clock", {
ZONE => $t->{timezone},
@@ -89,7 +98,7 @@ my %c2t = (
'BA' => 'Europe/Sarajevo',
'BE' => 'Europe/Brussels',
'BG' => 'Europe/Sofia',
-'BR' => 'Brazil/East', #- most people live on the east coast
+'BR' => 'America/Sao_Paulo', #- most brazilians live on this time zone
'BY' => 'Europe/Minsk',
'CA' => 'Canada/Eastern',
'CH' => 'Europe/Zurich',
@@ -110,7 +119,7 @@ my %c2t = (
'ID' => 'Asia/Jakarta',
'IE' => 'Europe/Dublin',
'IL' => 'Asia/Tel_Aviv',
-'IN' => 'Asia/Calcutta',
+'IN' => 'Asia/Kolkata',
'IR' => 'Asia/Tehran',
'IS' => 'Atlantic/Reykjavik',
'IT' => 'Europe/Rome',
@@ -167,6 +176,7 @@ sub get_ntp_server_tree {
}
sub ntp_servers() {
+ # FIXME: missing parameter:
+{ get_ntp_server_tree() };
}
@@ -176,6 +186,7 @@ sub dump_ntp_zone {
}
sub print_ntp_zone {
my ($zone, $name) = @_;
+ # FIXME: missing parameter:
my %servers = dump_ntp_zone($zone);
print qq(\$ntp_servers{"$name"} = {\n);
print join('', map { qq( N_("$_") => "$servers{$_}",\n) } sort(keys %servers));
@@ -195,7 +206,7 @@ sub print_ntp_servers() {
$ntp_servers{""} = {
N_("Global") => "pool.ntp.org",
};
-$ntp_servers{"Global"} = {
+$ntp_servers{Global} = {
N_("Africa") => "africa.pool.ntp.org",
N_("Asia") => "asia.pool.ntp.org",
N_("Europe") => "europe.pool.ntp.org",
@@ -203,11 +214,11 @@ $ntp_servers{"Global"} = {
N_("Oceania") => "oceania.pool.ntp.org",
N_("South America") => "south-america.pool.ntp.org",
};
-$ntp_servers{"Africa"} = {
+$ntp_servers{Africa} = {
N_("South Africa") => "za.pool.ntp.org",
N_("Tanzania") => "tz.pool.ntp.org",
};
-$ntp_servers{"Asia"} = {
+$ntp_servers{Asia} = {
N_("Bangladesh") => "bd.pool.ntp.org",
N_("China") => "cn.pool.ntp.org",
N_("Hong Kong") => "hk.pool.ntp.org",
@@ -225,7 +236,7 @@ $ntp_servers{"Asia"} = {
N_("Turkey") => "tr.pool.ntp.org",
N_("United Arab Emirates") => "ae.pool.ntp.org",
};
-$ntp_servers{"Europe"} = {
+$ntp_servers{Europe} = {
N_("Austria") => "at.pool.ntp.org",
N_("Belarus") => "by.pool.ntp.org",
N_("Belgium") => "be.pool.ntp.org",
@@ -263,7 +274,7 @@ $ntp_servers{"North America"} = {
N_("Mexico") => "mx.pool.ntp.org",
N_("United States") => "us.pool.ntp.org",
};
-$ntp_servers{"Oceania"} = {
+$ntp_servers{Oceania} = {
N_("Australia") => "au.pool.ntp.org",
N_("New Zealand") => "nz.pool.ntp.org",
};