diff --git a/setup_database.sh b/setup_database.sh index 626eaa4..8b301c1 100755 --- a/setup_database.sh +++ b/setup_database.sh @@ -17,12 +17,12 @@ sudo sed -i "s/^#listen_addresses =.*/listen_addresses = '*'/" "$PG_CONF" echo "[3] Updating pg_hba.conf for LAN + localhost access…" PG_HBA="/etc/postgresql/$(ls /etc/postgresql)/main/pg_hba.conf" -# Add localhost entry if missing +# Add localhost if ! grep -Eq "^[ ]*host[ ]+all[ ]+all[ ]+127.0.0.1/32" "$PG_HBA"; then echo "host all all 127.0.0.1/32 md5" | sudo tee -a "$PG_HBA" fi -# Add LAN entry if missing +# Add LAN if ! grep -q "$LAN_SUBNET" "$PG_HBA"; then echo "host all all $LAN_SUBNET md5" | sudo tee -a "$PG_HBA" fi @@ -34,12 +34,10 @@ echo "[5] Creating database + user (idempotent)…" sudo -u postgres psql <