Update alpine-install.func

This commit is contained in:
CanbiZ 2025-05-07 09:04:19 +02:00
parent 92ead4f330
commit 38b5403d08

View File

@ -98,20 +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
if grep -qi 'alpine' /etc/os-release; then if grep -qi 'alpine' /etc/os-release; then
CONFIG_FILE="/etc/udhcpc/udhcpc.conf" CONFIG_FILE="/etc/udhcpc/udhcpc.conf"
if grep -q '^RESOLV_CONF="no"' "$CONFIG_FILE"; then
echo -e "${INFO}${YW}[DEBUG] RESOLV_CONF already set correctly. No changes.${CL}" # Remove all active RESOLV_CONF= lines to avoid duplicates
elif grep -q '^#RESOLV_CONF=' "$CONFIG_FILE"; then sed -i '/^RESOLV_CONF=/d' "$CONFIG_FILE"
sed -i 's/^#RESOLV_CONF=.*/RESOLV_CONF="no"/' "$CONFIG_FILE"
echo -e "${INFO}${YW}[DEBUG] Uncommented and set RESOLV_CONF=\"no\"${CL}" # Rebuild file with clean insertion after comment header
elif grep -q '^RESOLV_CONF=' "$CONFIG_FILE"; then awk '
sed -i 's/^RESOLV_CONF=.*/RESOLV_CONF="no"/' "$CONFIG_FILE" /^# Do not overwrite \/etc\/resolv\.conf/ {
echo -e "${INFO}${YW}[DEBUG] Overwrote existing RESOLV_CONF=... line${CL}" print
else print "RESOLV_CONF=\"no\""
echo 'RESOLV_CONF="no"' >>"$CONFIG_FILE" next
echo -e "${INFO}${YW}[DEBUG] Added RESOLV_CONF=\"no\" at EOF${CL}" }
fi { 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 fi
while [ $i -gt 0 ]; do while [ $i -gt 0 ]; do