Update alpine-install.func
This commit is contained in:
parent
fe6893d50a
commit
10c418ef47
@ -98,26 +98,24 @@ msg_error() {
|
|||||||
setting_up_container() {
|
setting_up_container() {
|
||||||
msg_info "Setting up Container OS"
|
msg_info "Setting up Container OS"
|
||||||
|
|
||||||
# Apply udhcpc.conf DNS override patch if Alpine
|
# Check if a non-default DNS is configured in /etc/resolv.conf
|
||||||
|
DNS=$(grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | head -n1)
|
||||||
CONFIG_FILE="/etc/udhcpc/udhcpc.conf"
|
CONFIG_FILE="/etc/udhcpc/udhcpc.conf"
|
||||||
|
|
||||||
# Extract any configured DNS server from /etc/network/interfaces
|
# Patch only if DNS is set and not 127.0.0.1
|
||||||
CUSTOM_DNS=$(grep -E '^ *dns-nameservers' /etc/network/interfaces 2>/dev/null | awk '{print $2}')
|
if [ -n "$DNS" ] && [ "$DNS" != "127.0.0.1" ]; then
|
||||||
|
|
||||||
# Only patch if DNS is set and not 'host'
|
|
||||||
if [ -n "$CUSTOM_DNS" ] && [ "$CUSTOM_DNS" != "host" ]; then
|
|
||||||
# Remove all RESOLV_CONF= lines (active or commented)
|
# Remove all RESOLV_CONF= lines (active or commented)
|
||||||
sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE"
|
sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE"
|
||||||
|
|
||||||
# Rebuild file with single correct entry after header
|
# Rebuild file with single correct entry after header
|
||||||
awk '
|
awk '
|
||||||
/^# Do not overwrite \/etc\/resolv\.conf/ {
|
/^# Do not overwrite \/etc\/resolv\.conf/ {
|
||||||
print
|
print
|
||||||
print "RESOLV_CONF=\"no\""
|
print "RESOLV_CONF=\"no\""
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
{ print }
|
{ print }
|
||||||
' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
|
' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ $i -gt 0 ]; do
|
while [ $i -gt 0 ]; do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user