diff options
-rw-r--r-- | time_wizard/Ntp.pm | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/time_wizard/Ntp.pm b/time_wizard/Ntp.pm index 8630c605..fc97185c 100644 --- a/time_wizard/Ntp.pm +++ b/time_wizard/Ntp.pm @@ -142,20 +142,21 @@ $o->{pages} = { post => sub { if ($o->{var}{action} eq 'save_quit') { do_it(); - 'end' + 'end', } else { - 'test_server' + 'test_server', } }, data => [ { val => \$o->{var}{action}, list => [ keys %actions ], format => sub { $actions{$_[0]} } }, ], - next => 'config' + next => 'config', }, - end => { + end => { name => N("Time server configuration saved") . "\n\n" . N("Your server can now act as a time server for your local network."), end => 1, - next => 0 + next => 0, + no_back => 1, }, }; @@ -179,7 +180,7 @@ sub test { return 'end'; } my $command = "/usr/sbin/ntpdate -q $o->{var}{varserver1}"; # $o->{var}{varserver2}"; - my $o = MDK::Wizard::Wizcommon_gtk2::wizard_progress_bar($command, "Test NTP server Responding..."); + my $o = MDK::Wizard::Wizcommon_gtk2::gtk_log($command, "Test NTP server Responding..."); $o; # system("/usr/sbin/ntpdate -q $o->{var}{varserver1} $o->{var}{varserver2}"); if (!($? >> 8)) { @@ -190,29 +191,29 @@ sub test { } sub do_it { - 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"; - !-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: $!"; - -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"; + 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"; + !-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: $!"; + -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"; print NEW $o->{var}{varserver2}."\n"; - close NEW or die "can not close /etc/ntp/step-tickers: $!"; - substInFile { s/(# server clock.via.net)/$1\nserver $o->{var}{varserver1}/ } '/etc/ntp.conf' if -f '/etc/ntp.conf'; - standalone::explanations("Wrote /etc/ntp/step-tickers, starting services"); - my $command = "service crond stop; service atd stop; service ntpd stop; service ntpd start; service atd start; service crond start; /sbin/hwclock --systohc --utc"; - MDK::Wizard::Wizcommon_gtk2::wizard_progress_bar($command, "Configuring NTP, ATD and CROND services..."); + close NEW or die "can not close /etc/ntp/step-tickers: $!"; + substInFile { s/(# server clock.via.net)/$1\nserver $o->{var}{varserver1}/ } '/etc/ntp.conf' if -f '/etc/ntp.conf'; + standalone::explanations("Wrote /etc/ntp/step-tickers, starting services"); + my $command = "service crond stop; service atd stop; service ntpd stop; service ntpd start; service atd start; service crond start; /sbin/hwclock --systohc --utc"; + MDK::Wizard::Wizcommon_gtk2::gtk_log($command, "Configuring NTP, ATD and CROND services..."); } 1; |