aboutsummaryrefslogtreecommitdiff
path: root/system/postgresql
diff options
context:
space:
mode:
authorAdis Nezirovic <adis _at_ linux.org.ba>2010-05-11 15:18:43 +0200
committerMichiel van Wessem <michiel@slackbuilds.org>2010-05-11 15:18:43 +0200
commitbae18fdb80148edcdae1b2576e950bd40bcbea4d (patch)
tree853acf5d4399911d51721f78e7cccd52e748755e /system/postgresql
parentfa2426f410d0f29f621d095e5e71b89f3f032252 (diff)
system/postgresql: Initial import
Diffstat (limited to 'system/postgresql')
-rw-r--r--system/postgresql/README54
-rw-r--r--system/postgresql/doinst.sh16
-rw-r--r--system/postgresql/postgresql.SlackBuild136
-rw-r--r--system/postgresql/postgresql.info8
-rw-r--r--system/postgresql/postgresql.logrotate8
-rw-r--r--system/postgresql/rc.postgresql.new118
-rw-r--r--system/postgresql/setup.postgresql33
-rw-r--r--system/postgresql/slack-desc12
8 files changed, 385 insertions, 0 deletions
diff --git a/system/postgresql/README b/system/postgresql/README
new file mode 100644
index 000000000000..a2c2a189994c
--- /dev/null
+++ b/system/postgresql/README
@@ -0,0 +1,54 @@
+PostgreSQL is an advanced object-relational database management
+system (ORDBMS) based on POSTGRES. With more than 15 years of
+development history, it is quickly becoming the de facto
+database for enterprise level open source solutions.
+
+Homepage: http://www.postgresql.org
+
+This script builds postgresql with a couple of useful features in the
+contrib directory.
+
+adminpack -
+ File and log manipulation routines, used by pgAdmin
+ by Dave Page <dpage@vale-housing.co.uk>
+
+tsearch2 -
+ Full-text-index support using GiST
+ by Teodor Sigaev <teodor@sigaev.ru> and Oleg Bartunov
+ <oleg@sai.msu.su>.
+
+
+Before you can run postgresql you'll need to create the
+database files in /var/lib/pgsql. The following should do
+the trick.
+
+ # su postgres -c "initdb -D /var/lib/pgsql/data"
+
+Additionally, a logrotation script is added to /etc/logrotate.d/ and an
+rc.postgresql script is added. In order to activate postgresql at boot
+time and shut it down properly upon system shutdown, add the following
+lines to the following files.
+
+ /etc/rc.d/rc.local
+ ==================
+
+ # Startup postgresql
+ if [ -x /etc/rc.d/rc.postgresql ]; then
+ /etc/rc.d/rc.postgresql start
+ fi
+
+
+ /etc/rc.d/rc.local_shutdown
+ ===========================
+
+ # Stop postgres
+ if [ -x /etc/rc.d/rc.postgresql ]; then
+ /etc/rc.d/rc.postgresql stop
+ fi
+
+Additionally, you'll have to set the rc script to be executable just
+like any other Slackware rc script.
+
+ # chmod +x /etc/rc.d/rc.postgresql
+
+
diff --git a/system/postgresql/doinst.sh b/system/postgresql/doinst.sh
new file mode 100644
index 000000000000..4eed17e907f2
--- /dev/null
+++ b/system/postgresql/doinst.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+config() {
+ NEW="$1"
+ OLD="`dirname $NEW`/`basename $NEW .new`"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+config etc/rc.d/rc.postgresql.new
+config etc/logrotate.d/postgresql.new
diff --git a/system/postgresql/postgresql.SlackBuild b/system/postgresql/postgresql.SlackBuild
new file mode 100644
index 000000000000..46c180e5656b
--- /dev/null
+++ b/system/postgresql/postgresql.SlackBuild
@@ -0,0 +1,136 @@
+#!/bin/sh
+
+## Slackware build script for PostgreSQL
+## $Revision: 1addf65317c9 $
+## $Date: 2007/04/25 02:58:20 $
+##
+## Copyright 2007 Adis Nezirovic <adis _at_ linux.org.ba>
+## Licensed under GNU GPL v2
+
+# Slightly modified by the SlackBuilds Project
+PRGNAM=postgresql
+VERSION=8.2.4
+ARCH=${ARCH:-i486}
+BUILD=${BUILD:-1}
+TAG=${TAG:_SBo}
+CWD=`pwd`
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+# Exit on any and all errors
+set -e
+
+# Bail out if user or group isn't valid on your system
+# For slackbuilds.org, assigned postgres uid/gid are 209/209
+# see http://slackbuilds.org/uid_gid.txt
+# Other popular choice is 26/26
+if ! grep ^postgres: /etc/group 2>&1 > /dev/null; then
+ echo " Must have a postgres group to run this script."
+ echo " # groupadd -g 209 postgres"
+ echo " Or something similar."
+ exit 1
+elif ! grep ^postgres: /etc/passwd 2>&1 > /dev/null; then
+ echo " Must have a postgres user to run this script."
+ echo " # useradd -u 209 -g postgres -d /var/lib/pgsql postgres"
+ echo " Or something similar."
+ exit 1
+fi
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2"
+fi
+
+# Make sure we start from clean state
+rm -rf $TMP/$PRGNAM-$VERSION $PKG
+mkdir -p $TMP $PKG $OUTPUT
+
+cd $TMP
+tar xjvf $CWD/$PRGNAM-$VERSION.tar.bz2 || exit 1
+
+# Fix permissions here.
+chmod -R a-s,u+w,go+r-w $PRGNAM-$VERSION
+chown -R root:root $PRGNAM-$VERSION
+
+cd $TMP/$PRGNAM-$VERSION
+
+CFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --with-openssl \
+ --with-tcl \
+ --with-perl \
+ --with-python \
+ --enable-thread-safety || exit 1
+make || exit 1
+make DESTDIR=$PKG install-strip || exit 1
+
+# Two nice extensions:
+# adminpack for pgAdmin
+# tsearch2 for full text search
+cd $TMP/$PRGNAM-$VERSION/contrib/adminpack
+make || exit 1
+make DESTDIR=$PKG install-strip || exit 1
+
+cd $TMP/$PRGNAM-$VERSION/contrib/tsearch2
+make || exit 1
+make DESTDIR=$PKG install-strip || exit 1
+
+cd $TMP/$PRGNAM-$VERSION
+
+# man pages
+gzip -9 $PKG/usr/man/man?/*
+
+# docs
+mv $PKG/usr/doc/$PRGNAM $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a COPYRIGHT \
+ HISTORY \
+ README \
+ doc/* \
+ $PKG/usr/doc/$PRGNAM-$VERSION/
+rm -fr $PKG/usr/doc/$PRGNAM-$VERSION/{man.tar.gz,man1,manl,man7,postgres.tar.gz}
+
+# Ensure this flu^^^script spreads further
+SLACK_BUILD=$PKG/usr/share/$PRGNAM/SlackBuild
+mkdir -p $SLACK_BUILD
+cat $CWD/$PRGNAM.SlackBuild > $SLACK_BUILD/$PRGNAM.SlackBuild
+cat $CWD/$PRGNAM.info > $SLACK_BUILD/$PRGNAM.info
+cat $CWD/slack-desc > $SLACK_BUILD/slack-desc
+cat $CWD/doinst.sh > $SLACK_BUILD/doinst.sh
+cat $CWD/README > $SLACK_BUILD/README
+cat $CWD/rc.postgresql.new > $SLACK_BUILD/rc.postgresql.new
+cat $CWD/setup.postgresql > $SLACK_BUILD/setup.postgresql
+
+# base database directory
+# assumes you are using /var/lib/pgsql as a homedir for postgres user
+mkdir -p $PKG/var/lib/pgsql/data
+chown -R postgres:postgres $PKG/var/lib/pgsql
+chmod 700 $PKG/var/lib/pgsql
+# permissions for DATADIR should be u=rwx (0700)
+chmod 700 $PKG/var/lib/pgsql/data
+
+# description file
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+
+# pkgtool setup procedure
+mkdir -p $PKG/var/log/setup
+cat $CWD/setup.$PRGNAM > $PKG/var/log/setup/setup.$PRGNAM
+chmod 755 $PKG/var/log/setup/setup.$PRGNAM
+
+# rc script
+mkdir -p $PKG/etc/rc.d
+cat $CWD/rc.postgresql.new > $PKG/etc/rc.d/rc.postgresql.new
+
+# logrotation
+mkdir -p $PKG/etc/logrotate.d
+cat $CWD/postgresql.logrotate > $PKG/etc/logrotate.d/postgresql.new
+
+## make the package
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
diff --git a/system/postgresql/postgresql.info b/system/postgresql/postgresql.info
new file mode 100644
index 000000000000..c53f74a1cee5
--- /dev/null
+++ b/system/postgresql/postgresql.info
@@ -0,0 +1,8 @@
+PRGNAM="postgresql"
+VERSION="8.2.4"
+HOMEPAGE="http://www.postgresql.org"
+DOWNLOAD="ftp://ftp.postgresql.org/pub/source/v8.2.4/postgresql-8.2.4.tar.bz2"
+MD5SUM="af7ec100a33c41bfb8d87b5e0ec2f44a"
+MAINTAINER="Adis Nezirovic"
+EMAIL="adis _at_ linux.org.ba"
+APPROVED="BP{k}"
diff --git a/system/postgresql/postgresql.logrotate b/system/postgresql/postgresql.logrotate
new file mode 100644
index 000000000000..c8724992e240
--- /dev/null
+++ b/system/postgresql/postgresql.logrotate
@@ -0,0 +1,8 @@
+/var/log/postgresql.log {
+ postrotate
+ /etc/rc.d/rc.postgresql reload 2>&1 > /dev/null
+ endscript
+ size=100k
+ rotate 5
+ create 0640 postgres wheel
+}
diff --git a/system/postgresql/rc.postgresql.new b/system/postgresql/rc.postgresql.new
new file mode 100644
index 000000000000..329b7b092d18
--- /dev/null
+++ b/system/postgresql/rc.postgresql.new
@@ -0,0 +1,118 @@
+#!/bin/bash
+
+# PostgreSQL startup script for Slackware Linux
+# Copyright 2007 Adis Nezirovic <adis _at_ linux.org.ba>
+# Licensed under GNU GPL v2
+
+# Do not source this script (since it contains exit() calls)
+
+# Before you can run postgresql you'll need to create the
+# database files in /var/lib/pgsql. The following should do
+# the trick.
+#
+# $ su postgres -c "initdb -D /var/lib/pgsql/data"
+#
+
+LOGFILE=/var/log/postgresql
+DATADIR=/var/lib/pgsql/data
+POSTGRES=/usr/bin/postgres
+PIDFILE=postmaster.pid
+
+# Return values (according to LSB):
+# 0 - success
+# 1 - generic or unspecified error
+# 2 - invalid or excess argument(s)
+# 3 - unimplemented feature (e.g. "reload")
+# 4 - insufficient privilege
+# 5 - program is not installed
+# 6 - program is not configured
+# 7 - program is not running
+
+pg_ctl()
+{
+ CMD="/usr/bin/pg_ctl $@"
+ su - postgres -c "$CMD"
+}
+
+if [ ! -f $POSTGRES ]; then
+ echo "Could not find 'postgres' binary. Maybe PostgreSQL is not installed properly?"
+ exit 5
+fi
+
+case "$1" in
+
+ "start")
+ echo "Starting PostgreSQL"
+ touch $LOGFILE
+ chown postgres:wheel $LOGFILE
+ chmod 0640 $LOGFILE
+
+ if [ ! -e $DATADIR/PG_VERSION ]; then
+ echo "You should initialize the PostgreSQL database at location $DATADIR"
+ exit 6
+ fi
+
+ if [ `pgrep -f $POSTGRES` ]; then
+
+ echo "PostgreSQL daemon already running"
+ if [ ! -f $DATADIR/$PIDFILE ]; then
+ echo "Warning: Missing pid file $DATADIR/$PIDFILE"
+ fi
+ exit 1
+
+ else # remove old socket, if it exists and no daemon is running.
+
+ if [ ! -f $DATADIR/$PIDFILE ]; then
+ rm -f /tmp/.s.PGSQL.5432
+ rm -f /tmp/.s.PGSQL.5432.lock
+ pg_ctl start -w -l $LOGFILE -D $DATADIR
+ exit 0
+ else
+ echo "PostgreSQL daemon was not properly shut down"
+ echo "Please remove stale pid file $DATADIR/$PIDFILE"
+ exit 7
+ fi
+
+ fi
+ ;;
+
+ "stop")
+ echo "Shutting down PostgreSQL..."
+ pg_ctl stop -l $LOGFILE -D $DATADIR -m smart
+ ;;
+
+ "restart")
+ echo "Restarting PostgreSQL..."
+ pg_ctl restart -l $LOGFILE -D $DATADIR -m smart
+ ;;
+
+ "reload")
+ echo "Reloading configuration for PostgreSQL..."
+ pg_ctl reload -l $LOGFILE -D $DATADIR -m smart
+ ;;
+
+ "status")
+ if [ `pgrep -f $POSTGRES` ]; then
+ echo "PostgreSQL is running"
+
+ if [ ! -e $DATADIR/$PIDFILE ]; then
+ echo "Warning: Missing pid file $DATADIR/$PIDFILE"
+ fi
+
+ exit 0
+ else
+ echo "PostgreSQL is stopped"
+
+ if [ -e $DATADIR/$PIDFILE ]; then
+ echo "Detected stale pid file $DATADIR/$PIDFILE"
+ fi
+
+ exit 0
+ fi
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|status|restart|reload}"
+ exit 1
+ ;;
+esac
diff --git a/system/postgresql/setup.postgresql b/system/postgresql/setup.postgresql
new file mode 100644
index 000000000000..0c52cbf94928
--- /dev/null
+++ b/system/postgresql/setup.postgresql
@@ -0,0 +1,33 @@
+#!/bin/bash
+#BLURB="PostgreSQL"
+
+PG_HOME=/var/lib/pgsql
+PG_USER=postgres
+PG_USER_ID=26
+PG_GROUP=postgres
+PG_GROUP_ID=26
+
+echo "Adding PostgreSQL user and group..."
+groupadd -g $PG_GROUP_ID $PG_GROUP
+useradd -g $PG_GROUP -u $PG_USER_ID -d $PG_HOME -c PostgreSQL $PG_USER
+mkdir -p $PG_HOME/data
+
+## default permissions
+echo "Setting up permissions..."
+chown -R $PG_USER:$PG_GROUP $PG_HOME
+chmod 700 $PG_HOME
+chmod 700 $PG_HOME/data
+
+## database cluster
+if [ ! -f $PG_HOME/data/PG_VERSION ]; then
+ echo "Creating database cluster in $PG_HOME/data..."
+ su $PG_USER -c "initdb -D $PG_HOME/data"
+else
+ echo "*** WARNING ***" >&2
+ echo " There is already a database cluster in $PG_HOME/data." >&2
+ echo " If you are upgrading from an older version of PostgreSQL" >&2
+ echo " you will have to 'dump' and 'restore' your database." >&2
+ echo " See PostgreSQL manual for more details." >&2
+fi
+
+echo "PostgreSQL post-installation setup completed"
diff --git a/system/postgresql/slack-desc b/system/postgresql/slack-desc
new file mode 100644
index 000000000000..5a15c63f8b97
--- /dev/null
+++ b/system/postgresql/slack-desc
@@ -0,0 +1,12 @@
+ |-----handy-ruler-------------------------------------------------|
+postgresql: PostgreSQL
+postgresql:
+postgresql: PostgreSQL is an advanced object-relational database management
+postgresql: system (ORDBMS) based on POSTGRES. With more than 15 years of
+postgresql: development history, it is quickly becoming the de facto
+postgresql: database for enterprise level open source solutions.
+postgresql: This build includes full text search support (tsearch2).
+postgresql:
+postgresql: Homepage: http://www.postgresql.org
+postgresql:
+postgresql: