aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/postgresql/APKBUILD20
-rw-r--r--main/postgresql/pg-restore.confd16
-rw-r--r--main/postgresql/pg-restore.initd31
-rw-r--r--main/postgresql/postgresql.confd4
-rw-r--r--main/postgresql/postgresql.initd5
5 files changed, 69 insertions, 7 deletions
diff --git a/main/postgresql/APKBUILD b/main/postgresql/APKBUILD
index 625998e89d..00841fb1aa 100644
--- a/main/postgresql/APKBUILD
+++ b/main/postgresql/APKBUILD
@@ -1,17 +1,19 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=postgresql
pkgver=8.4.2
-pkgrel=0
+pkgrel=1
pkgdesc="A sophisticated object-relational DBMS"
url="http://www.postgresql.org/"
license="BSD"
-depends="bbsuid"
+depends="bbsuid postgresql-client"
install="$pkgname.pre-upgrade"
makedepends="readline-dev openssl-dev zlib-dev"
subpackages="$pkgname-dev $pkgname-doc libpq $pkgname-client"
source="ftp://ftp.$pkgname.org/pub/source/v$pkgver/$pkgname-$pkgver.tar.bz2
$pkgname.initd
$pkgname.confd
+ pg-restore.initd
+ pg-restore.confd
"
build() {
@@ -30,9 +32,13 @@ package() {
make DESTDIR="$pkgdir" install || return 1
install -D -m755 "$srcdir"/postgresql.initd \
- "$pkgdir"/etc/init.d/postgresql
+ "$pkgdir"/etc/init.d/postgresql || return 1
install -D -m644 "$srcdir"/postgresql.confd \
- "$pkgdir"/etc/conf.d/postgresql || return 1
+ "$pkgdir"/etc/conf.d/postgresql || return 1
+ install -D -m755 "$srcdir"/pg-restore.initd \
+ "$pkgdir"/etc/init.d/pg-restore || return 1
+ install -D -m644 "$srcdir"/pg-restore.confd \
+ "$pkgdir"/etc/conf.d/pg-restore || return 1
}
libpq() {
@@ -51,5 +57,7 @@ client() {
md5sums="d738227e2f1f742d2f2d4ab56496c5c6 postgresql-8.4.2.tar.bz2
-e1ac78f216a8969a46e4486270b85a9b postgresql.initd
-6218755fde294b7d17b77d280a9c9106 postgresql.confd"
+740bc8414ee27b4c81dee1690c32679f postgresql.initd
+d6b58fc2411fdadcb9b762464c5bee7d postgresql.confd
+e64d0ab26b077ed80d883c0c40704ff4 pg-restore.initd
+8d1b69ac56a1a0d1cfd7da337bf6c5e2 pg-restore.confd"
diff --git a/main/postgresql/pg-restore.confd b/main/postgresql/pg-restore.confd
new file mode 100644
index 0000000000..18bff4c2a3
--- /dev/null
+++ b/main/postgresql/pg-restore.confd
@@ -0,0 +1,16 @@
+
+# Enable this to dump databases on shutdown and restore on boot
+#
+#PGDUMP="/var/lib/postgresql/backup/databases.pgdump"
+
+# The dump file will be deleted once restored unless KEEP_DUMP is set.
+# This is to avoid accidental restoring of running database. If you know what
+# you are doing and want keep the dump, then enable the KEEP_DUMP option
+# below.
+#
+#KEEP_DUMP=yes
+
+# If you enable the KEEP_DUMP bove you probably also want the --clean option
+# the the pg_dumpall command.
+#PG_DUMPALL_OPTS="--clean"
+
diff --git a/main/postgresql/pg-restore.initd b/main/postgresql/pg-restore.initd
new file mode 100644
index 0000000000..aaf07cbe7d
--- /dev/null
+++ b/main/postgresql/pg-restore.initd
@@ -0,0 +1,31 @@
+#!/sbin/runscript
+
+opts="${opts} dump restore"
+
+depend() {
+ need postgresql
+}
+
+restore() {
+ [ -z "$PGDUMP" ] && return 0
+ ebegin "Restoring PostgreSQL $PGDUMP"
+ psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP"
+ eend $?
+ if [ -z "$KEEP_DUMP" ]; then
+ rm -f "$PGDUMP"
+ fi
+}
+
+dump() {
+ [ -z "$PGDUMP" ] && return 0
+ pg_dumpall -U ${PG_USER:-postgres} ${PG_DUMPALL_OPTS} -f "$PGDUMP"
+}
+
+start() {
+ restore
+}
+
+stop() {
+ dump
+}
+
diff --git a/main/postgresql/postgresql.confd b/main/postgresql/postgresql.confd
index 22ff61cd37..4fe28a4584 100644
--- a/main/postgresql/postgresql.confd
+++ b/main/postgresql/postgresql.confd
@@ -50,3 +50,7 @@ WAIT_FOR_START="-w"
#
# Example:
# export R_HOME="/usr/lib/R"
+
+# Automatically set up a new database if missing on startup
+#AUTO_SETUP=yes
+
diff --git a/main/postgresql/postgresql.initd b/main/postgresql/postgresql.initd
index e7941648c3..23b0acff4c 100644
--- a/main/postgresql/postgresql.initd
+++ b/main/postgresql/postgresql.initd
@@ -11,12 +11,15 @@ depend() {
}
checkconfig() {
- if [ ! -d "$PGDATA" ] ; then
+ [ -d "$PGDATA" ] && return 0
+
+ if [ -z "$AUTO_SETUP" ] || [ "$AUTO_SETUP" = "no" ]; then
eerror "Directory not found: $PGDATA"
eerror "Please make sure that PGDATA points to the right path."
eerror "You can run '/etc/init.d/postgresql setup' to setup a new database cluster."
return 1
fi
+ setup
}
start() {