Add bfsu mirror as another mirror of tuna (#2682)

* add bfsu for china mirror
This commit is contained in:
柚木鉉
2021-03-04 00:45:25 +08:00
committed by GitHub
parent 1d3796d75d
commit 98c1cbc889
2 changed files with 27 additions and 4 deletions

View File

@@ -64,6 +64,7 @@ fi
case $MAINLINE_MIRROR in
google) MAINLINE_KERNEL_SOURCE='https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable' ;;
tuna) MAINLINE_KERNEL_SOURCE='https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git' ;;
bfsu) MAINLINE_KERNEL_SOURCE='https://mirrors.bfsu.edu.cn/git/linux-stable.git' ;;
*) MAINLINE_KERNEL_SOURCE='git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git' ;;
esac
MAINLINE_KERNEL_DIR='linux-mainline'
@@ -491,12 +492,18 @@ DEBIAN_MIRROR='deb.debian.org/debian'
DEBIAN_SECURTY='security.debian.org/'
UBUNTU_MIRROR='ports.ubuntu.com/'
if [[ $DOWNLOAD_MIRROR == china ]] ; then
if [[ $DOWNLOAD_MIRROR == "china" ]] ; then
DEBIAN_MIRROR='mirrors.tuna.tsinghua.edu.cn/debian'
DEBIAN_SECURTY='mirrors.tuna.tsinghua.edu.cn/debian-security'
UBUNTU_MIRROR='mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/'
fi
if [[ $DOWNLOAD_MIRROR == "bfsu" ]] ; then
DEBIAN_MIRROR='mirrors.bfsu.edu.cn/debian'
DEBIAN_SECURTY='mirrors.bfsu.edu.cn/debian-security'
UBUNTU_MIRROR='mirrors.bfsu.edu.cn/ubuntu-ports/'
fi
# don't use mirrors that throws garbage on 404
while true; do

View File

@@ -175,6 +175,8 @@ create_sources_list()
# stage: add armbian repository and install key
if [[ $DOWNLOAD_MIRROR == "china" ]]; then
echo "deb http://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
elif [[ $DOWNLOAD_MIRROR == "bfsu" ]]; then
echo "deb http://mirrors.bfsu.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
else
echo "deb http://"$([[ $BETA == yes ]] && echo "beta" || echo "apt" )".armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
fi
@@ -1233,6 +1235,10 @@ function webseed ()
WEBSEED=(
"https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/"
)
elif [[ $DOWNLOAD_MIRROR == bfsu ]]; then
WEBSEED=(
"https://mirrors.bfsu.edu.cn/armbian-releases/"
)
fi
for toolchain in ${WEBSEED[@]}; do
# use only live, tnahosting return ok also when file is absent
@@ -1256,9 +1262,11 @@ download_and_verify()
local dirname=${filename//.tar.xz}
if [[ $DOWNLOAD_MIRROR == china ]]; then
local server="https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/"
else
local server=${ARMBIAN_MIRROR}
local server="https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/"
elif [[ $DOWNLOAD_MIRROR == bfsu ]]; then
local server="https://mirrors.bfsu.edu.cn/armbian-releases/"
else
local server=${ARMBIAN_MIRROR}
fi
if [[ -f ${localdir}/${dirname}/.download-complete ]]; then
@@ -1270,7 +1278,15 @@ download_and_verify()
if [[ $? -ne 7 && $? -ne 22 && $? -ne 0 ]]; then
display_alert "Timeout from $server" "retrying" "info"
server="https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/"
# switch to another china mirror if tuna timeouts
timeout 10 curl --head --fail --silent ${server}${remotedir}/${filename} 2>&1 >/dev/null
if [[ $? -ne 7 && $? -ne 22 && $? -ne 0 ]]; then
display_alert "Timeout from $server" "retrying" "info"
server="https://mirrors.bfsu.edu.cn/armbian-releases/"
fi
fi
# check if file exists on remote server before running aria2 downloader
[[ ! `timeout 10 curl --head --fail --silent ${server}${remotedir}/${filename}` ]] && return