aboutsummaryrefslogtreecommitdiffstats
path: root/unmaintained
diff options
context:
space:
mode:
Diffstat (limited to 'unmaintained')
-rw-r--r--unmaintained/pgcluster/APKBUILD75
-rw-r--r--unmaintained/pgcluster/musl-fixes.patch59
-rw-r--r--unmaintained/pgcluster/pgcluster.confd57
-rw-r--r--unmaintained/pgcluster/pgcluster.initd174
4 files changed, 365 insertions, 0 deletions
diff --git a/unmaintained/pgcluster/APKBUILD b/unmaintained/pgcluster/APKBUILD
new file mode 100644
index 0000000000..60a4c57ab6
--- /dev/null
+++ b/unmaintained/pgcluster/APKBUILD
@@ -0,0 +1,75 @@
+# Maintainer: Cameron Banta <cbanta@gmail.com>
+pkgname=pgcluster
+pkgver=1.9.00001
+_myver=1.9.0rc5
+pkgrel=0
+pkgdesc="PostgreSQL with multi-master cluster/replication patch"
+url="http://pgfoundry.org/projects/pgcluster/"
+arch="all !aarch64"
+license="BSD"
+depends=
+makedepends="readline-dev libressl-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-libpq $pkgname-client"
+source="http://pgfoundry.org/frs/download.php/1705/$pkgname-$_myver.tar.gz
+ musl-fixes.patch
+ $pkgname.initd
+ $pkgname.confd
+ "
+
+[ "$ALPINE_LIBC" = "eglibc" ] && arch=
+
+_builddir="$srcdir/$pkgname-$_myver"
+
+prepare() {
+ cd "$_builddir"
+ update_config_sub || return 1
+ for i in $source; do
+ case $i in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ esac
+ done
+}
+
+build() {
+ cd "$_builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --with-docdir=/usr/share/doc \
+ --with-openssl \
+ || return 1
+
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -D -m755 "$srcdir"/$pkgname.initd \
+ "$pkgdir"/etc/init.d/$pkgname
+ install -D -m644 "$srcdir"/$pkgname.confd \
+ "$pkgdir"/etc/conf.d/$pkgname || return 1
+}
+
+libpq() {
+ depends=
+ pkgdesc="PGCluster libraries"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpq.so* "$subpkgdir"/usr/lib/
+}
+
+client() {
+ depends=
+ pkgdesc="PGCluster client"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/psql "$subpkgdir"/usr/bin/
+}
+
+
+sha512sums="825b3da733c2e455bbdfca5833ec6f874d622529cc70fa6a398db458696d8398aa52101633ea703c698df0c86170b2522bb289ac3888b3f76575781f4a4c0d64 pgcluster-1.9.0rc5.tar.gz
+e07a310644f6bad61a199c0d16997d2cd5105a81ad92074839c8296f7357e0abd25a17601485f6baf5b62a07e478fda1ceb36ef79dff2341f5b5ea912bd5b17e musl-fixes.patch
+32f21e761e963f91bd248f52ecb3c2abb9f0951fd5fb6b29c682ef2825aae2ed37483da728dfb8ce6281305e75568a1eac5037ced04ead604ce1c800695a1b52 pgcluster.initd
+2dfa32a7c5fb39bf0fcc91f49a8fa432a983ad7eeecffe969f030e60da6ad5502aba6160daaae19c30c8596aab0ecf246775a53a18acb841c73c409a5a959bb2 pgcluster.confd"
diff --git a/unmaintained/pgcluster/musl-fixes.patch b/unmaintained/pgcluster/musl-fixes.patch
new file mode 100644
index 0000000000..4f03458cda
--- /dev/null
+++ b/unmaintained/pgcluster/musl-fixes.patch
@@ -0,0 +1,59 @@
+--- pgcluster-1.9.0rc5.orig/src/pgcluster/pgrp/main.c
++++ pgcluster-1.9.0rc5/src/pgcluster/pgrp/main.c
+@@ -166,7 +166,7 @@
+ static void startup_replication_server(void);
+ static int replicate_loop(int fd);
+ static void replicate_main(void);
+-static void quick_exit(SIGNAL_ARGS);
++static void signal_exit(SIGNAL_ARGS);
+ static void daemonize(void);
+ static void write_pid_file(void);
+ static void stop_pgreplicate(void);
+@@ -231,10 +231,10 @@
+
+ close(fd);
+
+- PGRsignal(SIGHUP, quick_exit);
+- PGRsignal(SIGINT, quick_exit);
+- PGRsignal(SIGQUIT, quick_exit);
+- PGRsignal(SIGTERM, quick_exit);
++ PGRsignal(SIGHUP, signal_exit);
++ PGRsignal(SIGINT, signal_exit);
++ PGRsignal(SIGQUIT, signal_exit);
++ PGRsignal(SIGTERM, signal_exit);
+ PGRsignal(SIGALRM, SIG_IGN);
+ PGRsignal(SIGPIPE, SIG_IGN);
+ setpgid(0,pgid);
+@@ -524,7 +524,7 @@
+
+ /*--------------------------------------------------------------------
+ * SYMBOL
+- * quick_exit()
++ * signal_exit()
+ * NOTES
+ * Exit child process
+ * ARGS
+@@ -534,10 +534,10 @@
+ *--------------------------------------------------------------------
+ */
+ static void
+-quick_exit(SIGNAL_ARGS)
++signal_exit(SIGNAL_ARGS)
+ {
+ #ifdef PRINT_DEBUG
+- show_debug("quick_exit:signo = %d", postgres_signal_arg);
++ show_debug("signal_exit:signo = %d", postgres_signal_arg);
+ #endif
+ exit(0);
+ }
+--- pgcluster-1.9.0rc5.orig/src/pgcluster/pgrp/recovery.c
++++ pgcluster-1.9.0rc5/src/pgcluster/pgrp/recovery.c
+@@ -398,7 +398,7 @@
+ #ifdef PRINT_DEBUG
+ show_debug("%s:already recovery job runing",func);
+ #endif
+- memset(packet,0,sizeof(packet));
++ memset(packet,0,sizeof(*packet));
+ PGRset_recovery_packet_no(packet, RECOVERY_ERROR_OCCUPIED) ;
+ status = send_packet(&Target,packet);
+ loop_end = true;
diff --git a/unmaintained/pgcluster/pgcluster.confd b/unmaintained/pgcluster/pgcluster.confd
new file mode 100644
index 0000000000..9e1376eec7
--- /dev/null
+++ b/unmaintained/pgcluster/pgcluster.confd
@@ -0,0 +1,57 @@
+# PostgreSQL's Database Directory
+PGDATA="/var/lib/postgresql/pgcluster"
+
+# PostgreSQL User
+PGUSER="postgres"
+
+# PostgreSQL Group
+PGGROUP="postgres"
+
+# control what gets started by init script
+PG_START_DB="yes"
+PG_START_REPLICATE="yes"
+PG_START_LB="no"
+
+# Extra options to run postmaster with, e.g.:
+# -N is the maximal number of client connections
+# -B is the number of shared buffers and has to be at least 2x the value for -N
+# Please read the man-page to postmaster for more options. Many of these options
+# can be set directly in the configuration-file.
+#PGOPTS="-N 512 -B 1024"
+
+
+# SERVER SHUTDOWN:
+# The server will receive 3 signals in the worst case:
+# 1. SIGTERM
+# This signals the server to ignore new connections and to
+# wait for all clients to end their transactions before shutting down.
+# Use WAIT_FOR_DISCONNECT to control how much time the clients
+# should have until the next signal is being sent.
+# 2. SIGINT
+# Tell the server to forcefully disconnect all clients.
+# Terminating a client results in a rollback of the open transactions for this client.
+# Use WAIT_FOR_CLEANUP to determine how much time the server has
+# for cleanup.
+# 3. SIGQUIT
+# This will terminate the server immediately and results in a recovery run for the next start.
+
+# Wait for clients to disconnect
+WAIT_FOR_DISCONNECT=30
+
+# Time the server has to clean up
+WAIT_FOR_CLEANUP=60
+
+# Time the server has to quit (with a recover-run on next startup)
+# Set to 0 to deactivate it
+WAIT_FOR_QUIT=60
+
+# Comment this out if you don't want to wait for the server to
+# startup before continuing. For example, if this server is a
+# PITR log shipping based replication standby
+WAIT_FOR_START="-w"
+
+# If you have to export environment variables for the database process,
+# this can be done here.
+#
+# Example:
+# export R_HOME="/usr/lib/R"
diff --git a/unmaintained/pgcluster/pgcluster.initd b/unmaintained/pgcluster/pgcluster.initd
new file mode 100644
index 0000000000..f08d63606f
--- /dev/null
+++ b/unmaintained/pgcluster/pgcluster.initd
@@ -0,0 +1,174 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-8.3,v 1.4 2008/09/28 22:53:02 caleb Exp $
+
+extra_started_commands="reload"
+extra_stopped_commands="setup"
+
+depend() {
+ use net
+ after firewall
+ provide postgresql
+}
+
+checkconfig() {
+ if [ ! -d "$PGDATA" ] ; then
+ eerror "Directory not found: $PGDATA"
+ eerror "Please make sure that PGDATA points to the right path."
+ eerror "You can run '/etc/init.d/pgcluster setup' to setup a new database cluster."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ #ebegin "Starting PostgreSQL"
+
+ if [ -f "$PGDATA/postmaster.pid" ] ; then
+ rm -f "$PGDATA/postmaster.pid"
+ fi
+
+ local retval
+
+ if [ ${PG_START_DB} == "yes" ]; then
+ ebegin "Starting PGCluster database instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl start ${WAIT_FOR_START} -o '--silent-mode=true ${PGOPTS}'" >/dev/null
+ retval=$?
+ if [ $retval -ne 0 ]; then
+ eend $retval
+ else
+
+ # The following is to catch the case of an already running server
+ # in which pg_ctl doesn't know to which server it connected to and false reports the server as 'up'
+ sleep 2
+ if [ ! -f "$PGDATA/postmaster.pid" ] ; then
+ eerror "The pid-file doesn't exist but pg_ctl reported a running server."
+ eerror "Please check whether there is another server running on the same port or read the log-file."
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/postmaster.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+ fi
+
+ if [ ${PG_START_REPLICATE} == "yes" ]; then
+ ebegin "Starting PGCluster replicate instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pgreplicate -D ${PGDATA} -l" >/dev/null
+ retval=$?
+ sleep 1
+ if [ ! -f "$PGDATA/pgreplicate.pid" ] ; then
+ eerror "Where's the pid file?"
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/pgreplicate.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+
+ if [ ${PG_START_LB} == "yes" ]; then
+ ebegin "Starting PGCluster load balancer instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pglb -D ${PGDATA} -l" >/dev/null
+ retval=$?
+ sleep 1
+ if [ ! -f "$PGDATA/pglb.pid" ] ; then
+ eerror "Where's the pid file?"
+ eend 1
+ else
+ local pid=$(grep "^[0-9]\+" "$PGDATA/pglb.pid")
+ test -d /proc/"${pid}"
+ eend $?
+ fi
+ fi
+ return
+}
+
+stop() {
+ local retval
+
+ if [ ${PG_START_LB} == "yes" ]; then
+ ebegin "Stopping PGCluster Load Balancer instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pglb -D ${PGDATA} -l stop" >/dev/null
+ eend $?
+ fi
+ if [ ${PG_START_REPLICATE} == "yes" ]; then
+ ebegin "Stopping PGCluster Replicate instance"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pgreplicate -D ${PGDATA} -l stop" >/dev/null
+ eend $?
+ fi
+
+
+ if [ ${PG_START_DB} == "yes" ]; then
+ ebegin "Stopping PGCLuster database (this can take up to $(( ${WAIT_FOR_DISCONNECT} + ${WAIT_FOR_CLEANUP} )) seconds)"
+ if [ ! -f "$PGDATA/postmaster.pid" ] ; then
+ ewarn "$PGDATA/postmaster.pid not found. Was it running?"
+ eend 1
+ return 0
+ fi
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -t ${WAIT_FOR_DISCONNECT} -m smart" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ ewarn "Some clients did not disconnect within ${WAIT_FOR_DISCONNECT} seconds."
+ ewarn "Going to shutdown the server anyway."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m fast" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ if [ ${WAIT_FOR_QUIT} -eq 0 ] ; then
+ eerror "Server did not shut down and sending the SIGQUIT has been disabled."
+ eend $retval
+ return $retval
+ fi
+
+ ewarn "Shutting down the server gracefully failed."
+ ewarn "Forcing it to shutdown which leads to a recover-run on next startup."
+
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl stop -m immediate" >/dev/null
+
+ retval=$?
+ [ $retval -eq 0 ] && eend $retval && return $retval
+
+ eerror "Forced shutdown failed!!! Something is wrong with your system, please take care of it manually."
+ eend $?
+ fi
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl reload" >/dev/null
+ eend $?
+}
+
+setup() {
+ ebegin "Creating a new PGCluster database cluster"
+ if [ -d "${PGDATA}" ] ; then
+ eend 1 "${PGDATA} already exist"
+ return
+ fi
+ mkdir -p "${PGDATA}"
+ chown -Rf postgres:postgres "${PGDATA}"
+ chmod 0700 "${PGDATA}"
+ cd "${PGDATA}" # to avoid the: could not change directory to "/root"
+ su -c "/usr/bin/initdb --pgdata ${PGDATA}" postgres
+ einfo "You can use the '/etc/init.d/pgcluster' script to run PostgreSQL instead"
+ einfo "of 'pg_ctl'."
+ eend $?
+}
+