feat(deploy): public repo quick-install via curl (1Panel style)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+24
-53
@@ -1,73 +1,44 @@
|
||||
# 1Panel + Docker 一键部署
|
||||
|
||||
## 全新安装(1Panel 风格,推荐新机)
|
||||
## 公共仓库一键安装(推荐,root 一条命令)
|
||||
|
||||
```bash
|
||||
echo 'NEXUS_GITEA_TOKEN=你的令牌' > /root/.nexus-deploy.env && chmod 600 /root/.nexus-deploy.env
|
||||
git clone "http://admin:你的令牌@66.154.115.8:3000/admin/Nexus.git" /opt/nexus
|
||||
cd /opt/nexus && sudo bash deploy/install-nexus-fresh.sh --skip-clone
|
||||
# 4核16G: 加 --profile 4c16g
|
||||
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
||||
```
|
||||
|
||||
私人仓库无法用匿名 `curl .../raw/...`(会下到 `Not found.`)。
|
||||
4 核 16G:
|
||||
|
||||
```bash
|
||||
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash -s -- --profile 4c16g
|
||||
```
|
||||
|
||||
安装完成后浏览器打开 `https://api.synaglobal.vip/app/install.html` 完成向导。
|
||||
|
||||
## NX 菜单(日常运维)
|
||||
## 已 clone 到 /opt/nexus
|
||||
|
||||
```bash
|
||||
bash deploy/nx
|
||||
# 或安装后: nx
|
||||
cd /opt/nexus && git pull
|
||||
bash deploy/install-nexus-fresh.sh --skip-clone
|
||||
```
|
||||
|
||||
- **主菜单** → 安装向导 / **上帝菜单**(重启 Python、升级、日志、备份)
|
||||
- 全新安装: `bash deploy/nx install-fresh`
|
||||
- 迁机/已有密钥: `bash deploy/nx install-auto`
|
||||
|
||||
**先确保** `deploy/nexus-1panel.secrets.sh` 存在(本机已从 `SECRETS.md` 配好)。
|
||||
|
||||
### 新机(带令牌 clone,无需 export)
|
||||
## NX 运维菜单
|
||||
|
||||
```bash
|
||||
git clone "http://admin:你的Gitea令牌@66.154.115.8:3000/admin/Nexus.git" /opt/nexus
|
||||
cd /opt/nexus
|
||||
# 若 secrets.sh 已随私人仓库 push(见下):
|
||||
bash deploy/nexus-1panel.sh install --skip-clone
|
||||
nx # 主菜单
|
||||
nx god # 上帝菜单(重启 Python / 升级 / 日志)
|
||||
```
|
||||
|
||||
### 私人仓库强制带上 secrets(仅你一人用时)
|
||||
装好后会注册:`nexus-install` · `nx` · `nexus-fresh`
|
||||
|
||||
在开发机:
|
||||
## 脚本说明
|
||||
|
||||
```bash
|
||||
git add -f deploy/nexus-1panel.secrets.sh
|
||||
git push origin main
|
||||
```
|
||||
|
||||
之后任意服务器 `git clone` / `pull` 即可直接:
|
||||
|
||||
```bash
|
||||
cd /opt/nexus && bash deploy/nexus-1panel.sh install --skip-clone
|
||||
```
|
||||
|
||||
### 4 核 16G
|
||||
|
||||
```bash
|
||||
bash deploy/nexus-1panel.sh install --profile 4c16g --skip-clone
|
||||
```
|
||||
|
||||
## 升级
|
||||
|
||||
```bash
|
||||
bash deploy/nexus-1panel.sh upgrade
|
||||
bash deploy/nexus-1panel.sh check
|
||||
bash deploy/nexus-1panel.sh ports
|
||||
```
|
||||
|
||||
## 文件说明
|
||||
|
||||
| 文件 | 说明 |
|
||||
| 文件 | 用途 |
|
||||
|------|------|
|
||||
| `nexus-1panel.sh` | 主脚本(可提交 Git) |
|
||||
| `nexus-1panel.secrets.sh` | 令牌 + NEXUS 密钥(gitignore,可 `git add -f`) |
|
||||
| `docker/profiles/*.env` | 1c4g / 2c8g / 4c16g 资源档位 |
|
||||
| `quick-install.sh` | 公共仓库 curl 入口(1Panel 风格) |
|
||||
| `install-nexus-fresh.sh` | 全新空库安装 |
|
||||
| `nexus-1panel.sh` | 迁机 / 升级底层 |
|
||||
| `nx` | 交互菜单 |
|
||||
|
||||
## 资源档位
|
||||
|
||||
`--profile 1c4g` · `2c8g`(默认)· `4c16g`
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# 从私人 Gitea 下载 install-nexus-fresh.sh 并执行(解决匿名 raw 404 → "Not: command not found")
|
||||
# 下载并执行 install-nexus-fresh.sh(公共仓库无需令牌)
|
||||
#
|
||||
# 用法:
|
||||
# echo 'NEXUS_GITEA_TOKEN=你的令牌' > /root/.nexus-deploy.env && chmod 600 /root/.nexus-deploy.env
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/download-install-fresh.sh" -o /tmp/dl.sh
|
||||
# sudo bash /tmp/dl.sh
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/download-install-fresh.sh" | bash
|
||||
#
|
||||
# 推荐(已 clone 时无需下载):
|
||||
# cd /opt/nexus && git pull && sudo bash deploy/install-nexus-fresh.sh --skip-clone
|
||||
# 推荐直接使用:
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NEXUS_GITEA_HOST="${NEXUS_GITEA_HOST:-66.154.115.8:3000}"
|
||||
NEXUS_GIT_BRANCH="${NEXUS_GIT_BRANCH:-main}"
|
||||
NEXUS_RAW_BASE="${NEXUS_RAW_BASE:-http://${NEXUS_GITEA_HOST}/admin/Nexus/raw/branch/${NEXUS_GIT_BRANCH}}"
|
||||
OUT="${OUT:-/tmp/install-nexus-fresh.sh}"
|
||||
|
||||
RED='\033[0;31m'
|
||||
@@ -20,30 +18,36 @@ GREEN='\033[0;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
||||
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
|
||||
|
||||
for cf in /root/.nexus-deploy.env /root/.nexus-secrets/nexus.env; do
|
||||
[[ -f "$cf" ]] && set -a && source "$cf" && set +a && break
|
||||
[[ -f "$cf" ]] && set -a && source "$cf" && set +a
|
||||
done
|
||||
|
||||
if [[ -z "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
err "缺少 NEXUS_GITEA_TOKEN"
|
||||
err " echo 'NEXUS_GITEA_TOKEN=...' > /root/.nexus-deploy.env && chmod 600 /root/.nexus-deploy.env"
|
||||
download() {
|
||||
local url base
|
||||
for base in "${NEXUS_RAW_BASE}" "http://${NEXUS_GITEA_HOST}/admin/Nexus/raw/${NEXUS_GIT_BRANCH}"; do
|
||||
url="${base}/deploy/install-nexus-fresh.sh"
|
||||
if curl -fsSL "$url" -o "$OUT" 2>/dev/null && head -1 "$OUT" | grep -q '^#!/'; then
|
||||
ok "已下载 install-nexus-fresh.sh"
|
||||
chmod +x "$OUT"
|
||||
exec bash "$OUT" "$@"
|
||||
fi
|
||||
done
|
||||
if [[ -n "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
url="http://${NEXUS_GITEA_HOST}/api/v1/repos/admin/Nexus/raw/deploy/install-nexus-fresh.sh?ref=${NEXUS_GIT_BRANCH}"
|
||||
if curl -fsSL -H "Authorization: token ${NEXUS_GITEA_TOKEN}" "$url" -o "$OUT" 2>/dev/null \
|
||||
&& head -1 "$OUT" | grep -q '^#!/'; then
|
||||
ok "已下载(API + 令牌)"
|
||||
chmod +x "$OUT"
|
||||
exec bash "$OUT" "$@"
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! download "$@"; then
|
||||
err "下载失败,请改用公共仓库一键入口:"
|
||||
err " curl -fsSL \"${NEXUS_RAW_BASE}/deploy/quick-install.sh\" | bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_URL="http://${NEXUS_GITEA_HOST}/api/v1/repos/admin/Nexus/raw/deploy/install-nexus-fresh.sh?ref=${NEXUS_GIT_BRANCH}"
|
||||
|
||||
if ! curl -fsSL -H "Authorization: token ${NEXUS_GITEA_TOKEN}" "$API_URL" -o "$OUT"; then
|
||||
err "下载失败: $API_URL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! head -1 "$OUT" | grep -q '^#!/'; then
|
||||
err "下载内容不是有效脚本(私人仓库 raw 需令牌,勿用无认证 curl)"
|
||||
err "文件开头: $(head -1 "$OUT" | cut -c1-80)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "$OUT"
|
||||
echo -e "${GREEN}[OK]${NC} 已下载 $OUT"
|
||||
exec bash "$OUT" "$@"
|
||||
|
||||
@@ -5,16 +5,14 @@
|
||||
# 适用:新机已装 1Panel / Docker,空库,走 /app/install.html 安装向导
|
||||
# 风格参考 1Panel quick_start.sh:分阶段检查 + 结束输出访问地址
|
||||
#
|
||||
# 用法(私人 Gitea 勿用无认证 raw,会下到 "Not found."):
|
||||
# 用法(公共仓库,root 下一条命令,参考 1Panel):
|
||||
#
|
||||
# 推荐 — 已 clone:
|
||||
# cd /opt/nexus && sudo bash deploy/install-nexus-fresh.sh --skip-clone
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
||||
#
|
||||
# 或 — 带令牌下载后执行:
|
||||
# echo 'NEXUS_GITEA_TOKEN=...' > /root/.nexus-deploy.env && chmod 600 /root/.nexus-deploy.env
|
||||
# sudo bash deploy/download-install-fresh.sh
|
||||
# 已 clone 到 /opt/nexus:
|
||||
# cd /opt/nexus && bash deploy/install-nexus-fresh.sh --skip-clone
|
||||
#
|
||||
# sudo bash deploy/install-nexus-fresh.sh --profile 4c16g
|
||||
# bash deploy/install-nexus-fresh.sh --profile 4c16g
|
||||
#
|
||||
# 凭据(任选其一,无需 export):
|
||||
# - /root/.nexus-deploy.env
|
||||
@@ -128,7 +126,9 @@ install_root_commands() {
|
||||
"${NEXUS_ROOT}/deploy/nexus-1panel.sh" 2>/dev/null || true
|
||||
ln -sf "${NEXUS_ROOT}/deploy/nx" /usr/local/bin/nx
|
||||
ln -sf "${NEXUS_ROOT}/deploy/install-nexus-fresh.sh" /usr/local/bin/nexus-fresh
|
||||
ln -sf "${NEXUS_ROOT}/deploy/quick-install.sh" /usr/local/bin/nexus-install
|
||||
info "已注册全局命令(root 直接输入即可):"
|
||||
info " nexus-install — 一键安装(公共仓库 curl)"
|
||||
info " nx — 主菜单 / 上帝菜单"
|
||||
info " nexus-fresh — 全新安装脚本"
|
||||
}
|
||||
@@ -224,16 +224,11 @@ phase_clone() {
|
||||
return 0
|
||||
fi
|
||||
load_credentials
|
||||
if [[ -z "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
error "缺少 Gitea 令牌,无法 clone 私人仓库"
|
||||
error "请任选一种方式:"
|
||||
error " echo 'NEXUS_GITEA_TOKEN=你的令牌' > /root/.nexus-deploy.env && chmod 600 /root/.nexus-deploy.env"
|
||||
error " 或在仓库 push deploy/nexus-1panel.secrets.sh 后重新运行本脚本"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local url
|
||||
url="$(git_clone_url)"
|
||||
if [[ -z "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
info "公共仓库:匿名 git clone(无需令牌)"
|
||||
fi
|
||||
mkdir -p "$(dirname "$NEXUS_ROOT")"
|
||||
|
||||
if [[ -d "${NEXUS_ROOT}/.git" ]]; then
|
||||
|
||||
@@ -379,12 +379,15 @@ require_token() {
|
||||
if [[ -n "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
error "Gitea 令牌为空(内置配置异常)。可执行: bash $0 init-token '<令牌>'"
|
||||
exit 1
|
||||
info "未配置 Gitea 令牌,按公共仓库匿名 clone/pull"
|
||||
}
|
||||
|
||||
git_remote_url() {
|
||||
echo "http://admin:${NEXUS_GITEA_TOKEN}@${NEXUS_GITEA_HOST}/${NEXUS_GITEA_REPO}"
|
||||
if [[ -n "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
echo "http://admin:${NEXUS_GITEA_TOKEN}@${NEXUS_GITEA_HOST}/${NEXUS_GITEA_REPO}"
|
||||
else
|
||||
echo "http://${NEXUS_GITEA_HOST}/${NEXUS_GITEA_REPO}"
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_packages() {
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# Nexus 6.0 — 公共仓库一键安装入口(参考 1Panel quick_start.sh)
|
||||
#
|
||||
# root 登录后一条命令:
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
||||
#
|
||||
# 或保存后执行:
|
||||
# curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" -o /tmp/quick-install.sh
|
||||
# bash /tmp/quick-install.sh
|
||||
#
|
||||
# 可选参数会传给 install-nexus-fresh.sh,例如:
|
||||
# bash /tmp/quick-install.sh --profile 4c16g
|
||||
# =============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NEXUS_GITEA_HOST="${NEXUS_GITEA_HOST:-66.154.115.8:3000}"
|
||||
NEXUS_GITEA_REPO="${NEXUS_GITEA_REPO:-admin/Nexus.git}"
|
||||
NEXUS_GIT_BRANCH="${NEXUS_GIT_BRANCH:-main}"
|
||||
NEXUS_ROOT="${NEXUS_ROOT:-/opt/nexus}"
|
||||
NEXUS_RAW_BASE="${NEXUS_RAW_BASE:-http://${NEXUS_GITEA_HOST}/admin/Nexus/raw/branch/${NEXUS_GIT_BRANCH}}"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
CYAN='\033[0;36m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
||||
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
||||
step() { echo -e "${CYAN}[STEP]${NC} $*"; }
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Nexus 公共仓库一键安装
|
||||
|
||||
curl -fsSL "${NEXUS_RAW_BASE}/deploy/quick-install.sh" | bash
|
||||
|
||||
可选参数: --profile 4c16g --domain 你的域名 --skip-1panel-check
|
||||
EOF
|
||||
}
|
||||
|
||||
validate_script_file() {
|
||||
local f="$1"
|
||||
if [[ ! -f "$f" ]] || ! head -1 "$f" | grep -q '^#!/'; then
|
||||
return 1
|
||||
fi
|
||||
if grep -qiE '^(Not found|404)' "$f" 2>/dev/null; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
download_script() {
|
||||
local name="$1" dest="$2"
|
||||
local url base
|
||||
for base in \
|
||||
"${NEXUS_RAW_BASE}" \
|
||||
"http://${NEXUS_GITEA_HOST}/admin/Nexus/raw/${NEXUS_GIT_BRANCH}"; do
|
||||
url="${base}/deploy/${name}"
|
||||
if curl -fsSL "$url" -o "$dest" 2>/dev/null && validate_script_file "$dest"; then
|
||||
info "已下载 ${name}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
run_via_git() {
|
||||
local url="http://${NEXUS_GITEA_HOST}/${NEXUS_GITEA_REPO}"
|
||||
if [[ -n "${NEXUS_GITEA_TOKEN:-}" ]]; then
|
||||
url="http://admin:${NEXUS_GITEA_TOKEN}@${NEXUS_GITEA_HOST}/${NEXUS_GITEA_REPO}"
|
||||
fi
|
||||
step "改用 git clone..."
|
||||
mkdir -p "$(dirname "$NEXUS_ROOT")"
|
||||
if [[ -d "${NEXUS_ROOT}/.git" ]]; then
|
||||
git -C "$NEXUS_ROOT" remote set-url origin "$url" 2>/dev/null || true
|
||||
git -C "$NEXUS_ROOT" fetch origin "$NEXUS_GIT_BRANCH" --depth 1 2>/dev/null || \
|
||||
git -C "$NEXUS_ROOT" fetch origin "$NEXUS_GIT_BRANCH" --prune
|
||||
git -C "$NEXUS_ROOT" reset --hard "origin/${NEXUS_GIT_BRANCH}" 2>/dev/null || \
|
||||
git -C "$NEXUS_ROOT" pull
|
||||
else
|
||||
rm -rf "$NEXUS_ROOT"
|
||||
git clone --depth 1 -b "$NEXUS_GIT_BRANCH" "$url" "$NEXUS_ROOT"
|
||||
fi
|
||||
chmod +x "${NEXUS_ROOT}/deploy/"*.sh 2>/dev/null || true
|
||||
exec bash "${NEXUS_ROOT}/deploy/install-nexus-fresh.sh" --skip-clone "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
error "请使用 root 执行(su - 后直接运行,不要用 sudo 包一层)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for cf in /root/.nexus-deploy.env /root/.nexus-secrets/nexus.env; do
|
||||
[[ -f "$cf" ]] && set -a && source "$cf" && set +a
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║${NC} Nexus 6.0 — 公共仓库一键安装 ${BLUE}║${NC}"
|
||||
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
case "${1:-}" in
|
||||
-h|--help) usage; exit 0 ;;
|
||||
esac
|
||||
|
||||
local tmp
|
||||
tmp="$(mktemp /tmp/install-nexus-fresh.XXXXXX.sh)"
|
||||
if download_script "install-nexus-fresh.sh" "$tmp"; then
|
||||
chmod +x "$tmp"
|
||||
exec bash "$tmp" "$@"
|
||||
fi
|
||||
|
||||
step "raw 下载失败,尝试 git clone..."
|
||||
run_via_git "$@"
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
main "$@"
|
||||
fi
|
||||
@@ -0,0 +1,26 @@
|
||||
# Changelog: 公共仓库 quick-install 一键脚本
|
||||
|
||||
**日期**: 2026-06-04
|
||||
|
||||
## 摘要
|
||||
|
||||
仓库改为公共后,新增 `deploy/quick-install.sh`(1Panel 风格 `curl | bash`),匿名 raw / git clone 均可用,无需 Gitea 令牌。
|
||||
|
||||
## 涉及文件
|
||||
|
||||
- `deploy/quick-install.sh` — 主入口
|
||||
- `deploy/install-nexus-fresh.sh` — 公共 clone、全局 `nexus-install`
|
||||
- `deploy/download-install-fresh.sh` — 简化
|
||||
- `deploy/nexus-1panel.sh` — 令牌可选
|
||||
- `deploy/README-1panel.md`、`SECRETS.md`
|
||||
|
||||
## 服务器用法
|
||||
|
||||
```bash
|
||||
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
||||
```
|
||||
|
||||
## 验证
|
||||
|
||||
- `curl` raw 返回 `#!/usr/bin/env bash`
|
||||
- `bash -n deploy/quick-install.sh`
|
||||
Reference in New Issue
Block a user