diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2019-09-17 11:19:52 +0200 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2019-09-17 11:19:52 +0200 |
commit | 2c1b0cf5775e0af2ef29f9090a608b87caf4de98 (patch) | |
tree | a8fabe54faa8af36627ad6ab53986820f451ce89 | |
parent | 26000016357895d6d3e81b5c82c1d50f3f7013fd (diff) |
#914: Fix duplicates when detecting network parameters and get main nameserver with Systemd.
-rwxr-xr-x | installer/opengnsys_installer.sh | 13 | ||||
-rwxr-xr-x | installer/opengnsys_update.sh | 2 |
2 files changed, 8 insertions, 7 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 diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index 5ea716de..dabd6177 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -496,7 +496,7 @@ function getNetworkSettings() SERVERIP="$ServidorAdm" DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')" for dev in $DEVICES; do - [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}') + [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4); exit;}') done } |