Compare commits

..
1 Commits
Author SHA1 Message Date
ji ruo 659e43e91e release(v0.3.35): sandbox upgrade guard, shell timezone i18n, and release notes
- Add validate_sandbox_compose check and compose snapshot backup/restore in deploy-lib.sh
- Show both git clone and non-git sync upgrade commands in sandbox page and settings card
- Gate standalone-to-sandbox warning in update modal to Docker non-sandbox mode only
- Add timezone-based zh/en auto-switching (with ARTEX_LANG override) across shell scripts
- Extract CHANGELOG.md section into GitHub Release notes and add v0.3.35 release notes
2026-12-04 16:45:32 +08:00
13 changed files with 698 additions and 205 deletions

No files matched your search

+28 -5
View File
@@ -130,6 +130,9 @@ jobs:
GH_REPO: ${{ github.repository }} GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }} RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
steps: steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.commit }}
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
with: with:
pattern: pkg-* pattern: pkg-*
@@ -163,6 +166,30 @@ jobs:
cat /tmp/artex-release.err >&2 cat /tmp/artex-release.err >&2
exit 1 exit 1
fi fi
- name: Build release notes body
env:
DOCKER_IMAGE: ${{ vars.ARTEX_DOCKER_IMAGE }}
run: |
version="${RELEASE_TAG#v}"
changelog_section="$(awk -v prefix="## [${version}]" '
index($0, prefix) == 1 { found=1; next }
found && index($0, "## [") == 1 { exit }
found { print }
' CHANGELOG.md | sed -e '/./,$!d')"
{
if [ -n "$changelog_section" ]; then
printf '%s\n\n---\n\n' "$changelog_section"
fi
cat <<EOF
### Docker Hub 镜像(Linux AMD64 / ARM64)
- 控制面:\`${DOCKER_IMAGE}:${RELEASE_TAG}\`(同时提供 \`latest\`)
- 透明代理网关:\`${DOCKER_IMAGE}-gateway:${RELEASE_TAG}\`(同时提供 \`latest\`)
- 沙箱执行环境:\`${DOCKER_IMAGE}-sandbox:${RELEASE_TAG}\`(同时提供 \`latest\`)
程序包提供 Linux、macOS 的 AMD64 / ARM64 及 Windows AMD64,并附 \`SHA256SUMS\`。部署、容器沙箱升级与在线更新说明见本仓库 README。
EOF
} > /tmp/release-body.md
- uses: softprops/action-gh-release@v2 - uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ needs.prepare.outputs.tag }} tag_name: ${{ needs.prepare.outputs.tag }}
@@ -173,11 +200,7 @@ jobs:
dist/*.zip dist/*.zip
dist/SHA256SUMS dist/SHA256SUMS
generate_release_notes: true generate_release_notes: true
body: | body_path: /tmp/release-body.md
Docker Hub 镜像:`${{ vars.ARTEX_DOCKER_IMAGE }}:${{ needs.prepare.outputs.tag }}`,同时提供 `latest`。
支持 Linux AMD64 / ARM64,Docker 会自动选择宿主机架构。
程序包提供 Linux、macOS 的 AMD64 / ARM64 及 Windows AMD64,并附 SHA256SUMS。
部署和在线更新说明见本仓库 README。
- name: Publish complete release - name: Publish complete release
run: gh release edit "$RELEASE_TAG" --draft=false --latest run: gh release edit "$RELEASE_TAG" --draft=false --latest
+14
View File
@@ -4,6 +4,20 @@
## [Unreleased] ## [Unreleased]
## [0.3.35] - 2026-12-04
### 核心架构亮点(容器化沙箱与透明代理网关)
- **任务/对话级容器沙箱隔离(`artex-sandbox`)**:每个任务与对话在独立非 root Docker 容器中运行 Bash、脚本与 Playwright 浏览器;主控通过 `docker-socket-proxy` 最小权限管理容器,沙箱网桥禁用容器间互通(`enable_icc=false`),支持内存/CPU/PIDs/SHM 限额与闲置/完结自动停机。
- **全流量透明代理网关(`artex-gateway`)**:采用 TUN + gVisor netstack(含策略路由自愈)在宿主机网络层统一接管沙箱 TCP / DNS / UDP / ICMP 流量,硬阻断沙箱直连外网 NAT;启用代理或代理池后自动通过上游代理转发原始 TCP 与 DNS-over-TCP,并默认阻断直连 UDP/ICMP 防止泄露真实出口 IP。
- **代理池与单容器级路由控制**:支持代理池定时轮换、健康检查冷却、故障切换与全池异常自动暂停续跑,并支持按任务/对话/定时任务容器维度独立设置出口策略(继承全局代理池、绑定指定代理节点、自定义代理或直连)。
### 本版本新增与改进
- **宿主机沙箱升级命令完善与旧编排拦截**:沙箱容器页与系统设置沙箱卡片在本地模式下区分展示 **git clone 部署**(`git pull --ff-only && ./update.sh --upgrade --tag <version> --skip-git-pull`)与 **非 git 部署**(自动备份旧 `docker-compose.yml` 并同步对应版本编排与脚本)两套一键复制命令;`scripts/deploy-lib.sh` 新增 `validate_sandbox_compose` 校验,拦截缺少 `docker-socket-proxy` / `artex-gateway` / `ARTEX_SANDBOX_MODE` 的旧版 2 服务 `docker-compose.yml`,并在部署快照中同步备份与回滚 `docker-compose.yml`。
- **Shell 脚本按系统时区自动切换中英文**:`install.sh`、`update.sh`、`scripts/deploy-lib.sh`、`start.sh`、`build.sh`、`dev.sh`、`reset-password.sh` 按宿主机时区自动选择中文或英文输出(大中华区时区输出中文,其余时区输出英文,并支持 `ARTEX_LANG=zh|en` 显式覆盖)。
- **更新弹窗与发布说明优化**:系统设置「版本与更新」弹窗中的「单容器版 → 沙箱隔离版」不可回滚提示改为仅在 Docker 非沙箱模式下显示,避免已是沙箱隔离版的用户在后续常规升级时看到误导提示;GitHub Release 工作流自动提取 `CHANGELOG.md` 对应版本说明并附带 `artex` / `artex-gateway` / `artex-sandbox` 三套多架构镜像信息。
## [0.3.34] - 2026-12-04 ## [0.3.34] - 2026-12-04
### 新增与改进 ### 新增与改进
+47 -31
View File
@@ -22,12 +22,11 @@ set -euo pipefail
cd "$(cd "$(dirname "$0")" && pwd)" cd "$(cd "$(dirname "$0")" && pwd)"
info() { printf '\033[36m[*]\033[0m %s\n' "$*"; } # shellcheck source=scripts/deploy-lib.sh
ok() { printf '\033[32m[+]\033[0m %s\n' "$*"; } . ./scripts/deploy-lib.sh
warn() { printf '\033[33m[!]\033[0m %s\n' "$*" >&2; }
die() { printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; }
usage() { usage() {
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
cat <<'EOF' cat <<'EOF'
用法: 用法:
./build.sh 编译当前系统当前架构 ./build.sh 编译当前系统当前架构
@@ -44,6 +43,24 @@ usage() {
多目标列表可通过 ARTEX_TARGETS 覆盖,例如: 多目标列表可通过 ARTEX_TARGETS 覆盖,例如:
ARTEX_TARGETS=linux/amd64,windows/amd64 ./build.sh --release ARTEX_TARGETS=linux/amd64,windows/amd64 ./build.sh --release
EOF EOF
else
cat <<'EOF'
Usage:
./build.sh Build for current OS/ARCH
./build.sh --target linux/amd64 Build for a specific target
./build.sh --release Build and package all supported targets
Options:
--release Build amd64/arm64 targets for Linux, macOS, Windows and create zips
--target OS/ARCH Set a single target, e.g. windows/amd64
--upx Require UPX binary compression (may affect some Linux environments)
--no-compress Skip UPX; use Go linker stripping and zip compression only
--help Show this help
Override target list via ARTEX_TARGETS, e.g.:
ARTEX_TARGETS=linux/amd64,windows/amd64 ./build.sh --release
EOF
fi
} }
RELEASE_TARGETS_DEFAULT="linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64" RELEASE_TARGETS_DEFAULT="linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64"
@@ -59,7 +76,7 @@ while [ "$#" -gt 0 ]; do
shift shift
;; ;;
--target) --target)
[ "$#" -ge 2 ] || die "--target 需要 OS/ARCH 参数" [ "$#" -ge 2 ] || die_l "--target 需要 OS/ARCH 参数" "--target requires an OS/ARCH value"
target_arg="$2" target_arg="$2"
case "$target_arg" in case "$target_arg" in
*/*) */*)
@@ -67,7 +84,7 @@ while [ "$#" -gt 0 ]; do
ARTEX_TARGET_ARCH="${target_arg##*/}" ARTEX_TARGET_ARCH="${target_arg##*/}"
ARTEX_TARGETS="$target_arg" ARTEX_TARGETS="$target_arg"
;; ;;
*) die "目标必须是 OS/ARCH,例如 linux/amd64" ;; *) die_l "目标必须是 OS/ARCH,例如 linux/amd64" "Target must be OS/ARCH, e.g. linux/amd64" ;;
esac esac
shift 2 shift 2
;; ;;
@@ -83,12 +100,11 @@ while [ "$#" -gt 0 ]; do
usage usage
exit 0 exit 0
;; ;;
*) die "未知参数:$1(使用 --help 查看用法)" ;; *) die_l "未知参数:$1(使用 --help 查看用法)" "Unknown option: $1 (use --help for usage)" ;;
esac esac
done done
command -v go >/dev/null 2>&1 || die "未检测到 Go(项目需要 Go 1.26 或更高版本)" command -v go >/dev/null 2>&1 || die_l "未检测到 Go(项目需要 Go 1.26 或更高版本)" "Go not found (Go 1.26 or newer is required)"
ARTEX_GOSUMDB="${ARTEX_GOSUMDB:-sum.golang.org}" ARTEX_GOSUMDB="${ARTEX_GOSUMDB:-sum.golang.org}"
if [ -z "${ARTEX_BUILD_VERSION:-}" ]; then if [ -z "${ARTEX_BUILD_VERSION:-}" ]; then
if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
@@ -112,16 +128,16 @@ else
fi fi
if [ "${ARTEX_SKIP_FRONTEND:-0}" = "1" ]; then if [ "${ARTEX_SKIP_FRONTEND:-0}" = "1" ]; then
[ -d server/webui/dist ] || die "ARTEX_SKIP_FRONTEND=1 但 server/webui/dist 不存在" [ -d server/webui/dist ] || die_l "ARTEX_SKIP_FRONTEND=1 但 server/webui/dist 不存在" "ARTEX_SKIP_FRONTEND=1 but server/webui/dist does not exist"
else else
command -v npm >/dev/null 2>&1 || die "未检测到 npm(前端静态构建需要 Node.js/npm)" command -v npm >/dev/null 2>&1 || die_l "未检测到 npm(前端静态构建需要 Node.js/npm)" "npm not found (Node.js/npm is required for static frontend build)"
command -v rsync >/dev/null 2>&1 || die "未检测到 rsync" command -v rsync >/dev/null 2>&1 || die_l "未检测到 rsync" "rsync not found"
info "构建前端静态资源" info_l "构建前端静态资源" "Building static frontend assets"
if [ "${ARTEX_SKIP_NPM_CI:-0}" != "1" ]; then if [ "${ARTEX_SKIP_NPM_CI:-0}" != "1" ]; then
(cd web && npm ci) (cd web && npm ci)
fi fi
(cd web && npm run build:static) (cd web && npm run build:static)
info "同步前端资源到 server/webui/dist" info_l "同步前端资源到 server/webui/dist" "Syncing frontend assets to server/webui/dist"
mkdir -p server/webui/dist mkdir -p server/webui/dist
rsync -a --delete web/out/ server/webui/dist/ rsync -a --delete web/out/ server/webui/dist/
fi fi
@@ -131,18 +147,18 @@ compress_binary() {
goos="$2" goos="$2"
case "$ARTEX_COMPRESS" in case "$ARTEX_COMPRESS" in
0|off|false|none) 0|off|false|none)
info "跳过 UPX:$binary" info_l "跳过 UPX:$binary" "Skipping UPX: $binary"
return 0 return 0
;; ;;
auto|required|true|1) ;; auto|required|true|1) ;;
*) die "ARTEX_COMPRESS 必须是 off、auto 或 required" ;; *) die_l "ARTEX_COMPRESS 必须是 off、auto 或 required" "ARTEX_COMPRESS must be off, auto, or required" ;;
esac esac
if ! command -v upx >/dev/null 2>&1; then if ! command -v upx >/dev/null 2>&1; then
if [ "$ARTEX_COMPRESS" = "required" ]; then if [ "$ARTEX_COMPRESS" = "required" ]; then
die "ARTEX_COMPRESS=required 但未检测到 upx" die_l "ARTEX_COMPRESS=required 但未检测到 upx" "ARTEX_COMPRESS=required but upx was not found"
fi fi
warn "未检测到 upx,保留 linker 压缩结果:$binary" warn_l "未检测到 upx,保留 linker 压缩结果:$binary" "upx not found; keeping linker-stripped binary: $binary"
return 0 return 0
fi fi
@@ -152,13 +168,13 @@ compress_binary() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if ! upx $upx_args -- "$binary"; then if ! upx $upx_args -- "$binary"; then
if [ "$ARTEX_COMPRESS" = "required" ]; then if [ "$ARTEX_COMPRESS" = "required" ]; then
die "UPX 压缩失败:$binary" die_l "UPX 压缩失败:$binary" "UPX compression failed: $binary"
fi fi
warn "UPX 不支持该目标格式,保留未压缩二进制:$binary" warn_l "UPX 不支持该目标格式,保留未压缩二进制:$binary" "UPX does not support this target; keeping uncompressed binary: $binary"
return 0 return 0
fi fi
after=$(wc -c < "$binary" | tr -d ' ') after=$(wc -c < "$binary" | tr -d ' ')
ok "UPX 压缩完成:$binary (${before} -> ${after} bytes)" ok_l "UPX 压缩完成:$binary (${before} -> ${after} bytes)" "UPX compression complete: $binary (${before} -> ${after} bytes)"
} }
package_binary() { package_binary() {
@@ -169,7 +185,7 @@ package_binary() {
package_root="${ARTEX_PACKAGE_DIR}/${package_name}" package_root="${ARTEX_PACKAGE_DIR}/${package_name}"
archive="${ARTEX_PACKAGE_DIR}/${package_name}.zip" archive="${ARTEX_PACKAGE_DIR}/${package_name}.zip"
command -v zip >/dev/null 2>&1 || die "打包需要 zip" command -v zip >/dev/null 2>&1 || die_l "打包需要 zip" "zip is required for packaging"
rm -rf "$package_root" "$archive" rm -rf "$package_root" "$archive"
mkdir -p "$package_root" mkdir -p "$package_root"
cp "$binary" "$package_root/" cp "$binary" "$package_root/"
@@ -186,20 +202,20 @@ package_binary() {
if [ -f README.md ]; then cp README.md "$package_root/"; fi if [ -f README.md ]; then cp README.md "$package_root/"; fi
(cd "$ARTEX_PACKAGE_DIR" && zip -q -r -9 "$(basename "$archive")" "$(basename "$package_root")") (cd "$ARTEX_PACKAGE_DIR" && zip -q -r -9 "$(basename "$archive")" "$(basename "$package_root")")
rm -rf "$package_root" rm -rf "$package_root"
ok "Release 压缩包:$archive" ok_l "Release 压缩包:$archive" "Release archive: $archive"
} }
build_target() { build_target() {
target="$1" target="$1"
case "$target" in case "$target" in
*/*) ;; */*) ;;
*) die "无效目标:$target(必须是 OS/ARCH)" ;; *) die_l "无效目标:$target(必须是 OS/ARCH)" "Invalid target: $target (must be OS/ARCH)" ;;
esac esac
goos="${target%%/*}" goos="${target%%/*}"
goarch="${target##*/}" goarch="${target##*/}"
case "$goos" in case "$goos" in
linux|darwin|windows) ;; linux|darwin|windows) ;;
*) die "不支持的系统:$goos(支持 linux、darwin、windows)" ;; *) die_l "不支持的系统:$goos(支持 linux、darwin、windows)" "Unsupported OS: $goos (supported: linux, darwin, windows)" ;;
esac esac
binary_name="artex" binary_name="artex"
@@ -211,7 +227,7 @@ build_target() {
fi fi
mkdir -p "$(dirname "$output")" mkdir -p "$(dirname "$output")"
info "编译 ${goos}/${goarch},版本 ${ARTEX_BUILD_VERSION}" info_l "编译 ${goos}/${goarch},版本 ${ARTEX_BUILD_VERSION}" "Building ${goos}/${goarch}, version ${ARTEX_BUILD_VERSION}"
GOSUMDB="$ARTEX_GOSUMDB" \ GOSUMDB="$ARTEX_GOSUMDB" \
CGO_ENABLED=0 \ CGO_ENABLED=0 \
GOOS="$goos" \ GOOS="$goos" \
@@ -226,7 +242,7 @@ build_target() {
compress_binary "$output" "$goos" compress_binary "$output" "$goos"
if command -v file >/dev/null 2>&1; then file "$output"; fi if command -v file >/dev/null 2>&1; then file "$output"; fi
if [ "$ARTEX_PACKAGE" = "1" ]; then package_binary "$output" "$goos" "$goarch"; fi if [ "$ARTEX_PACKAGE" = "1" ]; then package_binary "$output" "$goos" "$goarch"; fi
ok "编译完成:$output" ok_l "编译完成:$output" "Build complete: $output"
} }
write_checksums() { write_checksums() {
@@ -237,10 +253,10 @@ write_checksums() {
elif command -v shasum >/dev/null 2>&1; then elif command -v shasum >/dev/null 2>&1; then
(cd "$ARTEX_PACKAGE_DIR" && for archive in *.zip; do shasum -a 256 "$archive"; done > "$(basename "$checksum_file")") (cd "$ARTEX_PACKAGE_DIR" && for archive in *.zip; do shasum -a 256 "$archive"; done > "$(basename "$checksum_file")")
else else
warn "未检测到 sha256sum 或 shasum,跳过 SHA256SUMS" warn_l "未检测到 sha256sum 或 shasum,跳过 SHA256SUMS" "Neither sha256sum nor shasum found; skipping SHA256SUMS"
return 0 return 0
fi fi
ok "校验文件:$checksum_file" ok_l "校验文件:$checksum_file" "Checksums written: $checksum_file"
} }
mkdir -p "$ARTEX_OUTPUT_DIR" mkdir -p "$ARTEX_OUTPUT_DIR"
@@ -250,7 +266,7 @@ old_ifs="$IFS"
IFS=',' IFS=','
read -r -a targets <<< "$ARTEX_TARGETS" read -r -a targets <<< "$ARTEX_TARGETS"
IFS="$old_ifs" IFS="$old_ifs"
[ "${#targets[@]}" -gt 0 ] || die "ARTEX_TARGETS 不能为空" [ "${#targets[@]}" -gt 0 ] || die_l "ARTEX_TARGETS 不能为空" "ARTEX_TARGETS cannot be empty"
for target in "${targets[@]}"; do for target in "${targets[@]}"; do
target="${target//[[:space:]]/}" target="${target//[[:space:]]/}"
[ -n "$target" ] || continue [ -n "$target" ] || continue
@@ -259,5 +275,5 @@ done
if [ "$ARTEX_PACKAGE" = "1" ]; then if [ "$ARTEX_PACKAGE" = "1" ]; then
write_checksums write_checksums
info "Release 包已生成于:$ARTEX_PACKAGE_DIR" info_l "Release 包已生成于:$ARTEX_PACKAGE_DIR" "Release archives generated in: $ARTEX_PACKAGE_DIR"
fi fi
+4 -1
View File
@@ -6,6 +6,9 @@
set -euo pipefail set -euo pipefail
cd "$(dirname "$0")" cd "$(dirname "$0")"
# shellcheck source=scripts/deploy-lib.sh
. ./scripts/deploy-lib.sh
# 退出时结束本进程组内的所有子进程(后端 + 前端)。 # 退出时结束本进程组内的所有子进程(后端 + 前端)。
cleanup() { kill 0 2>/dev/null || true; } cleanup() { kill 0 2>/dev/null || true; }
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM
@@ -16,5 +19,5 @@ go run ./cmd/artex -addr :8787 -proxy 127.0.0.1:8788 &
# 前端热更新(Vite/Next dev server,/api 反代到 :8787)。 # 前端热更新(Vite/Next dev server,/api 反代到 :8787)。
( cd web && npm run dev ) & ( cd web && npm run dev ) &
echo "[dev] 后端 :8787 / 代理 :8788 / 前端 http://localhost:5173 (Ctrl-C 退出)" echo "$(msg '[dev] 后端 :8787 / 代理 :8788 / 前端 http://localhost:5173 (Ctrl-C 退出)' '[dev] Backend :8787 / Proxy :8788 / Frontend http://localhost:5173 (Ctrl-C to exit)')"
wait wait
+59 -40
View File
@@ -16,20 +16,22 @@ cd "$(cd "$(dirname "$0")" && pwd)"
# ── docker 环境检测 / 自动安装 ─────────────────── # ── docker 环境检测 / 自动安装 ───────────────────
ensure_docker(){ ensure_docker(){
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
ok "已检测到 docker 与 docker compose"; return ok_l "已检测到 docker 与 docker compose" "Detected docker and docker compose"; return
fi fi
warn "未检测到 docker / docker compose" warn_l "未检测到 docker / docker compose" "docker / docker compose not found"
case "$(uname -s)" in case "$(uname -s)" in
Linux) Linux)
if [ "$(ask '自动安装 Docker? (y/n)' y)" = y ]; then if is_yes "$(ask_l '自动安装 Docker? (y/n)' 'Install Docker automatically? (y/n)' y)"; then
curl -fsSL https://get.docker.com | sh curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker "$USER" || true sudo usermod -aG docker "$USER" || true
ok "Docker 安装完成(用户组变更需重新登录后免 sudo)" ok_l "Docker 安装完成(用户组变更需重新登录后免 sudo)" \
"Docker installed (re-login for docker group membership to take effect without sudo)"
else else
die "请自行安装 docker 后重试" die_l "请自行安装 docker 后重试" "Please install Docker manually and retry"
fi ;; fi ;;
Darwin) die "macOS 请安装 Docker Desktop:https://www.docker.com/products/docker-desktop/" ;; Darwin) die_l "macOS 请安装 Docker Desktop:https://www.docker.com/products/docker-desktop/" \
*) die "请自行安装 docker 后重试" ;; "On macOS, please install Docker Desktop: https://www.docker.com/products/docker-desktop/" ;;
*) die_l "请自行安装 docker 后重试" "Please install Docker manually and retry" ;;
esac esac
} }
@@ -38,7 +40,7 @@ install_docker(){
local tag="${1:-}" local tag="${1:-}"
ensure_docker ensure_docker
preflight_docker preflight_docker
validate_sandbox_compose "$COMPOSE_FILE" "$tag"
umask 077 umask 077
local is_fresh=0 local is_fresh=0
[ -f .env ] || is_fresh=1 [ -f .env ] || is_fresh=1
@@ -47,40 +49,41 @@ install_docker(){
if [ "$is_fresh" -eq 1 ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then if [ "$is_fresh" -eq 1 ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then
local key local key
key="$(ask 'ANTHROPIC_API_KEY(可留空,后续在 UI 配)' '')" key="$(ask_l 'ANTHROPIC_API_KEY(可留空,后续在 UI 配)' 'ANTHROPIC_API_KEY (optional, can be set later in UI)' '')"
[ -n "$key" ] && env_set ANTHROPIC_API_KEY "$key" .env [ -n "$key" ] && env_set ANTHROPIC_API_KEY "$key" .env
fi fi
pull_docker_images pull_docker_images
info "启动服务(${COMPOSE_FILE})…" info_l "启动服务(${COMPOSE_FILE})…" "Starting services (${COMPOSE_FILE})..."
docker compose -f "$COMPOSE_FILE" up -d --remove-orphans docker compose -f "$COMPOSE_FILE" up -d --remove-orphans
wait_for_health "$COMPOSE_FILE" || warn "服务仍在启动中,请执行 docker compose -f ${COMPOSE_FILE} logs -f artex 观察" wait_for_health "$COMPOSE_FILE" || warn_l "服务仍在启动中,请执行 docker compose -f ${COMPOSE_FILE} logs -f artex 观察" \
"Service is still starting; watch logs with: docker compose -f ${COMPOSE_FILE} logs -f artex"
ok "启动完成 → http://localhost:8787" ok_l "启动完成 → http://localhost:8787" "Started -> http://localhost:8787"
info "查看日志:docker compose -f ${COMPOSE_FILE} logs -f artex" info_l "查看日志:docker compose -f ${COMPOSE_FILE} logs -f artex" "View logs: docker compose -f ${COMPOSE_FILE} logs -f artex"
info "后续升级 / 回滚:./update.sh" info_l "后续升级 / 回滚:./update.sh" "Future upgrades / rollbacks: ./update.sh"
} }
# ── ② 本地编译运行 ────────────────────────────── # ── ② 本地编译运行 ──────────────────────────────
install_local(){ install_local(){
echo "数据库安装方式:" echo "$(msg '数据库安装方式:' 'PostgreSQL setup:')"
echo " 1) 连接已有 PostgreSQL" echo "$(msg ' 1) 连接已有 PostgreSQL' ' 1) Connect to an existing PostgreSQL')"
echo " 2) 用 Docker 起一个 PostgreSQL(需要 docker)" echo "$(msg ' 2) 用 Docker 起一个 PostgreSQL(需要 docker)' ' 2) Start a PostgreSQL container via Docker (requires docker)')"
case "$(ask '选择' 1)" in case "$(ask_l '选择' 'Select' 1)" in
2) 2)
ensure_docker ensure_docker
local pw; pw="$(ask 'Postgres 密码(回车随机)' "$(rand)")" local pw; pw="$(ask_l 'Postgres 密码(回车随机)' 'Postgres password (Enter to auto-generate)' "$(rand)")"
docker run -d --name artex-pg -p 5432:5432 \ docker run -d --name artex-pg -p 5432:5432 \
-e POSTGRES_USER=artex -e POSTGRES_PASSWORD="$pw" -e POSTGRES_DB=artex \ -e POSTGRES_USER=artex -e POSTGRES_PASSWORD="$pw" -e POSTGRES_DB=artex \
-v artex-pg:/var/lib/postgresql/data postgres:16-alpine -v artex-pg:/var/lib/postgresql/data postgres:16-alpine
DB_HOST=127.0.0.1 DB_PORT=5432 DB_USER=artex DB_PASS="$pw" DB_NAME=artex DB_SSL=disable ;; DB_HOST=127.0.0.1 DB_PORT=5432 DB_USER=artex DB_PASS="$pw" DB_NAME=artex DB_SSL=disable ;;
*) *)
DB_HOST="$(ask '数据库地址' 127.0.0.1)" DB_HOST="$(ask_l '数据库地址' 'Database host' 127.0.0.1)"
DB_PORT="$(ask '端口' 5432)" DB_PORT="$(ask_l '端口' 'Port' 5432)"
DB_USER="$(ask '账号' artex)" DB_USER="$(ask_l '账号' 'Username' artex)"
DB_PASS="$(ask '密码' '')" DB_PASS="$(ask_l '密码' 'Password' '')"
DB_NAME="$(ask '数据库名' artex)" DB_NAME="$(ask_l '数据库名' 'Database name' artex)"
DB_SSL="$(ask 'sslmode (disable/require)' disable)" ;; DB_SSL="$(ask_l 'sslmode (disable/require)' 'sslmode (disable/require)' disable)" ;;
esac esac
cat > config.json <<JSON cat > config.json <<JSON
@@ -95,39 +98,55 @@ install_local(){
} }
} }
JSON JSON
ok "已生成 config.json" ok_l "已生成 config.json" "Generated config.json"
command -v go >/dev/null 2>&1 || die "未检测到 Go,请先安装 Go(>=1.26):https://go.dev/dl/" command -v go >/dev/null 2>&1 || die_l "未检测到 Go,请先安装 Go(>=1.26):https://go.dev/dl/" \
"Go not found; please install Go (>=1.26): https://go.dev/dl/"
ok "Go: $(go version)" ok "Go: $(go version)"
if command -v npm >/dev/null 2>&1; then if command -v npm >/dev/null 2>&1; then
info "构建前端静态产物…" info_l "构建前端静态产物…" "Building static frontend assets..."
( cd web && npm ci && npm run build:static ) ( cd web && npm ci && npm run build:static )
rm -rf server/webui/dist && cp -r web/out server/webui/dist rm -rf server/webui/dist && cp -r web/out server/webui/dist
info "编译内嵌单二进制…" info_l "编译内嵌单二进制…" "Building embedded single binary..."
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
else else
warn "未检测到 npm:将编译**不内嵌前端**的后端(前端需另跑 npm run dev)" warn_l "未检测到 npm:将编译**不内嵌前端**的后端(前端需另跑 npm run dev)" \
"npm not found: building backend WITHOUT embedded frontend (run npm run dev separately)"
CGO_ENABLED=0 go build -o artex ./cmd/artex CGO_ENABLED=0 go build -o artex ./cmd/artex
fi fi
ok "编译完成 → ./artex" ok_l "编译完成 → ./artex" "Build complete -> ./artex"
info "启动…(Ctrl-C 退出)" info_l "启动…(Ctrl-C 退出)" "Starting... (Ctrl-C to exit)"
./start.sh ./start.sh
} }
usage(){ usage(){
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
cat <<'USAGE' cat <<'USAGE'
用法: ./install.sh [选项] 用法: ./install.sh [选项]
选项: 选项:
--docker 直接执行 Docker 部署(docker-compose.yml) --docker 直接执行 Docker 部署(docker-compose.yml)
--tag <TAG> 指定镜像版本 tag(如 v0.3.33 / latest) --tag <TAG> 指定镜像版本 tag(如 v0.3.34 / latest)
--local 使用本地 Go 编译运行 --local 使用本地 Go 编译运行
--skip-pull 跳过镜像拉取(适用于本地已构建镜像) --skip-pull 跳过镜像拉取(适用于本地已构建镜像)
-y, --yes 非交互模式(自动填充默认值) -y, --yes 非交互模式(自动填充默认值)
-h, --help 显示本帮助 -h, --help 显示本帮助
USAGE USAGE
else
cat <<'USAGE'
Usage: ./install.sh [options]
Options:
--docker Deploy with Docker (docker-compose.yml)
--tag <TAG> Target image tag (e.g. v0.3.34 / latest)
--local Build and run locally with Go
--skip-pull Skip pulling images (for locally built images)
-y, --yes Non-interactive mode (use default values)
-h, --help Show this help
USAGE
fi
} }
OPT_DOCKER=0 OPT_DOCKER=0
@@ -137,12 +156,12 @@ OPT_LOCAL=0
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case "$1" in case "$1" in
--docker) OPT_DOCKER=1 ;; --docker) OPT_DOCKER=1 ;;
--tag) shift; [ "$#" -gt 0 ] || die "--tag 需要参数"; OPT_TAG="$1" ;; --tag) shift; [ "$#" -gt 0 ] || die_l "--tag 需要参数" "--tag requires a value"; OPT_TAG="$1" ;;
--local) OPT_LOCAL=1 ;; --local) OPT_LOCAL=1 ;;
--skip-pull) export ARTEX_SKIP_PULL=1 ;; --skip-pull) export ARTEX_SKIP_PULL=1 ;;
-y|--yes) export ARTEX_NONINTERACTIVE=1 ;; -y|--yes) export ARTEX_NONINTERACTIVE=1 ;;
-h|--help) usage; exit 0 ;; -h|--help) usage; exit 0 ;;
*) die "未知参数:$1(使用 --help 查看帮助)" ;; *) die_l "未知参数:$1(使用 --help 查看帮助)" "Unknown option: $1 (use --help for usage)" ;;
esac esac
shift shift
done done
@@ -158,12 +177,12 @@ if [ "$OPT_DOCKER" -eq 1 ]; then
fi fi
echo "==========================================" echo "=========================================="
echo " ARTEX 安装部署" echo "$(msg ' ARTEX 安装部署' ' ARTEX Installer')"
echo " 1) Docker 部署(推荐:独立沙箱 + 全流量网关)" echo "$(msg ' 1) Docker 部署(推荐:独立沙箱 + 全流量网关)' ' 1) Docker deployment (recommended: isolated sandbox + transparent gateway)')"
echo " 2) 本地运行(Go 编译)" echo "$(msg ' 2) 本地运行(Go 编译)' ' 2) Local run (build with Go)')"
echo "==========================================" echo "=========================================="
case "$(ask '选择' 1)" in case "$(ask_l '选择' 'Select' 1)" in
1) install_docker "$OPT_TAG" ;; 1) install_docker "$OPT_TAG" ;;
2) install_local ;; 2) install_local ;;
*) die "无效选择" ;; *) die_l "无效选择" "Invalid selection" ;;
esac esac
+65 -23
View File
@@ -37,11 +37,51 @@ EXEC_KIND="" # compose | docker(docker 模式下用哪种 exec;空=自
NEWPASS="" NEWPASS=""
ASSUME_YES=0 ASSUME_YES=0
die() { echo "错误:$*" >&2; exit 1; } SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [ -f "${SCRIPT_DIR}/scripts/deploy-lib.sh" ]; then
# shellcheck source=scripts/deploy-lib.sh
. "${SCRIPT_DIR}/scripts/deploy-lib.sh"
else
ARTEX_SCRIPT_LANG="en"
case "$(printf '%s' "${ARTEX_LANG:-${TZ:-}}" | tr '[:upper:]' '[:lower:]')" in
zh*|*shanghai*|*chongqing*|*urumqi*|*hong_kong*|*macau*|*taipei*|prc|roc|cst-8*) ARTEX_SCRIPT_LANG="zh" ;;
esac
msg() { if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then printf '%s' "$1"; else printf '%s' "$2"; fi; }
fi
die() { echo "$(msg "错误:$*" "Error: $*")" >&2; exit 1; }
info() { echo "· $*" >&2; } info() { echo "· $*" >&2; }
die_l() { die "$(msg "$1" "$2")"; }
info_l() { info "$(msg "$1" "$2")"; }
usage() { sed -n '2,40p' "$0" | sed 's/^# \{0,1\}//'; exit 0; } usage() {
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
sed -n '2,25p' "$0" | sed 's/^# \{0,1\}//'
else
cat <<'USAGE'
=============================================================================
ARTEX Admin Password Reset Script
The login username is always ARTEX; the password is stored as a bcrypt hash
under settings key auth.password_hash. This script uses PostgreSQL pgcrypto
to generate a bcrypt hash compatible with golang.org/x/crypto/bcrypt.
Modes:
local (default) -- Connect via local psql (CLI args > --dsn/$ARTEX_PG_DSN > config.json)
docker -- Run psql inside the postgres container via docker compose exec / docker exec
Examples:
./reset-password.sh
./reset-password.sh -p 'NewPass!'
./reset-password.sh --dsn postgres://u:p@h:5432/artex
./reset-password.sh -H 127.0.0.1 -P 5433 -U artex -W pass -d artex
./reset-password.sh -m docker
./reset-password.sh -m docker -c pg-container --exec docker
=============================================================================
USAGE
fi
exit 0
}
# ---- 参数解析 ------------------------------------------------------------- # ---- 参数解析 -------------------------------------------------------------
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
@@ -59,7 +99,7 @@ while [[ $# -gt 0 ]]; do
-p|--new-password) NEWPASS="${2:-}"; shift 2 ;; -p|--new-password) NEWPASS="${2:-}"; shift 2 ;;
-y|--yes) ASSUME_YES=1; shift ;; -y|--yes) ASSUME_YES=1; shift ;;
-h|--help) usage ;; -h|--help) usage ;;
*) die "未知参数:$1(-h 查看用法)" ;; *) die_l "未知参数:$1(-h 查看用法)" "Unknown option: $1 (-h for usage)" ;;
esac esac
done done
@@ -120,16 +160,16 @@ if [[ -z "$MODE" ]]; then
MODE="local" MODE="local"
fi fi
fi fi
info "部署模式:$MODE" info_l "部署模式:$MODE" "Deployment mode: $MODE"
# ---- 采集新密码 ----------------------------------------------------------- # ---- 采集新密码 -----------------------------------------------------------
if [[ -z "$NEWPASS" ]]; then if [[ -z "$NEWPASS" ]]; then
read -r -s -p "输入新密码(用户名固定为 ARTEX):" NEWPASS; echo >&2 read -r -s -p "$(msg '输入新密码(用户名固定为 ARTEX):' 'Enter new password (username is ARTEX): ')" NEWPASS; echo >&2
[[ -n "$NEWPASS" ]] || die "密码不能为空" [[ -n "$NEWPASS" ]] || die_l "密码不能为空" "Password cannot be empty"
read -r -s -p "再次输入以确认:" NEWPASS2; echo >&2 read -r -s -p "$(msg '再次输入以确认:' 'Confirm new password: ')" NEWPASS2; echo >&2
[[ "$NEWPASS" == "$NEWPASS2" ]] || die "两次输入不一致" [[ "$NEWPASS" == "$NEWPASS2" ]] || die_l "两次输入不一致" "Passwords do not match"
fi fi
[[ -n "$NEWPASS" ]] || die "密码不能为空" [[ -n "$NEWPASS" ]] || die_l "密码不能为空" "Password cannot be empty"
# 通过环境变量把密码交给 psql(\getenv 读取,不进入 argv/ps) # 通过环境变量把密码交给 psql(\getenv 读取,不进入 argv/ps)
export ARTEX_RESET_NEWPASS="$NEWPASS" export ARTEX_RESET_NEWPASS="$NEWPASS"
@@ -155,20 +195,20 @@ if [[ "$MODE" == "local" ]]; then
if [[ -z "$DSN" && -z "$HOST$USER$DBNAME" ]]; then if [[ -z "$DSN" && -z "$HOST$USER$DBNAME" ]]; then
cfg="${CONFIG:-config.json}" cfg="${CONFIG:-config.json}"
if [[ -f "$cfg" ]]; then if [[ -f "$cfg" ]]; then
info "从 $cfg 读取数据库配置" info_l "从 $cfg 读取数据库配置" "Reading database config from $cfg"
apply_config_fields < <(read_config_json "$cfg") apply_config_fields < <(read_config_json "$cfg")
fi fi
fi fi
command -v psql >/dev/null 2>&1 || die "本机未找到 psql(请安装 postgresql-client,或改用 -m docker)" command -v psql >/dev/null 2>&1 || die_l "本机未找到 psql(请安装 postgresql-client,或改用 -m docker)" "psql not found locally (install postgresql-client or use -m docker)"
declare -a PSQL_ARGS=() declare -a PSQL_ARGS=()
if [[ -n "$DSN" ]]; then if [[ -n "$DSN" ]]; then
PSQL_ARGS=("$DSN") PSQL_ARGS=("$DSN")
target="$DSN" target="$DSN"
else else
[[ -n "$USER" ]] || die "缺少数据库用户(-U)或有效的 config.json/DSN" [[ -n "$USER" ]] || die_l "缺少数据库用户(-U)或有效的 config.json/DSN" "Missing database user (-U) or valid config.json/DSN"
[[ -n "$DBNAME" ]] || die "缺少数据库名(-d)或有效的 config.json/DSN" [[ -n "$DBNAME" ]] || die_l "缺少数据库名(-d)或有效的 config.json/DSN" "Missing database name (-d) or valid config.json/DSN"
HOST="${HOST:-127.0.0.1}"; PORT="${PORT:-5432}"; SSLMODE="${SSLMODE:-disable}" HOST="${HOST:-127.0.0.1}"; PORT="${PORT:-5432}"; SSLMODE="${SSLMODE:-disable}"
PSQL_ARGS=(-h "$HOST" -p "$PORT" -U "$USER" -d "$DBNAME") PSQL_ARGS=(-h "$HOST" -p "$PORT" -U "$USER" -d "$DBNAME")
[[ -n "$SSLMODE" ]] && export PGSSLMODE="$SSLMODE" [[ -n "$SSLMODE" ]] && export PGSSLMODE="$SSLMODE"
@@ -176,19 +216,20 @@ if [[ "$MODE" == "local" ]]; then
target="$USER@$HOST:$PORT/$DBNAME" target="$USER@$HOST:$PORT/$DBNAME"
fi fi
info "目标数据库:$target" info_l "目标数据库:$target" "Target database: $target"
if [[ "$ASSUME_YES" -ne 1 ]]; then if [[ "$ASSUME_YES" -ne 1 ]]; then
read -r -p "确认在该库重置 ARTEX 密码?[y/N] " ans read -r -p "$(msg '确认在该库重置 ARTEX 密码?[y/N] ' 'Reset ARTEX password in this database? [y/N] ')" ans
[[ "$ans" == "y" || "$ans" == "Y" ]] || die "已取消" [[ "$ans" == "y" || "$ans" == "Y" ]] || die_l "已取消" "Cancelled"
fi fi
if ! printf '%s\n' "$SQL" | psql "${PSQL_ARGS[@]}" -v ON_ERROR_STOP=1 -q >/dev/null; then if ! printf '%s\n' "$SQL" | psql "${PSQL_ARGS[@]}" -v ON_ERROR_STOP=1 -q >/dev/null; then
die "写入失败。若报 pgcrypto 权限/缺失,请用具备建扩展权限的角色,或先手动执行 CREATE EXTENSION pgcrypto。" die_l "写入失败。若报 pgcrypto 权限/缺失,请用具备建扩展权限的角色,或先手动执行 CREATE EXTENSION pgcrypto。" \
"Write failed. If pgcrypto is missing or permission was denied, use a role with CREATE EXTENSION privileges or run CREATE EXTENSION pgcrypto first."
fi fi
else else
# ---- docker ---- # ---- docker ----
command -v docker >/dev/null 2>&1 || die "未找到 docker" command -v docker >/dev/null 2>&1 || die_l "未找到 docker" "docker not found"
CONTAINER="${CONTAINER:-postgres}" CONTAINER="${CONTAINER:-postgres}"
# 选择 exec 方式:优先 docker compose exec(服务名),否则 docker exec(容器名) # 选择 exec 方式:优先 docker compose exec(服务名),否则 docker exec(容器名)
@@ -210,10 +251,10 @@ else
[[ -n "$DBPASS" ]] && export PGPASSWORD="$DBPASS" [[ -n "$DBPASS" ]] && export PGPASSWORD="$DBPASS"
[[ -z "${PGPASSWORD:-}" && -n "${POSTGRES_PASSWORD:-}" ]] && export PGPASSWORD="$POSTGRES_PASSWORD" [[ -z "${PGPASSWORD:-}" && -n "${POSTGRES_PASSWORD:-}" ]] && export PGPASSWORD="$POSTGRES_PASSWORD"
info "目标:容器 $CONTAINER 内 psql -U $DUSER -d $DNAME(exec=$EXEC_KIND)" info_l "目标:容器 $CONTAINER 内 psql -U $DUSER -d $DNAME(exec=$EXEC_KIND)" "Target: psql -U $DUSER -d $DNAME inside container $CONTAINER (exec=$EXEC_KIND)"
if [[ "$ASSUME_YES" -ne 1 ]]; then if [[ "$ASSUME_YES" -ne 1 ]]; then
read -r -p "确认在该容器数据库重置 ARTEX 密码?[y/N] " ans read -r -p "$(msg '确认在该容器数据库重置 ARTEX 密码?[y/N] ' 'Reset ARTEX password in this container database? [y/N] ')" ans
[[ "$ans" == "y" || "$ans" == "Y" ]] || die "已取消" [[ "$ans" == "y" || "$ans" == "Y" ]] || die_l "已取消" "Cancelled"
fi fi
# -e 只带名字不带值 → 从当前环境继承,密码不出现在 docker 命令 argv 里。 # -e 只带名字不带值 → 从当前环境继承,密码不出现在 docker 命令 argv 里。
@@ -227,9 +268,10 @@ else
fi fi
if ! printf '%s\n' "$SQL" | "${EXEC_CMD[@]}" >/dev/null; then if ! printf '%s\n' "$SQL" | "${EXEC_CMD[@]}" >/dev/null; then
die "写入失败。请确认容器名(-c)、数据库账号(.env 的 POSTGRES_*),以及角色有 pgcrypto 权限。" die_l "写入失败。请确认容器名(-c)、数据库账号(.env 的 POSTGRES_*),以及角色有 pgcrypto 权限。" \
"Write failed. Verify the container name (-c), database credentials (.env POSTGRES_*), and pgcrypto extension privileges."
fi fi
fi fi
unset ARTEX_RESET_NEWPASS unset ARTEX_RESET_NEWPASS
echo "✓ 已重置 ARTEX 管理员密码。请用用户名 ARTEX + 新密码登录(无需重启服务)。" echo "$(msg '✓ 已重置 ARTEX 管理员密码。请用用户名 ARTEX + 新密码登录(无需重启服务)。' '✓ ARTEX admin password reset. Log in with username ARTEX and the new password (no restart needed).')"
+150 -36
View File
@@ -9,10 +9,75 @@ COMPOSE_FILE="${ARTEX_COMPOSE_FILE:-docker-compose.yml}"
HEALTH_CHECK_URL="${ARTEX_HEALTH_URL:-http://127.0.0.1:8787/api/health}" HEALTH_CHECK_URL="${ARTEX_HEALTH_URL:-http://127.0.0.1:8787/api/health}"
HEALTH_CHECK_TIMEOUT="${ARTEX_HEALTH_TIMEOUT:-60}" HEALTH_CHECK_TIMEOUT="${ARTEX_HEALTH_TIMEOUT:-60}"
# ── 按系统时区自动选择脚本语言(zh / en;支持 ARTEX_LANG 显式覆盖)─────
detect_system_timezone(){
local tz=""
if [ -n "${TZ:-}" ]; then
tz="${TZ#:}"
elif [ -r /etc/timezone ]; then
tz="$(tr -d ' \t\r\n' < /etc/timezone 2>/dev/null || true)"
fi
if [ -z "$tz" ] && [ -L /etc/localtime ]; then
tz="$(readlink /etc/localtime 2>/dev/null || true)"
fi
if [ -z "$tz" ] && command -v timedatectl >/dev/null 2>&1; then
tz="$(timedatectl show -p Timezone --value 2>/dev/null || true)"
fi
case "$tz" in
*zoneinfo/*) tz="${tz#*zoneinfo/}" ;;
esac
printf '%s\n' "$tz"
}
detect_script_lang(){
local override
override="$(printf '%s' "${ARTEX_LANG:-}" | tr '[:upper:]' '[:lower:]')"
case "$override" in
zh|zh_*|zh-*) printf 'zh\n'; return 0 ;;
en|en_*|en-*) printf 'en\n'; return 0 ;;
esac
local tz tz_lc
tz="$(detect_system_timezone)"
tz_lc="$(printf '%s' "$tz" | tr '[:upper:]' '[:lower:]')"
case "$tz_lc" in
asia/shanghai|asia/chongqing|asia/chungking|asia/harbin|asia/kashgar|asia/urumqi|\
asia/hong_kong|asia/macau|asia/macao|asia/taipei|\
prc|roc|hongkong|etc/gmt-8|cst-8|cst-8:*|hkt|hkt-8*)
printf 'zh\n'
return 0
;;
"")
local abbr offset
abbr="$(date +%Z 2>/dev/null || true)"
offset="$(date +%z 2>/dev/null || true)"
if { [ "$abbr" = "CST" ] && [ "$offset" = "+0800" ]; } || [ "$abbr" = "HKT" ]; then
printf 'zh\n'
return 0
fi
;;
esac
printf 'en\n'
}
ARTEX_SCRIPT_LANG="$(detect_script_lang)"
msg(){
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
printf '%s' "$1"
else
printf '%s' "$2"
fi
}
info(){ printf '\033[36m[*]\033[0m %s\n' "$*"; } info(){ printf '\033[36m[*]\033[0m %s\n' "$*"; }
ok(){ printf '\033[32m[+]\033[0m %s\n' "$*"; } ok(){ printf '\033[32m[+]\033[0m %s\n' "$*"; }
warn(){ printf '\033[33m[!]\033[0m %s\n' "$*" >&2; } warn(){ printf '\033[33m[!]\033[0m %s\n' "$*" >&2; }
die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; } die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; }
info_l(){ info "$(msg "$1" "$2")"; }
ok_l(){ ok "$(msg "$1" "$2")"; }
warn_l(){ warn "$(msg "$1" "$2")"; }
die_l(){ die "$(msg "$1" "$2")"; }
ask(){ ask(){
local p="$1" d="${2:-}" a="" local p="$1" d="${2:-}" a=""
if [ "${ARTEX_NONINTERACTIVE:-0}" = "1" ]; then if [ "${ARTEX_NONINTERACTIVE:-0}" = "1" ]; then
@@ -22,6 +87,15 @@ ask(){
read -rp "$p${d:+ [$d]}: " a read -rp "$p${d:+ [$d]}: " a
echo "${a:-$d}" echo "${a:-$d}"
} }
ask_l(){
ask "$(msg "$1" "$2")" "${3:-}"
}
is_yes(){
case "${1:-}" in
y|Y|yes|YES) return 0 ;;
*) return 1 ;;
esac
}
rand(){ rand(){
local n="${1:-24}" local n="${1:-24}"
LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c "$n" LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c "$n"
@@ -124,7 +198,7 @@ init_base_env(){
cur_pw="$(env_get POSTGRES_PASSWORD "$file")" cur_pw="$(env_get POSTGRES_PASSWORD "$file")"
if [ -z "$cur_pw" ] || [ "$cur_pw" = "change-me-please" ]; then if [ -z "$cur_pw" ] || [ "$cur_pw" = "change-me-please" ]; then
local pw local pw
pw="$(ask 'Postgres 密码(回车随机生成)' "$(rand 24)")" pw="$(ask_l 'Postgres 密码(回车随机生成)' 'Postgres password (Enter to auto-generate)' "$(rand 24)")"
env_set POSTGRES_PASSWORD "$pw" "$file" env_set POSTGRES_PASSWORD "$pw" "$file"
fi fi
mkdir -p ./data ./skills mkdir -p ./data ./skills
@@ -186,21 +260,21 @@ prepare_env_for_docker(){
abs_data="$(pwd)/data" abs_data="$(pwd)/data"
if [ -z "$cur_data" ] || [ "$cur_data" = "/path/to/ARTEX/data" ]; then if [ -z "$cur_data" ] || [ "$cur_data" = "/path/to/ARTEX/data" ]; then
env_set ARTEX_HOST_DATA_DIR "$abs_data" "$file" env_set ARTEX_HOST_DATA_DIR "$abs_data" "$file"
ok "已设置 ARTEX_HOST_DATA_DIR=${abs_data}" ok_l "已设置 ARTEX_HOST_DATA_DIR=${abs_data}" "Set ARTEX_HOST_DATA_DIR=${abs_data}"
fi fi
local cur_tok local cur_tok
cur_tok="$(env_get ARTEX_GATEWAY_TOKEN "$file")" cur_tok="$(env_get ARTEX_GATEWAY_TOKEN "$file")"
if [ -z "$cur_tok" ]; then if [ -z "$cur_tok" ]; then
env_set ARTEX_GATEWAY_TOKEN "$(rand 32)" "$file" env_set ARTEX_GATEWAY_TOKEN "$(rand 32)" "$file"
ok "已自动生成 ARTEX_GATEWAY_TOKEN" ok_l "已自动生成 ARTEX_GATEWAY_TOKEN" "Auto-generated ARTEX_GATEWAY_TOKEN"
fi fi
if [ -n "$tag" ]; then if [ -n "$tag" ]; then
local norm local norm
norm="$(normalize_tag "$tag")" norm="$(normalize_tag "$tag")"
env_set ARTEX_TAG "$norm" "$file" env_set ARTEX_TAG "$norm" "$file"
ok "已将 ARTEX_TAG 设为 ${norm}" ok_l "已将 ARTEX_TAG 设为 ${norm}" "Set ARTEX_TAG=${norm}"
else else
local cur_tag local cur_tag
cur_tag="$(env_get ARTEX_TAG "$file")" cur_tag="$(env_get ARTEX_TAG "$file")"
@@ -221,7 +295,7 @@ prepare_migrated_workspaces(){
fi fi
for d in "${data_dir}/tasks" "${data_dir}/sessions" "${data_dir}/ephemeral"; do for d in "${data_dir}/tasks" "${data_dir}/sessions" "${data_dir}/ephemeral"; do
[ -d "$d" ] || continue [ -d "$d" ] || continue
info "校准迁移目录写权限(跳过符号链接):${d}" info_l "校准迁移目录写权限(跳过符号链接):${d}" "Fixing migrated workspace permissions (skipping symlinks): ${d}"
if [ "$use_sudo" -eq 1 ]; then if [ "$use_sudo" -eq 1 ]; then
sudo find "$d" ! -type l -type d -exec chmod 0777 {} + 2>/dev/null || true sudo find "$d" ! -type l -type d -exec chmod 0777 {} + 2>/dev/null || true
sudo find "$d" ! -type l -type f -exec chmod a+rw {} + 2>/dev/null || true sudo find "$d" ! -type l -type f -exec chmod a+rw {} + 2>/dev/null || true
@@ -241,14 +315,37 @@ preflight_docker(){
local os_name local os_name
os_name="$(uname -s)" os_name="$(uname -s)"
if [ "$os_name" != "Linux" ]; then if [ "$os_name" != "Linux" ]; then
warn "检测到当前宿主机为 ${os_name}(非 Linux)。透明网关(artex-gateway)需要 Linux 宿主机网络栈与 /dev/net/tun。" warn_l "检测到当前宿主机为 ${os_name}(非 Linux)。透明网关(artex-gateway)需要 Linux 宿主机网络栈与 /dev/net/tun。" \
"Detected host OS ${os_name} (non-Linux). The transparent gateway (artex-gateway) requires Linux host networking and /dev/net/tun."
if [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then if [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then
[ "$(ask '仍继续部署? (y/n)' n)" = "y" ] || die "已取消部署" is_yes "$(ask_l '仍继续部署? (y/n)' 'Continue deployment anyway? (y/n)' n)" || die_l "已取消部署" "Deployment cancelled"
fi fi
return 0 return 0
fi fi
if [ ! -e /dev/net/tun ]; then if [ ! -e /dev/net/tun ]; then
warn "宿主机未发现 /dev/net/tun:artex-gateway 启动时可能无法开启 TUN 模式(请确认内核加载 tun 模块)。" warn_l "宿主机未发现 /dev/net/tun:artex-gateway 启动时可能无法开启 TUN 模式(请确认内核加载 tun 模块)。" \
"/dev/net/tun not found on host: artex-gateway may not enable TUN mode (ensure the tun kernel module is loaded)."
fi
}
# 校验 docker-compose.yml 是否为新版沙箱隔离拓扑(防止误用旧版 2 服务编排导致静默回退本地模式)
validate_sandbox_compose(){
local file="${1:-$COMPOSE_FILE}" tag_hint="${2:-main}"
[ -n "$tag_hint" ] && [ "$tag_hint" != "latest" ] || tag_hint="main"
if [ ! -f "$file" ]; then
die_l "未找到编排文件:${file}。请先同步最新 docker-compose.yml 后重试。" \
"Compose file not found: ${file}. Sync the latest docker-compose.yml first."
fi
if ! grep -Eq '^[[:space:]]*docker-socket-proxy:[[:space:]]*$' "$file" \
|| ! grep -Eq '^[[:space:]]*artex-gateway:[[:space:]]*$' "$file" \
|| ! grep -Eq 'ARTEX_SANDBOX_MODE' "$file"; then
warn_l "检测到当前 ${file} 为旧版单容器编排(缺少 docker-socket-proxy / artex-gateway / ARTEX_SANDBOX_MODE),继续执行会导致升级后仍停留在本地模式。" \
"Detected legacy single-container ${file} (missing docker-socket-proxy / artex-gateway / ARTEX_SANDBOX_MODE); continuing would leave ARTEX in local mode."
warn_l "请先更新 ${file} 再重试(git 部署请先执行 git pull --ff-only;非 git 部署可执行):" \
"Update ${file} first and retry (run 'git pull --ff-only' for git clones, or for non-git deployments run):"
printf ' cp %s %s.bak && curl -fsSL https://raw.githubusercontent.com/RuoJi6/ARTEX/%s/docker-compose.yml -o %s\n' \
"$file" "$file" "$tag_hint" "$file" >&2
die_l "已中止升级,避免误用旧版编排文件。" "Aborted to prevent running with an outdated compose file."
fi fi
} }
@@ -258,7 +355,7 @@ stop_sandbox_runtime(){
if command -v docker >/dev/null 2>&1; then if command -v docker >/dev/null 2>&1; then
sbx_cids="$(docker ps -q --filter "label=artex.sandbox.managed=true" 2>/dev/null || true)" sbx_cids="$(docker ps -q --filter "label=artex.sandbox.managed=true" 2>/dev/null || true)"
if [ -n "$sbx_cids" ]; then if [ -n "$sbx_cids" ]; then
info "停止运行中的沙箱任务/会话容器…" info_l "停止运行中的沙箱任务/会话容器…" "Stopping running sandbox task/session containers..."
# shellcheck disable=SC2086 # shellcheck disable=SC2086
docker stop -t 10 $sbx_cids >/dev/null 2>&1 || true docker stop -t 10 $sbx_cids >/dev/null 2>&1 || true
fi fi
@@ -266,7 +363,8 @@ stop_sandbox_runtime(){
local gw_cid local gw_cid
gw_cid="$(find_service_cid artex-gateway "$COMPOSE_FILE")" gw_cid="$(find_service_cid artex-gateway "$COMPOSE_FILE")"
if [ -n "$gw_cid" ]; then if [ -n "$gw_cid" ]; then
info "优雅停止透明代理网关 artex-gateway(自动清理 TUN 与 iptables 规则)…" info_l "优雅停止透明代理网关 artex-gateway(自动清理 TUN 与 iptables 规则)…" \
"Gracefully stopping transparent gateway artex-gateway (cleaning up TUN & iptables rules)..."
docker compose -f "$COMPOSE_FILE" stop -t 15 artex-gateway >/dev/null 2>&1 || true docker compose -f "$COMPOSE_FILE" stop -t 15 artex-gateway >/dev/null 2>&1 || true
fi fi
fi fi
@@ -279,7 +377,8 @@ stop_sandbox_runtime(){
elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
sudo ./scripts/artex-sandbox-firewall.sh --cleanup >/dev/null 2>&1 || true sudo ./scripts/artex-sandbox-firewall.sh --cleanup >/dev/null 2>&1 || true
elif command -v ip >/dev/null 2>&1 && ip link show artex-tun0 >/dev/null 2>&1; then elif command -v ip >/dev/null 2>&1 && ip link show artex-tun0 >/dev/null 2>&1; then
warn "检测到宿主机残留 artex-tun0 / 策略路由,如需清理请执行:sudo ./scripts/artex-sandbox-firewall.sh --cleanup" warn_l "检测到宿主机残留 artex-tun0 / 策略路由,如需清理请执行:sudo ./scripts/artex-sandbox-firewall.sh --cleanup" \
"Residual artex-tun0 / policy routing detected on host; to clean up run: sudo ./scripts/artex-sandbox-firewall.sh --cleanup"
fi fi
fi fi
} }
@@ -291,24 +390,24 @@ wait_for_health(){
if [ "${ARTEX_SKIP_HEALTH:-0}" = "1" ]; then if [ "${ARTEX_SKIP_HEALTH:-0}" = "1" ]; then
return 0 return 0
fi fi
info "等待服务就绪(${url},超时 ${timeout_s}s)…" info_l "等待服务就绪(${url},超时 ${timeout_s}s)…" "Waiting for service readiness (${url}, timeout ${timeout_s}s)..."
while [ "$elapsed" -lt "$timeout_s" ]; do while [ "$elapsed" -lt "$timeout_s" ]; do
if command -v curl >/dev/null 2>&1 && curl -fsS --max-time 3 "$url" >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1 && curl -fsS --max-time 3 "$url" >/dev/null 2>&1; then
ok "健康检查通过:${url}" ok_l "健康检查通过:${url}" "Health check passed: ${url}"
return 0 return 0
fi fi
cid="$(find_service_cid artex "$compose_file")" cid="$(find_service_cid artex "$compose_file")"
if [ -n "$cid" ]; then if [ -n "$cid" ]; then
state="$(docker inspect --format '{{.State.Status}}' "$cid" 2>/dev/null || true)" state="$(docker inspect --format '{{.State.Status}}' "$cid" 2>/dev/null || true)"
if [ "$state" = "exited" ] || [ "$state" = "dead" ]; then if [ "$state" = "exited" ] || [ "$state" = "dead" ]; then
warn "artex 容器异常退出(state=${state})" warn_l "artex 容器异常退出(state=${state})" "artex container exited unexpectedly (state=${state})"
return 1 return 1
fi fi
fi fi
sleep 2 sleep 2
elapsed=$((elapsed + 2)) elapsed=$((elapsed + 2))
done done
warn "等待 ${url} 就绪超时(${timeout_s}s)" warn_l "等待 ${url} 就绪超时(${timeout_s}s)" "Timed out waiting for ${url} (${timeout_s}s)"
return 1 return 1
} }
@@ -354,6 +453,7 @@ create_deploy_snapshot(){
mkdir -p "$snap_dir" mkdir -p "$snap_dir"
[ -f .env ] && cp .env "${snap_dir}/dot.env" [ -f .env ] && cp .env "${snap_dir}/dot.env"
[ -f "$COMPOSE_FILE" ] && cp "$COMPOSE_FILE" "${snap_dir}/docker-compose.yml"
if command -v docker >/dev/null 2>&1; then if command -v docker >/dev/null 2>&1; then
artex_cid="$(find_service_cid artex)" artex_cid="$(find_service_cid artex)"
@@ -423,7 +523,7 @@ META
list_deploy_snapshots(){ list_deploy_snapshots(){
if [ ! -d "$DEPLOY_SNAP_DIR" ]; then if [ ! -d "$DEPLOY_SNAP_DIR" ]; then
info "暂无部署快照(升级前会自动生成)" info_l "暂无部署快照(升级前会自动生成)" "No deployment snapshots found (created automatically before upgrades)"
return 0 return 0
fi fi
local found=0 dir snap_id img pg reason local found=0 dir snap_id img pg reason
@@ -434,11 +534,16 @@ list_deploy_snapshots(){
img="$(env_get ARTEX_IMAGE_REF "${dir}/meta.env")" img="$(env_get ARTEX_IMAGE_REF "${dir}/meta.env")"
pg="$(env_get HAS_PG_DUMP "${dir}/meta.env")" pg="$(env_get HAS_PG_DUMP "${dir}/meta.env")"
reason="$(env_get SNAP_REASON "${dir}/meta.env")" reason="$(env_get SNAP_REASON "${dir}/meta.env")"
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
printf ' - %s [镜像: %s] [DB备份: %s] [来源: %s]\n' \ printf ' - %s [镜像: %s] [DB备份: %s] [来源: %s]\n' \
"$snap_id" "${img:-unknown}" "$([ "$pg" = "1" ] && echo "有" || echo "无")" "${reason:-?}" "$snap_id" "${img:-unknown}" "$([ "$pg" = "1" ] && echo "有" || echo "无")" "${reason:-?}"
else
printf ' - %s [image: %s] [DB backup: %s] [reason: %s]\n' \
"$snap_id" "${img:-unknown}" "$([ "$pg" = "1" ] && echo "yes" || echo "no")" "${reason:-?}"
fi
done done
if [ "$found" -eq 0 ]; then if [ "$found" -eq 0 ]; then
info "暂无部署快照" info_l "暂无部署快照" "No deployment snapshots found"
fi fi
} }
@@ -478,7 +583,8 @@ restore_snapshot_images(){
fi fi
env_set ARTEX_IMAGE "${artex_rb%:*}" .env env_set ARTEX_IMAGE "${artex_rb%:*}" .env
env_set ARTEX_TAG "${artex_rb##*:}" .env env_set ARTEX_TAG "${artex_rb##*:}" .env
ok "已绑定本地精确回滚镜像:${artex_rb}(原镜像:${artex_ref:-unknown})" ok_l "已绑定本地精确回滚镜像:${artex_rb}(原镜像:${artex_ref:-unknown})" \
"Pinned local rollback image: ${artex_rb} (original: ${artex_ref:-unknown})"
elif [ -n "$artex_ref" ]; then elif [ -n "$artex_ref" ]; then
local repo="${artex_ref%:*}" tag="${artex_ref##*:}" local repo="${artex_ref%:*}" tag="${artex_ref##*:}"
if [ "$repo" != "$artex_ref" ] && [ -n "$tag" ]; then if [ "$repo" != "$artex_ref" ] && [ -n "$tag" ]; then
@@ -516,34 +622,36 @@ restore_snapshot_images(){
restore_postgres_dump(){ restore_postgres_dump(){
local dump_gz="$1" compose_file="$2" local dump_gz="$1" compose_file="$2"
[ -f "$dump_gz" ] || die "快照中不存在数据库备份:${dump_gz}" [ -f "$dump_gz" ] || die_l "快照中不存在数据库备份:${dump_gz}" "Database backup not found in snapshot: ${dump_gz}"
local pg_cid pg_user pg_db local pg_cid pg_user pg_db
pg_cid="$(find_service_cid postgres "$compose_file")" pg_cid="$(find_service_cid postgres "$compose_file")"
[ -n "$pg_cid" ] || die "未找到运行中的 postgres 容器,无法恢复数据库备份" [ -n "$pg_cid" ] || die_l "未找到运行中的 postgres 容器,无法恢复数据库备份" "No running postgres container found; cannot restore database backup"
pg_user="$(env_get POSTGRES_USER .env)"; [ -n "$pg_user" ] || pg_user="artex" pg_user="$(env_get POSTGRES_USER .env)"; [ -n "$pg_user" ] || pg_user="artex"
pg_db="$(env_get POSTGRES_DB .env)"; [ -n "$pg_db" ] || pg_db="artex" pg_db="$(env_get POSTGRES_DB .env)"; [ -n "$pg_db" ] || pg_db="artex"
info "停止 artex 并恢复 PostgreSQL 快照(${dump_gz})…" info_l "停止 artex 并恢复 PostgreSQL 快照(${dump_gz})…" "Stopping artex and restoring PostgreSQL snapshot (${dump_gz})..."
docker compose -f "$compose_file" stop artex >/dev/null 2>&1 || true docker compose -f "$compose_file" stop artex >/dev/null 2>&1 || true
docker exec "$pg_cid" psql -U "$pg_user" -d postgres -v ON_ERROR_STOP=1 \ docker exec "$pg_cid" psql -U "$pg_user" -d postgres -v ON_ERROR_STOP=1 \
-c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${pg_db}' AND pid <> pg_backend_pid();" >/dev/null 2>&1 || true -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='${pg_db}' AND pid <> pg_backend_pid();" >/dev/null 2>&1 || true
docker exec "$pg_cid" psql -U "$pg_user" -d "$pg_db" -v ON_ERROR_STOP=1 \ docker exec "$pg_cid" psql -U "$pg_user" -d "$pg_db" -v ON_ERROR_STOP=1 \
-c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" >/dev/null -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" >/dev/null
gzip -dc "$dump_gz" | docker exec -i "$pg_cid" psql -U "$pg_user" -d "$pg_db" -v ON_ERROR_STOP=1 >/dev/null gzip -dc "$dump_gz" | docker exec -i "$pg_cid" psql -U "$pg_user" -d "$pg_db" -v ON_ERROR_STOP=1 >/dev/null
ok "PostgreSQL 快照恢复完成" ok_l "PostgreSQL 快照恢复完成" "PostgreSQL snapshot restored"
} }
rollback_to_snapshot(){ rollback_to_snapshot(){
local snap_id="${1:-}" restore_db="${2:-0}" local snap_id="${1:-}" restore_db="${2:-0}"
if [ -z "$snap_id" ]; then if [ -z "$snap_id" ]; then
[ -f "${DEPLOY_STATE_DIR}/latest" ] || die "未找到可回滚的部署快照(${DEPLOY_STATE_DIR}/latest 不存在)" [ -f "${DEPLOY_STATE_DIR}/latest" ] || die_l "未找到可回滚的部署快照(${DEPLOY_STATE_DIR}/latest 不存在)" \
"No rollback snapshot found (${DEPLOY_STATE_DIR}/latest does not exist)"
snap_id="$(cat "${DEPLOY_STATE_DIR}/latest")" snap_id="$(cat "${DEPLOY_STATE_DIR}/latest")"
fi fi
local snap_dir="${DEPLOY_SNAP_DIR}/${snap_id}" local snap_dir="${DEPLOY_SNAP_DIR}/${snap_id}"
local meta="${snap_dir}/meta.env" local meta="${snap_dir}/meta.env"
[ -f "$meta" ] || die "快照不存在:${snap_id}(可用 ./update.sh --list-snapshots 查看)" [ -f "$meta" ] || die_l "快照不存在:${snap_id}(可用 ./update.sh --list-snapshots 查看)" \
"Snapshot not found: ${snap_id} (run ./update.sh --list-snapshots to list snapshots)"
info "开始回滚到快照 ${snap_id}…" info_l "开始回滚到快照 ${snap_id}…" "Rolling back to snapshot ${snap_id}..."
stop_sandbox_runtime stop_sandbox_runtime
@@ -554,6 +662,9 @@ rollback_to_snapshot(){
cp "${snap_dir}/dot.env" .env cp "${snap_dir}/dot.env" .env
chmod 600 .env 2>/dev/null || true chmod 600 .env 2>/dev/null || true
fi fi
if [ -f "${snap_dir}/docker-compose.yml" ]; then
cp "${snap_dir}/docker-compose.yml" "$COMPOSE_FILE"
fi
env_set ARTEX_SANDBOX_MODE "docker" .env env_set ARTEX_SANDBOX_MODE "docker" .env
restore_snapshot_images "$meta" restore_snapshot_images "$meta"
@@ -563,13 +674,14 @@ rollback_to_snapshot(){
restore_postgres_dump "${snap_dir}/postgres.sql.gz" "$COMPOSE_FILE" restore_postgres_dump "${snap_dir}/postgres.sql.gz" "$COMPOSE_FILE"
fi fi
info "启动服务(${COMPOSE_FILE} --remove-orphans)…" info_l "启动服务(${COMPOSE_FILE} --remove-orphans)…" "Starting services (${COMPOSE_FILE} --remove-orphans)..."
docker compose -f "$COMPOSE_FILE" up -d --remove-orphans docker compose -f "$COMPOSE_FILE" up -d --remove-orphans
if wait_for_health "$COMPOSE_FILE"; then if wait_for_health "$COMPOSE_FILE"; then
ok "回滚完成 → http://localhost:8787" ok_l "回滚完成 → http://localhost:8787" "Rollback complete -> http://localhost:8787"
else else
die "回滚后健康检查未通过,请执行 docker compose -f ${COMPOSE_FILE} logs --tail=80 artex 排查" die_l "回滚后健康检查未通过,请执行 docker compose -f ${COMPOSE_FILE} logs --tail=80 artex 排查" \
"Health check failed after rollback; check logs: docker compose -f ${COMPOSE_FILE} logs --tail=80 artex"
fi fi
} }
@@ -577,14 +689,15 @@ rollback_to_snapshot(){
pull_docker_images(){ pull_docker_images(){
local sbx_img local sbx_img
if [ "${ARTEX_SKIP_PULL:-0}" = "1" ]; then if [ "${ARTEX_SKIP_PULL:-0}" = "1" ]; then
info "已跳过镜像拉取(ARTEX_SKIP_PULL=1)" info_l "已跳过镜像拉取(ARTEX_SKIP_PULL=1)" "Skipped image pull (ARTEX_SKIP_PULL=1)"
return 0 return 0
fi fi
info "拉取镜像(artex / artex-gateway / docker-socket-proxy / postgres)…" info_l "拉取镜像(artex / artex-gateway / docker-socket-proxy / postgres)…" \
"Pulling images (artex / artex-gateway / docker-socket-proxy / postgres)..."
docker compose -f "$COMPOSE_FILE" pull docker compose -f "$COMPOSE_FILE" pull
sbx_img="$(env_get ARTEX_SANDBOX_IMAGE .env)" sbx_img="$(env_get ARTEX_SANDBOX_IMAGE .env)"
[ -n "$sbx_img" ] || sbx_img="ruoji6/artex-sandbox:latest" [ -n "$sbx_img" ] || sbx_img="ruoji6/artex-sandbox:latest"
info "拉取沙箱执行镜像(${sbx_img})…" info_l "拉取沙箱执行镜像(${sbx_img})…" "Pulling sandbox worker image (${sbx_img})..."
docker pull "$sbx_img" docker pull "$sbx_img"
} }
@@ -592,14 +705,15 @@ deploy_with_rollback(){
local snap_id="${1:-}" local snap_id="${1:-}"
pull_docker_images pull_docker_images
info "启动服务(${COMPOSE_FILE})…" info_l "启动服务(${COMPOSE_FILE})…" "Starting services (${COMPOSE_FILE})..."
if ! docker compose -f "$COMPOSE_FILE" up -d --remove-orphans || ! wait_for_health "$COMPOSE_FILE"; then if ! docker compose -f "$COMPOSE_FILE" up -d --remove-orphans || ! wait_for_health "$COMPOSE_FILE"; then
warn "新版本启动或健康检查失败!" warn_l "新版本启动或健康检查失败!" "New version failed to start or pass health check!"
if [ -n "$snap_id" ] && [ -f "${DEPLOY_SNAP_DIR}/${snap_id}/meta.env" ]; then if [ -n "$snap_id" ] && [ -f "${DEPLOY_SNAP_DIR}/${snap_id}/meta.env" ]; then
warn "正在自动回滚到操作前快照 ${snap_id}…" warn_l "正在自动回滚到操作前快照 ${snap_id}…" "Automatically rolling back to pre-upgrade snapshot ${snap_id}..."
rollback_to_snapshot "$snap_id" 0 rollback_to_snapshot "$snap_id" 0
die "已自动回滚到 ${snap_id},请排查失败原因后重试" die_l "已自动回滚到 ${snap_id},请排查失败原因后重试" "Automatically rolled back to ${snap_id}; investigate the failure and retry"
fi fi
die "启动失败,请查看日志:docker compose -f ${COMPOSE_FILE} logs --tail=80 artex" die_l "启动失败,请查看日志:docker compose -f ${COMPOSE_FILE} logs --tail=80 artex" \
"Startup failed; check logs: docker compose -f ${COMPOSE_FILE} logs --tail=80 artex"
fi fi
} }
+84 -1
View File
@@ -19,10 +19,14 @@ assert_contains() {
grep -Fq -- "$needle" "$file" || fail "${msg}: '${needle}' not found in ${file}" grep -Fq -- "$needle" "$file" || fail "${msg}: '${needle}' not found in ${file}"
} }
# 1. Syntax check all deployment scripts # 1. Syntax check all shell scripts
bash -n "$REPO_ROOT/scripts/deploy-lib.sh" bash -n "$REPO_ROOT/scripts/deploy-lib.sh"
bash -n "$REPO_ROOT/install.sh" bash -n "$REPO_ROOT/install.sh"
bash -n "$REPO_ROOT/update.sh" bash -n "$REPO_ROOT/update.sh"
bash -n "$REPO_ROOT/build.sh"
bash -n "$REPO_ROOT/dev.sh"
bash -n "$REPO_ROOT/reset-password.sh"
sh -n "$REPO_ROOT/start.sh"
sh -n "$REPO_ROOT/scripts/artex-sandbox-firewall.sh" sh -n "$REPO_ROOT/scripts/artex-sandbox-firewall.sh"
pass "shell syntax checks" pass "shell syntax checks"
@@ -44,6 +48,56 @@ pass "shell syntax checks"
) )
pass "tag normalization and env helpers" pass "tag normalization and env helpers"
# 2b. Unit-test timezone-based language detection & script output switching
(
# shellcheck source=scripts/deploy-lib.sh
. "$REPO_ROOT/scripts/deploy-lib.sh"
assert_eq "$(ARTEX_LANG= TZ=Asia/Shanghai detect_script_lang)" "zh" "Asia/Shanghai -> zh"
assert_eq "$(ARTEX_LANG= TZ=:Asia/Hong_Kong detect_script_lang)" "zh" ":Asia/Hong_Kong -> zh"
assert_eq "$(ARTEX_LANG= TZ=Asia/Taipei detect_script_lang)" "zh" "Asia/Taipei -> zh"
assert_eq "$(ARTEX_LANG= TZ=Asia/Macau detect_script_lang)" "zh" "Asia/Macau -> zh"
assert_eq "$(ARTEX_LANG= TZ=Asia/Urumqi detect_script_lang)" "zh" "Asia/Urumqi -> zh"
assert_eq "$(ARTEX_LANG= TZ=CST-8 detect_script_lang)" "zh" "CST-8 -> zh"
assert_eq "$(ARTEX_LANG= TZ=UTC detect_script_lang)" "en" "UTC -> en"
assert_eq "$(ARTEX_LANG= TZ=America/New_York detect_script_lang)" "en" "America/New_York -> en"
assert_eq "$(ARTEX_LANG= TZ=Europe/London detect_script_lang)" "en" "Europe/London -> en"
assert_eq "$(ARTEX_LANG= TZ=Asia/Tokyo detect_script_lang)" "en" "Asia/Tokyo -> en"
assert_eq "$(ARTEX_LANG= TZ=Asia/Singapore detect_script_lang)" "en" "Asia/Singapore -> en"
assert_eq "$(ARTEX_LANG= TZ=CST6CDT detect_script_lang)" "en" "US CST6CDT -> en"
assert_eq "$(ARTEX_LANG=en TZ=Asia/Shanghai detect_script_lang)" "en" "ARTEX_LANG=en overrides zh timezone"
assert_eq "$(ARTEX_LANG=zh TZ=UTC detect_script_lang)" "zh" "ARTEX_LANG=zh overrides en timezone"
# Verify script CLI help switches language by TZ
ARTEX_LANG= TZ=Asia/Shanghai "$REPO_ROOT/update.sh" --help > "$TMP_DIR/update-zh.out"
ARTEX_LANG= TZ=America/New_York "$REPO_ROOT/update.sh" --help > "$TMP_DIR/update-en.out"
assert_contains "$TMP_DIR/update-zh.out" "用法: ./update.sh" "update.sh --help outputs zh for Asia/Shanghai"
assert_contains "$TMP_DIR/update-en.out" "Usage: ./update.sh" "update.sh --help outputs en for America/New_York"
ARTEX_LANG= TZ=Asia/Shanghai "$REPO_ROOT/install.sh" --help > "$TMP_DIR/install-zh.out"
ARTEX_LANG= TZ=UTC "$REPO_ROOT/install.sh" --help > "$TMP_DIR/install-en.out"
assert_contains "$TMP_DIR/install-zh.out" "用法: ./install.sh" "install.sh --help outputs zh for Asia/Shanghai"
assert_contains "$TMP_DIR/install-en.out" "Usage: ./install.sh" "install.sh --help outputs en for UTC"
ARTEX_LANG= TZ=Asia/Shanghai "$REPO_ROOT/build.sh" --help > "$TMP_DIR/build-zh.out"
ARTEX_LANG= TZ=UTC "$REPO_ROOT/build.sh" --help > "$TMP_DIR/build-en.out"
assert_contains "$TMP_DIR/build-zh.out" "用法:" "build.sh --help outputs zh for Asia/Shanghai"
assert_contains "$TMP_DIR/build-en.out" "Usage:" "build.sh --help outputs en for UTC"
ARTEX_LANG= TZ=Asia/Shanghai "$REPO_ROOT/reset-password.sh" --help > "$TMP_DIR/reset-zh.out"
ARTEX_LANG= TZ=UTC "$REPO_ROOT/reset-password.sh" --help > "$TMP_DIR/reset-en.out"
assert_contains "$TMP_DIR/reset-zh.out" "ARTEX 管理员密码重置脚本" "reset-password.sh --help outputs zh for Asia/Shanghai"
assert_contains "$TMP_DIR/reset-en.out" "ARTEX Admin Password Reset Script" "reset-password.sh --help outputs en for UTC"
mkdir -p "$TMP_DIR/start-check"
cp "$REPO_ROOT/start.sh" "$TMP_DIR/start-check/start.sh"
chmod +x "$TMP_DIR/start-check/start.sh"
( ARTEX_LANG= TZ=Asia/Shanghai "$TMP_DIR/start-check/start.sh" 2>"$TMP_DIR/start-zh.err" || true )
( ARTEX_LANG= TZ=UTC "$TMP_DIR/start-check/start.sh" 2>"$TMP_DIR/start-en.err" || true )
assert_contains "$TMP_DIR/start-zh.err" "找不到可执行文件" "start.sh outputs zh error for Asia/Shanghai"
assert_contains "$TMP_DIR/start-en.err" "Executable not found" "start.sh outputs en error for UTC"
)
pass "timezone-based zh/en language switching"
# 3. End-to-end workflow test with stubbed docker & curl in isolated workspace # 3. End-to-end workflow test with stubbed docker & curl in isolated workspace
WORK="$TMP_DIR/work" WORK="$TMP_DIR/work"
BIN_STUB="$TMP_DIR/bin" BIN_STUB="$TMP_DIR/bin"
@@ -258,4 +312,33 @@ assert_eq "$(cd "$FRESH" && . ./scripts/deploy-lib.sh && env_get ARTEX_HOST_DATA
[ -n "$(cd "$FRESH" && . ./scripts/deploy-lib.sh && env_get ARTEX_GATEWAY_TOKEN .env)" ] || fail "fresh install sets ARTEX_GATEWAY_TOKEN" [ -n "$(cd "$FRESH" && . ./scripts/deploy-lib.sh && env_get ARTEX_GATEWAY_TOKEN .env)" ] || fail "fresh install sets ARTEX_GATEWAY_TOKEN"
pass "fresh install.sh" pass "fresh install.sh"
# 3f. Outdated 2-service docker-compose.yml must be rejected (and snapshot backs up compose file)
[ -f "$WORK/.artex-deploy/snapshots/$snap_upg/docker-compose.yml" ] || fail "upgrade snapshot did not back up docker-compose.yml"
LEGACY_COMPOSE="$TMP_DIR/legacy-compose"
mkdir -p "$LEGACY_COMPOSE/scripts"
cp "$REPO_ROOT/update.sh" "$REPO_ROOT/install.sh" "$LEGACY_COMPOSE/"
cp "$REPO_ROOT/scripts/deploy-lib.sh" "$LEGACY_COMPOSE/scripts/"
chmod +x "$LEGACY_COMPOSE/update.sh" "$LEGACY_COMPOSE/install.sh" "$LEGACY_COMPOSE/scripts/deploy-lib.sh"
cat > "$LEGACY_COMPOSE/.env" <<'ENV'
POSTGRES_PASSWORD=testpass
ENV
cat > "$LEGACY_COMPOSE/docker-compose.yml" <<'YML'
services:
postgres:
image: postgres:16-alpine
artex:
image: ruoji6/artex:v0.3.32
YML
if ( cd "$LEGACY_COMPOSE" && ARTEX_LANG= TZ=Asia/Shanghai ./update.sh --upgrade --tag v0.3.35 --skip-git-pull --yes 2>"$TMP_DIR/legacy-zh.err" ); then
fail "legacy 2-service docker-compose.yml should be rejected (zh)"
fi
assert_contains "$TMP_DIR/legacy-zh.err" "旧版单容器编排" "zh error mentions legacy compose"
assert_contains "$TMP_DIR/legacy-zh.err" "RuoJi6/ARTEX/v0.3.35/docker-compose.yml" "zh error includes exact sync URL"
if ( cd "$LEGACY_COMPOSE" && ARTEX_LANG= TZ=UTC ./update.sh --upgrade --tag v0.3.35 --skip-git-pull --yes 2>"$TMP_DIR/legacy-en.err" ); then
fail "legacy 2-service docker-compose.yml should be rejected (en)"
fi
assert_contains "$TMP_DIR/legacy-en.err" "Detected legacy single-container" "en error mentions legacy compose"
assert_contains "$TMP_DIR/legacy-en.err" "RuoJi6/ARTEX/v0.3.35/docker-compose.yml" "en error includes exact sync URL"
pass "legacy docker-compose.yml rejection + compose snapshot backup"
echo "ALL DEPLOY/UPGRADE/ROLLBACK TESTS PASSED" echo "ALL DEPLOY/UPGRADE/ROLLBACK TESTS PASSED"
+55 -6
View File
@@ -20,9 +20,58 @@ set -u
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
BIN=./artex detect_script_lang() {
[ -x "$BIN" ] || { echo "[artex] 找不到可执行文件 $BIN" >&2; exit 1; } override=$(printf '%s' "${ARTEX_LANG:-}" | tr '[:upper:]' '[:lower:]')
case "$override" in
zh|zh_*|zh-*) printf 'zh\n'; return 0 ;;
en|en_*|en-*) printf 'en\n'; return 0 ;;
esac
tz=""
if [ -n "${TZ:-}" ]; then
tz=${TZ#:}
elif [ -r /etc/timezone ]; then
tz=$(tr -d ' \t\r\n' < /etc/timezone 2>/dev/null || true)
fi
if [ -z "$tz" ] && [ -L /etc/localtime ]; then
tz=$(readlink /etc/localtime 2>/dev/null || true)
fi
if [ -z "$tz" ] && command -v timedatectl >/dev/null 2>&1; then
tz=$(timedatectl show -p Timezone --value 2>/dev/null || true)
fi
case "$tz" in
*zoneinfo/*) tz=${tz#*zoneinfo/} ;;
esac
tz_lc=$(printf '%s' "$tz" | tr '[:upper:]' '[:lower:]')
case "$tz_lc" in
asia/shanghai|asia/chongqing|asia/chungking|asia/harbin|asia/kashgar|asia/urumqi|\
asia/hong_kong|asia/macau|asia/macao|asia/taipei|\
prc|roc|hongkong|etc/gmt-8|cst-8|cst-8:*|hkt|hkt-8*)
printf 'zh\n'
return 0
;;
"")
abbr=$(date +%Z 2>/dev/null || true)
offset=$(date +%z 2>/dev/null || true)
if { [ "$abbr" = "CST" ] && [ "$offset" = "+0800" ]; } || [ "$abbr" = "HKT" ]; then
printf 'zh\n'
return 0
fi
;;
esac
printf 'en\n'
}
ARTEX_SCRIPT_LANG=$(detect_script_lang)
msg() {
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
printf '%s' "$1"
else
printf '%s' "$2"
fi
}
BIN=./artex
[ -x "$BIN" ] || { printf '%s\n' "$(msg "[artex] 找不到可执行文件 $BIN" "[artex] Executable not found: $BIN")" >&2; exit 1; }
RESTART_CODE=75 RESTART_CODE=75
MAX_DELAY=60 MAX_DELAY=60
@@ -58,22 +107,22 @@ while :; do
child=0 child=0
if [ "$stopping" -eq 1 ]; then if [ "$stopping" -eq 1 ]; then
echo "[artex] 已停止" printf '%s\n' "$(msg "[artex] 已停止" "[artex] Stopped")"
exit 0 exit 0
fi fi
case "$code" in case "$code" in
0) 0)
echo "[artex] 正常退出" printf '%s\n' "$(msg "[artex] 正常退出" "[artex] Exited cleanly")"
exit 0 exit 0
;; ;;
"$RESTART_CODE") "$RESTART_CODE")
# 更新/回滚已就绪:重跑后 artex 会在启动时完成换装(见 selfupdate.Bootstrap)。 # 更新/回滚已就绪:重跑后 artex 会在启动时完成换装(见 selfupdate.Bootstrap)。
echo "[artex] 请求重启(应用新版本)…" printf '%s\n' "$(msg "[artex] 请求重启(应用新版本)…" "[artex] Restart requested (applying update)...")"
delay=1 delay=1
;; ;;
*) *)
echo "[artex] 异常退出 (code=$code),${delay}s 后重启" >&2 printf '%s\n' "$(msg "[artex] 异常退出 (code=$code),${delay}s 后重启" "[artex] Exited unexpectedly (code=$code), restarting in ${delay}s")" >&2
sleep "$delay" sleep "$delay"
delay=$((delay * 2)) delay=$((delay * 2))
[ "$delay" -gt "$MAX_DELAY" ] && delay=$MAX_DELAY [ "$delay" -gt "$MAX_DELAY" ] && delay=$MAX_DELAY
+69 -34
View File
@@ -11,17 +11,20 @@ cd "$(cd "$(dirname "$0")" && pwd)"
sync_repo(){ sync_repo(){
[ "${ARTEX_SKIP_GIT_PULL:-0}" = "1" ] && return 0 [ "${ARTEX_SKIP_GIT_PULL:-0}" = "1" ] && return 0
[ -d .git ] && command -v git >/dev/null 2>&1 || { warn "非 git 工作副本,跳过 git pull"; return 0; } [ -d .git ] && command -v git >/dev/null 2>&1 || { warn_l "非 git 工作副本,跳过 git pull" "Not a git working tree; skipping git pull"; return 0; }
[ "$(ask '拉取最新代码 (git pull --ff-only)? (y/n)' y)" = y ] || return 0 is_yes "$(ask_l '拉取最新代码 (git pull --ff-only)? (y/n)' 'Pull latest code (git pull --ff-only)? (y/n)' y)" || return 0
if ! git pull --ff-only; then if ! git pull --ff-only; then
warn "git pull 未能快进(本地有改动或分支分叉)——请手动处理后重试,本次沿用当前代码" warn_l "git pull 未能快进(本地有改动或分支分叉)——请手动处理后重试,本次沿用当前代码" \
"git pull could not fast-forward (local changes or diverged branch) -- continuing with current files"
fi fi
} }
require_docker_env(){ require_docker_env(){
command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1 \ command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1 \
|| die "未检测到 docker / docker compose,请先用 ./install.sh 安装部署" || die_l "未检测到 docker / docker compose,请先用 ./install.sh 安装部署" \
[ -f .env ] || die "未找到 .env,请先运行 ./install.sh 完成首次部署" "docker / docker compose not found; run ./install.sh first"
[ -f .env ] || die_l "未找到 .env,请先运行 ./install.sh 完成首次部署" \
".env not found; run ./install.sh for initial deployment"
} }
# ── ① Docker 升级(自动快照 + 失败自动回滚)───────────────────────────── # ── ① Docker 升级(自动快照 + 失败自动回滚)─────────────────────────────
@@ -31,21 +34,26 @@ update_docker(){
preflight_docker preflight_docker
if [ -z "$tag" ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then if [ -z "$tag" ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then
tag="$(ask '目标镜像 tag(回车沿用 .env / latest;如 v0.3.33)' '')" tag="$(ask_l '目标镜像 tag(回车沿用 .env / latest;如 v0.3.35)' 'Target image tag (Enter to keep .env / latest; e.g. v0.3.35)' '')"
fi fi
info "正在创建升级前部署快照(用于失败自动回滚或手动回滚)…" validate_sandbox_compose "$COMPOSE_FILE" "$tag"
info_l "正在创建升级前部署快照(用于失败自动回滚或手动回滚)…" \
"Creating pre-upgrade deployment snapshot (for auto-rollback or manual rollback)..."
local snap_id local snap_id
snap_id="$(create_deploy_snapshot "upgrade" "$skip_db")" snap_id="$(create_deploy_snapshot "upgrade" "$skip_db")"
ok "已创建回滚快照:${snap_id}" ok_l "已创建回滚快照:${snap_id}" "Created rollback snapshot: ${snap_id}"
prepare_env_for_docker "$tag" .env prepare_env_for_docker "$tag" .env
prepare_migrated_workspaces ./data prepare_migrated_workspaces ./data
deploy_with_rollback "$snap_id" deploy_with_rollback "$snap_id"
ok "升级完成 → http://localhost:8787" ok_l "升级完成 → http://localhost:8787" "Upgrade complete -> http://localhost:8787"
info "如需回滚到升级前状态:./update.sh --rollback ${snap_id}" info_l "如需回滚到升级前状态:./update.sh --rollback ${snap_id}" \
info "查看日志:docker compose -f ${COMPOSE_FILE} logs -f artex" "To roll back to the previous state: ./update.sh --rollback ${snap_id}"
info_l "查看日志:docker compose -f ${COMPOSE_FILE} logs -f artex" \
"View logs: docker compose -f ${COMPOSE_FILE} logs -f artex"
} }
# ── ④ 回滚到历史部署快照 ──────────────────────────────────────────────── # ── ④ 回滚到历史部署快照 ────────────────────────────────────────────────
@@ -54,20 +62,21 @@ interactive_rollback(){
require_docker_env require_docker_env
if [ -z "$snap_id" ]; then if [ -z "$snap_id" ]; then
echo "可用的部署回滚快照:" echo "$(msg '可用的部署回滚快照:' 'Available rollback snapshots:')"
list_deploy_snapshots list_deploy_snapshots
local latest="" local latest=""
[ -f "${DEPLOY_STATE_DIR}/latest" ] && latest="$(cat "${DEPLOY_STATE_DIR}/latest")" [ -f "${DEPLOY_STATE_DIR}/latest" ] && latest="$(cat "${DEPLOY_STATE_DIR}/latest")"
[ -n "$latest" ] || die "当前没有任何可回滚的部署快照" [ -n "$latest" ] || die_l "当前没有任何可回滚的部署快照" "No rollback snapshots available"
snap_id="$(ask '要回滚的快照 ID(回车选最新)' "$latest")" snap_id="$(ask_l '要回滚的快照 ID(回车选最新)' 'Snapshot ID to roll back to (Enter for latest)' "$latest")"
fi fi
local snap_dir="${DEPLOY_SNAP_DIR}/${snap_id}" local snap_dir="${DEPLOY_SNAP_DIR}/${snap_id}"
[ -f "${snap_dir}/meta.env" ] || die "快照不存在:${snap_id}" [ -f "${snap_dir}/meta.env" ] || die_l "快照不存在:${snap_id}" "Snapshot not found: ${snap_id}"
if [ "$restore_db" != "1" ] && [ "$(env_get HAS_PG_DUMP "${snap_dir}/meta.env")" = "1" ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then if [ "$restore_db" != "1" ] && [ "$(env_get HAS_PG_DUMP "${snap_dir}/meta.env")" = "1" ] && [ "${ARTEX_NONINTERACTIVE:-0}" != "1" ]; then
warn "当前版本与上一版本数据库结构前向/后向兼容,通常无需覆盖数据库。" warn_l "当前版本与上一版本数据库结构前向/后向兼容,通常无需覆盖数据库。" \
if [ "$(ask '是否同时用快照中的 postgres.sql.gz 覆盖恢复数据库? (y/n)' n)" = "y" ]; then "The database schema is forward/backward compatible; restoring the DB dump is usually unnecessary."
if is_yes "$(ask_l '是否同时用快照中的 postgres.sql.gz 覆盖恢复数据库? (y/n)' 'Also overwrite and restore the database from snapshot postgres.sql.gz? (y/n)' n)"; then
restore_db=1 restore_db=1
fi fi
fi fi
@@ -77,30 +86,36 @@ interactive_rollback(){
# ── ⑤ 本地编译更新 ────────────────────────────────────────────────────── # ── ⑤ 本地编译更新 ──────────────────────────────────────────────────────
update_local(){ update_local(){
command -v go >/dev/null 2>&1 || die "未检测到 Go(>=1.26):https://go.dev/dl/" command -v go >/dev/null 2>&1 || die_l "未检测到 Go(>=1.26):https://go.dev/dl/" \
[ -f config.json ] || warn "未找到 config.json——若首次部署请改用 ./install.sh" "Go (>=1.26) not found: https://go.dev/dl/"
[ -f config.json ] || warn_l "未找到 config.json——若首次部署请改用 ./install.sh" \
"config.json not found -- run ./install.sh for initial setup"
ok "Go: $(go version)" ok "Go: $(go version)"
if [ -x ./artex ]; then if [ -x ./artex ]; then
cp ./artex ./artex.old cp ./artex ./artex.old
ok "已备份当前二进制 → ./artex.old(如需回滚可执行 mv ./artex.old ./artex 后重启)" ok_l "已备份当前二进制 → ./artex.old(如需回滚可执行 mv ./artex.old ./artex 后重启)" \
"Backed up current binary -> ./artex.old (to roll back: mv ./artex.old ./artex and restart)"
fi fi
if command -v npm >/dev/null 2>&1; then if command -v npm >/dev/null 2>&1; then
info "重建前端静态产物…" info_l "重建前端静态产物…" "Rebuilding static frontend assets..."
( cd web && npm ci && npm run build:static ) ( cd web && npm ci && npm run build:static )
rm -rf server/webui/dist && cp -r web/out server/webui/dist rm -rf server/webui/dist && cp -r web/out server/webui/dist
info "重新编译内嵌单二进制…" info_l "重新编译内嵌单二进制…" "Rebuilding embedded single binary..."
CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex CGO_ENABLED=0 go build -tags embedui -trimpath -o artex ./cmd/artex
else else
warn "未检测到 npm:编译**不内嵌前端**的后端(前端需另跑 npm run dev)" warn_l "未检测到 npm:编译**不内嵌前端**的后端(前端需另跑 npm run dev)" \
"npm not found: building backend WITHOUT embedded frontend (run npm run dev separately)"
CGO_ENABLED=0 go build -o artex ./cmd/artex CGO_ENABLED=0 go build -o artex ./cmd/artex
fi fi
ok "编译完成 → ./artex" ok_l "编译完成 → ./artex" "Build complete -> ./artex"
warn "请重启正在运行的 artex 进程以生效(重启时会自动迁移 schema)" warn_l "请重启正在运行的 artex 进程以生效(重启时会自动迁移 schema)" \
"Please restart the running artex process to take effect (schema migrates automatically on startup)"
} }
usage(){ usage(){
if [ "$ARTEX_SCRIPT_LANG" = "zh" ]; then
cat <<'USAGE' cat <<'USAGE'
用法: ./update.sh [动作] [选项] 用法: ./update.sh [动作] [选项]
@@ -111,7 +126,7 @@ usage(){
--local 本地 Go 重新编译更新 --local 本地 Go 重新编译更新
选项: 选项:
--tag <TAG> 指定目标镜像版本 tag(如 v0.3.33 / latest) --tag <TAG> 指定目标镜像版本 tag(如 v0.3.34 / latest)
--restore-db 配合 --rollback 同时恢复快照中的 PostgreSQL 备份 --restore-db 配合 --rollback 同时恢复快照中的 PostgreSQL 备份
--no-db-backup 创建快照时跳过 pg_dump --no-db-backup 创建快照时跳过 pg_dump
--skip-pull 跳过镜像拉取 --skip-pull 跳过镜像拉取
@@ -119,6 +134,26 @@ usage(){
-y, --yes 非交互模式 -y, --yes 非交互模式
-h, --help 显示本帮助 -h, --help 显示本帮助
USAGE USAGE
else
cat <<'USAGE'
Usage: ./update.sh [action] [options]
Actions (opens interactive menu if omitted):
--upgrade Upgrade Docker deployment (creates rollback snapshot)
--rollback [SNAPSHOT_ID] Roll back to the latest or specified snapshot
--list-snapshots List all available rollback snapshots
--local Rebuild and update locally with Go
Options:
--tag <TAG> Target image tag (e.g. v0.3.34 / latest)
--restore-db With --rollback, also restore the snapshot PostgreSQL dump
--no-db-backup Skip pg_dump when creating a snapshot
--skip-pull Skip pulling Docker images
--skip-git-pull Skip git pull
-y, --yes Non-interactive mode
-h, --help Show this help
USAGE
fi
} }
ACTION="" ACTION=""
@@ -139,14 +174,14 @@ while [ "$#" -gt 0 ]; do
;; ;;
--list-snapshots) ACTION="list-snapshots" ;; --list-snapshots) ACTION="list-snapshots" ;;
--local) ACTION="local" ;; --local) ACTION="local" ;;
--tag) shift; [ "$#" -gt 0 ] || die "--tag 需要参数"; OPT_TAG="$1" ;; --tag) shift; [ "$#" -gt 0 ] || die_l "--tag 需要参数" "--tag requires a value"; OPT_TAG="$1" ;;
--restore-db) OPT_RESTORE_DB=1 ;; --restore-db) OPT_RESTORE_DB=1 ;;
--no-db-backup) OPT_SKIP_DB=1 ;; --no-db-backup) OPT_SKIP_DB=1 ;;
--skip-pull) export ARTEX_SKIP_PULL=1 ;; --skip-pull) export ARTEX_SKIP_PULL=1 ;;
--skip-git-pull) export ARTEX_SKIP_GIT_PULL=1 ;; --skip-git-pull) export ARTEX_SKIP_GIT_PULL=1 ;;
-y|--yes) export ARTEX_NONINTERACTIVE=1 ;; -y|--yes) export ARTEX_NONINTERACTIVE=1 ;;
-h|--help) usage; exit 0 ;; -h|--help) usage; exit 0 ;;
*) die "未知参数:$1(使用 --help 查看帮助)" ;; *) die_l "未知参数:$1(使用 --help 查看帮助)" "Unknown option: $1 (use --help for usage)" ;;
esac esac
shift shift
done done
@@ -173,14 +208,14 @@ case "$ACTION" in
esac esac
echo "==========================================" echo "=========================================="
echo " ARTEX 升级与回滚" echo "$(msg ' ARTEX 升级与回滚' ' ARTEX Upgrade & Rollback')"
echo " 1) Docker 升级(自动创建回滚快照)" echo "$(msg ' 1) Docker 升级(自动创建回滚快照)' ' 1) Docker upgrade (auto-creates rollback snapshot)')"
echo " 2) 回滚到历史部署快照" echo "$(msg ' 2) 回滚到历史部署快照' ' 2) Roll back to a previous snapshot')"
echo " 3) 本地更新(Go 重新编译)" echo "$(msg ' 3) 本地更新(Go 重新编译)' ' 3) Local update (rebuild with Go)')"
echo "==========================================" echo "=========================================="
case "$(ask '选择' 1)" in case "$(ask_l '选择' 'Select' 1)" in
1) sync_repo; update_docker "$OPT_TAG" "$OPT_SKIP_DB" ;; 1) sync_repo; update_docker "$OPT_TAG" "$OPT_SKIP_DB" ;;
2) interactive_rollback "$OPT_SNAP" "$OPT_RESTORE_DB" ;; 2) interactive_rollback "$OPT_SNAP" "$OPT_RESTORE_DB" ;;
3) sync_repo; update_local ;; 3) sync_repo; update_local ;;
*) die "无效选择" ;; *) die_l "无效选择" "Invalid selection" ;;
esac esac
+61 -14
View File
@@ -91,8 +91,8 @@ export default function SandboxPage() {
const [saving, setSaving] = React.useState(false); const [saving, setSaving] = React.useState(false);
const [pruning, setPruning] = React.useState(false); const [pruning, setPruning] = React.useState(false);
const [busyKey, setBusyKey] = React.useState<string>(""); const [busyKey, setBusyKey] = React.useState<string>("");
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.34"); const [upgradeTag, setUpgradeTag] = React.useState("v0.3.35");
const [copiedUpgradeCmd, setCopiedUpgradeCmd] = React.useState(false); const [copiedCmd, setCopiedCmd] = React.useState<"" | "git" | "sync">("");
// Filters // Filters
const [scopeFilter, setScopeFilter] = React.useState<"all" | "task" | "session">("all"); const [scopeFilter, setScopeFilter] = React.useState<"all" | "task" | "session">("all");
const [stateFilter, setStateFilter] = React.useState<"all" | "running" | "stopped">("all"); const [stateFilter, setStateFilter] = React.useState<"all" | "running" | "stopped">("all");
@@ -184,14 +184,25 @@ export default function SandboxPage() {
}); });
}, []); }, []);
const upgradeCommand = `git pull\n./update.sh --upgrade --tag ${upgradeTag}`; const gitUpgradeCommand = `git pull --ff-only && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
const syncUpgradeCommand = [
"(",
" set -e",
" mkdir -p scripts",
" if [ -f docker-compose.yml ]; then cp docker-compose.yml docker-compose.yml.bak; fi",
" for f in docker-compose.yml update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh; do",
` curl -fsSL "https://raw.githubusercontent.com/RuoJi6/ARTEX/${upgradeTag}/$f" -o "$f"`,
" done",
" chmod +x update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh",
`) && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`,
].join("\n");
const handleCopyUpgradeCommand = async () => { const handleCopyUpgradeCommand = async (kind: "git" | "sync", cmd: string) => {
try { try {
await navigator.clipboard.writeText(upgradeCommand); await navigator.clipboard.writeText(cmd);
setCopiedUpgradeCmd(true); setCopiedCmd(kind);
toast.success(L("升级命令已复制", "Upgrade command copied")); toast.success(L("升级命令已复制", "Upgrade command copied"));
window.setTimeout(() => setCopiedUpgradeCmd(false), 2000); window.setTimeout(() => setCopiedCmd((prev) => (prev === kind ? "" : prev)), 2000);
} catch { } catch {
toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually")); toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually"));
} }
@@ -440,32 +451,68 @@ export default function SandboxPage() {
)} )}
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent className="space-y-3"> <CardContent className="space-y-3.5">
<div className="space-y-1.5">
<p className="font-medium text-foreground text-xs">
{L("方式一:git clone 部署目录", "Option 1: Git clone deployment")}
</p>
<div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5"> <div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5">
<div className="flex min-w-0 items-start gap-2.5"> <div className="flex min-w-0 items-start gap-2.5">
<TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" /> <TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed"> <pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed">
<code>{upgradeCommand}</code> <code>{gitUpgradeCommand}</code>
</pre> </pre>
</div> </div>
<Button <Button
size="sm" size="sm"
variant="outline" variant="outline"
className="h-7 shrink-0 gap-1.5 px-2.5 text-xs" className="h-7 shrink-0 gap-1.5 px-2.5 text-xs"
onClick={() => void handleCopyUpgradeCommand()} onClick={() => void handleCopyUpgradeCommand("git", gitUpgradeCommand)}
> >
{copiedUpgradeCmd ? ( {copiedCmd === "git" ? (
<CheckIcon className="size-3.5 text-emerald-500" /> <CheckIcon className="size-3.5 text-emerald-500" />
) : ( ) : (
<CopyIcon className="size-3.5" /> <CopyIcon className="size-3.5" />
)} )}
{copiedUpgradeCmd ? L("已复制", "Copied") : L("复制命令", "Copy")} {copiedCmd === "git" ? L("已复制", "Copied") : L("复制命令", "Copy")}
</Button> </Button>
</div> </div>
</div>
<div className="space-y-1.5">
<p className="font-medium text-foreground text-xs">
{L(
"方式二:非 git 部署目录(仅含 docker-compose.yml 与 .env,自动备份并同步新版编排与脚本)",
"Option 2: Non-Git deployment (backs up docker-compose.yml and syncs latest compose & scripts)",
)}
</p>
<div className="flex items-start justify-between gap-3 rounded-md border bg-background px-3.5 py-2.5">
<div className="flex min-w-0 items-start gap-2.5">
<TerminalIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
<pre className="overflow-x-auto font-mono text-foreground text-xs leading-relaxed">
<code>{syncUpgradeCommand}</code>
</pre>
</div>
<Button
size="sm"
variant="outline"
className="h-7 shrink-0 gap-1.5 px-2.5 text-xs"
onClick={() => void handleCopyUpgradeCommand("sync", syncUpgradeCommand)}
>
{copiedCmd === "sync" ? (
<CheckIcon className="size-3.5 text-emerald-500" />
) : (
<CopyIcon className="size-3.5" />
)}
{copiedCmd === "sync" ? L("已复制", "Copied") : L("复制命令", "Copy")}
</Button>
</div>
</div>
<p className="text-muted-foreground text-xs leading-relaxed"> <p className="text-muted-foreground text-xs leading-relaxed">
{L( {L(
`升级会保留原有 PostgreSQL 数据、./data 与 ./skills,切换后无法回滚但会显著提高运行安全性。若非 git clone 部署,请先同步最新 docker-compose.yml、update.sh 与 scripts/ 后再执行 ./update.sh --upgrade --tag ${upgradeTag};完成后刷新本页即可进入 Docker 沙箱模式。`, "升级会保留原有 PostgreSQL 数据、./data 与 ./skills,并启动 4 个服务容器(postgres、docker-socket-proxy、artex、artex-gateway)。切换后无法回滚但会显著提高运行安全性;完成后刷新本页即可进入 Docker 沙箱模式。",
`Preserves PostgreSQL data, ./data, and ./skills. This switch is irreversible but significantly improves isolation security. If not deployed via git clone, sync the latest docker-compose.yml, update.sh, and scripts/ first, then run ./update.sh --upgrade --tag ${upgradeTag} and refresh this page.`, "Preserves PostgreSQL data, ./data, and ./skills, and starts 4 services (postgres, docker-socket-proxy, artex, artex-gateway). This switch is irreversible but significantly improves isolation security; refresh this page after upgrading.",
)} )}
</p> </p>
</CardContent> </CardContent>
@@ -56,8 +56,8 @@ export function SandboxCard() {
const [saving, setSaving] = React.useState(false); const [saving, setSaving] = React.useState(false);
const [pruning, setPruning] = React.useState(false); const [pruning, setPruning] = React.useState(false);
const [busyKey, setBusyKey] = React.useState(""); const [busyKey, setBusyKey] = React.useState("");
const [upgradeTag, setUpgradeTag] = React.useState("v0.3.34"); const [upgradeTag, setUpgradeTag] = React.useState("v0.3.35");
const [copiedUpgradeCmd, setCopiedUpgradeCmd] = React.useState(false); const [copiedCmd, setCopiedCmd] = React.useState<"" | "git" | "sync">("");
const [image, setImage] = React.useState(""); const [image, setImage] = React.useState("");
const [memoryMB, setMemoryMB] = React.useState("2048"); const [memoryMB, setMemoryMB] = React.useState("2048");
const [cpus, setCpus] = React.useState("2"); const [cpus, setCpus] = React.useState("2");
@@ -120,14 +120,15 @@ export function SandboxCard() {
}); });
}, []); }, []);
const upgradeCommand = `git pull && ./update.sh --upgrade --tag ${upgradeTag}`; const gitUpgradeCommand = `git pull --ff-only && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
const syncUpgradeCommand = `(set -e; mkdir -p scripts; if [ -f docker-compose.yml ]; then cp docker-compose.yml docker-compose.yml.bak; fi; for f in docker-compose.yml update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh; do curl -fsSL "https://raw.githubusercontent.com/RuoJi6/ARTEX/${upgradeTag}/$f" -o "$f"; done; chmod +x update.sh scripts/deploy-lib.sh scripts/artex-sandbox-firewall.sh) && ./update.sh --upgrade --tag ${upgradeTag} --skip-git-pull`;
const handleCopyUpgradeCommand = async () => { const handleCopyUpgradeCommand = async (kind: "git" | "sync", cmd: string) => {
try { try {
await navigator.clipboard.writeText(upgradeCommand); await navigator.clipboard.writeText(cmd);
setCopiedUpgradeCmd(true); setCopiedCmd(kind);
toast.success(L("升级命令已复制", "Upgrade command copied")); toast.success(L("升级命令已复制", "Upgrade command copied"));
window.setTimeout(() => setCopiedUpgradeCmd(false), 2000); window.setTimeout(() => setCopiedCmd((prev) => (prev === kind ? "" : prev)), 2000);
} catch { } catch {
toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually")); toast.error(L("复制失败,请手动复制命令", "Copy failed, please copy manually"));
} }
@@ -280,33 +281,62 @@ export function SandboxCard() {
) : null} ) : null}
{status && !status.enabled ? ( {status && !status.enabled ? (
<div className="space-y-2 rounded-md border border-amber-500/40 bg-amber-500/5 p-3"> <div className="space-y-2.5 rounded-md border border-amber-500/40 bg-amber-500/5 p-3">
<p className="text-muted-foreground text-xs"> <p className="text-muted-foreground text-xs">
{L( {L(
"在宿主机原部署目录执行以下命令升级至沙箱隔离版(保留数据库、./data 与 ./skills):", "在宿主机原部署目录执行以下命令升级至沙箱隔离版(保留数据库、./data 与 ./skills,需同步新版 docker-compose.yml):",
"Run the following command on the host deployment directory to upgrade to the sandbox edition (preserves DB, ./data, and ./skills):", "Run one of the commands below in your host deployment directory to upgrade to the sandbox edition (preserves DB, ./data, and ./skills; requires latest docker-compose.yml):",
)} )}
</p> </p>
<div className="space-y-1">
<p className="font-medium text-foreground text-[11px]">
{L("Git clone 部署目录", "Git clone deployment")}
</p>
<div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2"> <div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2">
<div className="flex min-w-0 items-center gap-2"> <div className="flex min-w-0 items-center gap-2">
<TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" /> <TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" />
<code className="overflow-x-auto font-mono text-foreground text-xs">{upgradeCommand}</code> <code className="overflow-x-auto font-mono text-foreground text-xs">{gitUpgradeCommand}</code>
</div> </div>
<Button <Button
size="sm" size="sm"
variant="outline" variant="outline"
className="h-7 shrink-0 gap-1 px-2 text-xs" className="h-7 shrink-0 gap-1 px-2 text-xs"
onClick={() => void handleCopyUpgradeCommand()} onClick={() => void handleCopyUpgradeCommand("git", gitUpgradeCommand)}
> >
{copiedUpgradeCmd ? ( {copiedCmd === "git" ? (
<CheckIcon className="size-3.5 text-emerald-500" /> <CheckIcon className="size-3.5 text-emerald-500" />
) : ( ) : (
<CopyIcon className="size-3.5" /> <CopyIcon className="size-3.5" />
)} )}
{copiedUpgradeCmd ? L("已复制", "Copied") : L("复制", "Copy")} {copiedCmd === "git" ? L("已复制", "Copied") : L("复制", "Copy")}
</Button> </Button>
</div> </div>
</div> </div>
<div className="space-y-1">
<p className="font-medium text-foreground text-[11px]">
{L("非 Git 部署目录(自动同步编排与脚本)", "Non-Git deployment (syncs compose & scripts)")}
</p>
<div className="flex items-center justify-between gap-2 rounded border bg-background px-3 py-2">
<div className="flex min-w-0 items-center gap-2">
<TerminalIcon className="size-3.5 shrink-0 text-muted-foreground" />
<code className="overflow-x-auto font-mono text-foreground text-xs">{syncUpgradeCommand}</code>
</div>
<Button
size="sm"
variant="outline"
className="h-7 shrink-0 gap-1 px-2 text-xs"
onClick={() => void handleCopyUpgradeCommand("sync", syncUpgradeCommand)}
>
{copiedCmd === "sync" ? (
<CheckIcon className="size-3.5 text-emerald-500" />
) : (
<CopyIcon className="size-3.5" />
)}
{copiedCmd === "sync" ? L("已复制", "Copied") : L("复制", "Copy")}
</Button>
</div>
</div>
</div>
) : null} ) : null}
{status?.enabled ? ( {status?.enabled ? (
@@ -56,6 +56,7 @@ export function UpdateCard() {
const { t, liveT } = useLiveTranslation(); const { t, liveT } = useLiveTranslation();
const [info, setInfo] = React.useState<UpdateCheck | null>(null); const [info, setInfo] = React.useState<UpdateCheck | null>(null);
const [checking, setChecking] = React.useState(true); const [checking, setChecking] = React.useState(true);
const [sandboxEnabled, setSandboxEnabled] = React.useState<boolean | null>(null);
const [confirmOpen, setConfirmOpen] = React.useState(false); const [confirmOpen, setConfirmOpen] = React.useState(false);
const [progress, setProgress] = React.useState<UpdateProgress | null>(null); const [progress, setProgress] = React.useState<UpdateProgress | null>(null);
// 与 progress 分开:暂存完成后进程就没了,SSE 会断,此时要切到轮询 /api/version。 // 与 progress 分开:暂存完成后进程就没了,SSE 会断,此时要切到轮询 /api/version。
@@ -86,6 +87,21 @@ export function UpdateCard() {
}; };
}, []); }, []);
React.useEffect(() => {
let active = true;
api
.sandboxStatus(false)
.then((st) => {
if (active) setSandboxEnabled(Boolean(st.enabled));
})
.catch(() => {
// keep null if sandbox status is unavailable
});
return () => {
active = false;
};
}, []);
React.useEffect(() => () => streamRef.current?.close(), []); React.useEffect(() => () => streamRef.current?.close(), []);
// quiet 同时决定要不要绕过后端缓存:进页面时的自动检查用缓存(顶栏刚查过), // quiet 同时决定要不要绕过后端缓存:进页面时的自动检查用缓存(顶栏刚查过),
@@ -458,6 +474,7 @@ export function UpdateCard() {
<AlertDialogDescription asChild> <AlertDialogDescription asChild>
<div className="space-y-2.5 text-left"> <div className="space-y-2.5 text-left">
<p>{t("settings.updateInterruptWarning")}</p> <p>{t("settings.updateInterruptWarning")}</p>
{info?.mode === "docker" && sandboxEnabled === false && (
<div className="space-y-1 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-amber-800 text-xs dark:text-amber-300"> <div className="space-y-1 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-amber-800 text-xs dark:text-amber-300">
<p className="flex items-center gap-1.5 font-medium"> <p className="flex items-center gap-1.5 font-medium">
<ShieldCheckIcon className="size-4 shrink-0" /> <ShieldCheckIcon className="size-4 shrink-0" />
@@ -465,6 +482,7 @@ export function UpdateCard() {
</p> </p>
<p className="leading-relaxed">{t("settings.standaloneToSandboxWarning")}</p> <p className="leading-relaxed">{t("settings.standaloneToSandboxWarning")}</p>
</div> </div>
)}
{info?.mode === "docker" && ( {info?.mode === "docker" && (
<p className="text-muted-foreground text-xs">{t("settings.dockerUpdateWarning")}</p> <p className="text-muted-foreground text-xs">{t("settings.dockerUpdateWarning")}</p>
)} )}