提交 27bccb9d 编写于 作者: M Marc G. Fournier

This patch fixes problems in initdb, including that it doesn't run

with some versions of sh, and a bug in the master make file that
causes it to issue the message "postgres has been built" at the wrong
time.

Submitted by: bryanh@giraffe.netgate.net (Bryan Henderson)
上级 22749a1d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile,v 1.5 1996/10/03 20:09:48 momjian Exp $ # $Header: /cvsroot/pgsql/src/Makefile,v 1.6 1996/10/04 20:07:04 scrappy Exp $
# #
# NOTES # NOTES
# objdir - location of the objects and generated files (eg. obj) # objdir - location of the objects and generated files (eg. obj)
...@@ -34,7 +34,9 @@ endif ...@@ -34,7 +34,9 @@ endif
$(MAKE) -C bin $@ $(MAKE) -C bin $@
$(MAKE) -C ../doc $@ $(MAKE) -C ../doc $@
@-chown -R $(POSTGRESLOGIN) $(POSTGRESDIR) 2>/dev/null @-chown -R $(POSTGRESLOGIN) $(POSTGRESDIR) 2>/dev/null
@echo All of Postgres95 is successfully made. Ready to install. @if test $@. = all. -o $@. = .; then \
echo All of Postgres95 is successfully made. Ready to install. ;\
fi
TAGS: TAGS:
rm -f TAGS; \ rm -f TAGS; \
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.8 1996/10/03 04:20:11 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.9 1996/10/04 20:07:10 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -57,28 +57,34 @@ noclean=0 ...@@ -57,28 +57,34 @@ noclean=0
template_only=0 template_only=0
POSTGRES_SUPERUSERNAME=$USER POSTGRES_SUPERUSERNAME=$USER
while [ "$#" -gt 0 ] for ARG ; do
do # We would normally use e.g. ${ARG#--username=} to parse the options, but
if [ "$1" = "-d" ]; then # there is a bug in some shells that makes that not work (BSD4.4 sh,
# September 1996 -- supposed to be fixed in later release). So we bypass
# the bug with this sed mess.
username_sed=`echo $ARG | sed s/^--username=//`
pgdata_sed=`echo $ARG | sed s/^--pgdata=//`
if [ $ARG = "--debug" -o $ARG = "-d" ]; then
debug=1 debug=1
echo "Running with debug mode on." echo "Running with debug mode on."
elif [ "$1" = "-n" ]; then elif [ $ARG = "--noclean" -o $ARG = "-n" ]; then
noclean=1 noclean=1
echo "Running with noclean mode on. Mistakes will not be cleaned up." echo "Running with noclean mode on. Mistakes will not be cleaned up."
elif [ "$1" = "-t" ]; then elif [ $ARG = "--template" ]; then
template_only=1 template_only=1
echo "updating template1 database only." echo "updating template1 database only."
elif [ "$1" = "-u" ]; then elif [ $username_sed. != $ARG. ]; then
shift POSTGRES_SUPERUSERNAME=$username_sed
POSTGRES_SUPERUSERNAME="$1" elif [ $pgdata_sed. != $ARG. ]; then
elif [ "$1" = "-r" ]; then PGDATA=$pgdata_sed
shift
PGDATA=$1
else else
echo "initdb [-t] [-d] [-n] [-u superuser] [-r datadir]" 1>&2 echo "Unrecognized option '$ARG'. Syntax is:"
exit 1 echo "initdb [--template] [--debug] [--noclean]" \
"[--username=SUPERUSER] [--pgdata=DATADIR]"
exit 100
fi fi
shift
done done
if [ "$debug" -eq 1 ]; then if [ "$debug" -eq 1 ]; then
...@@ -108,6 +114,7 @@ if [ $template_only -eq 0 ]; then ...@@ -108,6 +114,7 @@ if [ $template_only -eq 0 ]; then
echo "$CMDNAME: using $GLOBAL as input to create the global classes." echo "$CMDNAME: using $GLOBAL as input to create the global classes."
echo "$CMDNAME: using $PG_HBA_SAMPLE as the host-based authentication" \ echo "$CMDNAME: using $PG_HBA_SAMPLE as the host-based authentication" \
"control file." "control file."
echo
fi fi
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
...@@ -143,6 +150,7 @@ echo "We are initializing the database system with username" \ ...@@ -143,6 +150,7 @@ echo "We are initializing the database system with username" \
echo "Please be aware that Postgres is not secure. Anyone who can connect" echo "Please be aware that Postgres is not secure. Anyone who can connect"
echo "to the database can act as user $POSTGRES_SUPERUSERNAME" \ echo "to the database can act as user $POSTGRES_SUPERUSERNAME" \
"with very little effort." "with very little effort."
echo
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Create the data directory if necessary # Create the data directory if necessary
...@@ -165,11 +173,13 @@ if [ -d "$PGDATA" ]; then ...@@ -165,11 +173,13 @@ if [ -d "$PGDATA" ]; then
else else
if [ ! -d $PGDATA ]; then if [ ! -d $PGDATA ]; then
echo "Creating Postgres database system directory $PGDATA" echo "Creating Postgres database system directory $PGDATA"
echo
mkdir $PGDATA mkdir $PGDATA
if [ $? -ne 0 ]; then exit 5; fi if [ $? -ne 0 ]; then exit 5; fi
fi fi
if [ ! -d $PGDATA/base ]; then if [ ! -d $PGDATA/base ]; then
echo "Creating Postgres database system directory $PGDATA/base" echo "Creating Postgres database system directory $PGDATA/base"
echo
mkdir $PGDATA/base mkdir $PGDATA/base
if [ $? -ne 0 ]; then exit 5; fi if [ $? -ne 0 ]; then exit 5; fi
fi fi
...@@ -203,6 +213,8 @@ if [ $? -ne 0 ]; then ...@@ -203,6 +213,8 @@ if [ $? -ne 0 ]; then
exit 1; exit 1;
fi fi
echo
pg_version $PGDATA/base/template1 pg_version $PGDATA/base/template1
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
...@@ -210,8 +222,6 @@ pg_version $PGDATA/base/template1 ...@@ -210,8 +222,6 @@ pg_version $PGDATA/base/template1
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
if [ $template_only -eq 0 ]; then if [ $template_only -eq 0 ]; then
echo "$CMDNAME: creating global classes in $PGDATA"
echo "Creating global classes in $PG_DATA/base" echo "Creating global classes in $PG_DATA/base"
echo "Running: postgres $BACKENDARGS template1" echo "Running: postgres $BACKENDARGS template1"
...@@ -234,6 +244,8 @@ if [ $template_only -eq 0 ]; then ...@@ -234,6 +244,8 @@ if [ $template_only -eq 0 ]; then
exit 1; exit 1;
fi fi
echo
pg_version $PGDATA pg_version $PGDATA
cp $PG_HBA_SAMPLE $PGDATA/pg_hba cp $PG_HBA_SAMPLE $PGDATA/pg_hba
...@@ -262,10 +274,10 @@ if [ $template_only -eq 0 ]; then ...@@ -262,10 +274,10 @@ if [ $template_only -eq 0 ]; then
rm -f /tmp/create.$$ rm -f /tmp/create.$$
fi fi
echo
if [ $debug -eq 0 ]; then if [ $debug -eq 0 ]; then
echo "vacuuming template1" echo "vacuuming template1"
echo "vacuum" | postgres -F -Q template1 > /dev/null echo "vacuum" | postgres -F -Q template1 > /dev/null
fi fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册