#!/usr/bin/env bash # 安装/更新 Agent 的共享运行环境(系统工具、Python venv、Node 包、字体配置),可重复执行。 # 运行环境位于 /srv/agent-server/runtime,root 所有、服务只读。用法:sudo deploy/setup-runtime.sh set -euo pipefail cd "$(dirname "$0")/.." RT=/srv/agent-server/runtime [ "$(id -u)" = 0 ] || { echo "请用 sudo 运行" >&2; exit 1; } apt-get install -y -qq bubblewrap socat ripgrep pandoc poppler-utils qpdf libreoffice-core libreoffice-writer libreoffice-calc libreoffice-impress \ fonts-noto-cjk tesseract-ocr tesseract-ocr-chi-sim python3-venv >/dev/null install -d -m 0755 "$RT" [ -x "$RT/py/bin/python" ] || python3 -m venv "$RT/py" "$RT/py/bin/pip" install -q --upgrade pip "$RT/py/bin/pip" install -q -r deploy/runtime/requirements.txt install -d -m 0755 "$RT/node" install -m 0644 deploy/runtime/package.json "$RT/node/package.json" npm --prefix "$RT/node" install --omit=dev --no-audit --no-fund --loglevel=error install -m 0644 deploy/runtime/matplotlibrc "$RT/matplotlibrc" chown -R root:root "$RT" chmod -R a+rX "$RT" echo "运行环境已就绪:$RT"