initdb.sh 18.3 KB
Newer Older
M
 
Marc G. Fournier 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/bin/sh
#-------------------------------------------------------------------------
#
# initdb.sh--
#     Create (initialize) a Postgres database system.  
# 
#     A database system is a collection of Postgres databases all managed
#     by the same postmaster.  
#
#     To create the database system, we create the directory that contains
#     all its data, create the files that hold the global classes, create
#     a few other control files for it, and create one database:  the
#     template database.
#
#     The template database is an ordinary Postgres database.  Its data
#     never changes, though.  It exists to make it easy for Postgres to 
#     create other databases -- it just copies.
#
#     Optionally, we can skip creating the database system and just create
#     (or replace) the template database.
#
#     To create all those classes, we run the postgres (backend) program and
#     feed it data from bki files that are in the Postgres library directory.
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
29
#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.78 2000/01/13 18:22:10 petere Exp $
B
Bruce Momjian 已提交
30 31 32
#
#-------------------------------------------------------------------------

33
exit_nicely(){
B
Bruce Momjian 已提交
34 35
    echo
    echo "$CMDNAME failed."
36
    if [ "$noclean" -eq 0 ]; then
B
Bruce Momjian 已提交
37
        echo "Removing $PGDATA."
38
        rm -rf "$PGDATA" || echo "Failed."
39 40
        echo "Removing temp file $TEMPFILE."
        rm -rf "$TEMPFILE" || echo "Failed."
B
Bruce Momjian 已提交
41 42 43 44 45 46 47 48
    else
        echo "Data directory $PGDATA will not be removed at user's request."
    fi
    exit 1
}


CMDNAME=`basename $0`
49 50
if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ]
then
B
Bruce Momjian 已提交
51 52 53 54 55
    echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
    echo "as the (unprivileged) user that will own the server process."
    exit 1
fi

56
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
57 58 59 60 61
if [ "$TMPDIR" ]; then
    TEMPFILE="$TMPDIR/initdb.$$"
else
    TEMPFILE="/tmp/initdb.$$"
fi
B
Bruce Momjian 已提交
62 63 64 65

#
# Find out where we're located
#
66 67
if echo "$0" | grep '/' > /dev/null 2>&1 
then
B
Bruce Momjian 已提交
68 69 70 71
        # explicit dir name given
        PGPATH=`echo $0 | sed 's,/[^/]*$,,'`       # (dirname command is not portable)
else
        # look for it in PATH ('which' command is not portable)
B
Bruce Momjian 已提交
72 73
        for dir in `echo "$PATH" | sed 's/:/ /g'`
	do
B
Bruce Momjian 已提交
74 75
                # empty entry in path means current dir
                [ -z "$dir" ] && dir='.'
76
                if [ -f "$dir/$CMDNAME" ]
B
Bruce Momjian 已提交
77
		then
B
Bruce Momjian 已提交
78 79 80 81 82 83 84
                        PGPATH="$dir"
                        break
                fi
        done
fi

# Check if needed programs actually exist in path
B
Bruce Momjian 已提交
85 86
for prog in postgres pg_version
do
87
        if [ ! -x "$PGPATH/$prog" ]
B
Bruce Momjian 已提交
88
	then
B
Bruce Momjian 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
                echo "The program $prog needed by $CMDNAME could not be found. It was"
                echo "expected at:"
                echo "    $PGPATH/$prog"
                echo "If this is not the correct directory, please start $CMDNAME"
                echo "with a full search path. Otherwise make sure that the program"
                echo "was installed successfully."
                exit 1
        fi
done

# 0 is the default (non-)encoding
MULTIBYTEID=0
# This is placed here by configure --with-mb=XXX.
MULTIBYTE=__MULTIBYTE__

# Set defaults:
debug=0
noclean=0
template_only=0


