chore: migrate self-distribution links from GitHub to self-hosted Gitea
CI / test (push) Canceled after 0s
CI / anytls-smoke (push) Canceled after 0s

GitHub accounts suspended; all first-party distribution now served from
git.881218.xyz/rogue/NexusGate (Gitea):
- raw:  /rogue/NexusGate/raw/branch/<branch>/<path>
- release assets and source archives under the same repo path
- scripts gain a GIT_BASE variable built from NG_REPO (default
  rogue/NexusGate); NG_REPO/NG_BRANCH/--repo/--branch semantics unchanged
- panel enrollment/uninstall commands in public/app.js point at Gitea raw
- install.sh/nexusgate.sh/agent-singbox.sh stats source previously
  defaulted to the upstream repo (a2899882); defaults now this repo
Upstream dependency references (sagernet/sing-box Go module) untouched.
This commit is contained in:
aaaamoooo
2026-10-20 11:05:55 +00:00
parent 3951134940
commit f4ef3d96a6
8 changed files with 36 additions and 28 deletions
+8 -6
View File
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -Eeuo pipefail
REPO="${NG_REPO:-aaaamoooo/NexusGate}"
REPO="${NG_REPO:-rogue/NexusGate}"
BRANCH="${NG_BRANCH:-main}"
# 自建 Gitea 分发基址(raw / release / archive 均由此拼装)
GIT_BASE="https://git.881218.xyz/${REPO}"
# Agent 实现:默认 go(静态二进制,节点机不再需要 Node.js)。
# NG_AGENT_IMPL=node 可回退到旧版 Node agent(agent/agent.js + nodejs 包)。
AGENT_IMPL="${NG_AGENT_IMPL:-go}"
# Go agent 二进制所在的 GitHub Release tag
# Go agent 二进制所在的 Gitea Release tag
AGENT_RELEASE="${NG_AGENT_RELEASE:-agent-v0.6.8}"
CONTROLLER=""
TOKEN=""
@@ -14,14 +16,14 @@ TOKEN=""
die() { printf '错误:%s\n' "$*" >&2; exit 1; }
info() { printf '\033[1;36m[NexusGate Agent]\033[0m %s\n' "$*"; }
# NG_LOCAL_SRC 指向本地源码目录时跳过 GitHub 下载(本地改动尚未 push 时用这个)
# NG_LOCAL_SRC 指向本地源码目录时跳过远程下载(本地改动尚未 push 时用这个)
fetch() {
if [[ -n "${NG_LOCAL_SRC:-}" ]]; then
[[ -f "${NG_LOCAL_SRC}/$1" ]] || die "NG_LOCAL_SRC 目录缺少 $1"
cp -a "${NG_LOCAL_SRC}/$1" "$2"
else
# 加时间戳破坏 GitHub raw 缓存,避免拉到旧版
curl -fL --retry 3 "https://raw.githubusercontent.com/${REPO}/${BRANCH}/$1?t=$(date +%s)" -o "$2"
# 加时间戳破坏 raw 缓存,避免拉到旧版
curl -fL --retry 3 "${GIT_BASE}/raw/branch/${BRANCH}/$1?t=$(date +%s)" -o "$2"
fi
}
@@ -50,7 +52,7 @@ fetch_agent_binary() {
if [[ -n "${NG_LOCAL_SRC:-}" && -f "${NG_LOCAL_SRC}/agent-go/nexusgate-agent-linux-${arch}" ]]; then
cp -a "${NG_LOCAL_SRC}/agent-go/nexusgate-agent-linux-${arch}" "$out"
else
curl -fL --retry 3 "https://github.com/${REPO}/releases/download/${AGENT_RELEASE}/nexusgate-agent-linux-${arch}" -o "$out"
curl -fL --retry 3 "${GIT_BASE}/releases/download/${AGENT_RELEASE}/nexusgate-agent-linux-${arch}" -o "$out"
fi
[[ -s "$out" ]] || die 'Agent 二进制下载不完整'
}
+5 -5
View File
@@ -14,7 +14,7 @@ if [[ -x "$target" && -x "$stats_target" && "${2:-}" != '--force' ]]; then
exit 0
fi
# 优先从 GitHub Release 下载预编译二进制,免去现场编译
# 优先从 Gitea Release 下载预编译二进制,免去现场编译
# Release tag: sing-box-v1.13.21,需上传 nexusgate-sing-box-linux-<arch> 和 nexusgate-sing-box-stats-linux-<arch>
try_prebuilt() {
local arch dl_arch release_tag base_url tmp_bin tmp_stats
@@ -24,11 +24,11 @@ try_prebuilt() {
*) return 1 ;;
esac
release_tag="${NG_SINGBOX_RELEASE:-sing-box-v1.13.21}"
base_url="https://github.com/aaaamoooo/NexusGate/releases/download/${release_tag}"
base_url="https://git.881218.xyz/${NG_REPO:-rogue/NexusGate}/releases/download/${release_tag}"
tmp_bin="$(mktemp /tmp/nexusgate-singbox-bin.XXXXXX)"
tmp_stats="$(mktemp /tmp/nexusgate-singbox-stats.XXXXXX)"
trap 'rm -f -- "$tmp_bin" "$tmp_stats"' RETURN
printf '尝试从 GitHub Release 下载预编译 sing-box...\n'
printf '尝试从 Gitea Release 下载预编译 sing-box...\n'
if curl -fL --retry 2 --connect-timeout 15 -o "$tmp_bin" "${base_url}/nexusgate-sing-box-linux-${dl_arch}" 2>/dev/null && \
curl -fL --retry 2 --connect-timeout 15 -o "$tmp_stats" "${base_url}/nexusgate-sing-box-stats-linux-${dl_arch}" 2>/dev/null; then
chmod +x "$tmp_bin" "$tmp_stats"
@@ -80,12 +80,12 @@ printf '构建 sing-box %s(启用 V2Ray 统计 API,首次需下载 Go 依赖
GOBIN="$build_dir" GOTOOLCHAIN=auto GOMAXPROCS=1 go install -trimpath -ldflags='-s -w' -p 1 -tags with_v2ray_api "github.com/sagernet/sing-box/cmd/sing-box@${version}"
[[ -s "$build_dir/sing-box" ]] || { printf 'sing-box 构建失败\n' >&2; exit 1; }
repo="${NG_REPO:-a2899882/NexusGate}"
repo="${NG_REPO:-rogue/NexusGate}"
branch="${NG_BRANCH:-main}"
if [[ -n "${NG_STATS_SOURCE:-}" ]]; then
install -m 0600 "$NG_STATS_SOURCE" "$stats_source_dir/stats-query.go"
else
curl -fL --retry 3 "https://raw.githubusercontent.com/${repo}/${branch}/agent/stats-query.go" -o "$stats_source_dir/stats-query.go"
curl -fL --retry 3 "https://git.881218.xyz/${repo}/raw/branch/${branch}/agent/stats-query.go" -o "$stats_source_dir/stats-query.go"
fi
( cd "$stats_source_dir"
GOTOOLCHAIN=auto go mod init nexusgate/statsquery
+6 -4
View File
@@ -1,9 +1,11 @@
#!/usr/bin/env bash
set -Eeuo pipefail
REPO="${NG_REPO:-aaaamoooo/NexusGate}"
REPO="${NG_REPO:-rogue/NexusGate}"
BRANCH="${NG_BRANCH:-main}"
# Go agent 二进制所在的 GitHub Release tag(与 agent-install.sh 保持一致)
# 自建 Gitea 分发基址(raw / release 均由此拼装)
GIT_BASE="https://git.881218.xyz/${REPO}"
# Go agent 二进制所在的 Gitea Release tag(与 agent-install.sh 保持一致)
AGENT_RELEASE="${NG_AGENT_RELEASE:-agent-v0.6.8}"
die() { printf '错误:%s\n' "$*" >&2; exit 1; }
info() { printf '\033[1;36m[NexusGate Agent]\033[0m %s\n' "$*"; }
@@ -27,7 +29,7 @@ TARGET_IMPL="go"
info "当前 Agent 实现:${CURRENT_IMPL};更新目标:${TARGET_IMPL}"
raw_fetch() {
curl -fL --retry 3 "https://raw.githubusercontent.com/${REPO}/${BRANCH}/$1" -o "$2"
curl -fL --retry 3 "${GIT_BASE}/raw/branch/${BRANCH}/$1" -o "$2"
}
agent_arch() {
@@ -45,7 +47,7 @@ fetch_agent_binary() {
if [[ -n "${NG_LOCAL_SRC:-}" && -f "${NG_LOCAL_SRC}/agent-go/nexusgate-agent-linux-${arch}" ]]; then
cp -a "${NG_LOCAL_SRC}/agent-go/nexusgate-agent-linux-${arch}" "$out"
else
curl -fL --retry 3 "https://github.com/${REPO}/releases/download/${AGENT_RELEASE}/nexusgate-agent-linux-${arch}" -o "$out"
curl -fL --retry 3 "${GIT_BASE}/releases/download/${AGENT_RELEASE}/nexusgate-agent-linux-${arch}" -o "$out"
fi
[[ -s "$out" ]] || die 'Agent 二进制下载不完整'
}
+6 -4
View File
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -Eeuo pipefail
REPO="${NG_REPO:-a2899882/NexusGate}"
REPO="${NG_REPO:-rogue/NexusGate}"
BRANCH="${NG_BRANCH:-main}"
# 自建 Gitea 分发基址(源码归档由此拼装)
GIT_BASE="https://git.881218.xyz/${REPO}"
DOMAIN=""
EMAIL=""
@@ -61,7 +63,7 @@ fi
node_major="$(node -p 'process.versions.node.split(`.`)[0]')"
[[ "$node_major" -ge 18 ]] || die "需要 Node.js 18 或更高版本"
# NG_LOCAL_SRC 指向本地源码目录时跳过 GitHub 下载(本地改动尚未 push 时的全新安装用这个)
# NG_LOCAL_SRC 指向本地源码目录时跳过远程下载(本地改动尚未 push 时的全新安装用这个)
src_dir=""
if [[ -n "${NG_LOCAL_SRC:-}" ]]; then
[[ -f "${NG_LOCAL_SRC}/server.js" ]] || die "NG_LOCAL_SRC 目录不完整(缺少 server.js)"
@@ -71,10 +73,10 @@ else
tmp_dir="$(mktemp -d /tmp/nexusgate-install.XXXXXX)"
trap 'rm -rf -- "$tmp_dir"' EXIT
info "下载 ${REPO}@${BRANCH}"
curl -fL --retry 3 "https://github.com/${REPO}/archive/refs/heads/${BRANCH}.tar.gz" -o "$tmp_dir/source.tgz"
curl -fL --retry 3 "${GIT_BASE}/archive/${BRANCH}.tar.gz" -o "$tmp_dir/source.tgz"
mkdir -p "$tmp_dir/source"
tar -xzf "$tmp_dir/source.tgz" -C "$tmp_dir/source"
# GitHub tarball 解包后只有一层顶层目录;不用 --strip-components(BusyBox tar 不支持)
# 源码包解包后只有一层顶层目录;不用 --strip-components(BusyBox tar 不支持)
src_dir="$(echo "$tmp_dir/source"/*/)"
[[ -f "${src_dir}server.js" ]] || die "安装包不完整"
fi
+4 -2
View File
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -Eeuo pipefail
REPO="${NG_REPO:-a2899882/NexusGate}"
REPO="${NG_REPO:-rogue/NexusGate}"
BRANCH="${NG_BRANCH:-main}"
# 自建 Gitea 分发基址(源码归档由此拼装)
GIT_BASE="https://git.881218.xyz/${REPO}"
die() { printf '错误:%s\n' "$*" >&2; exit 1; }
info() { printf '\033[1;36m[NexusGate]\033[0m %s\n' "$*"; }
@@ -66,7 +68,7 @@ update_panel() {
backup "$current_backup"
stage="$(mktemp -d /tmp/nexusgate-update.XXXXXX)"
trap 'rm -rf -- "$stage"' RETURN
curl -fL --retry 3 "https://github.com/${REPO}/archive/refs/heads/${BRANCH}.tar.gz" -o "$stage/source.tgz"
curl -fL --retry 3 "${GIT_BASE}/archive/${BRANCH}.tar.gz" -o "$stage/source.tgz"
mkdir -p "$stage/source" && tar -xzf "$stage/source.tgz" -C "$stage/source" --strip-components=1
[[ -f "$stage/source/server.js" ]] || die "更新包不完整"
panel_stop