#!/usr/bin/perl # NTP Config Parser # Copyright (C) 2002 MandrakeSoft Arnaud Desmons # # 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 chooser4 { if ($ENV{chooser4} eq "save_quit") { do_it(); return 1; } 2; } sub test { system("/usr/sbin/ntpdate -q $ENV{server1} $ENV{server2}"); if (!($? >> 8)) { do_it(); return 1; } 2; } sub do_it { my $file = "/etc/sysconfig/clock"; MDK::Common::cp_af($file, $file.".orig"); open(NEW, "> $file") or die "can not open $file: $!"; print NEW "UTC=true\n"; print NEW "ZONE=$ENV{wiz_timezone}\n"; print NEW "ARC=false\n"; close NEW or die "can not close $file: $!"; MDK::Common::cp_af("/usr/share/zoneinfo/$ENV{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 $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;