feat : preparation de postgresql (WIP)
This commit is contained in:
@@ -45,6 +45,28 @@ require_cmd() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_postgres_service() {
|
||||||
|
if "$SUDO_BIN" systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if require_cmd service && "$SUDO_BIN" service "$POSTGRES_SERVICE_NAME" start >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if require_cmd pg_lsclusters && require_cmd pg_ctlcluster; then
|
||||||
|
local version cluster
|
||||||
|
while read -r version cluster _; do
|
||||||
|
[[ -n "$version" && -n "$cluster" ]] || continue
|
||||||
|
if "$SUDO_BIN" pg_ctlcluster "$version" "$cluster" start >/dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done < <(pg_lsclusters --no-header 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
[[ -f "$ENV_FILE" ]] || fail "fichier .env introuvable : $ENV_FILE"
|
[[ -f "$ENV_FILE" ]] || fail "fichier .env introuvable : $ENV_FILE"
|
||||||
|
|
||||||
set -a
|
set -a
|
||||||
@@ -94,7 +116,7 @@ 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..."
|
||||||
"$SUDO_BIN" systemctl start "$POSTGRES_SERVICE_NAME" >/dev/null 2>&1 || fail "impossible de démarrer PostgreSQL"
|
start_postgres_service || fail "impossible de démarrer PostgreSQL"
|
||||||
else
|
else
|
||||||
log "Service PostgreSQL déjà actif."
|
log "Service PostgreSQL déjà actif."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user