This is a set of scripts that can be used to build a PostgresQL instance "in a can" - use it for testing web apps that use PostgresQL.
Makefile Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



[dl]: git:// 


Sets up a new installation of the postgres data files and configuration.
Postgres can run as the user that installs these files.  Postgres will
be configured to use sockets rather than network for communications.

This is useful for developer environments or for applications which want
the exclusive use of the database (eg, ledgersmb).  Also useful for running
postgres-backed programs in environments where you don't have root.

This set of scripts[0] will set up a postgres configuration and runtime directory
under the current directory.  It will use the system executables.

The scripts will use to do some prep on the DB:
create a couple of databases and users with default passwords.
The scripts will convert into bootstrap.sql, and
then run bootstrap.sql in the psql environment.

For historical reasons, the scripts expect that the can-o-pg directory
will be in vendor/plugins/can-o-pg, and the Makefile will be beside vendor
(actually it's a link to vendor/plugins/can-o-pg).  That's because
can-o-pg was developed in a Rails environment.  However, it is not
required to run in that directory structure.  In the Makefile at the
top, change SCRIPTDIR to . (dot) if you do not want to put it in

[0] The scripts are collected together into a Makefile.  A few auxilliary
scripts are separated out into files (,, etc) but
are called from the Makefile.

To run the scriptlets in the Makefile, give the make command along with
the "target" name:

    make showconfig

will run the scriptlet associated with the "showconfig" target in the

        @echo POSTBIN="${POSTBIN}"
        @echo APPNAME="${APPNAME}"
        @echo DBPATH="${DBPATH}"
        @echo DBPASSWORD="${DBPASSWORD}"
        @echo SCRIPTDIR="${SCRIPTDIR}"
        @echo TOP="${TOP}"
        @echo APACHE2_MODDIR="${APACHE2_MODDIR}"
        @echo WEBSERVER="${WEBSERVER}"
        @echo MIMETYPES="${MIMETYPES}"
        @echo PHP5_MODDIR="${PHP5_MODDIR}"
        @echo DATABASE="${DATABASE}"
        @echo SYSTEMPORT="${SYSTEMPORT}"
        @echo SYSTEMURL="${SYSTEMURL}"

In case you want to edit the Makefile, note that makefiles use tabs (not spaces)
for delimiting the beginning of the lines for the scriptlets.


run "make showconfig" to see what the settings are, you should see something


If you need to override certain of these values (see the list below of overrideable
items), you can use the file "can-o-pg.settings" at the top level.  It is a makefile
format file that will be included into the Makefile at runtime if it exists.

Overrideable settings:

You can create the file with "touch can-o-pg.settings" or by redirecting the
make showconfig output to a file:

    make showconfig > can-o-pg.settings

Be sure to remove the items that are not overrideable.
If you want to change one of the other items, it must be done directly in
the Makefile.


Similarly, this script can run apache as a regular user (rather than root) for
development environments.

If you need Apache (and you do if you are doing PHP5 work), then just run
"make apache" and an apache configuration will be created in run, and a copy
of Apache will be started.   It will be started on a port number equal to 8000
plus your uid.  This choice is stable per user, but permits multiple users 
to work on a multiuser machine (this is common if you have windows programmers 
using putty to a linux machine).


No doubt you will need to tweak the database by hand at times.
phppgadmin is a very good tool. If you have a copy in /usr/share/phppgadmin,
it will be linked into the apache config at /phppgadmin.  It is connected
to the database by Unix domain socket.  You can use the roles created
by the bootstrap.sql, such as application_development.


You will find a Makefile at the top-level.

You'll want to edit eventually.

Open up the can-o-pg.settings, and change APPNAME= if the name of the current
directory is wrong.

But, for now, just do:

for Rails apps, you can:
        cp database.yml config/database.yml

("make server" will do this for you)

make psql                - starts psql in the current database context.
make INPUTFILE=foo load  - starts psql with "foo" on command line 
                           populate the database.
make apache
make apachestop         - stop apache
make stop               - shutdown database
make                    - start the DB again.  Careful, if you have fiddled too much
                          with the config/runtime files, it will wipe out your DB and
                          re-create from scratch.  You'll have to read the Makefile
                          dependencies to figure out when this will happen.
                          It might be nice to make a new rule just for starting the
                          executables so there is no risk of losing data, but that's
                          not there at the moment.
make showconfig         - show settings