Update install
This commit is contained in:
17
cattools.sh
17
cattools.sh
@@ -22,17 +22,26 @@ fi
|
||||
# install
|
||||
install_cattools() {
|
||||
local CATTOOLS_PATH="/usr/bin/cattools"
|
||||
local CATTOOLS_URL="https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh"
|
||||
local CATTOOLS_URLS=(
|
||||
"https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh"
|
||||
"https://fastly.jsdelivr.net/gh/miaoermua/cattools@main/cattools.sh"
|
||||
)
|
||||
|
||||
if [ ! -f "$CATTOOLS_PATH" ]; then
|
||||
echo "cattools 未安装,正在安装..."
|
||||
curl -m 5 -s -o "$CATTOOLS_PATH" "$CATTOOLS_URL"
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
for URL in "${CATTOOLS_URLS[@]}"; do
|
||||
curl -m 5 -s -o "$CATTOOLS_PATH" "$URL" && break
|
||||
done
|
||||
|
||||
if [ ! -f "$CATTOOLS_PATH" ] || [ ! -s "$CATTOOLS_PATH" ]; then
|
||||
echo "cattools 下载失败,请检查网络连接。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "$CATTOOLS_PATH"
|
||||
echo "cattools 安装成功。"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -49,6 +58,7 @@ check_for_updates() {
|
||||
if curl -m 5 -s -o "$TEMP_FILE" "$URL"; then
|
||||
if [ -s "$TEMP_FILE" ]; then
|
||||
echo "更新已找到,替换当前脚本..."
|
||||
echo ""
|
||||
mv "$TEMP_FILE" "$0"
|
||||
chmod +x "$0"
|
||||
exec "$0" "$@"
|
||||
@@ -58,6 +68,7 @@ check_for_updates() {
|
||||
|
||||
rm -f "$TEMP_FILE"
|
||||
echo "没有找到更新,继续运行当前脚本..."
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Menu Function
|
||||
|
||||
Reference in New Issue
Block a user