summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Williams <neil.williams@linaro.org>2017-05-11 15:44:49 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-05-12 12:40:53 +0000
commitdcce9e311aefd77ec481f1b8884f8dd6fa67e491 (patch)
treeef1e1c4e35e4d897f2d345e3263770a2aca49f2a
parente05458bb602ec1043c2749c3e72d5b6607ac4dc4 (diff)
Add a script to populate local DNS in NFS
When used with a Debian initramfs (jessie, stretch or later) when the kernel reports dns0 : 10.15.0.1 when mounting the NFS, use this data to populate /etc/resolv.conf Avoids overwriting an existing /etc/resolv.conf Usage: ./automated/utils/nfs-dns.sh eth0 Change-Id: Ie61fde7081f71110d8a4bc6ebe154ca1cfc5beac
-rwxr-xr-xautomated/utils/nfs-dns.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/automated/utils/nfs-dns.sh b/automated/utils/nfs-dns.sh
new file mode 100755
index 0000000..de8a7da
--- /dev/null
+++ b/automated/utils/nfs-dns.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+DEVICE=$1
+
+if [ -z "${DEVICE}" ]; then
+ echo "Must specify the device which has been configured by the kernel."
+ exit 1
+fi
+
+if [ -e '/etc/resolv.conf' ]; then
+ echo "Not altering an existing /etc/resolv.conf"
+ echo "If DNS does not operate for local addresses, see"
+ echo "/run/net-*.conf"
+ exit 2
+fi
+
+if [ ! -e "/run/net-${DEVICE}.conf" ]; then
+ echo "/run/net-${DEVICE}.conf is missing - wrong interface specified?"
+ exit 3
+fi
+
+# shellcheck source=eth0
+. /run/net-"${DEVICE}".conf
+
+echo domain "${DNSDOMAIN}" > /etc/resolv.conf
+echo nameserver "${IPV4DNS0}" >> /etc/resolv.conf