summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a040f5)
raw | patch | inline | side by side (parent: 4a040f5)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 9 Dec 2008 13:52:22 +0000 (13:52 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 9 Dec 2008 13:52:22 +0000 (13:52 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13206 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/corefunctions.pm | patch | blob | history |
index 7af8f4941b42a8d098260696d0b695c1dc21d391..7e19a8b18dcdbd1f0e37d3e2f8dd2b0e94cddc56 100644 (file)
open (FILE, "<$chrony_file");
my @file = <FILE>;
close FILE;
+ my @new_file;
foreach my $line (@file) {
- if ($line =~ /server /) {
- if ($found_server_flag) {
- $line =~ s/^server [\s\S]+$//;
+ if ($line =~ /^server\s+/) {
+ if ($found_server_flag) {
+ $line =~ s/^server\s+[\S]+\s+$//;
} else {
- $line =~ s/^server [\s\S]+$/$ntp_servers_string/;
+ $line =~ s/^server\s+[\S]+\s+$/$ntp_servers_string/;
}
$found_server_flag++;
}
+ push(@new_file, $line);
}
# Append new server if no old server configuration found
if (not $found_server_flag) {
- push(@file, "\n# ntp server configuration written by GOsa-si\n");
- push(@file, $ntp_servers_string);
+ push(@new_file, "\n# ntp server configuration written by GOsa-si\n");
+ push(@new_file, $ntp_servers_string);
}
# Write changes to file and close it
open (FILE, ">$chrony_file");
- print FILE join("", @file);
+ print FILE join("", @new_file);
close FILE;
&main::daemon_log("INFO: wrote new configuration file: $chrony_file", 5);