From b09935046800a5de3e2b4b08ca3231652a9f48e0 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 7 May 2025 09:13:35 +0200 Subject: [PATCH] Update alpine-install.func --- misc/alpine-install.func | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/misc/alpine-install.func b/misc/alpine-install.func index b34b350..ab3a02b 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -99,24 +99,20 @@ setting_up_container() { msg_info "Setting up Container OS" # Apply udhcpc.conf DNS override patch if Alpine - if grep -qi 'alpine' /etc/os-release; then - CONFIG_FILE="/etc/udhcpc/udhcpc.conf" + CONFIG_FILE="/etc/udhcpc/udhcpc.conf" - # Remove all active RESOLV_CONF= lines to avoid duplicates - sed -i '/^RESOLV_CONF=/d' "$CONFIG_FILE" + # Remove all RESOLV_CONF= lines (active or commented) + sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE" - # Rebuild file with clean insertion after comment header - awk ' - /^# Do not overwrite \/etc\/resolv\.conf/ { - print - print "RESOLV_CONF=\"no\"" - next - } - { print } - ' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE" - - echo -e "${INFO}${YW}[DEBUG] Cleaned and set RESOLV_CONF=\"no\" in $CONFIG_FILE${CL}" - fi + # Rebuild file with single correct entry after header + awk ' + /^# Do not overwrite \/etc\/resolv\.conf/ { + print + print "RESOLV_CONF=\"no\"" + next + } + { print } +' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE" while [ $i -gt 0 ]; do if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then