From 75980515e1d9a20e682a1233c52a1001460b6c49 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Tue, 21 May 2019 18:05:15 -0700 Subject: [PATCH] WIP: fixes ever growing whitepsace --- adjust_apache.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/adjust_apache.pl b/adjust_apache.pl index adb7ba6b..5d835c27 100755 --- a/adjust_apache.pl +++ b/adjust_apache.pl @@ -45,10 +45,16 @@ my @host_lines = `cat /etc/hosts`; chomp (@host_lines); @host_lines = ("127.0.0.1 localhost", @host_lines) if (@host_lines < 1); +my $removed = 0; for (my $i =$#host_lines-1; $i>=0; $i--) { my $line = $host_lines[$i]; if ($line =~ /$MgrHostname/) { splice(@host_lines, $i, 1); + $removed++; + } + if (($removed < 2) && ( $line eq "" || $line eq "\n")) { + splice(@host_lines, $i, 1); + $removed++; } } @host_lines = (@host_lines, ("$ip $MgrHostname", "\n"));