From dae8f7f24e8b02a0d2bf03684b4ac8b39e7682a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=96=E5=A5=B3=E5=AD=A9=E7=9A=84=E5=B0=8F=E7=81=AB?= =?UTF-8?q?=E6=9F=B4?= <44471469+Erope@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:52:38 +0800 Subject: [PATCH] Feature/v0 scripts (#512) * update contributors[no ci] * Add v0 release * Add install.sh to keep the v0 panel functioning properly * Modify sync.py * Remove release-v0.yaml --------- Co-authored-by: github-actions[bot] --- .github/sync.py | 3 ++ README.md | 3 +- script/install.sh | 102 +++++++++++++++++++++++++++++++++++++++++++ script/install_en.sh | 52 ++++++++++++++++++++++ 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 script/install.sh create mode 100644 script/install_en.sh diff --git a/.github/sync.py b/.github/sync.py index 691efcb..514138b 100644 --- a/.github/sync.py +++ b/.github/sync.py @@ -52,7 +52,10 @@ def delete_gitee_releases(latest_id, client, uri, token): print(f'Current release ids: {release_ids}') release_ids.remove(latest_id) + # 2024.12.01 保留 v0 开头的 Release for id in release_ids: + if id.startswith('v0'): + continue release_uri = f"{uri}/{id}" delete_data = { 'access_token': token diff --git a/README.md b/README.md index d6edd6c..95a07ec 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,6 @@ You can change the dashboard language in the settings page (`/setting`) after th Darc Z. Creling Core F -Tater Li Tony adminsama Acgpiano @@ -78,8 +77,10 @@ You can change the dashboard language in the settings page (`/setting`) after th lyj unclezs 缘生 +严浩 凌 玖叁 +Tater Li Tao Chen Spetrum Nanjing Hopefun Network Technology Co. Ltd. diff --git a/script/install.sh b/script/install.sh new file mode 100644 index 0000000..a299597 --- /dev/null +++ b/script/install.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +#======================================================== +# master 分支安装脚本重定向 +#======================================================== + +# 判断是否应使用中国镜像 + +geo_check() { + api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace" + ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" + set -- "$api_list" + for url in $api_list; do + text="$(curl -A "$ua" -m 10 -s "$url")" + endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')" + if echo "$text" | grep -qw 'CN'; then + isCN=true + break + elif echo "$url" | grep -q "$endpoint"; then + break + fi + done +} + +# 向用户确认是否使用中国镜像 +geo_check + +if [ "$isCN" = true ]; then + read -p "检测到您的IP可能来自中国大陆,是否使用中国镜像? [y/n] " choice + case "$choice" in + y|Y) + echo "将使用中国镜像..." + USE_CN_MIRROR=true + ;; + n|N) + echo "将使用国际镜像..." + USE_CN_MIRROR=false + ;; + *) + echo "输入无效,将使用国际镜像..." + USE_CN_MIRROR=false + ;; + esac +else + USE_CN_MIRROR=false +fi + +# 默认引导用户使用 master 分支 v1 新面板安装脚本,但若使用了 install_agent 参数,则默认重定向至 v0 +if echo "$@" | grep -q "install_agent"; then + echo "检测到 v0 面板 install_agent 参数,将使用 v0 分支脚本..." + echo "警告: v0 面板已停止维护,请尽快升级至 v1 面板,详见文档:https://nezha.wiki/,5s 后继续运行脚本" + # 强制等待 5 秒 + sleep 5 + is_v1=false +else + # 让用户选择是否执行新脚本 + echo "v1 面板已正式发布,v0 已停止维护,若您已安装 v0 面板,请尽快升级至 v1 面板" + echo "v1 与 v0 有较大差异,详见文档:https://nezha.wiki/" + echo "若您暂时不想升级,请输入 n 并按回车键以继续使用 v0 面板脚本" + read -p "是否执行 v1 面板安装脚本? [y/n] " choice + case "$choice" in + n|N) + is_v1=false + ;; + *) + is_v1=true + ;; + esac +fi + +if [ "$is_v1" = true ]; then + echo "将使用 v1 面板安装脚本..." + if [ "$USE_CN_MIRROR" = true ]; then + shell_url="https://gitee.com/naibahq/scripts/raw/main/install.sh" + else + shell_url="https://raw.githubusercontent.com/nezhahq/scripts/main/install.sh" + fi + file_name="nezha.sh" +else + echo "将使用 v0 面板安装脚本,脚本将会下载为nezha_v0.sh" + if [ "$USE_CN_MIRROR" = true ]; then + shell_url="https://gitee.com/naibahq/scripts/raw/v0/install.sh" + else + shell_url="https://raw.githubusercontent.com/nezhahq/scripts/refs/heads/v0/install.sh" + fi + file_name="nezha_v0.sh" +fi + + +if command -v wget >/dev/null 2>&1; then + wget -O "/tmp/nezha.sh" "$shell_url" +elif command -v curl >/dev/null 2>&1; then + curl -o "/tmp/nezha.sh" "$shell_url" +else + echo "错误: 未找到 wget 或 curl,请安装其中任意一个后再试" + exit 1 +fi + +chmod +x "/tmp/nezha.sh" +mv "/tmp/nezha.sh" "./$file_name" +# 携带原参数运行新脚本 +exec ./"$file_name" "$@" \ No newline at end of file diff --git a/script/install_en.sh b/script/install_en.sh new file mode 100644 index 0000000..037f324 --- /dev/null +++ b/script/install_en.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +#======================================================== +# master install script redirect +#======================================================== + +# Default: Guide users to use master branch v1 new panel installation script +# However, if install_agent parameter is used, redirect to v0 by default +if echo "$@" | grep -q "install_agent"; then + echo "Detected v0 panel install_agent parameter, will use v0 branch script..." + echo "Warning: v0 panel is no longer maintained, please upgrade to v1 panel ASAP. See docs: https://nezha.wiki/, script will continue in 5s" + sleep 5 + is_v1=false +else + echo "v1 panel has been officially released, v0 is no longer maintained. If you have v0 panel installed, please upgrade to v1 ASAP" + echo "v1 differs significantly from v0, see documentation: https://nezha.wiki/" + echo "If you don't want to upgrade now, enter 'n' and press Enter to continue using v0 panel script" + read -p "Execute v1 panel installation script? [y/n] " choice + case "$choice" in + n|N) + is_v1=false + ;; + *) + is_v1=true + ;; + esac +fi + +if [ "$is_v1" = true ]; then + echo "Will use v1 panel installation script..." + shell_url="https://raw.githubusercontent.com/nezhahq/scripts/main/install_en.sh" + file_name="nezha.sh" +else + echo "Will use v0 panel installation script, script will be downloaded as nezha_v0.sh" + shell_url="https://raw.githubusercontent.com/nezhahq/scripts/refs/heads/v0/install_en.sh" + file_name="nezha_v0.sh" +fi + + +if command -v wget >/dev/null 2>&1; then + wget -O "/tmp/nezha.sh" "$shell_url" +elif command -v curl >/dev/null 2>&1; then + curl -o "/tmp/nezha.sh" "$shell_url" +else + echo "Error: wget or curl not found, please install either one and try again" + exit 1 +fi + +chmod +x "/tmp/nezha.sh" +mv "/tmp/nezha.sh" "./$file_name" +# Run the new script with the original parameters +exec ./"$file_name" "$@"