Simplify copyable installer output

This commit is contained in:
mango
2026-04-27 22:05:13 +08:00
parent e043026725
commit 28d5a27ab5

View File

@@ -1,71 +1,48 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# 顶尖协议一键脚本统一入口 # 顶尖协议一键脚本统一入口: ss2022+shadowtls / anytls / snell v5 / Reality
# Mirror: https://mjjtop.com/proxy set -e
# Protocols: ss2022+shadowtls / anytls / snell v5 / reality
set -euo pipefail
BASE_URL="${MIRROR_BASE_URL:-https://mjjtop.com/admin/proxy-installer/raw/branch/main}" BASE_URL="${MIRROR_BASE_URL:-https://mjjtop.com/admin/proxy-installer/raw/branch/main}"
TMP_DIR="/tmp/mjjtop-proxy-installer" TMP_DIR="/tmp/mjjtop-proxy-installer"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info(){ echo -e "${GREEN}[INFO]${NC} $*"; }
warn(){ echo -e "${YELLOW}[WARN]${NC} $*"; }
err(){ echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
if [[ "${PROXY_INSTALLER_SKIP_ROOT_CHECK:-0}" != "1" ]]; then
[[ ${EUID:-$(id -u)} -eq 0 ]] || err "请用 root 运行"
fi
command -v curl >/dev/null 2>&1 || err "缺少 curl请先安装: apt install -y curl"
mkdir -p "$TMP_DIR" mkdir -p "$TMP_DIR"
err(){ echo "[ERROR] $*" >&2; exit 1; }
info(){ echo "[INFO] $*"; }
[ "${PROXY_INSTALLER_SKIP_ROOT_CHECK:-0}" = "1" ] || [ "$(id -u)" = "0" ] || err "请用 root 运行"
command -v curl >/dev/null 2>&1 || err "缺少 curl请先安装: apt install -y curl"
run_remote(){ run_remote(){
local name="$1" name="$1"
local script_path="$2" script_path="$2"
local file="$TMP_DIR/$script_path" file="$TMP_DIR/$script_path"
info "下载 $name 脚本:$BASE_URL/scripts/$script_path" info "下载 $name: $BASE_URL/scripts/$script_path"
curl -fsSL "$BASE_URL/scripts/$script_path" -o "$file" curl -fsSL "$BASE_URL/scripts/$script_path" -o "$file"
chmod +x "$file" chmod +x "$file"
info "开始执行 $name" info "开始执行 $name"
exec bash "$file" exec bash "$file"
} }
show_menu() {
clear 2>/dev/null || true
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} 顶尖协议一键脚本 / mjjtop proxy${NC}"
echo -e "${CYAN}========================================${NC}"
echo "1) ss2022 + shadowtls"
echo "2) anytls"
echo "3) snell v5"
echo "4) Reality (Xray)"
echo "0) 退出"
echo
}
case "${1:-}" in case "${1:-}" in
ss|ss2022|shadowtls) run_remote "ss2022 + shadowtls" "ss2022-shadowtls.sh" ;; ss|ss2022|shadowtls) run_remote "ss2022 + shadowtls" "ss2022-shadowtls.sh" ;;
anytls|any) run_remote "anytls" "anytls.sh" ;; anytls|any) run_remote "anytls" "anytls.sh" ;;
snell|snell5) run_remote "snell v5" "snell-v5.sh" ;; snell|snell5) run_remote "snell v5" "snell-v5.sh" ;;
reality|xray) run_remote "Reality (Xray)" "reality.sh" ;; reality|xray) run_remote "Reality (Xray)" "reality.sh" ;;
"") ;; "") ;;
*) err "未知参数$1,可用: ss | anytls | snell | reality" ;; *) err "未知参数: $1,可用: ss | anytls | snell | reality" ;;
esac esac
cat <<'MENU'
while true; do ========================================
show_menu 顶尖协议一键脚本 / mjjtop proxy
read -rp "请选择协议 [0-4]: " choice ========================================
1) ss2022 + shadowtls
2) anytls
3) snell v5
4) Reality (Xray)
0) 退出
MENU
printf '请选择协议 [0-4]: '
read choice
case "$choice" in case "$choice" in
1) run_remote "ss2022 + shadowtls" "ss2022-shadowtls.sh" ;; 1) run_remote "ss2022 + shadowtls" "ss2022-shadowtls.sh" ;;
2) run_remote "anytls" "anytls.sh" ;; 2) run_remote "anytls" "anytls.sh" ;;
3) run_remote "snell v5" "snell-v5.sh" ;; 3) run_remote "snell v5" "snell-v5.sh" ;;
4) run_remote "Reality (Xray)" "reality.sh" ;; 4) run_remote "Reality (Xray)" "reality.sh" ;;
0|q|Q) exit 0 ;; 0|q|Q) exit 0 ;;
*) warn "无效选择"; sleep 1 ;; *) err "无效选择" ;;
esac esac
done