From 0344d20c1560bb2162af7e33f8070ea0b3ddfd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Wed, 12 Jan 2022 07:49:58 +0100 Subject: [PATCH] Support for multi source download when using https protocol (#3306) * Bugfix - toolchain download only from a single source * - replaced hardcoded continent value with dynamic - set https download as default since its downloading from multiple closest servers by default --- config/templates/config-example.conf | 2 +- lib/general.sh | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/templates/config-example.conf b/config/templates/config-example.conf index 021063288e..f9e4c02a35 100644 --- a/config/templates/config-example.conf +++ b/config/templates/config-example.conf @@ -19,6 +19,6 @@ DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8 EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages INSTALL_HEADERS="" # install kernel headers package LIB_TAG="master" # change to "branchname" to use any branch currently available. -USE_TORRENT="yes" # use torrent network for faster toolchain and cache download +USE_TORRENT="no" # use torrent network for faster toolchain and cache download DOWNLOAD_MIRROR="" # set to "china" to use mirrors.tuna.tsinghua.edu.cn CARD_DEVICE="" # device name /dev/sdx of your SD card to burn directly to the card when done diff --git a/lib/general.sh b/lib/general.sh index 3906020410..204c3abb0f 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -1588,23 +1588,22 @@ function webseed () { # list of mirrors that host our files unset text - WEBSEED=($(curl -s https://redirect.armbian.com/mirrors | jq '.[] |.[] | values' | grep https | awk '!a[$0]++')) + # Hardcoded to EU mirrors since + local CCODE=$(curl -s redirect.armbian.com/geoip | jq '.continent.code' -r) + WEBSEED=($(curl -s https://redirect.armbian.com/mirrors | jq -r '.'${CCODE}' | .[] | values')) # aria2 simply split chunks based on sources count not depending on download speed # when selecting china mirrors, use only China mirror, others are very slow there if [[ $DOWNLOAD_MIRROR == china ]]; then WEBSEED=( - "https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/" + https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/ ) elif [[ $DOWNLOAD_MIRROR == bfsu ]]; then WEBSEED=( - "https://mirrors.bfsu.edu.cn/armbian-releases/" + https://mirrors.bfsu.edu.cn/armbian-releases/ ) fi for toolchain in ${WEBSEED[@]}; do - # use only live, tnahosting return ok also when file is absent - if [[ $(wget -S --spider "${toolchain}${1}" 2>&1 >/dev/null | grep 'HTTP/1.1 200 OK') && ${toolchain} != *tnahosting* ]]; then - text="${text} ${toolchain}${1}" - fi + text="${text} ${toolchain}${1}" done text="${text:1}" echo "${text}" @@ -1693,7 +1692,7 @@ download_and_verify() # direct download if torrent fails if [[ ! -f "${localdir}/${filename}.complete" ]]; then if [[ ! `timeout 10 curl --head --fail --silent ${server}${remotedir}/${filename} 2>&1 >/dev/null` ]]; then - display_alert "downloading from $(echo $server | cut -d'/' -f3 | cut -d':' -f1) using http(s) network" "$filename" + display_alert "downloading using http(s) network" "$filename" aria2c --download-result=hide --rpc-save-upload-metadata=false --console-log-level=error \ --dht-file-path="${SRC}"/cache/.aria2/dht.dat --disable-ipv6=true --summary-interval=0 --auto-file-renaming=false --dir="${localdir}" ${server}${remotedir}/${filename} $(webseed "${remotedir}/${filename}") -o "${filename}" # mark complete