]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
/etc/resolv.conf grows indefinitely 2812/head
authorRachid Koucha <47061324+Rachid-Koucha@users.noreply.github.com>
Sun, 27 Jan 2019 12:46:48 +0000 (13:46 +0100)
committerGitHub <noreply@github.com>
Sun, 27 Jan 2019 12:46:48 +0000 (13:46 +0100)
This file grows indefinitely : upon each DHCP lease renew,
the "nameserver ..dns..." line is added at the end of the file.
Make a "grep" in the file to make sure that the same line
does not already exist.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
templates/lxc-busybox.in

index 2171e2d597fbca62a5878ce9f1814db7f04fe6b2..3782687a54e65ac4497d438279db9f4e308869af 100644 (file)
@@ -164,7 +164,10 @@ case "\$1" in
 
     [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
     for i in \$dns ; do
-      echo nameserver \$i >> /etc/resolv.conf
+      grep "nameserver \$i" /etc/resolv.conf > /dev/null 2>&1
+      if [ \$? -ne 0 ]; then
+        echo nameserver \$i >> /etc/resolv.conf
+      fi
     done
     ;;
 esac