feat : preparation de postgresql (WIP)
This commit is contained in:
@@ -45,6 +45,31 @@ require_cmd() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure_postgres_cluster() {
|
||||||
|
if ! require_cmd pg_lsclusters || ! require_cmd pg_createcluster; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if pg_lsclusters --no-header 2>/dev/null | grep -q .; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local version=""
|
||||||
|
if [[ -d /etc/postgresql ]]; then
|
||||||
|
version="$(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | LC_ALL=C sort -V | tail -n 1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$version" ]] && require_cmd psql; then
|
||||||
|
version="$(psql --version 2>/dev/null | awk '{print $3}' | cut -d. -f1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$version" ]] || return 1
|
||||||
|
|
||||||
|
log "Aucun cluster PostgreSQL détecté, création de ${version}/main..."
|
||||||
|
"$SUDO_BIN" pg_createcluster "$version" main --start >/dev/null 2>&1 || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
collect_postgres_diagnostics() {
|
collect_postgres_diagnostics() {
|
||||||
local diagnostics=""
|
local diagnostics=""
|
||||||
|
|
||||||
@@ -134,6 +159,8 @@ else
|
|||||||
log "PostgreSQL déjà installé."
|
log "PostgreSQL déjà installé."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ensure_postgres_cluster || fail "aucun cluster PostgreSQL disponible et création automatique impossible"
|
||||||
|
|
||||||
if ! "$SUDO_BIN" systemctl is-active --quiet "$POSTGRES_SERVICE_NAME"; then
|
if ! "$SUDO_BIN" systemctl is-active --quiet "$POSTGRES_SERVICE_NAME"; then
|
||||||
log "Démarrage du service PostgreSQL..."
|
log "Démarrage du service PostgreSQL..."
|
||||||
if ! start_postgres_service; then
|
if ! start_postgres_service; then
|
||||||
|
|||||||
Reference in New Issue
Block a user