Skip to content

Commit f192da1

Browse files
committed
Provide more useful error message if 'postgres -V' failed. Advertise
pg_ctl '-l' option.
1 parent 253c8fe commit f192da1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/bin/initdb/initdb.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
2424
# Portions Copyright (c) 1994, Regents of the University of California
2525
#
26-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.121 2001/02/18 18:33:59 momjian Exp $
26+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.122 2001/03/13 21:37:15 petere Exp $
2727
#
2828
#-------------------------------------------------------------------------
2929

@@ -117,8 +117,19 @@ elif [ -x "$bindir/postgres" ]; then
117117
then
118118
PGPATH=$bindir
119119
else
120-
echo "The program '$bindir/postgres' needed by $CMDNAME does not belong to" 1>&2
121-
echo "PostgreSQL version $VERSION. Check your installation." 1>&2
120+
# Maybe there was an error message?
121+
errormsg=`$bindir/postgres -V 2>&1 >/dev/null`
122+
(
123+
echo "The program "
124+
echo " '$bindir/postgres'"
125+
echo "needed by $CMDNAME does not belong to PostgreSQL version $VERSION, or"
126+
echo "there may be a configuration problem."
127+
if test x"$errormsg" != x""; then
128+
echo
129+
echo "This was the error message issued by that program:"
130+
echo "$errormsg"
131+
fi
132+
) 1>&2
122133
exit 1
123134
fi
124135
else
@@ -638,9 +649,11 @@ echo "VACUUM pg_database" \
638649
echo
639650
echo "Success. You can now start the database server using:"
640651
echo ""
641-
echo " $PGPATH/postmaster -D $PGDATA"
652+
echo " $PGPATH/postmaster -D $PGDATA"
642653
echo "or"
643-
echo " $PGPATH/pg_ctl -D $PGDATA start"
654+
# (Advertise -l option here, otherwise we have a background
655+
# process writing to the terminal.)
656+
echo " $PGPATH/pg_ctl -D $PGDATA -l logfile start"
644657
echo
645658

646659
exit 0

0 commit comments

Comments
 (0)