Update hotupdate

This commit is contained in:
喵二
2024-07-08 22:40:34 +08:00
committed by GitHub
parent 595cd27b3f
commit 5cd75b3b66

View File

@@ -30,16 +30,31 @@ fi
update_cattools() { update_cattools() {
echo "Please wait for the script to be updated." echo "Please wait for the script to be updated."
local temp_file=$(mktemp) local temp_file=$(mktemp)
if curl --silent --connect-timeout 5 -o "$temp_file" https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh; then local retries=3
echo "cattools update downloaded from the first URL." local success=false
elif curl --silent --connect-timeout 5 -o "$temp_file" https://fastly.jsdelivr.net/gh/miaoermua/cattools@main/cattools.sh; then
echo "cattools update downloaded from the second URL." while [ $retries -gt 0 ]; do
else if curl --silent --connect-timeout 3 --max-time 9 -o "$temp_file" https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh; then
echo "cattools update downloaded from the first URL."
success=true
break
elif curl --silent --connect-timeout 3 --max-time 9 -o "$temp_file" https://fastly.jsdelivr.net/gh/miaoermua/cattools@main/cattools.sh; then
echo "cattools update downloaded from the second URL."
success=true
break
else
echo "Attempt $(3 - retries + 1) failed. Retrying..."
retries=$((retries - 1))
fi
done
if [ "$success" = false ]; then
echo "Unable to download the latest version, continue to use the current offline version." echo "Unable to download the latest version, continue to use the current offline version."
echo "" echo ""
rm -f "$temp_file" rm -f "$temp_file"
return return
fi fi
mv "$temp_file" /usr/bin/cattools mv "$temp_file" /usr/bin/cattools
chmod +x /usr/bin/cattools chmod +x /usr/bin/cattools
echo "cattools updated successfully." echo "cattools updated successfully."