feat : preparation de postgresql (WIP)
This commit is contained in:
@@ -45,6 +45,26 @@ require_cmd() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collect_postgres_diagnostics() {
|
||||||
|
local diagnostics=""
|
||||||
|
|
||||||
|
if "$SUDO_BIN" systemctl status "$POSTGRES_SERVICE_NAME" --no-pager >/dev/null 2>&1; then
|
||||||
|
diagnostics+="systemctl status ${POSTGRES_SERVICE_NAME}: OK; "
|
||||||
|
elif require_cmd systemctl; then
|
||||||
|
diagnostics+="systemctl status ${POSTGRES_SERVICE_NAME}: $( "$SUDO_BIN" systemctl status "$POSTGRES_SERVICE_NAME" --no-pager 2>/dev/null | tail -n 5 | tr '\n' ' ' ); "
|
||||||
|
fi
|
||||||
|
|
||||||
|
if require_cmd pg_lsclusters; then
|
||||||
|
diagnostics+="pg_lsclusters: $(pg_lsclusters --no-header 2>/dev/null | tr '\n' ' '); "
|
||||||
|
fi
|
||||||
|
|
||||||
|
if require_cmd journalctl; then
|
||||||
|
diagnostics+="journalctl: $( "$SUDO_BIN" journalctl -u "$POSTGRES_SERVICE_NAME" -n 10 --no-pager 2>/dev/null | tr '\n' ' ' ); "
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s' "${diagnostics% }"
|
||||||
|
}
|
||||||
|
|
||||||
start_postgres_service() {
|
start_postgres_service() {
|
||||||
if "$SUDO_BIN" systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1; then
|
if "$SUDO_BIN" systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1; then
|
||||||
return 0
|
return 0
|
||||||
@@ -116,7 +136,9 @@ fi
|
|||||||
|
|
||||||
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..."
|
||||||
start_postgres_service || fail "impossible de démarrer PostgreSQL"
|
if ! start_postgres_service; then
|
||||||
|
fail "impossible de démarrer PostgreSQL. $(collect_postgres_diagnostics)"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log "Service PostgreSQL déjà actif."
|
log "Service PostgreSQL déjà actif."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user