From a4f2ef126cc18c67c4629219faf1c44a843c64fd Mon Sep 17 00:00:00 2001 From: gaofei Date: Fri, 30 Aug 2024 11:39:11 +0800 Subject: [PATCH] update all --- README.md | 2 +- quick_client.sh | 2 +- quick_server.sh | 38 ++++++++++++++++++++++++++++++-------- update_bin.sh | 11 +++++++---- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 26029cc..13c873d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ bash <(curl -fsSL https://raw.githubusercontent.com/xxoommd/magic/main/quick_ser - Gitea: ```shell -bash <(curl -fsSL https://gitee.com/xxoommd/magic/raw/main/quick_server.sh) +DOWNLOAD_SRC=gitee bash <(curl -fsSL https://gitee.com/xxoommd/magic/raw/main/quick_server.sh) ``` #### client diff --git a/quick_client.sh b/quick_client.sh index ff63ac2..9534d35 100755 --- a/quick_client.sh +++ b/quick_client.sh @@ -24,7 +24,7 @@ fi TAG=${TAG:-latest} -github_download_url_prefix="https://gitee.com/xxoommd/magic/releases/download" +github_download_url_prefix="https://github.com/xxoommd/magic/releases/download" gitee_download_url_prefix="https://github.com/xxoommd/ultimate_collection/releases/download" naive_bin_name="" diff --git a/quick_server.sh b/quick_server.sh index e4800a1..4784c09 100755 --- a/quick_server.sh +++ b/quick_server.sh @@ -7,16 +7,15 @@ YELLOW='\033[0;33m' UNDERLINE='\033[4m' # 下划线 NC='\033[0m' # No Color -if [[ -z $DEPLOY_DOMAIN ]]; then - echo - echo "[${RED}Err${NC}] DEPLOY_DOMAIN is not set" - echo +# 仅root用户执行 +if [ "$(id -u)" -eq 0 ]; then + echo "当前用户是 root" +else + echo -e "${RED}[Err]${NC}当前用户不是 root" exit 1 fi -caddy_download_url="https://gitee.com/xxoommd/magic/releases/download/v0.1/caddy-linux-amd64" -hysteria_download_url="https://gitee.com/xxoommd/magic/releases/download/v0.1/hysteria-linxu-amd64-avx" - +# 验证域名格式是否合法 function is_valid_domain() { local str="$1" @@ -28,9 +27,15 @@ function is_valid_domain() { fi } -# 验证域名格式是否合法 echo -e "\n[INFO] Validate DOMAN: ${BLUE}${DEPLOY_DOMAIN}${NC} ..." +if [[ -z $DEPLOY_DOMAIN ]]; then + echo + echo "[${RED}Err${NC}] DEPLOY_DOMAIN is not set" + echo + exit 1 +fi + if is_valid_domain "$DEPLOY_DOMAIN"; then echo -e "[INFO] ${BLUE}${UNDERLINE}$DEPLOY_DOMAIN${NC} is a valid domain.\n" else @@ -38,6 +43,23 @@ else exit 1 fi +TAG=${TAG:-"latest"} + +echo -e "[INFO] Using TAG: ${YELLOW}${TAG}${NC}" + +caddy_download_url="" +hysteria_download_url="" + +if [ "$DOWNLOAD_SRC" = "gitee" ]; then + echo -e "[INFO] Download from ${YELLOW}Gitee${NC} ..." + caddy_download_url="https://gitee.com/xxoommd/magic/releases/download/${TAG}/caddy-linux-amd64" + hysteria_download_url="https://gitee.com/xxoommd/magic/releases/download/${TAG}/hysteria-linxu-amd64-avx" +else + echo -e "[INFO] Download from ${YELLOW}Github${NC} ..." + caddy_download_url="https://github.com/xxoommd/magic/releases/download/${TAG}/caddy-linux-amd64" + hysteria_download_url="https://github.com/xxoommd/magic/releases/download/${TAG}/hysteria-linxu-amd64-avx" +fi + # 设置工作目录 WORKING_DIR="/root/.local/magic" if [ ! -d "${WORKING_DIR}" ]; then diff --git a/update_bin.sh b/update_bin.sh index 700b649..e891ea8 100755 --- a/update_bin.sh +++ b/update_bin.sh @@ -97,11 +97,14 @@ function update_naive() { chmod +x $BIN_PATH/naive* && ls -lhF $BIN_PATH/naive* } -function update_hysteria() { - curl -s -L -o $BIN_PATH/hysteria-linxu-amd64-avx https://download.hysteria.network/app/latest/hysteria-linux-amd64-avx && - curl -s -L -o $BIN_PATH/hysteria-darwin-amd64-avx https://download.hysteria.network/app/latest/hysteria-darwin-amd64-avx && +function download_hysteria() { + echo "- Downloading hysteria-linxu-amd64-avx ..." && + curl -s -L -o $BIN_PATH/hysteria-linxu-amd64-avx https://download.hysteria.network/app/latest/hysteria-linux-amd64-avx && + echo "- Downloading hysteria-darwin-amd64 ..." && curl -s -L -o $BIN_PATH/hysteria-darwin-amd64 https://download.hysteria.network/app/latest/hysteria-darwin-amd64 && + echo "- Downloading hysteria-darwin-arm64 ..." && curl -s -L -o $BIN_PATH/hysteria-darwin-arm64 https://download.hysteria.network/app/latest/hysteria-darwin-arm64 && + echo "- Downloading hysteria-windows-amd64-avx.exe ..." && curl -s -L -o $BIN_PATH/hysteria-windows-amd64-avx.exe https://download.hysteria.network/app/latest/hysteria-windows-amd64-avx.exe && echo && chmod +x $BIN_PATH/* && ls -lhF $BIN_PATH/hy* @@ -164,7 +167,7 @@ function main() { if [ "$up_hy" = true ]; then echo -e "[INFO] Downloading ${GREEN}hysteria2${NC} ..." - if update_hysteria; then + if download_hysteria; then echo -e "[INFO] Download ${GREEN}hysteria2${NC} success" else echo -e "[Err] Download ${GREEN}hysteria2${NC} fail"