Ticket #16991: Portfile

File Portfile, 4.9 KB (added by dweber@…, 16 years ago)

postgresql83-server with SSL connections

Line 
1# -*- 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
2
3# $Id: Portfile 40169 2008-09-23 10:35:46Z mww@macports.org $
4
5PortSystem 1.0
6
7set server      postgresql83
8
9name            ${server}-server
10version         8.3.4
11categories      databases
12platforms       darwin
13maintainers     mww jwa
14description     Run ${server} as a server
15
16long_description    Run ${server} as a server (with SSL connections).
17
18homepage        http://www.postgresql.org/
19master_sites    postgresql
20
21livecheck.check regex
22livecheck.url   ${homepage}/versions.rss
23livecheck.regex (8.3.\[0-9\]+)
24
25depends_run     port:${server} \
26                port:openssl
27
28fetch           {}
29checksum        {}
30extract         {}
31use_configure   no
32build           {}
33
34set libdir      ${prefix}/lib/${server}
35set logdir      ${prefix}/var/log/${server}
36# Is it possible to prompt for a user defined database path?
37set dbdir       ${prefix}/var/db/${server}/defaultdb
38set dbpid       ${dbdir}/postmaster.pid
39set dbuser      postgres
40set dbgrp       postgres
41
42startupitem.create      yes
43startupitem.name        ${name}
44startupitem.logfile     ${logdir}/postgres.log
45startupitem.logevents   yes
46startupitem.init        "PGCTL=${libdir}/bin/pg_ctl"
47
48# Options passed through to postmaster via 'pg_ctl -o'
49# -i  enable TCP/IP connections
50# -l  enable SSL connections
51startupitem.start   \
52    "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} start -w -l ${logdir}/postgres.log -o \\\"-i -l\\\"\""
53startupitem.stop    \
54    "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} stop -s -m fast\""
55startupitem.restart \
56    "su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL83DATA:=${dbdir}} restart -w -s -m fast\""
57startupitem.pidfile     clean ${dbpid}
58
59destroot {
60    # Check if the user and group already exist and replace them?
61    addgroup ${dbgrp}
62    set gid [existsgroup ${dbgrp}]
63    adduser ${dbuser} shell=/bin/sh gid=${gid} \
64        home=${prefix}/var/db/${server} \
65        realname=PostgreSQL\ Server
66
67    xinstall -m 755 -d ${destroot}${logdir}
68    system "touch ${destroot}${logdir}/postgres.log"
69    system "chown -R ${dbuser}:${dbgrp} ${destroot}${logdir}"
70}
71
72post-install {
73    ui_msg "
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75% To create a database instance, after install do
76% %% sudo mkdir -p ${dbdir}
77% %% sudo chown ${dbuser}:${dbgrp} ${dbdir}
78% %% sudo su ${dbuser} -c \'${libdir}/bin/initdb -D ${dbdir}\'
79% (You can replace ${dbdir} with any path of your choice, but
80% you must then modify the startup management scripts in
81% ${prefix}/etc/LaunchDaemons/org.macports.${name}/.
82% These scripts over-ride the PGDATA environment variable.)
83%
84% This server will accept SSL connections, which must be
85% enabled by a server certificate in your data directory.  This
86% server will NOT start without an SSL certificate and it is not
87% possible to provide a generic certificate automatically.  For more
88% information, see http://developer.postgresql.org/pgdocs/postgres/ssl-tcp.html
89% To create a self-signed certificate:
90% $ sudo -i
91% # cd ${dbdir}
92% # openssl req -new -text -out server.req
93% Fill out the information that openssl asks for. The program will
94% generate a key that is passphrase protected; enter any passphrase at
95% the prompt for a PEM passphrase (it will be removed from the key later).
96% When prompted for a \"Common Name\", make sure you enter the local
97% host name.  The challenge password can be left blank. Now, to remove
98% the PEM passphrase (for automatic startup of the server), run:
99% # openssl rsa -in privkey.pem -out server.key
100% # rm privkey.pem
101% Enter the old passphrase to unlock the existing key. Now do:
102% # openssl req -x509 -in server.req -text -key server.key -out server.crt
103% # chmod og-rwx server.key
104% # chown ${dbuser}:${dbgrp} server.*
105% That's it. A self-signed certificate can be used for testing, but a
106% certificate signed by a certificate authority (CA; either a global CA
107% or a local one) should be used in production, so a client can verify
108% the server's identity.
109%
110% To load the startup deamon, run:
111% $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.${name}.plist
112% To unload the startup deamon, run:
113% $ sudo launchctl unload -w /Library/LaunchDaemons/org.macports.${name}.plist
114%
115% Run 'port install pgAdmin3' to administer PostgreSQL
116% Run 'port install slony1' to manage replication for PostgreSQL
117%
118% To tweak your DBMS, consider increasing kern.sysv.shmmax
119% by adding an increased kern.sysv.shmmax .. to /etc/sysctl.conf
120%
121% Please read the documentation for the complete list of run-time
122% configuration settings and how to set them on the command line or in
123% the configuration file.  The server config can be found in:
124%
125% The server log can be found in:
126% ${prefix}/var/log/${server}/postgres.log
127%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"
128}
129