Commit 09ff8d96 authored by Christoph Berg's avatar Christoph Berg

pg_createcluster: set parameters in the new postgresql.conf.

parent 9562f4e2
......@@ -19,3 +19,6 @@
# Options to pass to initdb.
#initdb_options = ''
# All other options are copied into the new cluster's postgresql.conf, e.g.:
#listen_addresses = '*'
......@@ -4,7 +4,8 @@ postgresql-common (142) UNRELEASED; urgency=low
/etc/postgresql-common).
* The default behavior of pg_createcluster can be configured in
/etc/postgresql-common/createcluster.conf. This also allows to disable the
creation of "main" clusters when postgresql server packages are installed.
creation of "main" clusters when postgresql server packages are installed,
and to set parameters in the new postgresql.conf.
* debian/postgresql-common.postgresql.init: Do not die of one cluster fails
to start. (Closes: #699911)
* pg_upgradecluster: Use a distinct name (pg_hba.conf.pg_upgradecluster) for
......
......@@ -27,6 +27,15 @@ my @postgres_user = getpwnam 'postgres';
my %defaultconf;
my $explicit_auth_config = 0;
# replace placeholders
# Arguments: <string> <version> <cluster>
sub replace_v_c ($$$) {
my ($str, $version, $cluster) = @_;
$str =~ s/%v/$version/g;
$str =~ s/%c/$cluster/g;
return $str;
}
# call initdb
# Arguments: <version> <data directory> <owner uid> <owner gid> <initdb options>
sub init_db {
......@@ -50,15 +59,11 @@ sub init_db {
my @initdb = (get_program_path 'initdb', $version);
die 'Internal error: could not determine initdb path' unless $initdb[0];
if (my $options = $defaultconf{'initdb_options'}) {
$options =~ s/%v/$version/g;
$options =~ s/%c/$cluster/g; # fixme: global var
push @initdb, split (/\s+/, $options);
push @initdb, split (/\s+/, replace_v_c ($options, $version, $cluster));
}
push @initdb, ('-D', $datadir);
if (my $xlogdir = $defaultconf{'xlogdir'}) {
$xlogdir =~ s/%v/$version/g;
$xlogdir =~ s/%c/$cluster/g; # fixme: global var
push @initdb, ('--xlogdir', $xlogdir);
push @initdb, ('--xlogdir', replace_v_c ($xlogdir, $version, $cluster));
}
if ($explicit_auth_config) {
# do nothing
......@@ -302,10 +307,8 @@ foreach my $argv (@ARGV) {
}
if (!defined $datadir) {
$datadir = $defaultconf{'data_directory'} || "/var/lib/postgresql/%v/%c";
$datadir = replace_v_c ($defaultconf{'data_directory'} || "/var/lib/postgresql/%v/%c", $version, $cluster);
$datadir =~ s!/+$!!;
$datadir =~ s/%v/$version/g;
$datadir =~ s/%c/$cluster/g;
my $pd = $datadir;
$pd =~ s!/[^/]*$!!;
......@@ -527,6 +530,13 @@ if ($socketdir eq '/var/run/postgresql') {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 'external_pid_file', "/var/run/postgresql/$version-$cluster.pid";
}
# handle other createcluster.conf parameters
foreach my $guc (sort keys %defaultconf) {
next if $guc =~ /^(create_main_cluster|start_conf|data_directory|xlogdir|initdb_options)$/;
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf',
$guc, replace_v_c ($defaultconf{$guc}, $version, $cluster);
}
# start it if requested
if ($start) {
system '/usr/bin/pg_ctlcluster', $version, $cluster, 'start';
......@@ -772,6 +782,12 @@ default, i.e. pg_xlog is remains in the data directory.
Other options to pass to B<initdb>.
=item I<other options> (Default: none)
All other options listed are copied into the new cluster's postgresql.conf, e.g.:
listen_addresses = '*'
=back
=head1 SEE ALSO
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment