aboutsummaryrefslogtreecommitdiff
path: root/straper/install-base.sh
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-20 19:16:32 +0100
committerLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-20 19:16:32 +0100
commit39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2 (patch)
tree9221704f413398cfb5d5759083b1e7032566820e /straper/install-base.sh
parent6b59b75c3a294060dea66bdee16ffaf95ae92889 (diff)
downloadbin-39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2.tar.gz
bin-39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2.zip
feat: first fully successful run e2e on straper
Diffstat (limited to 'straper/install-base.sh')
-rwxr-xr-xstraper/install-base.sh32
1 files changed, 23 insertions, 9 deletions
diff --git a/straper/install-base.sh b/straper/install-base.sh
index f26e484..a37de64 100755
--- a/straper/install-base.sh
+++ b/straper/install-base.sh
@@ -115,8 +115,24 @@ bootstrap_dns_prepare() {
local test_host="${BOOTSTRAP_TEST_HOST:-deb.debian.org}"
local backup="/etc/resolv.conf.labunix-preinstall.bak"
+ # Always write a static resolv.conf — breaks any symlink to systemd-resolved
+ # stub (127.0.0.53) which can disappear when services restart mid-install.
+ [[ -e /etc/resolv.conf && ! -e "${backup}" ]] && cp -a /etc/resolv.conf "${backup}" || true
+
if getent ahostsv4 "${test_host}" >/dev/null 2>&1; then
- report "${SCRIPT_NAME}" "dns" "bootstrap" "check" "ok" "resolver already working" ""
+ # DNS works but may be via stub — write static file pointing at real resolver
+ local current_ns
+ current_ns="$(grep '^nameserver' /etc/resolv.conf 2>/dev/null | head -1 | awk '{print $2}')"
+ # Never use stub addresses — they won't survive service restarts
+ if [[ "$current_ns" == "127.0.0.53" || "$current_ns" == "127.0.0.54" || -z "$current_ns" ]]; then
+ current_ns="1.1.1.1"
+ fi
+ [[ -L /etc/resolv.conf ]] && rm -f /etc/resolv.conf
+ printf 'nameserver %s
+nameserver 9.9.9.9
+' "$current_ns" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ report "${SCRIPT_NAME}" "dns" "bootstrap" "check" "ok" "static resolv.conf written: ${current_ns}" ""
return 0
fi
@@ -125,17 +141,15 @@ bootstrap_dns_prepare() {
die "bootstrap DNS check failed: no outbound IP connectivity"
fi
- if command -v dig >/dev/null 2>&1 && dig +time=2 +tries=1 +short @1.1.1.1 "${test_host}" >/dev/null 2>&1; then
- [[ -e /etc/resolv.conf && ! -e "${backup}" ]] && cp -a /etc/resolv.conf "${backup}" || true
- printf 'nameserver 1.1.1.1
+ [[ -L /etc/resolv.conf ]] && rm -f /etc/resolv.conf
+ printf 'nameserver 1.1.1.1
nameserver 9.9.9.9
' > /etc/resolv.conf
- chmod 644 /etc/resolv.conf || true
+ chmod 644 /etc/resolv.conf
- if getent ahostsv4 "${test_host}" >/dev/null 2>&1; then
- report "${SCRIPT_NAME}" "dns" "bootstrap" "fallback" "changed" "static resolv.conf applied" "${backup}"
- return 0
- fi
+ if getent ahostsv4 "${test_host}" >/dev/null 2>&1; then
+ report "${SCRIPT_NAME}" "dns" "bootstrap" "fallback" "changed" "static fallback resolv.conf applied" "${backup}"
+ return 0
fi
note_failure "${SCRIPT_NAME}" "dns" "bootstrap" "check" "DNS still broken after fallback attempt"