netgescon-day0/scripts/ops/setup_postgresql.sh

24 lines
888 B
Bash
Executable File

#!/usr/bin/env bash
set -e
echo "=== Installazione ed Inizializzazione Server DB PostgreSQL per NetGescon ==="
# 1. Installazione pacchetti sistema
apt-get update
apt-get install -y postgresql postgresql-contrib php-pgsql
# 2. Avvio e abilitazione servizio PostgreSQL
systemctl enable postgresql
systemctl start postgresql
# 3. Creazione Database e Utente NetGescon
sudo -u postgres psql -c "CREATE DATABASE netgescon;" || true
sudo -u postgres psql -c "CREATE USER netgescon WITH PASSWORD 'netgescon_pass';" || true
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netgescon TO netgescon;" || true
sudo -u postgres psql -d netgescon -c "GRANT ALL ON SCHEMA public TO netgescon;" || true
# 4. Riavvio eventuale servizio PHP-FPM / Web server
systemctl restart php*-fpm 2>/dev/null || true
echo "=== INSTALLAZIONE ED INIZIALIZZAZIONE POSTGRESQL COMPLETATA CON SUCCESSO ==="