diff options
Diffstat (limited to 'extra/postgresql')
-rw-r--r-- | extra/postgresql/PKGBUILD | 9 | ||||
-rwxr-xr-x | extra/postgresql/postgresql | 74 | ||||
-rw-r--r-- | extra/postgresql/postgresql.install | 14 |
3 files changed, 66 insertions, 31 deletions
diff --git a/extra/postgresql/PKGBUILD b/extra/postgresql/PKGBUILD index 741ffc2fe..f6c50c036 100644 --- a/extra/postgresql/PKGBUILD +++ b/extra/postgresql/PKGBUILD @@ -1,9 +1,9 @@ -# $Id: PKGBUILD 108463 2011-01-31 13:52:30Z dan $ +# $Id: PKGBUILD 120038 2011-04-18 17:35:03Z dan $ # Maintainer: Dan McGee <dan@archlinux.org> pkgbase=postgresql pkgname=('postgresql-libs' 'postgresql-docs' 'postgresql') -pkgver=9.0.3 +pkgver=9.0.4 pkgrel=1 arch=('i686' 'x86_64') url="http://www.postgresql.org" @@ -11,6 +11,7 @@ license=('custom:PostgreSQL') makedepends=('libxml2' 'python2' 'perl') source=(ftp://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2 \ postgresql postgresql.confd build.patch postgresql.pam postgresql.logrotate) +install=postgresql.install build() { cd "${srcdir}/${pkgbase}-${pkgver}" @@ -128,8 +129,8 @@ package_postgresql() { "${pkgdir}/etc/logrotate.d/postgresql" } -md5sums=('928df8c40bb012ad10756e58b70516fb' - '49bfa0d1089e26e2098d362ca5fa6503' +md5sums=('80390514d568a7af5ab61db1cda27e29' + '89ada7c282d9ffb82c6adc89bc2778ad' 'd63a05943cf0a2726aa2070f3033c569' '4d74f4227dc5e12bf95b3490758d86c9' '96f82c38f3f540b53f3e5144900acf17' diff --git a/extra/postgresql/postgresql b/extra/postgresql/postgresql index fb7be3dd7..3a8bf44f8 100755 --- a/extra/postgresql/postgresql +++ b/extra/postgresql/postgresql @@ -4,34 +4,31 @@ . /etc/rc.d/functions . /etc/conf.d/postgresql +# Default PGROOT if it wasn't defined in the conf.d file +PGROOT=${PGROOT:-/var/lib/postgres} +PG_CTL="/usr/bin/pg_ctl -D $PGROOT/data -l /var/log/postgresql.log -s -w" + +postgres_init() { + # initialization + if [ ! -d $PGROOT/data ]; then + mkdir -p $PGROOT/data && chown -R postgres:postgres $PGROOT + su - postgres -c "/usr/bin/initdb $INITOPTS -D $PGROOT/data" + fi + if [ ! -e /var/log/postgresql.log ]; then + touch /var/log/postgresql.log + chown postgres /var/log/postgresql.log + fi +} + case "$1" in start) + postgres_init stat_busy "Starting PostgreSQL" - # initialization - if [ ! `egrep '^postgres:' /etc/group` ]; then - stat_busy "Adding postgres group" - groupadd -g 88 postgres - stat_done - fi - if [ ! `egrep '^postgres:' /etc/passwd` ]; then - stat_busy "Adding postgres user" - useradd -u 88 -g postgres -d $PGROOT -s /bin/bash postgres - [ -d $PGROOT ] && chown -R postgres:postgres $PGROOT - stat_done - fi - if [ ! -d $PGROOT/data ]; then - mkdir -p $PGROOT/data && chown -R postgres:postgres $PGROOT - su - postgres -c "/usr/bin/initdb $INITOPTS -D $PGROOT/data" - fi - if [ ! -e /var/log/postgresql.log ]; then - touch /var/log/postgresql.log - chown postgres /var/log/postgresql.log - fi - # start the process su - postgres -c \ - "/usr/bin/pg_ctl -D $PGROOT/data -l /var/log/postgresql.log -W start" + "$PG_CTL start" if [ $? -gt 0 ]; then stat_fail + exit 1 else add_daemon postgresql stat_done @@ -40,7 +37,7 @@ case "$1" in stop) stat_busy "Stopping PostgreSQL" su - postgres -c \ - "/usr/bin/pg_ctl -D $PGROOT/data -l /var/log/postgresql.log -w stop" + "$PG_CTL stop -m fast" if [ $? -gt 0 ]; then stat_fail else @@ -48,12 +45,35 @@ case "$1" in stat_done fi ;; + reload) + stat_busy "Reloading PostgreSQL" + su - postgres -c \ + "$PG_CTL reload" + if [ $? -gt 0 ]; then + stat_fail + exit 1 + else + stat_done + fi + ;; restart) - $0 stop - sleep 3 - $0 start + postgres_init + stat_busy "Restarting PostgreSQL" + su - postgres -c \ + "$PG_CTL restart -m fast" + if [ $? -gt 0 ]; then + stat_fail + exit 1 + else + add_daemon postgresql + stat_done + fi + ;; + status) + stat_busy "Checking PostgreSQL status"; + ck_status postgresql ;; *) - echo "usage: $0 {start|stop|restart}" + echo "usage: $0 {start|stop|reload|restart|status}" esac exit 0 diff --git a/extra/postgresql/postgresql.install b/extra/postgresql/postgresql.install new file mode 100644 index 000000000..4a6f9b848 --- /dev/null +++ b/extra/postgresql/postgresql.install @@ -0,0 +1,14 @@ +post_install() { + 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 /sbin/nologin postgres + passwd -l postgres >/dev/null +} + +post_upgrade() { + post_install $1 +} + +post_remove() { + getent passwd postgres >/dev/null && userdel postgres + getent group postgres >/dev/null && groupdel postgres +} |