# Note: There is a single compelling reason that the name of the database
#       superuser be the same as the Unix user owning the server process:
#       The single user postgres backend will only connect as the database
#       user with the same name as the Unix user running it. That's
#       a security measure. It might change in the future (why?), but for
#       now the --username option is only a fallback if both id and whoami
#       fail, and in that case the argument _must_ be the name of the effective
#       user.
118
POSTGRES_SUPERUSERNAME="$EffectiveUser"
119
POSTGRES_SUPERUSERID="`id -u 2>/dev/null || echo 0`"
B
Bruce Momjian 已提交
120 121 122

Password='_null_'

123
while [ "$#" -gt 0 ]
B
Bruce Momjian 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
do
    case "$1" in
        --help|-\?)
                usage=t
                break
                ;;
        --debug|-d)
                debug=1
                echo "Running with debug mode on."
                ;;
        --noclean|-n)
                noclean=1
                echo "Running with noclean mode on. Mistakes will not be cleaned up."
                ;;
        --template|-t)
                template_only=1
                echo "Updating template1 database only."
                ;;
# The database superuser. See comments above.
        --username|-u)
                POSTGRES_SUPERUSERNAME="$2"
                shift;;
        --username=*)
                POSTGRES_SUPERUSERNAME=`echo $1 | sed 's/^--username=//'`
                ;;
        -u*)
                POSTGRES_SUPERUSERNAME=`echo $1 | sed 's/^-u//'`
                ;;
# The sysid of the database superuser. See comments above.
        --sysid|-i)
                POSTGRES_SUPERUSERID="$2"
                shift;;
        --sysid=*)
                POSTGRES_SUPERUSERID=`echo $1 | sed 's/^--sysid=//'`
                ;;
        -i*)
                POSTGRES_SUPERUSERID=`echo $1 | sed 's/^-i//'`
                ;;
# The default password of the database superuser.
        --password|-W)
                Password="$2"
                shift;;
        --password=*)
                Password=`echo $1 | sed 's/^--password=//'`
                ;;
        -W*)
                Password=`echo $1 | sed 's/^-W//'`
                ;;
# Directory where to install the data. No default, unless the environment
# variable PGDATA is set.
        --pgdata|-D)
                PGDATA="$2"
                shift;;
        --pgdata=*)
                PGDATA=`echo $1 | sed 's/^--pgdata=//'`
                ;;
        -D*)
                PGDATA=`echo $1 | sed 's/^-D//'`
                ;;
# The directory where the database templates are stored (traditionally in
# $prefix/lib). This is now autodetected for the most common layouts.
        --pglib|-L)
                PGLIB="$2"
                shift;;
        --pglib=*)
                PGLIB=`echo $1 | sed 's/^--pglib=//'`
                ;;
        -L*)
                PGLIB=`echo $1 | sed 's/^-L//'`
                ;;
# The encoding of the template1 database. Defaults to what you chose
# at configure time. (see above)
        --pgencoding|-e)
                MULTIBYTE="$2"
                shift;;
        --pgencoding=*)
                MULTIBYTE=`echo $1 | sed 's/^--pgencoding=//'`
                ;;
        -e*)
                MULTIBYTE=`echo $1 | sed 's/^-e//'`
                ;;
        *)
                echo "Unrecognized option '$1'. Try -? for help."
                exit 1
                ;;
    esac
    shift
done

213 214
if [ "$usage" ]
then
215 216 217 218 219 220 221 222 223 224 225 226
 	echo ""
 	echo "Usage: $CMDNAME [options]"
 	echo ""
        echo "    -t,           --template           "
        echo "    -d,           --debug              "
        echo "    -n,           --noclean            "
        echo "    -i SYSID,     --sysid=SYSID        "
        echo "    -W PASSWORD,  --password=PASSWORD  "
        echo "    -u SUPERUSER, --username=SUPERUSER " 
        echo "    -D DATADIR,   --pgdata=DATADIR     "
        echo "    -L LIBDIR,    --pglib=LIBDIR       "
 	
227 228
 	if [ -n "$MULTIBYTE" ]
	then 
229
 		echo "    -e ENCODING,  --pgencoding=ENCODING"
