mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +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"; | ||||
|   my $foundit = 0; | ||||
|   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++) { | ||||
|     my $ln =$lines[$i]; | ||||
|     chomp($ln); | ||||
|     if ($ln =~ /^###-LF-HOSTAME-NEXT-###/) { | ||||
|       print FILE "$ln\n"; | ||||
|       print FILE "$ip $MgrHostname\n"; | ||||
|       $i++; | ||||
|       $foundit = 1; | ||||
|     } | ||||
|     else { | ||||
|       print FILE "$ln\n"; | ||||
|   for my $ln (@lines) { | ||||
|     $was_blank = $blank; | ||||
|     $blank = ($ln =~ /^\s*$/) ? 1 : 0; | ||||
|     next if ($blank && $was_blank); | ||||
|     next if ($ln =~/^$ip $MgrHostname$/); | ||||
|     next if ($ln =~ /^###-LF-HOSTAME-NEXT-###/); | ||||
|     if ($ln =~ /\b($MgrHostname|lanforge-srv|$ip)\b/) { | ||||
|        print "Matching LINE $ln\n"; | ||||
|        my @hunks = split(/\s+/, $ln); | ||||
|        for my $hunk (@hunks) { | ||||
|          #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) { | ||||
|     print FILE "###-LF-HOSTAME-NEXT-###\n"; | ||||
|     print FILE "$ip $MgrHostname"; | ||||
|   push(@newlines, "###-LF-HOSTAME-NEXT-###"); | ||||
|  | ||||
|   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; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds