2323#
2424# Copyright (c) 1994, Regents of the University of California
2525#
26- # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.112 2000/11/09 11:26:00 vadim Exp $
26+ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.113 2000/11/11 22:59:46 petere Exp $
2727#
2828# -------------------------------------------------------------------------
2929
3434
3535exit_nicely (){
3636 sttyecho > /dev/null2>&1
37- echo
38- echo " $CMDNAME failed."
37+ echo 1>&2
38+ echo " $CMDNAME failed." 1>&2
3939if [" $noclean " != yes ]; then
4040if [" $template_only " != yes ]&& [" $made_new_pgdata " = yes ]; then
41- echo " Removing$PGDATA ."
42- rm -rf" $PGDATA " || echo " Failed."
41+ echo " Removing$PGDATA ." 1>&2
42+ rm -rf" $PGDATA " || echo " Failed." 1>&2
4343fi
44- echo " Removing temp file$TEMPFILE ."
45- rm -rf" $TEMPFILE " || echo " Failed."
44+ echo " Removing temp file$TEMPFILE ." 1>&2
45+ rm -rf" $TEMPFILE " || echo " Failed." 1>&2
4646else
47- echo " Data directory$PGDATA will not be removed at user's request."
47+ echo " Data directory$PGDATA will not be removed at user's request." 1>&2
4848fi
4949exit 1
5050}
@@ -117,43 +117,43 @@ elif [ -x "$bindir/postgres" ]; then
117117then
118118 PGPATH=$bindir
119119else
120- echo " The program '$bindir /postgres' needed by$CMDNAME does not belong to"
121- echo " PostgreSQL version$VERSION . Check your installation."
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
122122exit 1
123123fi
124124else
125- echo " The program 'postgres' is needed by$CMDNAME but was not found in"
126- echo " the directory '$bindir '. Check your installation."
125+ echo " The program 'postgres' is needed by$CMDNAME but was not found in" 1>&2
126+ echo " the directory '$bindir '. Check your installation." 1>&2
127127exit 1
128128fi
129129
130130
131131# Now we can assume that 'pg_id' belongs to the same version as the
132132# verified 'postgres' in the same directory.
133133if [! -x " $PGPATH /pg_id" ]; then
134- echo " The program 'pg_id' is needed by$CMDNAME but was not found in"
135- echo " the directory '$PGPATH '. Check your installation."
134+ echo " The program 'pg_id' is needed by$CMDNAME but was not found in" 1>&2
135+ echo " the directory '$PGPATH '. Check your installation." 1>&2
136136exit 1
137137fi
138138
139139
140140EffectiveUser=` $PGPATH /pg_id -n -u`
141141if [-z " $EffectiveUser " ]; then
142- echo " $CMDNAME : could not determine current user name"
142+ echo " $CMDNAME : could not determine current user name" 1>&2
143143exit 1
144144fi
145145
146146if [` $PGPATH /pg_id -u` -eq 0 ]
147147then
148- echo " You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"
149- echo " as the (unprivileged) user that will own the server process."
148+ echo " You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')" 1>&2
149+ echo " as the (unprivileged) user that will own the server process." 1>&2
150150exit 1
151151fi
152152
153153
154154short_version=` echo$VERSION | sed -e' s!^\([0-9][0-9]*\.[0-9][0-9]*\).*!\1!' `
155155if [ x" $short_version " = x" " ]; then
156- echo " $CMDNAME : bug: version numberis out of format"
156+ echo " $CMDNAME : bug: version numberhas wrong format" 1>&2
157157exit 1
158158fi
159159
252252 ;;
253253-* )
254254echo " $CMDNAME : invalid option:$1 "
255- echo " Try-? for help."
255+ echo " Try' $CMDNAME -?' for help."
256256exit 1
257257;;
258258* )
263263done
264264
265265if [" $usage " ]; then
266- echo " $CMDNAME initialized a PostgreSQL database cluster."
266+ echo " $CMDNAME initializes a PostgreSQL database cluster."
267267echo
268268echo " Usage:"
269269echo " $CMDNAME [options] datadir"
270270echo
271271echo " Options:"
272- echo " [-D, --pgdata]<datadir> Location for this database cluster"
272+ echo " [-D, --pgdata]DATADIR Location for this database cluster"
273273echo " -W, --pwprompt Prompt for a password for the new superuser"
274274if [-n " $MULTIBYTE " ]; then
275- echo " -E, --encoding<encoding> Set the default multibyte encoding for new databases"
275+ echo " -E, --encodingENCODING Set the default multibyte encoding for new databases"
276276fi
277- echo " -i, --sysid<sysid> Database sysid for the superuser"
277+ echo " -i, --sysidSYSID Database sysid for the superuser"
278278echo " Less commonly used options:"
279- echo " -L<directory> Where to find the input files"
279+ echo " -LDIRECTORY Where to find the input files"
280280echo " -t, --template Re-initialize template database only"
281281echo " -d, --debug Generate lots of debugging output"
282282echo " -n, --noclean Do not clean up after errors"
@@ -294,15 +294,17 @@ then
294294MULTIBYTEID=` $PGPATH /pg_encoding$MULTIBYTE `
295295if [" $? " -ne 0 ]
296296then
297+ (
297298echo " $CMDNAME : pg_encoding failed"
298299echo
299300echo " Perhaps you did not configure PostgreSQL for multibyte support or"
300301echo " the program was not successfully installed."
302+ )1>&2
301303exit 1
302304fi
303305if [-z " $MULTIBYTEID " ]
304306then
305- echo " $CMDNAME :$MULTIBYTE is not a valid encoding name"
307+ echo " $CMDNAME :$MULTIBYTE is not a valid encoding name" 1>&2
306308exit 1
307309fi
308310fi
314316
315317if [-z " $PGDATA " ]
316318then
319+ (
317320echo " $CMDNAME : You must identify where the the data for this database"
318321echo " system will reside. Do this with either a -D invocation"
319322echo " option or a PGDATA environment variable."
320- echo
323+ ) 1>&2
321324exit 1
322325fi
323326
353356for PREREQ_FILE in " $TEMPLATE1_BKI " " $GLOBAL_BKI " " $PG_HBA_SAMPLE "
354357do
355358if [! -f " $PREREQ_FILE " ]; then
359+ (
356360echo " $CMDNAME does not find the file '$PREREQ_FILE '."
357361echo " This means you have a corrupted installation or identified the"
358362echo " wrong directory with the -L invocation option."
363+ )1>&2
359364exit 1
360365fi
361366done
362367
363368for file in " $TEMPLATE1_BKI " " $GLOBAL_BKI " ; do
364369if [ x" ` sed 1q$file ` " != x" # PostgreSQL$short_version " ]; then
370+ (
365371echo " The input file '$file ' needed by$CMDNAME does not"
366372echo " belong to PostgreSQL$VERSION . Check your installation or specify the"
367373echo " correct path using the -L option."
374+ )1>&2
368375exit 1
369376fi
370377done
@@ -391,10 +398,12 @@ if [ x"$pgdata_contents" != x ]
391398then
392399if [" $template_only " != yes ]
393400then
401+ (
394402echo " $CMDNAME : The directory$PGDATA is exists but is not empty."
395403echo " If you want to create a new database system, either remove or empty"
396404echo " the directory$PGDATA or run initdb with an argument"
397405echo " other than$PGDATA ."
406+ )1>&2
398407exit 1
399408fi
400409else
@@ -509,13 +518,13 @@ if [ "$PwPrompt" ]; then
509518 sttyecho > /dev/null2>&1
510519echo
511520if [" $FirstPw " != " $SecondPw " ]; then
512- echo " Passwords didn't match."
521+ echo " Passwords didn't match." 1>&2
513522 exit_nicely
514523fi
515524echo " ALTER USER\" $POSTGRES_SUPERUSERNAME \" WITH PASSWORD '$FirstPw '" \
516525| " $PGPATH " /postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
517526if [! -f $PGDATA /pg_pwd ]; then
518- echo " The password file wasn't generated. Please report this problem."
527+ echo " The password file wasn't generated. Please report this problem." 1>&2
519528 exit_nicely
520529fi
521530echo " Setting password"