Files
Agent-System-Dev/docker/verify-env.sh
T

51 lines
2.0 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
fail_expect() {
local expected="$1"
local actual="$2"
echo "校验失败: 期望: ${expected}"
echo "校验失败: 实际: ${actual}"
exit 1
}
command -v git >/dev/null 2>&1 || fail_expect "git 可执行文件存在" "git 不存在"
command -v make >/dev/null 2>&1 || fail_expect "make 可执行文件存在" "make 不存在"
go_version="$(go version 2>&1 || true)"
[[ "${go_version}" == *"go1.27.1"* ]] || fail_expect "go version 输出包含 go1.27.1" "${go_version}"
node_version="$(node --version 2>&1 || true)"
[[ "${node_version}" == "v26.10.0" ]] || fail_expect "v26.10.0" "${node_version}"
npm_version="$(npm --version 2>&1 || true)"
[[ -n "${npm_version}" ]] || fail_expect "npm --version 有输出" "空输出"
python_version="$(python3 --version 2>&1 || true)"
[[ "${python_version}" =~ ^Python\ 3\.14\.[0-9]+$ ]] || fail_expect "Python 3.14.x" "${python_version}"
if ! sshd_output="$(sshd -t 2>&1)"; then
fail_expect "sshd -t 检查通过" "${sshd_output}"
fi
id dev >/dev/null 2>&1 || fail_expect "用户 dev 存在" "用户 dev 不存在"
sudo_list="$(sudo -l -U dev 2>&1 || true)"
echo "${sudo_list}" | grep -q "NOPASSWD" || fail_expect "sudo -l -U dev 含 NOPASSWD" "${sudo_list}"
if [ "${PLAYWRIGHT_BROWSERS_PATH:-}" != "/opt/ms-playwright" ]; then
fail_expect "PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright" "${PLAYWRIGHT_BROWSERS_PATH:-<未设置>}"
fi
chromium_path="$(
find /opt/ms-playwright -type f \( -name headless_shell -o -name chrome \) 2>/dev/null | head -n 1
)"
[ -n "${chromium_path}" ] || fail_expect "在 /opt/ms-playwright 下存在 headless_shell 或 chrome" "未找到可执行文件"
[ -x "${chromium_path}" ] || fail_expect "chromium 可执行文件具有执行权限" "${chromium_path} 不可执行"
chromium_dom="$("${chromium_path}" --headless --no-sandbox --disable-gpu --dump-dom about:blank 2>&1 || true)"
echo "${chromium_dom}" | grep -q "<html" || fail_expect "chromium --dump-dom 输出包含 <html" "${chromium_dom}"
echo "verify-env: PASS"