B
Bruce Momjian 已提交
230
	fi
231 232 233
 	echo "    -?,           --help               "           	
 	echo ""	 
 	exit 0
B
Bruce Momjian 已提交
234 235 236 237 238 239
fi

#-------------------------------------------------------------------------
# Resolve the multibyte encoding name
#-------------------------------------------------------------------------

240 241
if [ "$MULTIBYTE" ]
then
B
Bruce Momjian 已提交
242
	MULTIBYTEID=`$PGPATH/pg_encoding $MULTIBYTE`
243
        if [ "$?" -ne 0 ]
B
Bruce Momjian 已提交
244
	then
B
Bruce Momjian 已提交
245 246 247 248 249
                echo "The program pg_encoding failed. Perhaps you did not configure"
                echo "PostgreSQL for multibyte support or the program was not success-"
                echo "fully installed."
                exit 1
        fi
250 251
	if [ -z "$MULTIBYTEID" ]
	then
B
Bruce Momjian 已提交
252 253 254 255 256 257 258 259 260 261
		echo "$CMDNAME: $MULTIBYTE is not a valid encoding name."
		exit 1
	fi
fi


#-------------------------------------------------------------------------
# Make sure he told us where to build the database system
#-------------------------------------------------------------------------

262 263
if [ -z "$PGDATA" ]
then
B
Bruce Momjian 已提交
264 265 266 267 268 269 270 271 272 273
    echo "$CMDNAME: You must identify where the the data for this database"
    echo "system will reside.  Do this with either a --pgdata invocation"
    echo "option or a PGDATA environment variable."
    echo
    exit 1
fi

# The data path must be absolute, because the backend doesn't like
# '.' and '..' stuff. (Should perhaps be fixed there.)

274 275
if ! echo "$PGDATA" | grep '^/' > /dev/null 2>&1
then
B
Bruce Momjian 已提交
276 277 278 279 280 281 282 283 284
    echo "$CMDNAME: The data path must be specified as an absolute path."
    exit 1
fi

#---------------------------------------------------------------------------
# Figure out who the Postgres superuser for the new database system will be.
#---------------------------------------------------------------------------

# This means they have neither 'id' nor 'whoami'!
285 286
if [ -z "$POSTGRES_SUPERUSERNAME" ]
then 
B
Bruce Momjian 已提交
287 288 289 290 291 292 293 294 295 296 297 298 299 300
    echo "$CMDNAME: Could not determine what the name of the database"
    echo "superuser should be. Please use the --username option."
    exit 1
fi

echo "This database system will be initialized with username \"$POSTGRES_SUPERUSERNAME\"."
echo "This user will own all the data files and must also own the server process."
echo


#-------------------------------------------------------------------------
# Find the input files
#-------------------------------------------------------------------------

301 302
if [ -z "$PGLIB" ]
then
B
Bruce Momjian 已提交
303 304
        for dir in "$PGPATH/../lib" "$PGPATH/../lib/pgsql"
	do
305
                if [ -f "$dir/global1.bki.source" ]
B
Bruce Momjian 已提交
306
		then
307
                        PGLIB="$dir"
B
Bruce Momjian 已提交
308 309 310 311 312
                        break
                fi
        done
fi

313 314
if [ -z "$PGLIB" ]
then
B
Bruce Momjian 已提交
315 316 317 318 319 320 321
        echo "$CMDNAME: Could not find the \"lib\" directory, that contains"
        echo "the files needed by initdb. Please specify it with the"
        echo "--pglib option."
        exit 1
fi


322 323 324
TEMPLATE="$PGLIB"/local1_template1.bki.source
GLOBAL="$PGLIB"/global1.bki.source
PG_HBA_SAMPLE="$PGLIB"/pg_hba.conf.sample
B
Bruce Momjian 已提交
325

