respect du standard pour l'installation de postgres
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
create_pg_db.sh
|
||||
create_pg_role.sh
|
||||
setup-postgres17.sh
|
||||
setup-postgres.sh
|
||||
|
||||
@@ -9,18 +9,32 @@ check_root
|
||||
|
||||
set -e
|
||||
|
||||
echo "Ajout du dépôt officiel PostgreSQL 17..."
|
||||
mkdir -p /etc/apt/keyrings
|
||||
wget -qO /etc/apt/keyrings/postgresql.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc
|
||||
chmod 644 /etc/apt/keyrings/postgresql.asc
|
||||
|
||||
echo "deb [signed-by=/etc/apt/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
echo "Installation de PostgreSQL 17..."
|
||||
echo "📦 Mise à jour des paquets..."
|
||||
apt update -y
|
||||
apt install -y postgresql-17
|
||||
|
||||
echo "Activation et démarrage du service PostgreSQL..."
|
||||
echo "📚 Installation de postgresql-common (pour script de dépôt officiel)..."
|
||||
apt install -y postgresql-common
|
||||
|
||||
echo "➕ Ajout automatique du dépôt officiel PostgreSQL (via pgdg script)..."
|
||||
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
|
||||
|
||||
echo ""
|
||||
echo "🧩 Versions disponibles dans le dépôt :"
|
||||
AVAILABLE_VERSIONS=$(apt-cache search "^postgresql-[0-9][0-9]$" | awk '{print $1}' | cut -d'-' -f2 | sort -nr)
|
||||
echo "$AVAILABLE_VERSIONS"
|
||||
|
||||
read -p "➡️ Entrez la version PostgreSQL à installer (ex: 17) : " PG_VERSION
|
||||
|
||||
if ! echo "$AVAILABLE_VERSIONS" | grep -q "^${PG_VERSION}$"; then
|
||||
echo "❌ Version PostgreSQL invalide ou non disponible : ${PG_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Installation de PostgreSQL $PG_VERSION..."
|
||||
apt update -y
|
||||
apt install -y "postgresql-${PG_VERSION}"
|
||||
|
||||
echo "🚀 Activation et démarrage du service PostgreSQL..."
|
||||
systemctl enable postgresql
|
||||
systemctl start postgresql
|
||||
|
||||
@@ -48,14 +62,14 @@ echo "🔧 Configuration du mot de passe de l'utilisateur postgres..."
|
||||
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
|
||||
|
||||
echo "🔧 Configuration de l'accès local en md5..."
|
||||
PG_HBA="/etc/postgresql/17/main/pg_hba.conf"
|
||||
PG_HBA="/etc/postgresql/${PG_VERSION}/main/pg_hba.conf"
|
||||
sed -i "s/^\(local\s\+all\s\+postgres\s\+\)peer/\1md5/" "$PG_HBA"
|
||||
|
||||
echo "♻️ Redémarrage de PostgreSQL pour appliquer les changements..."
|
||||
systemctl restart postgresql
|
||||
|
||||
echo ""
|
||||
echo "✅ Installation terminée."
|
||||
echo "✅ Installation de PostgreSQL ${PG_VERSION} terminée."
|
||||
echo "-------------------------------------------"
|
||||
echo " Mot de passe de l'utilisateur postgres :"
|
||||
echo " ${POSTGRES_PASSWORD}"
|
||||
Reference in New Issue
Block a user