This is not a config file. Just a few notes to allow proper configuration
of the PostgreSQL database server.


1) Create a new database cluster:
* move "main" DB cluster from /var to /srv
    mkdir -p /srv/postgresql/data
        or, on a standby cluster configuration (/etc/postgresql/ is csync2'ed; /srv/.db/ is drbd'ed)
            mkdir -p /srv/.db/postgresql/data
            ln -s .db/postgresql /srv/postgresql
            chown postgres /var/log/postgresql/
    pg_ctlcluster 7.4 main stop
    pg_dropcluster 7.4 main
    pg_createcluster --datadir=/srv/postgresql/data/7.4/main --locale=fr_FR.UTF-8 7.4 main
    pg_ctlcluster 7.4 main start
    pg_dropcluster --stop 8.1 main
    pg_createcluster --datadir=/srv/postgresql/data/8.1/main --locale=fr_FR.UTF-8 8.1 main
    pg_ctlcluster 8.1 main start
    pg_lsclusters
        Version Cluster   Port Status Owner    Data directory                     Log file
        7.4     main      5432 online postgres /srv/postgresql/data/7.4/main      /var/log/postgresql/postgresql-7.4-main.log
        8.1     main      5433 online postgres /srv/postgresql/data/8.1/main      /var/log/postgresql/postgresql-8.1-main.log


2) Configure Postgres authorization (pg_hba.conf):
* each cluster must be configured : /etc/postgresql/7.4/main/pg_hba.conf
* TODO check the exact contents
    # >>> Doloforge administrative login by UNIX sockets: members of the Postgres group "doloforge" are allowed
    # Be sure that /var/lib/postgres/data/global/pg_group contains the users of the group (may not)
    # If not : "ALTER GROUP "doloforge" ADD USER "nhuillard";"
    local   all         +doloforge                                      ident sameuser
    # All other connections by UNIX sockets : doloforge denied
    local   all         all                                             reject
    # All IPv4 connections from localhost (devl) / APs (test+prod)
    host    all         all         127.0.0.1/32                        ident sameuser
    host    all         all         ::1/128                             ident sameuser
    host    all         all         10.0.1.32/27                        ident sameuser
    host    all         all         10.0.1.64/27                        ident sameuser
    # <<< End Doloforge config
* recharger Postgres après avoir modifié les autorisations
    pg_ctlcluster 7.4 main reload
* authorize TCP/IP connections in
    vi /etc/postgresql/7.4/main/postgresql.conf
    pg_ctlcluster 7.4 main restart


3) Add Doloforge user/group and admins in the Postgres instance (or cluster, in Debian etch):
* doloforge system users and groups
    sudo -u postgres bash
    psql template1
        CREATE GROUP "doloforge" WITH SYSID 999;
        CREATE USER "doloforge" WITH SYSID 999 CREATEDB CREATEUSER IN GROUP "doloforge";
        CREATE USER "root" WITH SYSID 10 CREATEDB CREATEUSER IN GROUP "doloforge";
        CREATE GROUP "www-data" WITH SYSID 33;
        CREATE USER "www-data" WITH SYSID 33 IN GROUP "www-data";
    psql --cluster 8.1/main template1
        CREATE USER "doloforge" CREATEDB CREATEUSER;
        CREATE USER "root" CREATEDB CREATEUSER IN GROUP "doloforge";
        CREATE USER "www-data";
* for each doloforge administrator
    sudo -u postgres bash
    psql template1
        CREATE USER "nhuillard" WITH SYSID 1000 CREATEDB CREATEUSER IN GROUP "doloforge";
        CREATE DATABASE "nhuillard";
    psql --cluster 8.1/main template1
        CREATE USER "nhuillard" CREATEDB CREATEUSER IN GROUP "doloforge";
        CREATE DATABASE "nhuillard";


4) Create projects databases
* simply let Doloforge do...
    doloforge config --update
* or, for each new project (connect as an administrator)
    psql template1
        CREATE GROUP "internal";
        CREATE USER "internal" IN GROUP "internal";
        CREATE DATABASE "internal_sandbox" WITH OWNER "internal" ENCODING 'UNICODE';
    psql internal_sandbox
        COMMENT ON DATABASE "internal_sandbox" IS 'Sandbox project for developer training';
    psql --cluster 8.1/main template1
        CREATE GROUP "internal";
        CREATE DATABASE "internal_sandbox" WITH OWNER "internal";
    psql --cluster 8.1/main internal_sandbox
        COMMENT ON DATABASE "internal_sandbox" IS 'Sandbox project for developer training';
* FIXME : ROLE and permissions on 8.1 (USER/GROUP -> ROLE ; "le rôle «www-data» n'est pas autorisé à se connecter")




From /usr/share/doc/postgresql-7.4/README.Debian.gz
    66 Cluster management
    67 ------------------
    68 For managing clusters, the following commands are provided (each with its own
    69 manual page):
    70
    71    pg_createcluster  - Create a new cluster or integrate an existing one into
    72                        the postgresql-common architecture.
    73    pg_dropcluster    - Completely remove a cluster.
    74    pg_ctlcluster     - Control the server process of a cluster (start, stop,
    75                        restart).
    76    pg_lsclusters     - Show a list of all existing clusters and their status.
    77    pg_upgradecluster - Migrate a cluster from one major version to another one.

