Update alpine-install.func

This commit is contained in:
CanbiZ 2025-05-07 09:27:54 +02:00
parent fe6893d50a
commit 10c418ef47

View File

@ -98,14 +98,12 @@ msg_error() {
setting_up_container() {
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"
# Extract any configured DNS server from /etc/network/interfaces
CUSTOM_DNS=$(grep -E '^ *dns-nameservers' /etc/network/interfaces 2>/dev/null | awk '{print $2}')
# Only patch if DNS is set and not 'host'
if [ -n "$CUSTOM_DNS" ] && [ "$CUSTOM_DNS" != "host" ]; then
# Patch only if DNS is set and not 127.0.0.1
if [ -n "$DNS" ] && [ "$DNS" != "127.0.0.1" ]; then
# Remove all RESOLV_CONF= lines (active or commented)
sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE"