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} "
You can’t perform that action at this time.
0 commit comments