# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 # $Id$ PortSystem 1.0 set server postgresql83 name ${server}-server version 8.3.4 categories databases platforms darwin maintainers mww jwa description Run ${server} as a server long_description Run ${server} as a server (with SSL connections). homepage http://www.postgresql.org/ master_sites postgresql livecheck.check regex livecheck.url ${homepage}/versions.rss livecheck.regex (8.3.\[0-9\]+) depends_run port:${server} \ port:openssl fetch {} checksum {} extract {} use_configure no build {} set libdir ${prefix}/lib/${server} set logdir ${prefix}/var/log/${server} # Is it possible to prompt for a user defined database path? set dbdir ${prefix}/var/db/${server}/defaultdb set dbpid ${dbdir}/postmaster.pid set dbuser postgres set dbgrp postgres startupitem.create yes startupitem.name ${name} startupitem.logfile ${logdir}/postgres.log startupitem.logevents yes startupitem.init "PGCTL=${libdir}/bin/pg_ctl" # Options passed through to postmaster via 'pg_ctl -o' # -i enable TCP/IP connections # -l enable SSL connections startupitem.start \ "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} start -w -l ${logdir}/postgres.log -o \\\"-i -l\\\"\"" startupitem.stop \ "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} stop -s -m fast\"" startupitem.restart \ "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} restart -w -s -m fast\"" startupitem.pidfile clean ${dbpid} destroot { # Check if the user and group already exist and replace them? addgroup ${dbgrp} set gid [existsgroup ${dbgrp}] adduser ${dbuser} shell=/bin/sh gid=${gid} \ home=${prefix}/var/db/${server} \ realname=PostgreSQL\ Server xinstall -m 755 -d ${destroot}${logdir} system "touch ${destroot}${logdir}/postgres.log" system "chown -R ${dbuser}:${dbgrp} ${destroot}${logdir}" } post-install { ui_msg " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % To create a database instance, after install do % %% sudo mkdir -p ${dbdir} % %% sudo chown ${dbuser}:${dbgrp} ${dbdir} % %% sudo su ${dbuser} -c \'${libdir}/bin/initdb -D ${dbdir}\' % (You can replace ${dbdir} with any path of your choice, but % you must then modify the startup management scripts in % ${prefix}/etc/LaunchDaemons/org.macports.${name}/. % These scripts over-ride the PGDATA environment variable.) % % This server will accept SSL connections, which must be % enabled by a server certificate in your data directory. This % server will NOT start without an SSL certificate and it is not % possible to provide a generic certificate automatically. For more % information, see http://developer.postgresql.org/pgdocs/postgres/ssl-tcp.html % To create a self-signed certificate: % $ sudo -i % # cd ${dbdir} % # openssl req -new -text -out server.req % Fill out the information that openssl asks for. The program will % generate a key that is passphrase protected; enter any passphrase at % the prompt for a PEM passphrase (it will be removed from the key later). % When prompted for a \"Common Name\", make sure you enter the local % host name. The challenge password can be left blank. Now, to remove % the PEM passphrase (for automatic startup of the server), run: % # openssl rsa -in privkey.pem -out server.key % # rm privkey.pem % Enter the old passphrase to unlock the existing key. Now do: % # openssl req -x509 -in server.req -text -key server.key -out server.crt % # chmod og-rwx server.key % # chown ${dbuser}:${dbgrp} server.* % That's it. A self-signed certificate can be used for testing, but a % certificate signed by a certificate authority (CA; either a global CA % or a local one) should be used in production, so a client can verify % the server's identity. % % To load the startup deamon, run: % $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.${name}.plist % To unload the startup deamon, run: % $ sudo launchctl unload -w /Library/LaunchDaemons/org.macports.${name}.plist % % Run 'port install pgAdmin3' to administer PostgreSQL % Run 'port install slony1' to manage replication for PostgreSQL % % To tweak your DBMS, consider increasing kern.sysv.shmmax % by adding an increased kern.sysv.shmmax .. to /etc/sysctl.conf % % Please read the documentation for the complete list of run-time % configuration settings and how to set them on the command line or in % the configuration file. The server config can be found in: % % The server log can be found in: % ${prefix}/var/log/${server}/postgres.log %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" }