27
27
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
28
28
# Portions Copyright (c) 1994, Regents of the University of California
29
29
#
30
- # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.132 2001/08/10 18:57:38 tgl Exp $
30
+ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.133 2001/08/25 00:31:17 petere Exp $
31
31
#
32
32
# -------------------------------------------------------------------------
33
33
@@ -343,14 +343,16 @@ POSTGRESQL_CONF_SAMPLE="$datadir"/postgresql.conf.sample
343
343
344
344
if [ " $show_setting " = yes ] || [ " $debug " = yes ]
345
345
then
346
+ (
346
347
echo
347
- echo " Initdb variables:"
348
+ echo " initdb variables:"
348
349
for var in PGDATA datadir PGPATH MULTIBYTE MULTIBYTEID \
349
350
POSTGRES_SUPERUSERNAME POSTGRES_SUPERUSERID POSTGRES_BKI \
350
351
POSTGRES_DESCR POSTGRESQL_CONF_SAMPLE \
351
352
PG_HBA_SAMPLE PG_IDENT_SAMPLE ; do
352
353
eval " echo ' '$var =\$ $var "
353
354
done
355
+ ) 1>&2
354
356
fi
355
357
356
358
if [ " $show_setting " = yes ] ; then
386
388
trap ' echo "Caught signal." ; exit_nicely' 1 2 3 15
387
389
388
390
# Let's go
389
- echo " This database system will be initialized with username \" $POSTGRES_SUPERUSERNAME \" ."
391
+ echo " This database system will be initialized with user name \" $POSTGRES_SUPERUSERNAME \" ."
390
392
echo " This user will own all the data files and must also own the server process."
391
393
echo
392
394
@@ -411,28 +413,32 @@ then
411
413
exit 1
412
414
else
413
415
if [ ! -d " $PGDATA " ]; then
414
- echo " Creating directory $PGDATA "
416
+ $ECHO_N " creating directory $PGDATA ... " $ECHO_C
415
417
mkdir -p " $PGDATA " > /dev/null 2>&1 || mkdir " $PGDATA " || exit_nicely
416
418
made_new_pgdata=yes
417
419
else
418
- echo " Fixing permissions on existing directory $PGDATA "
420
+ $ECHO_N " Fixing permissions on existing directory $PGDATA ... " $ECHO_C
419
421
chmod go-rwx " $PGDATA " || exit_nicely
420
422
fi
423
+ echo " ok"
421
424
422
425
if [ ! -d " $PGDATA " /base ]
423
426
then
424
- echo " Creating directory $PGDATA /base"
427
+ $ECHO_N " creating directory $PGDATA /base... " $ECHO_C
425
428
mkdir " $PGDATA " /base || exit_nicely
429
+ echo " ok"
426
430
fi
427
431
if [ ! -d " $PGDATA " /global ]
428
432
then
429
- echo " Creating directory $PGDATA /global"
433
+ $ECHO_N " creating directory $PGDATA /global... " $ECHO_C
430
434
mkdir " $PGDATA " /global || exit_nicely
435
+ echo " ok"
431
436
fi
432
437
if [ ! -d " $PGDATA " /pg_xlog ]
433
438
then
434
- echo " Creating directory $PGDATA /pg_xlog"
439
+ $ECHO_N " creating directory $PGDATA /pg_xlog... " $ECHO_C
435
440
mkdir " $PGDATA " /pg_xlog || exit_nicely
441
+ echo " ok"
436
442
fi
437
443
fi
438
444
441
447
#
442
448
# RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1
443
449
444
- rm -rf " $PGDATA " /base/1 || exit_nicely
445
- mkdir " $PGDATA " /base/1 || exit_nicely
450
+ # common backend options
451
+ PGSQL_OPT= " -F -D $PGDATA "
446
452
447
453
if [ " $debug " = yes ]
448
454
then
449
455
BACKEND_TALK_ARG=" -d"
456
+ else
457
+ PGSQL_OPT=" $PGSQL_OPT -o /dev/null"
450
458
fi
451
459
452
- FIRSTRUN=" -boot -x1 -F -D$PGDATA $BACKEND_TALK_ARG "
453
460
454
- echo " Creating template1 database in $PGDATA /base/1"
455
- [ " $debug " = yes ] && echo " Running: $PGPATH /postgres $FIRSTRUN template1"
461
+ $ECHO_N " creating template1 database in $PGDATA /base/1... " $ECHO_C
462
+
463
+ rm -rf " $PGDATA " /base/1 || exit_nicely
464
+ mkdir " $PGDATA " /base/1 || exit_nicely
456
465
457
466
cat " $POSTGRES_BKI " \
458
467
| sed -e " s/POSTGRES/$POSTGRES_SUPERUSERNAME /g" \
459
468
-e " s/PGUID/$POSTGRES_SUPERUSERID /g" \
460
469
-e " s/ENCODING/$MULTIBYTEID /g" \
461
- | " $PGPATH " /postgres $FIRSTRUN template1 \
470
+ | " $PGPATH " /postgres -boot -x1 $PGSQL_OPT $BACKEND_TALK_ARG template1 \
462
471
|| exit_nicely
463
472
464
473
echo $short_version > " $PGDATA " /base/1/PG_VERSION || exit_nicely
465
474
475
+ echo " ok"
476
+
466
477
# #########################################################################
467
478
#
468
479
# CREATE CONFIG FILES
469
480
481
+ $ECHO_N " creating configuration files... " $ECHO_C
482
+
470
483
echo $short_version > " $PGDATA /PG_VERSION" || exit_nicely
471
484
472
485
cp " $PG_HBA_SAMPLE " " $PGDATA " /pg_hba.conf || exit_nicely
@@ -475,6 +488,8 @@ cp "$POSTGRESQL_CONF_SAMPLE" "$PGDATA"/postgresql.conf || exit_nicely
475
488
chmod 0600 " $PGDATA " /pg_hba.conf " $PGDATA " /pg_ident.conf \
476
489
" $PGDATA " /postgresql.conf
477
490
491
+ echo " ok"
492
+
478
493
# #########################################################################
479
494
#
480
495
# CREATE VIEWS and other things
@@ -484,14 +499,9 @@ chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
484
499
# To break an SQL command across lines in this script, backslash-escape all
485
500
# internal newlines in the command.
486
501
487
- if [ " $debug " = yes ]
488
- then
489
- PGSQL_OPT=" -O -F -D$PGDATA "
490
- else
491
- PGSQL_OPT=" -o /dev/null -O -F -D$PGDATA "
492
- fi
502
+ PGSQL_OPT=" $PGSQL_OPT -O"
493
503
494
- echo " Initializing pg_shadow."
504
+ $ECHO_N " initializing pg_shadow... " $ECHO_C
495
505
496
506
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
497
507
-- Create a trigger so that direct updates to pg_shadow will be written
505
515
if [ " $? " -ne 0 ]; then
506
516
exit_nicely
507
517
fi
518
+ echo " ok"
508
519
509
520
# set up password
510
521
if [ " $PwPrompt " ]; then
@@ -522,21 +533,23 @@ if [ "$PwPrompt" ]; then
522
533
echo " Passwords didn't match." 1>&2
523
534
exit_nicely
524
535
fi
536
+ $ECHO_N " setting password... " $ECHO_C
525
537
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
526
538
ALTER USER "$POSTGRES_SUPERUSERNAME " WITH PASSWORD '$FirstPw ';
527
539
EOF
528
540
if [ " $? " -ne 0 ]; then
529
541
exit_nicely
530
542
fi
531
543
if [ ! -f $PGDATA /global/pg_pwd ]; then
544
+ echo
532
545
echo " The password file wasn't generated. Please report this problem." 1>&2
533
546
exit_nicely
534
547
fi
535
- echo " Setting password "
548
+ echo " ok "
536
549
fi
537
550
538
551
539
- echo " Enabling unlimited row width for system tables."
552
+ $ECHO_N " enabling unlimited row size for system tables... " $ECHO_C
540
553
541
554
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
542
555
ALTER TABLE pg_attrdef CREATE TOAST TABLE;
549
562
if [ " $? " -ne 0 ]; then
550
563
exit_nicely
551
564
fi
565
+ echo " ok"
552
566
553
567
554
- echo " Creating system views."
568
+ $ECHO_N " creating system views... " $ECHO_C
555
569
556
570
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
557
571
795
809
if [ " $? " -ne 0 ]; then
796
810
exit_nicely
797
811
fi
812
+ echo " ok"
798
813
799
- echo " Loading pg_description."
814
+ $ECHO_N " loading pg_description... " $ECHO_C
800
815
(
801
816
cat << EOF
802
817
CREATE TEMP TABLE tmp_pg_description ( \
@@ -815,17 +830,19 @@ EOF
815
830
EOF
816
831
) \
817
832
| " $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
833
+ echo " ok"
818
834
819
- echo " Vacuuming database. "
835
+ $ECHO_N " vacuuming database template1... " $ECHO_C
820
836
821
837
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
822
838
VACUUM FULL ANALYZE;
823
839
EOF
824
840
if [ " $? " -ne 0 ]; then
825
841
exit_nicely
826
842
fi
843
+ echo " ok"
827
844
828
- echo " Copying template1 to template0."
845
+ $ECHO_N " copying template1 to template0... " $ECHO_C
829
846
830
847
" $PGPATH " /postgres $PGSQL_OPT template1 > /dev/null << EOF
831
848
CREATE DATABASE template0;
845
862
if [ " $? " -ne 0 ]; then
846
863
exit_nicely
847
864
fi
865
+ echo " ok"
848
866
849
867
850
868
# #########################################################################
0 commit comments