From c40b0ed998c34aeed423f3c2eff3f79b77784d7b Mon Sep 17 00:00:00 2001 From: AnthonyDuan Date: Sat, 22 Nov 2025 21:49:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(setup):=20noble=20=E4=B8=8A=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E6=B7=BB=E5=8A=A0=20MongoDB=20APT=20=E6=BA=90?= =?UTF-8?q?=E5=B9=B6=E6=B8=85=E7=90=86=E6=BA=90=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E5=9B=9E=E9=80=80=E5=88=B0=20Docker=20?= =?UTF-8?q?=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 6308efc..d464002 100644 --- a/setup.sh +++ b/setup.sh @@ -15,7 +15,7 @@ apt-get install -y python3 python3-venv python3-pip git ffmpeg rsync curl gnupg echo "安装并启动 MongoDB..." MONGO_READY=false if ! command -v mongod >/dev/null 2>&1; then - if [ -n "$CODENAME" ]; then + if [ -n "$CODENAME" ] && echo "$CODENAME" | grep -Eq '^(focal|jammy)$'; then curl -fsSL https://pgp.mongodb.com/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg || true echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu ${CODENAME}/mongodb-org/7.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-7.0.list || true if apt-get update -y; then @@ -25,7 +25,8 @@ if ! command -v mongod >/dev/null 2>&1; then fi fi if [ "$MONGO_READY" = false ]; then - echo "APT 仓库不可用,改用 Docker 部署 MongoDB..." + echo "APT 仓库不可用或版本不支持,改用 Docker 部署 MongoDB..." + rm -f /etc/apt/sources.list.d/mongodb-org-7.0.list || true apt-get install -y docker.io systemctl enable --now docker || true mkdir -p /var/lib/mongo @@ -43,7 +44,7 @@ if ! command -v mongod >/dev/null 2>&1; then else MONGO_READY=true fi -if [ "$MONGO_READY" = true ]; then +if [ "$MONGO_READY" = true ] && systemctl list-unit-files | grep -q '^mongod\.service'; then systemctl enable mongod || true systemctl restart mongod || systemctl start mongod || true fi