This file is indexed.

/usr/bin/pg_createcluster is in postgresql-common 129.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 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
118
119
120
121
122
123
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
#!/usr/bin/perl -w

# Create new PostgreSQL cluster or integrate an existing data directory into
# the postgresql-common infrastructure.
#
# (C) 2005-2009 Martin Pitt <mpitt@debian.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

use lib '/usr/share/postgresql-common';
use PgCommon;
use Getopt::Long;
use POSIX qw/setlocale LC_ALL/;

$ENV{'PATH'} = '/bin:/usr/bin'; # untaint

my @postgres_user = getpwnam 'postgres';

# call initdb 
# Arguments: <version> <data directory> <owner uid> <owner gid>
sub init_db {
    $datadir = (-l $_[1]) ? readlink $_[1] : $_[1];
    if ($_[0] ge '8.4') {
	$ident_method = 'ident';
    } else {
	$ident_method = 'ident sameuser';
    }
    if ($_[0] ge '9.1') {
	$peer_method = 'peer';
    } else {
	$peer_method = $ident_method;
    }

    if (system 'install', '-d', '-o', $_[2], '-g', $_[3], $datadir) {
        error 'could not create data directory; you might need to run this program with root privileges';
    }

    @initdb = ((get_program_path 'initdb', $_[0]), '-D', $datadir);
    die 'Internal error: could not determine initdb path' unless $initdb[0];
    push @initdb, ('-A', $ident_method);
    push @initdb, ('--encoding', $encoding) if $encoding;
    push @initdb, ('--locale', $locale) if $locale;
    push @initdb, ('--lc-collate', $lc_collate) if $lc_collate;
    push @initdb, ('--lc-ctype', $lc_ctype) if $lc_ctype;
    push @initdb, ('--lc-messages', $lc_messages) if $lc_messages;
    push @initdb, ('--lc-monetary', $lc_monetary) if $lc_monetary;
    push @initdb, ('--lc-numeric', $lc_numeric) if $lc_numeric;
    push @initdb, ('--lc-time', $lc_time) if $lc_time;

    # pre-8.2 servers do not ignore LANG when LC_ALL is set; work around this
    # bug
    if ($_[0] le '8.2' && $ENV{'LC_ALL'}) {
        $ENV{'LANG'} = $ENV{'LC_ALL'};
    }

    if (fork) {
        wait;
        error 'initdb failed' if $?;
    } else{
        close STDOUT;
        change_ugid $_[2], $_[3];
        open STDOUT, ">/dev/null";
        exec @initdb;
    }
}

# move a file to a directory with defined permissions; set <postgresql.conf option> in
# postgresql.conf.
# Arguments: <source file> <target dir> <uid> <gid> <perms> <postgresql.conf option>
sub move_conffile {
    ($file, $target, $uid, $gid, $perms, $confopt) = @_;
    $realfile = $file;
    while (-l $realfile) {
        $realfile = readlink $realfile;
    }
    if (-e $file) {
        print "Moving configuration file $realfile to $target...\n";
	install_file $realfile, $target, $uid, $gid, $perms;
        unlink $file, $realfile;

	@pathcomps = split ('/', $file);
	$target .= '/' . $pathcomps[-1];
	PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', $confopt, $target if $confopt;
    } else {
        error "move_conffile: required configuration file $realfile does not exist";
    }
}

#
# Version specific default configuration
#

