From 0ee197486ec1c62ca446ee1f4e963b0c7625e6d6 Mon Sep 17 00:00:00 2001 From: gaohengyi Date: Thu, 29 Aug 2024 16:19:38 +0800 Subject: [PATCH] first commit --- README.md | 29 ++++++++++++ quick_client.sh | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 README.md create mode 100644 quick_client.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..35ca924 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +## QUICK START + +1. Set variable: `DEPLOY_DOMAIN` + +```shell +export DEPLOY_DOMAIN=xxx.xxx +``` + +2. Start + +- server + +```shell +curl -o- https://raw.githubusercontent.com/xxoommd/magic/main/x/quick_server.sh | bash +``` + +- client + + - Github: + +```shell +curl -o- https://raw.githubusercontent.com/xxoommd/magic/main/quick_client.sh | bash +``` + + - Gitea: + +```shell +curl -o- https://gitee.com/xxoommd/magic/raw/main/quick_client.sh | bash +``` \ No newline at end of file diff --git a/quick_client.sh b/quick_client.sh new file mode 100644 index 0000000..c9a00a9 --- /dev/null +++ b/quick_client.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +GREEN='\033[0;32m' +RED='\033[0;31m' +BLUE='\033[0;34m' +YELLOW='\033[0;33m' +UNDERLINE='\033[4m' # 下划线 +NC='\033[0m' # No Color + +function logerr() { + echo -e "[${RED}ERR${NC}] $1" +} + +function loginfo() { + echo -e "[INFO] $1" +} + +if [[ -z $DEPLOY_DOMAIN ]]; then + echo + logerr "env:DEPLOY_DOMAIN is not set" + echo + exit 1 +fi + +download_url_naive="" +download_url_hysteria="" + +os_arch=$(uname -m) +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + if [[ $os_arch != "x86_64" ]]; then + logerr "Unsuppored arch: ${YELLOW}${os_arch}"${NC} + exit 1 + fi + + download_url_naive="https://github.com/xxoommd/ultimate_collection/releases/download/latest/naive-linux-amd64" + download_url_hysteria="https://github.com/xxoommd/ultimate_collection/releases/download/latest/hysteria-linux-amd64-avx" +elif [[ "$OSTYPE" == "darwin"* ]]; then + if [[ $os_arch == "x86_64" ]]; then + download_url_naive="https://github.com/xxoommd/ultimate_collection/releases/download/latest/naive-darwin-amd64" + download_url_hysteria="https://github.com/xxoommd/ultimate_collection/releases/download/latest/hysteria-darwin-amd64-avx" + elif [[ $os_arch == "arm64" ]]; then + download_url_naive="https://github.com/xxoommd/ultimate_collection/releases/download/latest/naive-darwin-arm64" + download_url_hysteria="https://github.com/xxoommd/ultimate_collection/releases/download/latest/hysteria-darwin-arm64" + else + logerr "Unsuppored arch: ${YELLOW}${os_arch}"${NC} + exit 1 + fi +elif [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* ]]; then + if [[ $os_arch == "x86_64" ]]; then + download_url_naive="https://github.com/xxoommd/ultimate_collection/releases/download/latest/naive-windows-amd64.exe" + download_url_hysteria="https://github.com/xxoommd/ultimate_collection/releases/download/latest/hysteria-windows-amd64-avx.exe" + else + logerr "Unsuppored arch: ${YELLOW}${os_arch}"${NC} + exit 1 + fi +else + logerr "Unsupported OS: ${YELLOW}$OSTYPE${NC} arch: {YELLOW}$os_arch${NC}" + exit 1 +fi + +if [ -z "$download_url_naive" ] || [ -z "$download_url_hysteria" ]; then + logerr "Download URL is null. Naive:$download_url_naive Hysteria:$download_url_hysteria" + exit 1 +fi + +function download_bin() { + curl -o ./naive -L $download_url_naive && curl -o ./hysteria -L $download_url_hysteria && chmod +x ./naive ./hysteria +} + +HYSTERIA_CONFIG="./hysteria-config.yaml" +NAIVE_CONFIG="./naive-config.json" + +function gen_hysteria_config() { + + cat >$HYSTERIA_CONFIG <${NAIVE_CONFIG} <