simplify nameserver logic and use simple grep options
This commit is contained in:
parent
9fdf39b3aa
commit
43615fb124
@ -94,17 +94,14 @@ enable_outbound_network_for_product_vm() {
|
||||
# Check host nameserver configuration
|
||||
echo -n "Checking local DNS configuration... "
|
||||
if [ -f /etc/resolv.conf ]; then
|
||||
nameserver="$(egrep '^nameserver' /etc/resolv.conf | grep -P -v 'nameserver[ \t]+127.' | head -3)"
|
||||
nameserver="$(grep '^nameserver' /etc/resolv.conf | grep -v 'nameserver\s\s*127.' | head -3)"
|
||||
fi
|
||||
if [ -z "$nameserver" ]; then
|
||||
echo "/etc/resolv.conf does not contain a nameserver. Using 8.8.8.8 for DNS."
|
||||
nameserver="nameserver 8.8.8.8"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
else
|
||||
echo "Could not find /etc/resolv.conf. Using 8.8.8.8 for DNS"
|
||||
nameserver="nameserver 8.8.8.8"
|
||||
fi
|
||||
|
||||
# Enable internet access on inside the VMs
|
||||
echo -n "Enabling outbound network/internet access for the product VM... "
|
||||
@ -128,7 +125,7 @@ enable_outbound_network_for_product_vm() {
|
||||
expect "$prompt"
|
||||
send "sed \"s/GATEWAY=.*/GATEWAY=\"$gateway_ip\"/g\" -i /etc/sysconfig/network\r"
|
||||
expect "$prompt"
|
||||
send "echo -e \"$nameserver\\nnameserver 8.8.8.8\" > /etc/dnsmasq.upstream\r"
|
||||
send "echo -e \"$nameserver\" > /etc/dnsmasq.upstream\r"
|
||||
expect "$prompt"
|
||||
send "service network restart >/dev/null 2>&1\r"
|
||||
expect "$prompt"
|
||||
|
Loading…
Reference in New Issue
Block a user