Update hotupdate
This commit is contained in:
19
cattools.sh
19
cattools.sh
@@ -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
|
||||||
|
local success=false
|
||||||
|
|
||||||
|
while [ $retries -gt 0 ]; do
|
||||||
|
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."
|
echo "cattools update downloaded from the first URL."
|
||||||
elif curl --silent --connect-timeout 5 -o "$temp_file" https://fastly.jsdelivr.net/gh/miaoermua/cattools@main/cattools.sh; then
|
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."
|
echo "cattools update downloaded from the second URL."
|
||||||
|
success=true
|
||||||
|
break
|
||||||
else
|
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."
|
||||||
|
|||||||
Reference in New Issue
Block a user