326 327 328
TEMPLATE_DESCR="$PGLIB"/local1_template1.description
GLOBAL_DESCR="$PGLIB"/global1.description
PG_GEQO_SAMPLE="$PGLIB"/pg_geqo.sample
329
PG_POSTMASTER_OPTS_DEFAULT_SAMPLE="$PGLIB"/postmaster.opts.default.sample
B
Bruce Momjian 已提交
330

B
Bruce Momjian 已提交
331 332
for PREREQ_FILE in "$TEMPLATE" "$GLOBAL" "$PG_HBA_SAMPLE"
do
333 334
    if [ ! -f "$PREREQ_FILE" ]
	then 
B
Bruce Momjian 已提交
335 336 337 338 339 340 341 342 343
        echo "$CMDNAME does not find the file '$PREREQ_FILE'."
        echo "This means you have a corrupted installation or identified the"
        echo "wrong directory with the --pglib invocation option."
        exit 1
    fi
done

[ "$debug" -ne 0 ] && echo "$CMDNAME: Using $TEMPLATE as input to create the template database."

344 345
if [ "$template_only" -eq 0 ]
then
B
Bruce Momjian 已提交
346 347
    [ "$debug" -ne 0 ] && echo "$CMDNAME: Using $GLOBAL as input to create the global classes."
    [ "$debug" -ne 0 ] && echo "$CMDNAME: Using $PG_HBA_SAMPLE as default authentication control file."
B
Bruce Momjian 已提交
348
fi
B
Bruce Momjian 已提交
349

B
Bruce Momjian 已提交
350
trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15
B
Bruce Momjian 已提交
351 352


M
 
Marc G. Fournier 已提交
353 354 355 356 357 358 359
# -----------------------------------------------------------------------
# Create the data directory if necessary
# -----------------------------------------------------------------------

# umask must disallow access to group, other for files and dirs
umask 077

360 361 362
if [ -f "$PGDATA"/PG_VERSION ]
then
    if [ "$template_only" -eq 0 ]
B
Bruce Momjian 已提交
363
    then
364 365
        echo "$CMDNAME: The file $PGDATA/PG_VERSION already exists."
        echo "This probably means initdb has already been run and the"
M
 
Marc G. Fournier 已提交
366 367
        echo "database system already exists."
        echo 
368 369
        echo "If you want to create a new database system, either remove"
        echo "the directory $PGDATA or run initdb with a --pgdata argument"
M
 
Marc G. Fournier 已提交
370 371 372 373
        echo "other than $PGDATA."
        exit 1
    fi
else
374 375
    if [ ! -d "$PGDATA" ]
	then
376
        echo "Creating database system directory $PGDATA"
377
        mkdir "$PGDATA" || exit_nicely
378 379
    else
        echo "Fixing permissions on pre-existing data directory $PGDATA"
380
	chmod go-rwx "$PGDATA" || exit_nicely
M
 
Marc G. Fournier 已提交
381
    fi
382

383 384
    if [ ! -d "$PGDATA"/base ]
	then
385
        echo "Creating database system directory $PGDATA/base"
386
        mkdir "$PGDATA"/base || exit_nicely
M
 
Marc G. Fournier 已提交
387
    fi
388
    if [ ! -d "$PGDATA"/pg_xlog ]
B
Bruce Momjian 已提交
389
    then
390
        echo "Creating database XLOG directory $PGDATA/pg_xlog"
391
        mkdir "$PGDATA"/pg_xlog || exit_nicely
392
    fi
M
 
Marc G. Fournier 已提交
393 394 395 396 397 398
fi

#----------------------------------------------------------------------------
# Create the template1 database
#----------------------------------------------------------------------------

399 400
rm -rf "$PGDATA"/base/template1 || exit_nicely
mkdir "$PGDATA"/base/template1 || exit_nicely
M
 
Marc G. Fournier 已提交
401

402 403
if [ "$debug" -eq 1 ]
then
M
 
Marc G. Fournier 已提交
404 405 406 407 408 409
    BACKEND_TALK_ARG="-d"
else
    BACKEND_TALK_ARG="-Q"
fi

