Skip to content

Commit 2edf006

Browse files
authored
Merge branch 'master' into marc/debian-release-tests
2 parents b2e5c21 + d250882 commit 2edf006

4 files changed

Lines changed: 51 additions & 7 deletions

File tree

‎iso/scripts/common_iso_generation.sh‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,34 @@ WORKDIR="/usr/src/app"
44
ISO_BUILD_PATH="${WORKDIR}/dappnode-iso"
55
DAPPNODE_ISO_PREFIX="Dappnode-"
66

7+
# Usage: download_iso <path> <name> <url> [fallback_url...]
8+
# URLs are tried in order, which covers mirrors that move older releases elsewhere.
79
download_iso() {
810
local iso_path=$1
911
local iso_name=$2
10-
local iso_url=$3
12+
shift 2
1113

1214
echo "[INFO] Downloading base ISO image: ${iso_name}..."
13-
if [ ! -f "${iso_path}" ]; then
14-
wget "${iso_url}" -O "${iso_path}"
15+
if [ -f "${iso_path}" ]; then
16+
echo "[INFO] Download complete!"
17+
return 0
1518
fi
16-
echo "[INFO] Download complete!"
19+
20+
local iso_url
21+
for iso_url in "$@"; do
22+
# Unlike busybox wget, curl moves on to the next address when a mirror
23+
# host resolves to several and one of them is down.
24+
if curl -fsSL --retry 3 --retry-connrefused --connect-timeout 30 -o "${iso_path}" "${iso_url}"; then
25+
echo "[INFO] Download complete!"
26+
return 0
27+
fi
28+
# A failed download leaves a partial file behind, which would be reused on the next run
29+
rm -f "${iso_path}"
30+
echo "[WARN] Could not download ${iso_url}"
31+
done
32+
33+
echo "[ERROR] Could not download ${iso_name} from any known location"
34+
exit 1
1735
}
1836

1937
verify_download() {

‎iso/scripts/generate_dappnode_iso_debian.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ BASE_ISO_NAME="debian-13.5.0-amd64-netinst.iso"
99
BASE_ISO_VERSION="${BASE_ISO_NAME#debian-}"
1010
BASE_ISO_VERSION="${BASE_ISO_VERSION%-amd64-netinst.iso}"
1111
BASE_ISO_PATH="/images/${BASE_ISO_NAME}"
12-
BASE_ISO_URL="https://cdimage.debian.org/mirror/cdimage/archive/${BASE_ISO_VERSION}/amd64/iso-cd/${BASE_ISO_NAME}"
12+
# Debian serves the newest point release from debian-cd/ and only moves it to the
13+
# archive once it is superseded, so try both.
14+
BASE_ISO_URL="https://cdimage.debian.org/debian-cd/${BASE_ISO_VERSION}/amd64/iso-cd/${BASE_ISO_NAME}"
15+
BASE_ISO_ARCHIVE_URL="https://cdimage.debian.org/mirror/cdimage/archive/${BASE_ISO_VERSION}/amd64/iso-cd/${BASE_ISO_NAME}"
1316
BASE_ISO_SHASUM="95838884f5ea6c82421dfe6baaa5a639dbbe6756c1e380f9fe7a7cb0c1949d2a ${BASE_ISO_PATH}"
1417

1518
DAPPNODE_ISO_NAME="${DAPPNODE_ISO_PREFIX}${BASE_ISO_NAME}"
@@ -87,7 +90,7 @@ generate_debian_iso() {
8790
-isohybrid-gpt-basdat -o "${iso_output_path}" ${iso_build_path}
8891
}
8992

90-
download_iso "${BASE_ISO_PATH}" "${BASE_ISO_NAME}" "${BASE_ISO_URL}"
93+
download_iso "${BASE_ISO_PATH}" "${BASE_ISO_NAME}" "${BASE_ISO_URL}" "${BASE_ISO_ARCHIVE_URL}"
9194
verify_download "${BASE_ISO_PATH}" "${BASE_ISO_SHASUM}"
9295
clean_old_files "${ISO_BUILD_PATH}" "${DAPPNODE_ISO_PREFIX}"
9396
extract_iso "${BASE_ISO_PATH}" "${ISO_BUILD_PATH}"

‎scripts/dappnode_install.sh‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,17 @@ normalize_ipfs_version_ref() {
428428
local cid_path="$ref"
429429
local manifest_url="${IPFS_ENDPOINT%/}${cid_path}/dappnode_package.json"
430430
local manifest
431-
manifest="$(download_stdout "$manifest_url" 2>/dev/null || true)"
431+
# On the first boot after an ISO install this runs from rc.local, which
432+
# does not wait for DHCP (Debian's allow-hotplug interfaces are not part
433+
# of network-online.target), so give the network up to ~2 minutes.
434+
local attempt
435+
for attempt in $(seq 1 24); do
436+
manifest="$(download_stdout "$manifest_url" 2>/dev/null || true)"
437+
[[ -n "$manifest" ]] && break
438+
# stdout is this function's return value, so report on stderr
439+
[[ "$attempt" -eq 1 ]] && warn "Could not fetch IPFS manifest for ${comp} yet, retrying..." >&2
440+
[[ "$attempt" -lt 24 ]] && sleep 5
441+
done
432442
if [[ -z "$manifest" ]]; then
433443
error "Could not fetch IPFS manifest for ${comp} from: $manifest_url"
434444
error "Provide ${comp}_VERSION as /ipfs/<cid>:<version> (example: /ipfs/Qm...:0.2.11)"

‎scripts/dappnode_install_pre.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,21 @@ install_iptables() {
107107
fi
108108
}
109109

110+
# The Debian installer comments out the install media's cdrom: APT source only
111+
# after the late-commands have run. Until then apt-get update fails on it, so
112+
# disable it now as the installer would (apt-setup/disable-cdrom-entries).
113+
disable_iso_cdrom_sources() {
114+
[ "$ISO_INSTALLATION" = "true" ] || return 0
115+
local sources_file
116+
for sources_file in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do
117+
[ -f "$sources_file" ] || continue
118+
sed -i -E 's/^(deb(-src)?[[:space:]]+(\[[^]]*\][[:space:]]+)?cdrom:)/# \1/' "$sources_file"
119+
done
120+
}
121+
110122
# HOST UPDATE
111123
host_update() {
124+
disable_iso_cdrom_sources
112125
# Process substitution keeps apt-get's exit status while still logging its
113126
# output. A regular pipeline would return tee's status and hide dpkg errors.
114127
apt-get update > >(tee -a "$LOG_FILE") 2>&1 || return $?

0 commit comments

Comments
 (0)