summaryrefslogtreecommitdiffstats
path: root/installer/opengnsys_installer.sh
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2019-09-17 11:19:52 +0200
committerRamón M. Gómez <ramongomez@us.es>2019-09-17 11:19:52 +0200
commit2c1b0cf5775e0af2ef29f9090a608b87caf4de98 (patch)
treea8fabe54faa8af36627ad6ab53986820f451ce89 /installer/opengnsys_installer.sh
parent26000016357895d6d3e81b5c82c1d50f3f7013fd (diff)
#914: Fix duplicates when detecting network parameters and get main nameserver with Systemd.
Diffstat (limited to 'installer/opengnsys_installer.sh')
-rwxr-xr-xinstaller/opengnsys_installer.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh
index 24c055f0..f2451872 100755
--- a/installer/opengnsys_installer.sh
+++ b/installer/opengnsys_installer.sh
@@ -881,17 +881,18 @@ function getNetworkSettings()
exit 1
fi
for dev in ${DEVICE[*]}; do
- SERVERIP[i]=$(ip -o addr show dev "$dev" | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
+ SERVERIP[i]=$(ip -o addr show dev "$dev" | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4); exit;}')
if [ -n "${SERVERIP[i]}" ]; then
- NETMASK[i]=$( cidr2mask $(ip -o addr show dev "$dev" | awk '$3~/inet$/ {sub (/.*\//, "", $4); print ($4)}') )
- NETBROAD[i]=$(ip -o addr show dev "$dev" | awk '$3~/inet$/ {print ($6)}')
- NETIP[i]=$(ip route list proto kernel | awk -v d="$dev" '$3==d && /src/ {sub (/\/.*/,""); print $1}')
- ROUTERIP[i]=$(ip route list default | awk -v d="$dev" '$5==d {print $3}')
+ NETMASK[i]=$( cidr2mask $(ip -o addr show dev "$dev" | awk '$3~/inet$/ {sub (/.*\//, "", $4); print ($4); exit;}') )
+ NETBROAD[i]=$(ip -o addr show dev "$dev" | awk '$3~/inet$/ {print ($6); exit;}')
+ NETIP[i]=$(ip route list proto kernel | awk -v d="$dev" '$3==d && /src/ {sub (/\/.*/,""); print $1; exit;}')
+ ROUTERIP[i]=$(ip route list default | awk -v d="$dev" '$5==d {print $3; exit;}')
DEFAULTDEV=${DEFAULTDEV:-"$dev"}
fi
let i++
done
- DNSIP=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n1)
+ DNSIP=$(systemd-resolve --status 2>/dev/null | awk '/DNS Servers:/ {print $3; exit;}')
+ [ -z "$DNSIP" ] && DNSIP=$(awk '/nameserver/ {print $2; exit;}' /etc/resolv.conf)
if [ -z "${NETIP[*]}" -o -z "${NETMASK[*]}" ]; then
errorAndLog "${FUNCNAME}(): Network not detected."
exit 1