mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
adjust_apache updated to consolidate hostnames for manangement ip, duplicate hostname lines cause trouble
This commit is contained in:
@@ -56,24 +56,44 @@ if (-f "$fname") {
|
|||||||
open(FILE, ">$fname") or die "Couldn't open file: $fname for writing: $!\n\n";
|
open(FILE, ">$fname") or die "Couldn't open file: $fname for writing: $!\n\n";
|
||||||
my $foundit = 0;
|
my $foundit = 0;
|
||||||
my $i;
|
my $i;
|
||||||
|
chomp(@lines);
|
||||||
|
# we want to consolidate the $ip $hostname entry for MgrHostname
|
||||||
|
my @newlines = ();
|
||||||
|
my %more_hostnames = ("lanforge-srv" => 1);
|
||||||
|
my $new_entry = "$ip ";
|
||||||
|
my $blank = 0;
|
||||||
|
my $was_blank = 0;
|
||||||
|
|
||||||
for ($i = 0; $i<@lines; $i++) {
|
for my $ln (@lines) {
|
||||||
my $ln =$lines[$i];
|
$was_blank = $blank;
|
||||||
chomp($ln);
|
$blank = ($ln =~ /^\s*$/) ? 1 : 0;
|
||||||
if ($ln =~ /^###-LF-HOSTAME-NEXT-###/) {
|
next if ($blank && $was_blank);
|
||||||
print FILE "$ln\n";
|
next if ($ln =~/^$ip $MgrHostname$/);
|
||||||
print FILE "$ip $MgrHostname\n";
|
next if ($ln =~ /^###-LF-HOSTAME-NEXT-###/);
|
||||||
$i++;
|
if ($ln =~ /\b($MgrHostname|lanforge-srv|$ip)\b/) {
|
||||||
$foundit = 1;
|
print "Matching LINE $ln\n";
|
||||||
}
|
my @hunks = split(/\s+/, $ln);
|
||||||
else {
|
for my $hunk (@hunks) {
|
||||||
print FILE "$ln\n";
|
#print "HUNK{$hunk} ";
|
||||||
|
next if ($hunk =~ /^($ip|lanforge-srv|$MgrHostname)$/);
|
||||||
|
$more_hostnames{$hunk} = 1;
|
||||||
|
}
|
||||||
|
next;
|
||||||
}
|
}
|
||||||
|
print "ok ln[$ln]\n";
|
||||||
|
push(@newlines, $ln);
|
||||||
}
|
}
|
||||||
if (!$foundit) {
|
push(@newlines, "###-LF-HOSTAME-NEXT-###");
|
||||||
print FILE "###-LF-HOSTAME-NEXT-###\n";
|
|
||||||
print FILE "$ip $MgrHostname";
|
for my $ln (@newlines) {
|
||||||
|
print FILE "$ln\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print FILE "$ip $MgrHostname";
|
||||||
|
for my $name (keys %more_hostnames) {
|
||||||
|
print FILE " $name";
|
||||||
|
}
|
||||||
|
print FILE "\n\n";
|
||||||
close FILE;
|
close FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user