diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-07-04 10:29:36 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-07-04 10:45:22 +0200 |
commit | 7bc6b1e356a0c157e575167c6fa57f647f52d601 (patch) | |
tree | bef38a1ebc44aa5ad3478eb578e582b84b27ddb6 | |
parent | 7a9df4d2886ef19417db9f4cf0c65b3160f877fc (diff) | |
download | postgresql-setup-7bc6b1e356a0c157e575167c6fa57f647f52d601.tar.gz postgresql-setup-7bc6b1e356a0c157e575167c6fa57f647f52d601.tar.xz postgresql-setup-7bc6b1e356a0c157e575167c6fa57f647f52d601.zip |
service: avoid cryptic failure with old config
If user removes currently provided /etc/postgresql/postgresql
configuration file, PGDATA env variable is not set. The
`systemctl start postgresql` would fail similarly to
`systemctl start postgresql@NOTCONFIGURED` when the configuration
file was not created yet with cryptic message
"Usage: ... "
Stop this behavior rather explicitly with proper error in
check-db-dir script.
Warn also user in similar fashion that the configuration should be
adjusted in case the PGDATA was set directly in service file.
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | postgresql-check-db-dir.in | 26 | ||||
-rw-r--r-- | postgresql.service.in | 2 |
3 files changed, 31 insertions, 5 deletions
@@ -1,5 +1,13 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +New in 0.9.2 version + +* The postgresql-check-db-dir is now more strict to admin's configuration + and tries to avoid future incompatibilities by warning about the + /etc/postgresql/$servicename file non-existence. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + New in 0.9.1 version * The postgresql-setup script does not require --port option when upgrading. diff --git a/postgresql-check-db-dir.in b/postgresql-check-db-dir.in index 3514247..2dd0649 100644 --- a/postgresql-check-db-dir.in +++ b/postgresql-check-db-dir.in @@ -7,14 +7,32 @@ # bit slow to mount. But we can at least emit a message advising newbies # what to do. -PGDATA="$1" +if test -z "$1"; then + echo "Maintainer error: $0 must be run with one argument" + exit 1 +fi + +service_name="$1" + +if [ -z "$PGDATA" ]; then + echo $"You try to start '$service_name' service" + echo $"but the required \$PGDATA environment variable is not set." + echo $"You should use the @PKGCONFIG_DIR@/$service_name" + echo $"configuration file to set \$PGDATA. For more info see" + echo $"the @README_DIST@ file." -if [ -z "$PGDATA" ] -then - echo "Usage: $0 database-path" exit 1 fi +# Warn the user that the configuration should be adjusted. +conf_file="@PKGCONFIG_DIR@/$service_name" +if test ! -r "$conf_file"; then + echo >&2 $"WARNING: Note that file '$conf_file'" + echo >&2 $"does not exist. Your configuration will be supported for some" + echo >&2 $"time but you are encouraged to create this file according to" + echo >&2 $"@README_DIST@ documentation." +fi + # Full PostgreSQL version, e.g. 9.0.2 PGVERSION=@PGVERSION@ diff --git a/postgresql.service.in b/postgresql.service.in index ad0a3e1..4b9fc95 100644 --- a/postgresql.service.in +++ b/postgresql.service.in @@ -27,7 +27,7 @@ OOMScoreAdjust=-1000 Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj Environment=PG_OOM_ADJUST_VALUE=0 -ExecStartPre=@libexecdir@/postgresql-check-db-dir ${PGDATA} +ExecStartPre=@libexecdir@/postgresql-check-db-dir %N # Temporarily use postgresql-ctl wrapper around pg_ctl until there will # exist clients which set PGPORT in service file. |