sub configure_8_1 {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'stats_row_level', 'on';
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'autovacuum', 'on';
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

sub configure_8_2 {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'stats_row_level', 'on';
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'autovacuum', 'on';
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

sub configure_8_3 {
    # 8.3 enables autovacuum by default
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

sub configure_8_4 {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

sub configure_9_0 {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

sub configure_9_1 {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'log_line_prefix', '%t ';
}

# Set up the default pg_hba.conf file:
# - Add a "local all" entry to pg_hba.conf for the db superuser before all
# other entries. 
# - Change default authentication for host entries to md5.
sub setup_pg_hba {
    $user = (getpwuid $owneruid)[0];
    $fname = "$confdir/pg_hba.conf";
    $su_comment = "
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
";
    
    open (F, $fname) or error "could not open $fname for reading";
    $search = 1;
    while (<F>) {
	$line = $_;
	# add superuser entry before column description line
	if ($search && /#.*TYPE\s+DATABASE/) {
	    push @lines, $su_comment;
	    $s = sprintf "%-7s %-15s %-39s %s\n", 'local', 'all', $user, $peer_method;
	    push @lines, $s;
	    push @lines, "\n";
	    $search = 0;
	}

	# default authentication for Unix socket connections
	if ($line =~ /^#?local/) {
	    $line =~ s/trust/$peer_method/;
	}

	# default authentication for TCP connections
	if ($line =~ /^#?host/) {
	    $line =~ s/($ident_method|trust)/md5/;
	}
	push @lines, $line;
    }
    close F;

    error "setup_pg_hba: did not find insert position" if $search;

    open (F, ">$fname") or error "could not open $fname for writing";
    foreach (@lines) {
	print F $_;
    }
    close F;
}

#
# Execution starts here
#

# command line arguments

my $startconf = 'auto';

# this flag gets set when we started creating the cluster, and thus we need to
# clean up on errors
my $cleanup_cruft = 0;

exit 1 unless GetOptions ('u|user=s' => \$owneruid, 'g|group=s' => \$ownergid,
    's|socketdir=s' => \$socketdir, 'd|datadir=s' => \$datadir, 
    'start' => \$start, 'e|encoding=s' => \$encoding, 
    'l|logfile=s' => \$custom_logfile, 'start-conf=s' => \$startconf,
    'p|port=i' => \$port, 'locale=s' => \$locale,
    'lc-collate=s' => \$lc_collate, 'lc-ctype=s' => \$lc_ctype,
    'lc-messages=s' => \$lc_messages, 'lc-monetary=s' => \$lc_monetary,
    'lc-numeric=s' => \$lc_numeric, 'lc-time=s' => \$lc_time);

# check validity of locale
unless (setlocale (LC_ALL, "")) {
    error ('The locale requested by the environment is invalid.')
}

if ($#ARGV != 1) {
    print "Usage: $0 [options] <version> <cluster name>

Options:
  -u <uid>      cluster owner and superuser (default: 'postgres')
  -g <gid>      group for data files (default: primary group of owner)
  -d <dir>      data directory (default: 
                /var/lib/postgresql/<version>/<cluster name>)
  -s <dir>      socket directory (default: /var/run/postgresql for clusters
                owned by 'postgres', /tmp for other clusters)
  -l <dir>      path to desired log file (default:
                /var/log/postgresql/postgresql-<version>-<cluster>.log)
  --locale <encoding>
                set cluster locale (default: inherit from environment)
  --lc-collate/ctype/messages/monetary/numeric/time <locale>
                like --locale, but only set for a particular category
  -e <encoding> Default encoding (default: derived from locale)
  -p <port>     port number (default: next free port starting from 5432)
  --start       start the cluster after creating it
  --start-conf auto|manual|disabled
                Set automatic startup behaviour in start.conf (default: 'auto')
";
    exit 1;
}

error 'Invalid --start-conf value' if $startconf ne 'auto' &&
    $startconf ne 'manual' && $startconf ne 'disabled';

if ($owneruid) {
    $owneruid = (getpwnam $owneruid)[2] unless $owneruid =~ /\d+/;
} elsif ($> == 0) {
    $owneruid = getpwnam 'postgres';
    error 'User postgresql does not exist' unless $owneruid;
} else
{
    $owneruid = $>;
}

if ($ownergid) {
    $ownergid = (getgrnam $ownergid)[2] unless $ownergid =~ /\d+/;
} else {
    $ownergid = (getpwuid $owneruid)[3];
}

error 'clusters must not be owned by root' unless $owneruid && $ownergid;

($version) = $ARGV[0] =~ /^(\d+\.\d+)$/;
($cluster) = $ARGV[1] =~ /^([-.\w]+)$/;
error 'invalid cluster name' unless defined $cluster;

if (!defined $datadir) {
    $pd = "/var/lib/postgresql/$version";
    $datadir = "$pd/$cluster";

    # ensure that the version data dir is owned by postgres as well, so that
    # it can be administrated without root permissions
    if (!stat $pd) {
        system 'install', '-d', '-o', $postgres_user[2], '-g', $postgres_user[3], $pd;
    }

}
$confdirp = "$PgCommon::confroot/$version";
$confdir = "$confdirp/$cluster";

# some sanity checks
error "invalid version: $version" unless get_program_path 'initdb', $version;
error 'cluster configuration already exists' 
    if -e "$confdir/postgresql.conf" || -e "$confdir/pg_hba.conf";

if (defined $port) {
    error 'port must be a positive integer between 1024 and 65535' 
	unless $port =~ /^\d+/ && $port >= 1024 && $port <= 65535;

    foreach $v (get_versions) {
	foreach $c (get_version_clusters $v) {
	    error "port $port is already used by cluster $v/$c"
		if (get_cluster_port $v, $c) == $port;
	}
    }
} else {
    $port = next_free_port;
}

# create configuration directory
if (!stat $confdirp) {
    system 'install', '-d', '-o', $postgres_user[2], '-g', $postgres_user[3], $confdirp;
}
error 'could not create configuration directory; you might ' .
    'need to run this program with root privileges' if system ('install', '-d', $confdir);

# now we created the first new directory for this cluster and start to rollback
# on error
$cleanup_cruft = 1;

# check whether we have an already existing cluster; check version and
# determine owner in this case
$newcluster = 0;

if (-f "$datadir/PG_VERSION") {
    if (open F, "$datadir/PG_VERSION") {
        $existingver = <F>;
        close F;
    } else {
        error "could not open $datadir/PG_VERSION";
    }
    ($owneruid, $ownergid) = (stat "$datadir/PG_VERSION")[4,5];
    if ($existingver = $version) {
        print "Configuring already existing cluster (configuration: $confdir, data: $datadir, owner: $owneruid:$ownergid)\n";
    } else {
        error "$datadir already contains a version $existingver cluster";
    }
} else {
    print "Creating new cluster (configuration: $confdir, data: $datadir)...\n";
    init_db $version, $datadir, $owneruid, $ownergid;
    $newcluster = 1;
}

# create default "start" file
set_cluster_start_conf $version, $cluster, $startconf;

# create default pg_ctl.conf file
set_cluster_pg_ctl_conf $version, $cluster, '';

# move conffiles, setup permissions
move_conffile "$datadir/postgresql.conf", $confdir, $owneruid, $ownergid, '644';
move_conffile "$datadir/pg_hba.conf", $confdir, $owneruid, $ownergid, '640', 'hba_file';
move_conffile "$datadir/pg_ident.conf", $confdir, $owneruid, $ownergid, '640', 'ident_file';
chown $owneruid, $ownergid, $datadir, $confdir, "$confdir/start.conf" or die "chown: $!";
chown $owneruid, $ownergid, $datadir, $confdir, "$confdir/pg_ctl.conf" or die "chown: $!";

PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'data_directory', $datadir;

# add access for database superuser
setup_pg_hba if $newcluster;

# configure socket directory
if ($socketdir && ! -e $socketdir) {
    if (system 'install', '-d', '-m', '0755', '-o', $owneruid, '-g', $ownergid, $socketdir) {
        error 'could not create socket directory';
    }
}
$orig_euid = $>;
$orig_egid = $);
$) = $ownergid;
$> = $owneruid;
unless ($socketdir) {
    if (-w '/var/run/postgresql') {
	$socketdir = '/var/run/postgresql';
    } else {
        $socketdir='/tmp';
	print "Warning: The socket directory for owners other than 'postgres'
defaults to /tmp. You might want to change the unix_socket_directory parameter
in postgresql.conf to a more secure directory.
"
    }
}
set_cluster_socketdir $version, $cluster, $socketdir if $socketdir;
$> = $orig_euid;
$) = $orig_egid;

print "Configuring postgresql.conf to use port $port...\n";
set_cluster_port $version, $cluster, $port;

# create log file
if (! -d '/var/log/postgresql') {
    mkdir '/var/log/postgresql' or
	error "could not create log directory; you might need to run this program with root privileges";
    chmod 01775, '/var/log/postgresql';
    chown 0, $postgres_user[3], '/var/log/postgresql';
}
$real_logfile = $custom_logfile || "/var/log/postgresql/postgresql-$version-$cluster.log";
if (! -e $real_logfile) {
    open L, ">>$real_logfile" or error "could not create log file $real_logfile";
    close L;
}
chmod 0640, $real_logfile;
my $g;
if ($owneruid < 500) {
    $g = (getgrnam 'adm')[2];
} else {
    $g = $ownergid;
}
chown $owneruid, $g, $real_logfile;
# if we are using a non-default log file, create a log symlink
if ($custom_logfile) {
    symlink $real_logfile, "$confdir/log";
    chown $owneruid, $ownergid, "$confdir/log";
}

# version specific default configuration tweaking
$conf_fn = "configure_$version";
$conf_fn =~tr/./_/;
&$conf_fn if defined &$conf_fn and $newcluster;

# Check whether we can access the SSL private key as the cluster owner
my $ssl_key_access;
my ($uid, $euid, $gid, $egid) = ($<, $>, $(, $));
change_ugid $owneruid, $ownergid;
$ssl_key_access = -r '/etc/ssl/private/ssl-cert-snakeoil.key';
$> = $euid;
$< = $uid; 
$( = $gid;
$) = $egid;
die "changing euid back: $!" if $> != $euid;
die "changing egid back: $!" if $) != $egid;

# create SSL certificate symlinks to the default certificate if it exists; if
# so, enable SSL

if ($newcluster && -e '/etc/ssl/certs/ssl-cert-snakeoil.pem' && 
    $ssl_key_access) {
    symlink '/etc/ssl/certs/ssl-cert-snakeoil.pem', $datadir.'/server.crt';
    symlink '/etc/ssl/private/ssl-cert-snakeoil.key', $datadir.'/server.key';

    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'ssl', 'true';
}

# create SSL client certificate root symlink if appropriate
if ($newcluster && -e '/etc/postgresql-common/root.crt') {
    open F, '/etc/postgresql-common/root.crt';
    my $val;
    read F, $val, 4096;
    if ($val =~ /^-----BEGIN CERTIFICATE-----/m) {
	symlink '/etc/postgresql-common/root.crt', $datadir.'/root.crt';
    }
}

# create default (empty) environment file
open ENV, ">$confdir/environment" or error "could not create environment file";
print ENV "# environment variables for postmaster process
# This file has the same syntax as postgresql.conf: 
#  VARIABLE = simple_value
#  VARIABLE2 = 'any value!'
# I. e. you need to enclose any value which does not only consist of letters,
# numbers, and '-', '_', '.' in single quotes. Shell commands are not
# evaluated.
";
close ENV;
chmod 0644, "$confdir/environment";
chown $owneruid, $ownergid, "$confdir/environment";

$cleanup_cruft = 0;

# configure to create external PID file
if ($socketdir eq '/var/run/postgresql') {
    PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'external_pid_file', "/var/run/postgresql/$version-$cluster.pid";
}

# start it if requested
if ($start) {
    system '/usr/bin/pg_ctlcluster', $version, $cluster, 'start';
}

END {
    # clean up cruft if something went wrong
    if ($cleanup_cruft && defined $version && defined $cluster) {
	system "pg_dropcluster $version $cluster 2>/dev/null";
	exit 1;
    }
}

__END__

=head1 NAME

pg_createcluster - create a new PostgreSQL cluster

=head1 SYNOPSIS

B<pg_createcluster> [I<options>] I<version> I<name>

=head1 DESCRIPTION

B<pg_createcluster> creates a new PostgreSQL server cluster (i. e. a
collection of databases served by a L<postmaster(1)> instance) and
integrates it into the multi-version/multi-cluster architecture of the
B<postgresql-common> package. 

Every cluster is uniquely identified by its version and name. The name can be
arbitrary. The default cluster that is created on installation of a server
package is C<main>. However, you might wish to create other clusters for
testing, with other superusers, a cluster for each user on a shared server,
etc. C<pg_createcluster> will abort with an error if you try to create a
cluster with a name that already exists for that version.

Given a major PostgreSQL I<version> (like "8.2" or "8.3") and a cluster
I<name>, it creates the necessary configuration files in
C</etc/postgresql/>I<version>C</>I<name>C</>; in particular these are
C<postgresql.conf>, C<pg_ident.conf>, C<pg_hba.conf>, a postgresql-common
specific configuration file C<start.conf> (see B<STARTUP CONTROL> below),
C<pg_ctl.conf>, and a symbolic link C<log> which points to the log file (by
default, C</var/log/postgresql/postgresql->I<version>C<->I<name>C<.log>).

C<postgresql.conf> is automatically adapted to use the next available port, i.
e. the first port (starting from 5432) which is not yet used by an already
existing cluster.

If the data directory does not yet exist, PostgreSQL's L<initdb(1)> command is
used to generate a new cluster structure. If the data directory already exists,
it is integrated into the B<postgresql-common> structure by moving the
configuration file and setting the data_directory option. Please note that this
I<only> works for data directories which were created directly with B<initdb>, i.
e. all the configuration files (C<postgresql.conf> etc.) must be present in the
data directory.

If a custom socket directory is given and it does not exist, it is created.

If the log file does not exist, it is created. In any case the permissions are
adjusted to allow write access to the cluster owner. Please note that
C<postgresql.conf> can be customized to specify C<log_directory> and/or
C<log_filename>; if at least one of these options is present, then the symbolic
link C<log> in the cluster configuration directory is ignored.

If the default snakeoil SSL certificate exists
(C</etc/ssl/certs/ssl-cert-snakeoil.pem> and
C</etc/ssl/private/ssl-cert-snakeoil.key>), this program creates symlinks to
these files in the data directory (C<server.crt> and C<server.key>) and enables
SSL for that cluster (option B<ssl> in C<postgresql.conf>). Therefore all
clusters will use the same SSL certificate by default. Of course you can
replace these symlinks with a cluster specific certificate.

=head1 OPTIONS

=over 4

=item B<-u> I<user>, B<--user=>I<user>

Set the user who owns the cluster and becomes the database superuser to the
given name or uid.  By default, this is the user B<postgres>.  A cluster must
not be owned by root.

=item B<-g> I<group>, B<--group=>I<group>

Change the group of the cluster related data files. By default this will be the
primary group of the database owner.

=item B<-d> I<dir>, B<--datadir=>I<dir>

Explicitly set the data directory path, which is used to store all the actual
databases and tables. This will become quite big (easily in the order of five
times the amount of actual data stored in the cluster). Defaults to
C</var/lib/postgresql/>I<version>C</>I<cluster>.

=item B<-s> I<dir>, B<--socketdir=>I<dir>

Explicitly set the directory where the L<postmaster(1)> server stores the Unix
socket for local connections. Defaults to C</var/run/postgresql/> for clusters
owned by the user B<postgres>, and C</tmp> for clusters owned by other users.
Please be aware that C</tmp> is an unsafe directory since everybody can create
a socket there and impersonate the database server. If the given directory does
not exist, it is created with appropriate permissions.

=item B<-l> I<path>, B<--logfile=>I<path>

Explicitly set the path for the L<postmaster(1)> server log file. Defaults to
C</var/log/postgresql/postgresql->I<version>C<->I<cluster>C<.log>.

=item B<--locale=>I<locale>

Set the default locale for the database cluster. If this option is not
specified, the locale is inherited from the environment that
B<pg_createcluster> runs in.

=item B<--lc-collate=>I<locale>

=item B<--lc-ctype=>I<locale>

=item B<--lc-messages=>I<locale>

=item B<--lc-monetary=>I<locale>

=item B<--lc-numeric=>I<locale>

=item B<--lc-time=>I<locale>

Like B<--locale>, but only sets the locale in the specified category.

=item B<-e> I<encoding>, B<--encoding=>I<encoding>

Select the encoding of the template database. This will also be the default
encoding of any database you create later, unless you override it there. The
default is derived from the locale, or SQL_ASCII if that does not work.  The
character sets supported by the PostgreSQL server are described in the
documentation. 

B<Note>: It is not recommended to set this option directly! Set the locale
instead.

=item B<-p> I<port>, B<--port=>I<port>

Select the port the new cluster listens on (for the Unix socket and the TCP
port); this must be a number between 1024 and 65535, since PostgreSQL does not
run as root and thus needs an unprivileged port number. By default the next
free port starting from 5432 is assigned.

=item B<--start>

Immediately start a server for the cluster after creating it (i. e. call
C<pg_ctlcluster> I<version cluster> C<start> on it). By default, the cluster is
not started.

=item B<--start-conf=>B<auto>|B<manual>|B<disabled>

Set the initial value in the C<start.conf> configuration file. See B<STARTUP
CONTROL> below. By default, B<auto> is used, which means that the cluster is
handled by C</etc/init.d/postgresql>, i. e. starts and stops
automatically on system boot.

=back

=head1 STARTUP CONTROL

The C<start.conf> file in the cluster configuration directory controls the
start/stop behavior of that cluster's postmaster process. The file can contain
comment lines (started with '#'), empty lines, and must have exactly one
line with one of the following keywords:

=over 4

=item B<auto>

The postmaster process is started/stopped automatically in the init script.
This is also the default if the file is missing.

=item B<manual>

The postmaster process is not handled by the init script, but manually
controlling the cluster with L<pg_ctlcluster(1)> is permitted.

=item B<disable>

Neither the init script nor L<pg_ctlcluster(1)> are permitted to start/stop the
cluster. Please be aware that this will not stop the cluster owner from calling
lower level tools to control the postmaster process; this option is only meant
to prevent accidents during maintenance, not more.

The C<pg_ctl.conf> file in the cluster configuration directory can contain
additional options passed to pg_ctl of that cluster.

=back

=head1 SEE ALSO

L<pg_ctlcluster(8)>, L<pg_lsclusters(1)>, L<pg_wrapper(1)>

=head1 AUTHOR

Martin Pitt L<E<lt>mpitt@debian.orgE<gt>>