|
|
699f87 |
#!/bin/sh
|
|
|
699f87 |
|
|
|
699f87 |
# This script verifies that the postgresql data directory has been correctly
|
|
|
699f87 |
# initialized. We do not want to automatically initdb it, because that has
|
|
|
699f87 |
# a risk of catastrophic failure (ie, overwriting a valuable database) in
|
|
|
699f87 |
# corner cases, such as a remotely mounted database on a volume that's a
|
|
|
699f87 |
# bit slow to mount. But we can at least emit a message advising newbies
|
|
|
699f87 |
# what to do.
|
|
|
699f87 |
|
|
|
699f87 |
PGDATA="$1"
|
|
|
699f87 |
|
|
|
699f87 |
if [ -z "$PGDATA" ]
|
|
|
699f87 |
then
|
|
|
699f87 |
echo "Usage: $0 database-path"
|
|
|
699f87 |
exit 1
|
|
|
699f87 |
fi
|
|
|
699f87 |
|
|
|
699f87 |
# PGVERSION is the full package version, e.g., 9.1.2
|
|
|
699f87 |
# Note: the specfile inserts the correct value during package build
|
|
|
699f87 |
PGVERSION=xxxx
|
|
|
699f87 |
# PGMAJORVERSION is major version, e.g., 9.1 (this should match PG_VERSION)
|
|
|
699f87 |
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
|
|
|
699f87 |
# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
|
|
|
699f87 |
# Note: the specfile inserts the correct value during package build
|
|
|
699f87 |
PREVMAJORVERSION=xxxx
|
|
|
699f87 |
# PGDOCDIR is the directory containing the package's documentation
|
|
|
699f87 |
# Note: the specfile inserts the correct value during package build
|
|
|
699f87 |
PGDOCDIR=xxxx
|
|
|
699f87 |
|
|
|
699f87 |
# Check for the PGDATA structure
|
|
|
699f87 |
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
|
|
|
699f87 |
then
|
|
|
699f87 |
# Check version of existing PGDATA
|
|
|
699f87 |
if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
|
|
|
699f87 |
then
|
|
|
699f87 |
: A-OK
|
|
|
699f87 |
elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
|
|
|
699f87 |
then
|
|
|
699f87 |
echo $"An old version of the database format was found."
|
|
|
699f87 |
echo $"Use \"postgresql-setup upgrade\" to upgrade to version $PGMAJORVERSION."
|
|
|
699f87 |
echo $"See $PGDOCDIR/README.rpm-dist for more information."
|
|
|
699f87 |
exit 1
|
|
|
699f87 |
else
|
|
|
699f87 |
echo $"An old version of the database format was found."
|
|
|
699f87 |
echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
|
|
|
699f87 |
echo $"See $PGDOCDIR/README.rpm-dist for more information."
|
|
|
699f87 |
exit 1
|
|
|
699f87 |
fi
|
|
|
699f87 |
else
|
|
|
699f87 |
# No existing PGDATA! Warn the user to initdb it.
|
|
|
699f87 |
echo $"\"$PGDATA\" is missing or empty."
|
|
|
699f87 |
echo $"Use \"postgresql-setup initdb\" to initialize the database cluster."
|
|
|
699f87 |
echo $"See $PGDOCDIR/README.rpm-dist for more information."
|
|
|
699f87 |
exit 1
|
|
|
699f87 |
fi
|
|
|
699f87 |
|
|
|
699f87 |
exit 0
|