db-move: moved webkit2gtk from [testing] to [extra] (x86_64)
[arch-packages.git] / postgresql / trunk / postgresql-check-db-dir
bloba2134cde5191b7f21f37d3eefdc4238ccd644e77
1 #!/bin/sh
3 # This script verifies that the postgresql data directory has been correctly
4 # initialized. We do not want to automatically initdb it, because that has
5 # a risk of catastrophic failure (ie, overwriting a valuable database) in
6 # corner cases, such as a remotely mounted database on a volume that's a
7 # bit slow to mount. But we can at least emit a message advising newbies
8 # what to do.
10 PGDATA="$1"
12 if [ -z "$PGDATA" ]
13 then
14 echo "Usage: $0 database-path"
15 exit 1
18 # PGMAJORVERSION is major version
19 PGMAJORVERSION=15
20 # PREVMAJORVERSION is the previous major version
21 PREVMAJORVERSION=14
23 # Check for the PGDATA structure
24 if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
25 then
26 # Check version of existing PGDATA
27 if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
28 then
29 : A-OK
30 elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
31 then
32 echo $"An old version of the database format was found."
33 echo $"See https://wiki.archlinux.org/index.php/PostgreSQL#Upgrading_PostgreSQL"
34 exit 1
35 else
36 echo $"An old version of the database format was found."
37 echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
38 echo $"See http://www.postgresql.org/docs/$PGMAJORVERSION/static/upgrading.html"
39 exit 1
41 else
42 # No existing PGDATA! Warn the user to initdb it.
43 echo $"\"$PGDATA\" is missing or empty. Use a command like"
44 echo $" su - postgres -c \"initdb --locale en_US.UTF-8 -D '$PGDATA'\""
45 echo $"with relevant options, to initialize the database cluster."
46 exit 1
49 exit 0