diff options
author | Arnaud Desmons <adesmons@mandriva.com> | 2002-09-02 14:07:44 +0000 |
---|---|---|
committer | Arnaud Desmons <adesmons@mandriva.com> | 2002-09-02 14:07:44 +0000 |
commit | 04143a661a72da86d0eeadd41e09c1293cd8cce7 (patch) | |
tree | 4a9a102e4038d3d5c032d423da484678c3a95ccc /time_wizard/scripts | |
parent | f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87 (diff) | |
download | drakwizard-04143a661a72da86d0eeadd41e09c1293cd8cce7.tar drakwizard-04143a661a72da86d0eeadd41e09c1293cd8cce7.tar.gz drakwizard-04143a661a72da86d0eeadd41e09c1293cd8cce7.tar.bz2 drakwizard-04143a661a72da86d0eeadd41e09c1293cd8cce7.tar.xz drakwizard-04143a661a72da86d0eeadd41e09c1293cd8cce7.zip |
perl traduction
Diffstat (limited to 'time_wizard/scripts')
-rw-r--r-- | time_wizard/scripts/NTPConf.pm | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/time_wizard/scripts/NTPConf.pm b/time_wizard/scripts/NTPConf.pm new file mode 100644 index 00000000..5b81124a --- /dev/null +++ b/time_wizard/scripts/NTPConf.pm @@ -0,0 +1,70 @@ +#!/usr/bin/perl + +# NTP Config Parser + +# Copyright (C) 2002 MandrakeSoft Arnaud Desmons <adesmons@mandrakesoft.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package NTPConf; +require "__WIZ_HOME__/common/scripts/Vareqval.pm"; +require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm"; +use MDK::Common; +use strict; +use standalone; + +sub chooser { + if ($ENV{chooser1} eq "local") { + do_it(); + return 1; + } + 2; +} + +sub test { + system("/usr/sbin/ntpdate -q $ENV{server1} $ENV{server2}"); + if (!($? >> 8)) { + do_it(); + return 2; + } + return 1; +} + +sub do_it { + my $file = "/etc/sysconfig/clock"; + MDK::Common::cp_af($file, $file.".orig"); + open(NEW, "> $file") or die "can not open /etc/ntp/step-tickers: $!"; + print NEW "UTC=true\n"; + print NEW "ZONE=$ENV{wiz_timezone}\n"; + print NEW "ARC=false\n"; + close NEW or die "can not close /etc/ntp/step-tickers: $!"; + MDK::Common::cp_af("/usr/share/zoneinfo/$ENV{wiz_timezone}", "/etc/localtime"); + 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 $ENV{server1}."\n"; + print NEW $ENV{server2}."\n"; + close NEW or die "can not close /etc/ntp/step-tickers: $!"; + standalone::explanations("Wrote /etc/ntp/step-tickers, starting services"); + my @services = qw(crond atd ntpd); + foreach (@services) { + system("/etc/rc.d/init.d/$_ stop"); + } + foreach (reverse @services) { + system("/etc/rc.d/init.d/$_ start"); + } + system("/sbin/hwclock --systohc --utc"); + 10; +} +1; |