diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2015-03-02 09:41:33 +0100 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2015-03-02 10:10:53 +0100 |
commit | 7b1dbe74c98f5be41ad5605260f0edbf40a9fcd1 (patch) | |
tree | 12ce1599858a23ee9a0d9088543450b9e4617f62 /postgresql-check-db-dir.in | |
parent | 9094981751e776fa93537c91bc0e678f4d806b91 (diff) | |
download | postgresql-setup-7b1dbe74c98f5be41ad5605260f0edbf40a9fcd1.tar.gz postgresql-setup-7b1dbe74c98f5be41ad5605260f0edbf40a9fcd1.tar.xz postgresql-setup-7b1dbe74c98f5be41ad5605260f0edbf40a9fcd1.zip |
postgresql-check-db-dir: match configuration approach
* configure.ac (PGDATADIR): Use /var/lib/pgsql/data when prefix is
set to /usr.
(rawpkgdatadir): New directory. Its different from pkgdatadir,
because thats often set to /usr/share/postgresql.
* Makefile.am: Include new rawpkgdatadir Makefile.inc. Fix
distcheck by mentioning legacyscripts_SCRIPTS in GENERATED_FILES.
* postgresql-check-db-dir.in: Use library.sh to give user better
advice. Use @NAME_BINARYBASE@ prefix.
(bad_version): New function.
(PREVMAJORVERSION): Removed unused variable.
* postgresql-setup.in: Cut out the config-parsing routines into
library.sh.
* share/postgresql-setup/library.sh.in: New library file. Added
new option 'list' for parse_upgrade_setup.
* share/postgresql-setup/Makefile.inc: New file.
* share/postgresql-setup/.gitignore: Ignore library.sh.
Diffstat (limited to 'postgresql-check-db-dir.in')
-rw-r--r-- | postgresql-check-db-dir.in | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/postgresql-check-db-dir.in b/postgresql-check-db-dir.in index fec7891..0d9854d 100644 --- a/postgresql-check-db-dir.in +++ b/postgresql-check-db-dir.in @@ -42,35 +42,53 @@ PGVERSION=@PGVERSION@ # Major version of PostgreSQL, e.g. 9.0 PGMAJORVERSION=@PGMAJORVERSION@ -# Previous major version, e.g., 8.4, for upgrades -PREVMAJORVERSION=@PREVMAJORVERSION@ - # Distribution README file README_DIST=@README_DIST@ +bad_version() +{ + local real_version="$1" + + . "@rawpkgdatadir@/library.sh" + + while read id version; do + test "$version" = "$real_version" || continue + + local cmd="postgresql-setup --upgrade" + + test "@NAME_DEFAULT_PREV_SERVICE@" = "$id" \ + || cmd="$cmd --upgrade-from $id" + + echo $"An old version of the database format was found." + echo $"Use '$cmd' to upgrade to version '$PGMAJORVERSION'" + echo $"See $README_DIST for more information." + + return + done < <(parse_upgrade_setup list) + + echo $"An old version '$real_version' of the database format was found." + echo $"You need to dump and reload before using PostgreSQL $PGVERSION." + echo $"See $README_DIST for more information." + + return +} + # Check for the PGDATA structure if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ] then + real_version=`cat "$PGDATA/PG_VERSION"` # Check version of existing PGDATA - if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ] + if [ x"$real_version" = x"$PGMAJORVERSION" ] then : A-OK - elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ] - then - echo $"An old version of the database format was found." - echo $"Use \"postgresql-setup --upgrade\" to upgrade to version $PGMAJORVERSION." - echo $"See $README_DIST for more information." - exit 1 else - echo $"An old version of the database format was found." - echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION." - echo $"See $README_DIST for more information." + bad_version "$real_version" exit 1 fi else # No existing PGDATA! Warn the user to initdb it. echo $"\"$PGDATA\" is missing or empty." - echo $"Use \"postgresql-setup --initdb\" to initialize the database cluster." + echo $"Use \"@NAME_BINARYBASE@-setup --initdb\" to initialize the database cluster." echo $"See $README_DIST for more information." exit 1 fi |