clouddreamai-cicd-setup 1.5.36 → 1.5.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/scripts/deploy.sh +31 -0
package/package.json
CHANGED
|
@@ -369,6 +369,37 @@ create_database() {
|
|
|
369
369
|
return
|
|
370
370
|
fi
|
|
371
371
|
|
|
372
|
+
# 配置 PostgreSQL 允许 Docker 容器连接
|
|
373
|
+
local PG_CONF="/www/server/pgsql/data/postgresql.conf"
|
|
374
|
+
local PG_HBA="/www/server/pgsql/data/pg_hba.conf"
|
|
375
|
+
local PG_RESTART_NEEDED=false
|
|
376
|
+
|
|
377
|
+
if [ -f "$PG_CONF" ]; then
|
|
378
|
+
# 检查是否已配置监听所有地址
|
|
379
|
+
if ! grep -q "^listen_addresses = '\*'" "$PG_CONF"; then
|
|
380
|
+
echo "配置 PostgreSQL 监听所有地址..."
|
|
381
|
+
sed -i "s/^#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
|
|
382
|
+
sed -i "s/^listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
|
|
383
|
+
PG_RESTART_NEEDED=true
|
|
384
|
+
fi
|
|
385
|
+
fi
|
|
386
|
+
|
|
387
|
+
if [ -f "$PG_HBA" ]; then
|
|
388
|
+
# 检查是否已允许 Docker 网络连接
|
|
389
|
+
if ! grep -q "172.17.0.0/16" "$PG_HBA"; then
|
|
390
|
+
echo "配置 PostgreSQL 允许 Docker 容器连接..."
|
|
391
|
+
echo "host all all 172.17.0.0/16 md5" >> "$PG_HBA"
|
|
392
|
+
PG_RESTART_NEEDED=true
|
|
393
|
+
fi
|
|
394
|
+
fi
|
|
395
|
+
|
|
396
|
+
if [ "$PG_RESTART_NEEDED" = true ]; then
|
|
397
|
+
echo "重启 PostgreSQL 服务..."
|
|
398
|
+
systemctl restart postgresql 2>/dev/null || /etc/init.d/postgresql restart 2>/dev/null || sudo -u postgres /www/server/pgsql/bin/pg_ctl reload -D /www/server/pgsql/data 2>/dev/null || true
|
|
399
|
+
sleep 2
|
|
400
|
+
echo "✓ PostgreSQL 配置已更新"
|
|
401
|
+
fi
|
|
402
|
+
|
|
372
403
|
# 使用 sudo -u postgres 执行,利用 peer 认证无需密码
|
|
373
404
|
# 检查并创建用户
|
|
374
405
|
if ! sudo -u postgres $PSQL_CMD -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1; then
|