3030# Check the catalog version
3131CATALOG_VERSION_NO=2016081311
3232MAJORVER=9.6
33+ if [! -f " ${PGDATA} /global/pg_control" -a -f " ${PGDATA} /postgresql.conf" ]; then
34+ # looks like we have Debian with separate directory for configs
35+ SAVE_PGDATA=" $PGDATA "
36+ PGDATA=` sed -n" /data_directory/{s/^data_directory = '//
37+ s/'.*$//
38+ p}" ${PGDATA} /postgresql.conf`
39+ if [-z " $PGDATA " -o ! -f " ${PGDATA} /global/pg_control" ]; then
40+ echo " Cannot find valid database in$PGDATA " 1>&2 ;
41+ exit 1
42+ fi
43+ fi
3344CATVER=` ${PGBIN} pg_controldata| sed -n' /Catalog version number:/s/^.*: *//p' `
3445if [" $CATVER " != $CATALOG_VERSION_NO ]; then
3546if [-n " $check " ]; then
3647echo " Database needs upgrade"
3748exit 1
3849fi
39- if [! -f " ${PGDATA} /global/pg_control" ]; then
40- # looks like we have Debian with separate directory for configs
41- SAVE_PGDATA=" $PGDATA "
42- PGDATA=` sed -n" /data_directory/{s/^data_directory = '//
43- s/'.*$//
44- p}" /etc/postgresql/9.6/main/postgresql.conf`
45- if [-z " $PGDATA " -o ! -f " ${PGDATA} /global/pg_control" ]; then
46- echo " Cannot find valid database in$PGDATA " 1>&2 ;
47- exit 1
48- fi
49- if [-f " $PGDATA /postmaster.pid" ]; then
50- echo " postmaster.pid exists. Is another backend running on$PGDATA " 1>&2 ;
51- exit 1;
52- fi
50+ if [-f " $PGDATA /postmaster.pid" ]; then
51+ echo " postmaster.pid exists. Is another backend running on$PGDATA " 1>&2 ;
52+ exit 1;
5353fi
5454# Fix pg_control file
5555" ${PGBIN} pg_controldata" -c
@@ -60,11 +60,11 @@ if [ "$CATVER" != $CATALOG_VERSION_NO ]; then
6060(cd$i ; mv PG_${MAJORVER} _$CATVER PG_${MAJORVER} _$CATALOG_VERSION_NO )
6161done
6262)
63- if [-n " $SAVE_PGDATA " ]; then
64- PGDATA=" $SAVE_PGDATA "
65- fi
6663fi
6764
65+ if [-n " $SAVE_PGDATA " ]; then
66+ PGDATA=" $SAVE_PGDATA "
67+ fi
6868
6969for dir in " $PGSHARE " /usr/pgsql-9.6/share /usr/share/postgresql/9.6 /usr/pgsql/9.6/share /usr/share/pgsql /usr/share/postgrespro96; do
7070if [-d " $dir /pgpro-upgrade" ]; then