BACKENDARGS="-boot -C -F -D$PGDATA $BACKEND_TALK_ARG"
410
FIRSTRUN="-boot -x -C -F -D$PGDATA $BACKEND_TALK_ARG"
M
 
Marc G. Fournier 已提交
411

B
Bruce Momjian 已提交
412
echo "Creating template database in $PGDATA/base/template1"
413
[ "$debug" -ne 0 ] && echo "Running: $PGPATH/postgres $FIRSTRUN template1"
M
 
Marc G. Fournier 已提交
414

415
cat "$TEMPLATE" \
416
| sed -e "s/PGUID/$POSTGRES_SUPERUSERID/g" \
417
| "$PGPATH"/postgres $FIRSTRUN template1 \
418
|| exit_nicely
M
 
Marc G. Fournier 已提交
419

420
"$PGPATH"/pg_version "$PGDATA"/base/template1 || exit_nicely
M
 
Marc G. Fournier 已提交
421 422 423 424 425

#----------------------------------------------------------------------------
# Create the global classes, if requested.
#----------------------------------------------------------------------------

426 427
if [ "$template_only" -eq 0 ]
then
428 429
    echo "Creating global relations in $PGDATA/base"
    [ "$debug" -ne 0 ] && echo "Running: $PGPATH/postgres $BACKENDARGS template1"
M
 
Marc G. Fournier 已提交
430

431
    cat "$GLOBAL" \
432 433 434
    | sed -e "s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
          -e "s/PGUID/$POSTGRES_SUPERUSERID/g" \
          -e "s/PASSWORD/$Password/g" \
435
    | "$PGPATH"/postgres $BACKENDARGS template1 \
436
    || exit_nicely
M
 
Marc G. Fournier 已提交
437

438
    "$PGPATH"/pg_version "$PGDATA" || exit_nicely
M
 
Marc G. Fournier 已提交
439

440 441
    cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf     || exit_nicely
    cp "$PG_GEQO_SAMPLE" "$PGDATA"/pg_geqo.sample || exit_nicely
442
    cp "$PG_POSTMASTER_OPTS_DEFAULT_SAMPLE" "$PGDATA"/postmaster.opts.default || exit_nicely
M
 
Marc G. Fournier 已提交
443

444
    echo "Adding template1 database to pg_database"
M
 
Marc G. Fournier 已提交
445

446
    echo "open pg_database" > "$TEMPFILE"
447
    echo "insert (template1 $POSTGRES_SUPERUSERID $MULTIBYTEID template1)" >> $TEMPFILE
448 449
    #echo "show" >> "$TEMPFILE"
    echo "close pg_database" >> "$TEMPFILE"
M
 
Marc G. Fournier 已提交
450

451
    [ "$debug" -ne 0 ] && echo "Running: $PGPATH/postgres $BACKENDARGS template1 < $TEMPFILE"
M
 
Marc G. Fournier 已提交
452

453
    "$PGPATH"/postgres $BACKENDARGS template1 < "$TEMPFILE"
454
    # Gotta remove that temp file before exiting on error.
455 456
    retval="$?"
    if [ "$noclean" -eq 0 ]
B
Bruce Momjian 已提交
457
    then
458
            rm -f "$TEMPFILE" || exit_nicely
M
 
Marc G. Fournier 已提交
459
    fi
460
    [ "$retval" -ne 0 ] && exit_nicely
M
 
Marc G. Fournier 已提交
461 462 463 464
fi

echo

465
PGSQL_OPT="-o /dev/null -O -F -Q -D$PGDATA"
M
 
Marc G. Fournier 已提交
466

B
Bruce Momjian 已提交
467 468
# Create a trigger so that direct updates to pg_shadow will be written
# to the flat password file pg_pwd
469 470
echo "CREATE TRIGGER pg_sync_pg_pwd AFTER INSERT OR UPDATE OR DELETE ON pg_shadow" \
     "FOR EACH ROW EXECUTE PROCEDURE update_pg_pwd()" \
471
     | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
