From 11d2ce0209e3a719a6fdc7ae5d1d4ca0c9ec2cd4 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:20:10 +0800 Subject: [PATCH] Create install.sh --- install.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..1830d6f --- /dev/null +++ b/install.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Check ROOT & OpenWrt +if [ $(id -u) != "0" ]; then + echo "Error: You must be root to run this script, please use root user" + exit 1 +fi + +openwrt_release=$(cat /etc/openwrt_release) +if ! grep -q "OpenWrt" <<< "$openwrt_release"; then + echo "Your system is not supported!" + 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 + echo "cattools is installed successfully!" + echo "please type ‘cattools’ or ‘/usr/bin/cattools’ to run it." +}