From 80aeb2c106769f94c69b8a05a40819155e296b98 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 17 Oct 2012 16:30:47 +0000 Subject: (do_it) do not reinvent output() --- time_wizard/Ntp.pm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'time_wizard') diff --git a/time_wizard/Ntp.pm b/time_wizard/Ntp.pm index 4f76504a..c754a833 100644 --- a/time_wizard/Ntp.pm +++ b/time_wizard/Ntp.pm @@ -199,18 +199,16 @@ sub do_it { 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: $!"; + output($file, qq(UTC=true +ZONE=$o->{var}{wiz_timezone} +ARC=false +)); -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"; - print NEW $o->{var}{varserver3} . "\n"; - close NEW or die "can not close /etc/ntp/step-tickers: $!"; + output('/etc/ntp/step-tickers', join("\n", $o->{var}{varserver1}, + $o->{var}{varserver2}, + $o->{var}{varserver3}, + undef)); 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"; -- cgit v1.2.1