B
Bruce Momjian 已提交
472

473
# Create the initial pg_pwd (flat-file copy of pg_shadow)
474 475
echo "Writing password file."
echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" \
476
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
477

478
# An ordinary COPY will leave the file too loosely protected.
479 480 481 482
# Note: If you lied above and specified a --username different from the one
# you really are, this will manifest itself in this command failing because
# of a missing file, since the COPY command above failed. It would perhaps
# be better if postgres returned an error code.
483
chmod go-rw "$PGDATA"/pg_pwd || exit_nicely
484 485

echo "Creating view pg_user."
486 487 488 489 490 491 492 493 494 495
echo "CREATE VIEW pg_user AS \
        SELECT \
            usename, \
            usesysid, \
            usecreatedb, \
            usetrace, \
            usesuper, \
            usecatupd, \
            '********'::text as passwd, \
            valuntil \
496
        FROM pg_shadow" \
497
        | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
498 499

echo "REVOKE ALL on pg_shadow FROM public" \
500
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
501 502

echo "Creating view pg_rules."
503 504 505 506 507 508 509
echo "CREATE VIEW pg_rules AS \
        SELECT \
            C.relname AS tablename, \
            R.rulename AS rulename, \
	    pg_get_ruledef(R.rulename) AS definition \
	FROM pg_rewrite R, pg_class C \
	WHERE R.rulename !~ '^_RET' \
510
            AND C.oid = R.ev_class;" \
511
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
512 513

echo "Creating view pg_views."
514 515 516 517 518 519 520 521 522 523
echo "CREATE VIEW pg_views AS \
        SELECT \
            C.relname AS viewname, \
            pg_get_userbyid(C.relowner) AS viewowner, \
            pg_get_viewdef(C.relname) AS definition \
        FROM pg_class C \
        WHERE C.relhasrules \
            AND	EXISTS ( \
                SELECT rulename FROM pg_rewrite R \
                    WHERE ev_class = C.oid AND ev_type = '1' \
524
            )" \
525
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
526 527

echo "Creating view pg_tables."
528 529 530 531 532 533 534 535 536 537 538 539
echo "CREATE VIEW pg_tables AS \
        SELECT \
            C.relname AS tablename, \
	    pg_get_userbyid(C.relowner) AS tableowner, \
	    C.relhasindex AS hasindexes, \
	    C.relhasrules AS hasrules, \
	    (C.reltriggers > 0) AS hastriggers \
        FROM pg_class C \
        WHERE C.relkind IN ('r', 's') \
            AND NOT EXISTS ( \
                SELECT rulename FROM pg_rewrite \
                    WHERE ev_class = C.oid AND ev_type = '1' \
540
            )" \
541
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
542 543

echo "Creating view pg_indexes."
544 545 546 547 548 549 550
echo "CREATE VIEW pg_indexes AS \
        SELECT \
            C.relname AS tablename, \
	    I.relname AS indexname, \
            pg_get_indexdef(X.indexrelid) AS indexdef \
        FROM pg_index X, pg_class C, pg_class I \
	WHERE C.oid = X.indrelid \
551
            AND I.oid = X.indexrelid" \
552
        | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
553 554

echo "Loading pg_description."
555 556 557 558 559
echo "COPY pg_description FROM STDIN" > $TEMPFILE
cat "$TEMPLATE_DESCR" >> $TEMPFILE
cat "$GLOBAL_DESCR" >> $TEMPFILE

cat $TEMPFILE \
560
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
561 562 563 564 565
if [ "$noclean" -eq 0 ]
then
    rm -f "$TEMPFILE" || exit_nicely
fi

566 567
echo "Vacuuming database."
echo "VACUUM ANALYZE" \
568
	| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
569 570 571 572

echo
echo "$CMDNAME completed successfully. You can now start the database server."
echo "($PGPATH/postmaster -D $PGDATA)"
573 574
echo "or"
echo "($PGPATH/pg_ctl -D $PGDATA start)"
575 576 577
echo

exit 0