aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron W. Swenson <titanofold@gentoo.org>2013-08-21 00:59:16 +0000
committerAaron W. Swenson <titanofold@gentoo.org>2013-08-21 00:59:16 +0000
commitdbf7529b88ea447dbfed0bf3f1a9c7627e6285af (patch)
tree3e20192b7b0c6f74ce22bc644f253a46031517e3
parentNew systemd files (diff)
downloadpatches-dbf7529b88ea447dbfed0bf3f1a9c7627e6285af.tar.gz
patches-dbf7529b88ea447dbfed0bf3f1a9c7627e6285af.tar.bz2
patches-dbf7529b88ea447dbfed0bf3f1a9c7627e6285af.zip
Updated systemd files.
-rw-r--r--postgresql-check-db-dir36
-rw-r--r--postgresql.service14
2 files changed, 43 insertions, 7 deletions
diff --git a/postgresql-check-db-dir b/postgresql-check-db-dir
new file mode 100644
index 0000000..d4e1083
--- /dev/null
+++ b/postgresql-check-db-dir
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+eerror() {
+ echo "$@" >&2
+}
+
+# Check that DATA_DIR has been set
+if [ -z ${DATA_DIR} ] ; then
+ eerror "DATA_DIR not set"
+ exit 1
+fi
+
+# Check that DATA_DIR exists
+if [ ! -d ${DATA_DIR} ] ; then
+ eerror "Directory not found: ${DATA_DIR}"
+ eerror "HINT: Ensure that DATA_DIR points to the right path."
+ eerror "HINT: Or perhaps you need to create the database cluster:"
+ eerror " emerge --config dev-db/postgresql-server:@SLOT@"
+ exit 1
+fi
+
+# Check for the existence of PostgreSQL's config files, and set the
+# proper mode and ownership.
+# Only three files should be checked as potentially other files
+# may be in PGDATA that should not be touched.
+for file in postgresql pg_hba pg_ident ; do
+ file="${PGDATA%/}/${file}.conf"
+ if [ ! -f ${file} ] ; then
+ eerror "${file} not found"
+ eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
+ exit 1
+ fi
+done
diff --git a/postgresql.service b/postgresql.service
index 3d70197..f8be8ac 100644
--- a/postgresql.service
+++ b/postgresql.service
@@ -36,16 +36,16 @@ Environment=DATA_DIR=/var/lib/postgresql/@SLOT@/data
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
-# Disable OOM kill on the postmaster
-OOMScoreAdjust=-1000
-
-#ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA}
-ExecStart=/usr/lib/postgresql-@SLOT@/bin/pg_ctl start -D ${PGDATA} -s -l ${DATA_DIR}/postmaster.log -o "-p ${PGPORT} --data-directory=${DATA_DIR}" -w -t 300
-ExecStop=/usr/lib/postgresql-@SLOT@/bin/pg_ctl stop -D ${PGDATA} -s -m fast -o "--data-directory=${DATA_DIR}"
-ExecReload=/usr/lib/postgresql-@SLOT@/bin/pg_ctl reload -D ${PGDATA} -s -o "--data-directory=${DATA_DIR}"
+ExecStartPre=/usr/bin/postgresql-@SLOT@-check-db-dir
+ExecStart=/usr/lib/postgresql-@SLOT@/bin/pg_ctl start -D ${DATA_DIR} -s -l ${DATA_DIR}/postmaster.log -o "-p ${PGPORT} -D ${PGDATA} --data-directory=${DATA_DIR}" -w -t 300
+ExecStop=/usr/lib/postgresql-@SLOT@/bin/pg_ctl stop -D ${DATA_DIR} -s -m fast
+ExecReload=/usr/lib/postgresql-@SLOT@/bin/pg_ctl reload -D ${DATA_DIR} -s
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
+# Disable OOM kill on the postmaster
+OOMScoreAdjust=-1000
+
[Install]
WantedBy=multi-user.target