summaryrefslogtreecommitdiffstats
path: root/time_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'time_wizard')
-rw-r--r--time_wizard/Ntp.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/time_wizard/Ntp.pm b/time_wizard/Ntp.pm
index a4fc4ca9..9ea8144f 100644
--- a/time_wizard/Ntp.pm
+++ b/time_wizard/Ntp.pm
@@ -183,7 +183,10 @@ sub get_timezone {
}
sub test {
- $::testing and return 'end';
+ if ($::testing) {
+ do_it();
+ return 'end';
+ }
system("/usr/sbin/ntpdate -q $o->{var}{varserver1} $o->{var}{varserver2}");
if (!($? >> 8)) {
do_it();
@@ -193,16 +196,20 @@ sub test {
}
sub do_it {
- $::testing and return;
+ if ($::testing){
+ print "Would have written\nUTC=true\nZONE=$o->{var}{wiz_timezone}\nARC=false\n to /etc/sysconfig/clock\n\n";
+ print "Would have copied /usr/share/zoneinfo/$o->{var}{wiz_timezone} to /etc/localtime\n";
+ return
+ }
my $file = "/etc/sysconfig/clock";
- MDK::Common::cp_af($file, $file.".orig");
+ !-f "$file.orig" and MDK::Common::cp_af($file, $file.".orig");
local *NEW;
open(NEW, "> $file") or die "can not open $file: $!";
print NEW "UTC=true\n";
print NEW "ZONE=$o->{var}{wiz_timezone}\n";
print NEW "ARC=false\n";
close NEW or die "can not close $file: $!";
- MDK::Common::cp_af("/usr/share/zoneinfo/$o->{var}{wiz_timezone}", "/etc/localtime");
+ -f "/usr/share/zoneinfo/$o->{var}{wiz_timezone}" and MDK::Common::cp_af("/usr/share/zoneinfo/$o->{var}{wiz_timezone}", "/etc/localtime");
-f "/etc/ntp/step-tickers" and MDK::Common::cp_af("/etc/ntp/step-tickers", "/etc/ntp/step-tickers.orig");
open(NEW, "> /etc/ntp/step-tickers") or die "can not open /etc/ntp/step-tickers: $!";
print NEW $o->{var}{varserver1}."\n";