diff options
author | root <root@rshg054.dnsready.net> | 2012-09-17 00:03:15 +0000 |
---|---|---|
committer | root <root@rshg054.dnsready.net> | 2012-09-17 00:03:15 +0000 |
commit | d1d75c37c446dfbe9cbae503300e17f2973dbf44 (patch) | |
tree | b456fdc00f58cc15c7faf27ed12dfc9a0f8741b4 /testing/postgresql | |
parent | 50634781b5673a447953e357a63baa66515ec868 (diff) |
Mon Sep 17 00:03:15 UTC 2012
Diffstat (limited to 'testing/postgresql')
-rw-r--r-- | testing/postgresql/PKGBUILD | 26 | ||||
-rwxr-xr-x | testing/postgresql/postgresql-check-db-dir | 49 | ||||
-rw-r--r-- | testing/postgresql/postgresql.install | 10 | ||||
-rw-r--r-- | testing/postgresql/postgresql.service | 19 |
4 files changed, 82 insertions, 22 deletions
diff --git a/testing/postgresql/PKGBUILD b/testing/postgresql/PKGBUILD index e7f743d8e..7a79156d6 100644 --- a/testing/postgresql/PKGBUILD +++ b/testing/postgresql/PKGBUILD @@ -1,32 +1,32 @@ -# $Id: PKGBUILD 165398 2012-08-17 23:34:22Z heftig $ +# $Id: PKGBUILD 166687 2012-09-15 16:47:20Z dan $ # Maintainer: Dan McGee <dan@archlinux.org> pkgbase=postgresql pkgname=('postgresql-libs' 'postgresql-docs' 'postgresql') -pkgver=9.1.4 +pkgver=9.2.0 _majorver=${pkgver%.*} -pkgrel=2 +pkgrel=1 arch=('i686' 'x86_64') url="http://www.postgresql.org/" license=('custom:PostgreSQL') makedepends=('krb5' 'libxml2' 'python2' 'perl' 'tcl' 'openssl>=1.0.0') -source=(ftp://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2 +source=(http://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2 postgresql.rcd postgresql.confd postgresql.pam postgresql.logrotate - postgresql.service postgresql-initdb) -md5sums=('a8035688dba988b782725ac1aec60186' + postgresql.service postgresql-check-db-dir) +md5sums=('8c4c32a4abe8cf61b02c8366181ede50' '1ddd1df8010549f237e7983bb326025e' 'a54d09a20ab1672adf08f037df188d53' '96f82c38f3f540b53f3e5144900acf17' 'd28e443f9f65a5712c52018b84e27137' - '1ec1fbf1ce998324248c543e6cc2c5e6' - '1488a98a5d5d96a04416e4f5872223bf') -sha256sums=('a0795a8eb3ae2d1a2914b63bf143d20182835d90699915ff43567c041d3c9712' + 'f0d46e63198db0a1e51dcd4a0599cd33' + '505e0e4abfc746cae9558584d471a03c') +sha256sums=('3731c607df492bbb57f37917b49f57719c0d6f823720426431fff10d82b1fe33' '9f6307b1358892e304f9474a456f0cb9160cfb8812a9da0430abe647f8a9cf45' '3de5c059eead8816db15c2c5588e6196d6c4b0d704faf1a20912796cf589ba81' '57dfd072fd7ef0018c6b0a798367aac1abb5979060ff3f9df22d1048bb71c0d5' '6abb842764bbed74ea4a269d24f1e73d1c0b1d8ecd6e2e6fb5fb10590298605e' - '7014ccc8f3bbac8be9473a43fca2ed4037ee04e56d8e07d6027b3b4ef0317c89' - 'c22f82a3cf5b555935039853fab2d7e5ff6188cdb1fb528fa9171a87b94f42b0') + 'af41dd8c1e6b124880fb4347c9fa4adabdef5b6e6bd13601cac25eb9e7bc7774' + '3a3279d290f556bf7a362670e32b491794f47ed218f6b8c6acef366a3291f669') build() { cd "${srcdir}/postgresql-${pkgver}" @@ -139,8 +139,8 @@ package_postgresql() { install -D -m755 "${srcdir}/postgresql.rcd" "${pkgdir}/etc/rc.d/postgresql" install -D -m644 "${srcdir}/postgresql.service" \ "${pkgdir}/usr/lib/systemd/system/postgresql.service" - install -D -m755 "${srcdir}/postgresql-initdb" \ - "${pkgdir}/usr/lib/systemd/scripts/postgresql-initdb" + install -D -m755 "${srcdir}/postgresql-check-db-dir" \ + "${pkgdir}/usr/bin/postgresql-check-db-dir" # install conf file install -D -m644 ${srcdir}/postgresql.confd \ diff --git a/testing/postgresql/postgresql-check-db-dir b/testing/postgresql/postgresql-check-db-dir new file mode 100755 index 000000000..542c82209 --- /dev/null +++ b/testing/postgresql/postgresql-check-db-dir @@ -0,0 +1,49 @@ +#!/bin/sh + +# This script verifies that the postgresql data directory has been correctly +# initialized. We do not want to automatically initdb it, because that has +# a risk of catastrophic failure (ie, overwriting a valuable database) in +# corner cases, such as a remotely mounted database on a volume that's a +# bit slow to mount. But we can at least emit a message advising newbies +# what to do. + +PGDATA="$1" + +if [ -z "$PGDATA" ] +then + echo "Usage: $0 database-path" + exit 1 +fi + +# PGMAJORVERSION is major version +PGMAJORVERSION=9.2 +# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades +PREVMAJORVERSION=9.1 + +# Check for the PGDATA structure +if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ] +then + # Check version of existing PGDATA + if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ] + then + : A-OK + elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ] + then + echo $"An old version of the database format was found." + echo $"See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreSQL" + exit 1 + else + echo $"An old version of the database format was found." + echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION." + echo $"See http://www.postgresql.org/docs/9.2/static/upgrading.html" + exit 1 + fi +else + # No existing PGDATA! Warn the user to initdb it. + echo $"\"$PGDATA\" is missing or empty. Use a command like" + echo $" su - postgres -c \"initdb --locale en_US.UTF-8 -D '$PGDATA'\"" + echo $"with relevant options, to initialize the database cluster." + exit 1 +fi + +exit 0 diff --git a/testing/postgresql/postgresql.install b/testing/postgresql/postgresql.install index c52432271..7b73f6fa9 100644 --- a/testing/postgresql/postgresql.install +++ b/testing/postgresql/postgresql.install @@ -2,9 +2,13 @@ post_install() { if [ ! -d '/var/lib/postgres' ]; then mkdir -p '/var/lib/postgres' fi - getent group postgres >/dev/null || groupadd -g 88 postgres - getent passwd postgres >/dev/null || useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres - passwd -l postgres >/dev/null + if ! getent group postgres >/dev/null; then + groupadd -g 88 postgres + fi + if ! getent passwd postgres >/dev/null; then + useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres + passwd -l postgres >/dev/null + fi } post_upgrade() { diff --git a/testing/postgresql/postgresql.service b/testing/postgresql/postgresql.service index 2fcd3e93d..bea14e01e 100644 --- a/testing/postgresql/postgresql.service +++ b/testing/postgresql/postgresql.service @@ -1,19 +1,26 @@ [Unit] Description=PostgreSQL database server +After=network.target [Service] Type=forking +TimeoutSec=120 +User=postgres +Group=postgres + +Environment=PGROOT=/var/lib/postgres +Environment=PGLOG=/var/log/postgresql.log + SyslogIdentifier=postgres PIDFile=/var/lib/postgres/data/postmaster.pid -# initdb script takes care for symlinking $PGROOT to /var/lib/postgres -ExecStartPre=/usr/lib/systemd/scripts/postgresql-initdb -ExecStart= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data start" -ExecReload=/bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data reload" -ExecStop= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data stop -m fast" +ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data +ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 +ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload +ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast # Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in -# killing Postgres +# killing Postgres, so adjust it downward OOMScoreAdjust=-200 [Install] |