Skip to content

Commit

Permalink
Support for multi source download when using https protocol (armbian#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
igorpecovnik authored and root committed Feb 4, 2022
1 parent 06dbc9e commit 3670910
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/templates/config-example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 7 additions & 8 deletions lib/general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3670910

Please sign in to comment.