Files
gsfdc/deploy/bootstrap-host.sh
T
wuzilongandCursor 9c7c80e194 feat: 把估价智能体和部署配置提交到主分支
门户估价对话、会员与智能体账号,以及生产 Docker 部署一直停在工作区,远端主分支还没有这些改动。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 09:42:44 +08:00

63 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# 只在 CentOS 服务器上执行。不格式化磁盘。
set -euo pipefail
if [[ "$(id -u)" -ne 0 ]]; then
echo "需要 root"
exit 1
fi
if [[ ! -f /etc/os-release ]] || ! grep -Eq 'CentOS Stream|centos' /etc/os-release; then
echo "这个脚本只在 CentOS 服务器上执行"
exit 1
fi
if ! swapon --show | grep -q .; then
if [[ ! -f /swapfile ]]; then
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
fi
swapon /swapfile || true
grep -q '/swapfile' /etc/fstab || echo '/swapfile none swap sw 0 0' >> /etc/fstab
fi
cat > /etc/sysctl.d/99-gsfdc.conf <<'EOF'
vm.swappiness=10
vm.overcommit_memory=1
net.core.somaxconn=1024
EOF
sysctl --system >/dev/null || true
if ! command -v docker >/dev/null 2>&1; then
dnf -y install dnf-plugins-core
dnf config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
if [[ ! -f /etc/docker/daemon.json ]]; then
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<'EOF'
{
"registry-mirrors": ["https://docker.1ms.run", "https://docker.m.daocloud.io"],
"log-driver": "json-file",
"log-opts": {"max-size": "10m", "max-file": "3"},
"live-restore": true
}
EOF
fi
systemctl enable --now docker
if mountpoint -q /data; then
mkdir -p /data/gsfdc
echo "数据盘已挂在 /data。生成配置时使用 DATA_ROOT=/data/gsfdc"
else
echo "没有挂载 /data。先不要格式化磁盘。用 lsblk 确认数据盘后,再决定挂载点。"
echo "在此之前数据放在部署目录的 data/。"
fi
if systemctl is-active --quiet firewalld; then
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
fi
echo "主机准备完成。接下来在部署目录执行 docker load 和 ./up.sh"