From 98c1cbc8899af32487bdcc81c69560845e8aabdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E6=9C=A8=E9=89=89?= <740291272@qq.com> Date: Thu, 4 Mar 2021 00:45:25 +0800 Subject: [PATCH] Add bfsu mirror as another mirror of tuna (#2682) * add bfsu for china mirror --- lib/configuration.sh | 9 ++++++++- lib/general.sh | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/configuration.sh b/lib/configuration.sh index 503303ebc..e0f24b4fb 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -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 diff --git a/lib/general.sh b/lib/general.sh index de2fc7796..9ac342ce8 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -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