mirror of
https://github.com/oneclickvirt/pve.git
synced 2025-09-05 22:25:59 +08:00
fix: 归档旧函数
This commit is contained in:
parent
63eef3e621
commit
b5674e2fb0
1 changed files with 50 additions and 1 deletions
|
@ -116,6 +116,55 @@ check_interface(){
|
|||
exit 1
|
||||
}
|
||||
|
||||
# 查找最佳ARM镜像源
|
||||
find_best_arm_mirror() {
|
||||
arch_pve_urls=(
|
||||
"https://global.mirrors.apqa.cn"
|
||||
"https://mirrors.apqa.cn"
|
||||
"https://hk.mirrors.apqa.cn"
|
||||
"https://mirrors.lierfang.com"
|
||||
"https://de.mirrors.apqa.cn"
|
||||
)
|
||||
min_ping=9999
|
||||
min_ping_url=""
|
||||
for url in "${arch_pve_urls[@]}"; do
|
||||
url_without_protocol="${url#https://}"
|
||||
ping_result=$(ping -c 3 -q "$url_without_protocol" | grep -oP '(?<=min/avg/max/mdev = )[0-9.]+')
|
||||
avg_ping=$(echo "$ping_result" | cut -d '/' -f 2)
|
||||
if [ ! -z "$avg_ping" ]; then
|
||||
echo "Ping [$url_without_protocol]: $avg_ping ms"
|
||||
if (($(echo "$avg_ping < $min_ping" | bc -l))); then
|
||||
min_ping="$avg_ping"
|
||||
min_ping_url="$url"
|
||||
fi
|
||||
else
|
||||
_yellow "Unable to get ping [$url_without_protocol]"
|
||||
fi
|
||||
done
|
||||
# 验证最佳镜像源连接是否正常
|
||||
if [ -n "$min_ping_url" ]; then
|
||||
echo "Trying to fetch the page using curl from: $min_ping_url"
|
||||
if curl -s -o /dev/null "$min_ping_url"; then
|
||||
echo "curl succeeded, using the URL: $min_ping_url"
|
||||
else
|
||||
echo "curl failed with URL: $min_ping_url"
|
||||
# 尝试其他镜像源
|
||||
for url in "${arch_pve_urls[@]}"; do
|
||||
if [ "$url" != "$min_ping_url" ]; then
|
||||
echo "Trying the next URL: $url"
|
||||
if curl -s -o /dev/null "$url"; then
|
||||
echo "curl succeeded, using the URL: $url"
|
||||
min_ping_url="$url"
|
||||
break
|
||||
else
|
||||
echo "curl failed with URL: $url"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 提取物理网卡名字
|
||||
interface_1=$(lshw -C network | awk '/logical name:/{print $3}' | sed -n '1p')
|
||||
interface_2=$(lshw -C network | awk '/logical name:/{print $3}' | sed -n '2p')
|
||||
|
@ -163,4 +212,4 @@ user_ip="172.16.1.${num}"
|
|||
# # 如果 https://githubapi.spiritlhl.workers.dev/ 请求失败,则使用 https://githubapi.spiritlhl.top/ ,此时可能宿主机在国内
|
||||
# if [ -z "$response" ]; then
|
||||
# response=$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://githubapi.spiritlhl.top/repos/oneclickvirt/pve_lxc_images/releases/tags/${en_system}" | grep -oP '"name": "\K[^"]+\.zst' | awk 'NR%2==1')
|
||||
# fi
|
||||
# fi
|
||||
|
|
Loading…
Add table
Reference in a new issue