From 8dc434b6614cae916f641c3b4df8f8dc5f50bf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=B5=E4=BA=8C?= <66155308+miaoermua@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:14:26 +0800 Subject: [PATCH] Update hotupdate --- cattools.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/cattools.sh b/cattools.sh index d33c239..6c31f2d 100644 --- a/cattools.sh +++ b/cattools.sh @@ -19,6 +19,42 @@ if ! grep -q "OpenWrt" <<< "$openwrt_release"; then exit 1 fi +# installed +install_cattools() { + if [ ! -f /usr/bin/cattools ]; then + echo "cattools not found, installing..." + if curl --silent --connect-timeout 5 -o /usr/bin/cattools https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh; then + echo "cattools installed successfully from the first URL." + elif curl --silent --connect-timeout 5 -o /usr/bin/cattools https://fastly.jsdelivr.net/gh/miaoermua/cattools@main/cattools.sh; then + echo "cattools installed successfully from the second URL." + else + echo "Failed to download cattools from both URLs." + exit 1 + fi + chmod +x /usr/bin/cattools + fi +} + +# Update +update_cattools() { + local temp_file=$(mktemp) + if curl --silent --connect-timeout 5 -o "$temp_file" https://raw.githubusercontent.com/miaoermua/cattools/main/cattools.sh; then + 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 + echo "cattools update downloaded from the second URL." + else + echo "Failed to download updates for cattools from both URLs. Continuing with the existing version." + rm -f "$temp_file" + return + fi + mv "$temp_file" /usr/bin/cattools + chmod +x /usr/bin/cattools + echo "cattools updated successfully." +} + +install_cattools +update_cattools + # Menu Function show_menu() { echo "----------------------------------------------------------"