fix(setup): noble 上跳过添加 MongoDB APT 源并清理源文件,强制回退到 Docker 部署
This commit is contained in:
7
setup.sh
7
setup.sh
@@ -15,7 +15,7 @@ apt-get install -y python3 python3-venv python3-pip git ffmpeg rsync curl gnupg
|
|||||||
echo "安装并启动 MongoDB..."
|
echo "安装并启动 MongoDB..."
|
||||||
MONGO_READY=false
|
MONGO_READY=false
|
||||||
if ! command -v mongod >/dev/null 2>&1; then
|
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
|
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
|
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
|
if apt-get update -y; then
|
||||||
@@ -25,7 +25,8 @@ if ! command -v mongod >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$MONGO_READY" = false ]; then
|
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
|
apt-get install -y docker.io
|
||||||
systemctl enable --now docker || true
|
systemctl enable --now docker || true
|
||||||
mkdir -p /var/lib/mongo
|
mkdir -p /var/lib/mongo
|
||||||
@@ -43,7 +44,7 @@ if ! command -v mongod >/dev/null 2>&1; then
|
|||||||
else
|
else
|
||||||
MONGO_READY=true
|
MONGO_READY=true
|
||||||
fi
|
fi
|
||||||
if [ "$MONGO_READY" = true ]; then
|
if [ "$MONGO_READY" = true ] && systemctl list-unit-files | grep -q '^mongod\.service'; then
|
||||||
systemctl enable mongod || true
|
systemctl enable mongod || true
|
||||||
systemctl restart mongod || systemctl start mongod || true
|
systemctl restart mongod || systemctl start mongod || true
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user