Update alpine-install.func

This commit is contained in:
CanbiZ 2025-05-07 09:15:35 +02:00
parent b099350468
commit c74738bfcf

View File

@ -101,6 +101,11 @@ setting_up_container() {
# Apply udhcpc.conf DNS override patch if Alpine # Apply udhcpc.conf DNS override patch if Alpine
CONFIG_FILE="/etc/udhcpc/udhcpc.conf" CONFIG_FILE="/etc/udhcpc/udhcpc.conf"
# Extract any configured DNS server from /etc/network/interfaces
DNS_LINE=$(grep -E '^ *dns-nameservers' /etc/network/interfaces 2>/dev/null | awk '{print $2}')
# Only patch if DNS is set and not 'host'
if [ -n "$DNS_LINE" ] && [ "$DNS_LINE" != "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"
@ -113,6 +118,7 @@ setting_up_container() {
} }
{ 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
while [ $i -gt 0 ]; do while [ $i -gt 0 ]; do
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then