File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,16 +4,34 @@ WORKDIR="/usr/src/app"
44ISO_BUILD_PATH=" ${WORKDIR} /dappnode-iso"
55DAPPNODE_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.
79download_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
1937verify_download () {
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ BASE_ISO_NAME="debian-13.5.0-amd64-netinst.iso"
99BASE_ISO_VERSION=" ${BASE_ISO_NAME# debian-} "
1010BASE_ISO_VERSION=" ${BASE_ISO_VERSION% -amd64-netinst.iso} "
1111BASE_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} "
1316BASE_ISO_SHASUM=" 95838884f5ea6c82421dfe6baaa5a639dbbe6756c1e380f9fe7a7cb0c1949d2a ${BASE_ISO_PATH} "
1417
1518DAPPNODE_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} "
9194verify_download " ${BASE_ISO_PATH} " " ${BASE_ISO_SHASUM} "
9295clean_old_files " ${ISO_BUILD_PATH} " " ${DAPPNODE_ISO_PREFIX} "
9396extract_iso " ${BASE_ISO_PATH} " " ${ISO_BUILD_PATH} "
Original file line number Diff line number Diff 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)"
Original file line number Diff line number Diff 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
111123host_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 $?
You can’t perform that action at this time.
0 commit comments