File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,9 +23,33 @@ if [[ -z $DISTRO_NAME ]]; then
2323 exit 1
2424fi
2525
26+ check_cdn () {
27+ local o_url=$1
28+ local shuffled_cdn_urls=($( shuf -e " ${cdn_urls[@]} " ) ) # 打乱数组顺序
29+ for cdn_url in " ${shuffled_cdn_urls[@]} " ; do
30+ if curl -sL -k " $cdn_url$o_url " --max-time 6 | grep -q " success" > /dev/null 2>&1 ; then
31+ export cdn_success_url=" $cdn_url "
32+ return
33+ fi
34+ sleep 0.5
35+ done
36+ export cdn_success_url=" "
37+ }
38+
39+ check_cdn_file () {
40+ check_cdn " https://raw.githubusercontent.com/spiritLHLS/ecs/main/back/test"
41+ if [ -n " $cdn_success_url " ]; then
42+ echo " CDN available, using CDN"
43+ else
44+ echo " No CDN available, no use CDN"
45+ fi
46+ }
47+
2648# Update webvirtcompute
2749echo -e " \nUpdating webvirtcompute..."
28- wget -O /tmp/webvirtcompute-$DISTRO_NAME$DISTRO_VERSION -amd64.tar.gz https://github.com/oneclickvirt/webvirtcloud/releases/download/webvirtcloud_dep/webvirtcompute-$DISTRO_NAME$DISTRO_VERSION -amd64.tar.gz
50+ cdn_urls=(" https://cdn0.spiritlhl.top/" " http://cdn1.spiritlhl.net/" " http://cdn2.spiritlhl.net/" " http://cdn3.spiritlhl.net/" " http://cdn4.spiritlhl.net/" )
51+ check_cdn_file
52+ wget -O /tmp/webvirtcompute-$DISTRO_NAME$DISTRO_VERSION -amd64.tar.gz " ${cdn_success_url} https://github.com/oneclickvirt/webvirtcloud/releases/download/webvirtcloud_dep/webvirtcompute-$DISTRO_NAME$DISTRO_VERSION -amd64.tar.gz"
2953tar -xvf /tmp/webvirtcompute-$DISTRO_NAME$DISTRO_VERSION -amd64.tar.gz -C /tmp
3054systemctl stop webvirtcompute
3155cp /tmp/webvirtcompute/webvirtcompute /usr/local/bin/webvirtcompute
You can’t perform that action at this time.
0 commit comments