Commit 51c45a09 authored by Christoph Berg's avatar Christoph Berg

pg_createcluster, pg_virtualenv: -o will set postgresql.conf parameters.

parent fa78452a
......@@ -21,6 +21,7 @@ postgresql-common (153) UNRELEASED; urgency=medium
* pgxs_debian_control.mk: Add "clean: debian/control" and
".PHONY: debian/control".
* pg_virtualenv: Fix exit code shown with -s.
* pg_createcluster, pg_virtualenv: -o will set postgresql.conf parameters.
[ Martin Pitt ]
* testsuite, pg_virtualenv: Don't fail if ifconfig is not installed. We
......
......@@ -4,7 +4,7 @@
# the postgresql-common infrastructure.
#
# (C) 2005-2013 Martin Pitt <mpitt@debian.org>
# (C) 2012-2013 Christoph Berg <myon@debian.org>
# (C) 2012-2014 Christoph Berg <myon@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
......@@ -203,6 +203,7 @@ my $cleanup_cruft = 0;
# command line arguments
my $startconf = '';
my $pgoptions = [];
my $createclusterconf = "$PgCommon::common_confdir/createcluster.conf";
my $environmentfile = "$PgCommon::common_confdir/environment";
......@@ -210,6 +211,9 @@ 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,
'o|pgoption=s' => sub { $_[1] =~ /(.*?)=(.*)/ or error ("No '=' in pgoption '$_[1]'");
push @pgoptions, [$1, $2];
},
'createclusterconf=s' => \$createclusterconf,
'environment=s' => \$environmentfile,
'p|port=i' => \$port, 'locale=s' => \$locale,
......@@ -276,9 +280,9 @@ if ($ownergid) {
error 'clusters must not be owned by root' unless $owneruid && $ownergid;
($version) = $ARGV[0] =~ /^(\d+\.\d+)$/;
error 'invalid version' unless defined $version;
error "invalid version '$ARGV[0]'" unless defined $version;
($cluster) = $ARGV[1] =~ /^([-.\w]+)$/;
error 'invalid cluster name' unless defined $cluster;
error "invalid cluster name '$ARGV[1]'" unless defined $cluster;
splice @ARGV, 0, 2;
# initdb options passed after --
......@@ -534,6 +538,11 @@ foreach my $guc (sort keys %defaultconf) {
$guc, replace_v_c ($defaultconf{$guc}, $version, $cluster);
}
# process --pgoption parameters
foreach my $guc (@pgoptions) {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', $guc->[0], $guc->[1];
}
# start it if requested
if ($start) {
system 'pg_ctlcluster', $version, $cluster, 'start';
......@@ -700,6 +709,10 @@ 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.
=item B<-o> I<guc>B<=>I<value>, B<--pgoption> I<guc>B<=>I<value>
Configuration option to set in the new C<postgresql.conf> file.
=item B<--createclusterconf=>I<file>
Alternative B<createcluster.conf> file to use. Default is
......
......@@ -5,7 +5,7 @@
# existing clusters.
#
# (C) 2005-2012 Martin Pitt <mpitt@debian.org>
# (C) 2012-2013 Christoph Berg <myon@debian.org>
# (C) 2012-2014 Christoph Berg <myon@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
......@@ -40,13 +40,15 @@ help ()
echo " -v 'version ...' list of PostgreSQL versions to run [default: latest]"
echo " -c 'options' extra options to pass to pg_createcluster"
echo " -i 'initdb opts' extra initdb options to pass to pg_createcluster"
echo " -o 'guc=value' postgresql.conf options to pass to pg_createcluster"
echo " -s open a shell when command fails"
exit ${1:-0}
}
# option parsing
PG_VERSIONS=""
while getopts "ac:i:hsv:" opt ; do
PGCONF_OPTS=""
while getopts "ac:i:ho:sv:" opt ; do
case $opt in
a) for d in /usr/lib/postgresql/*/bin/pg_ctl; do
# prepend version so latest ends up first (i.e. on port 5432)
......@@ -55,6 +57,7 @@ while getopts "ac:i:hsv:" opt ; do
c) CREATE_OPTS="$OPTARG" ;;
i) INITDB_OPTS="$OPTARG" ;;
h) help ;;
o) PGCONF_OPTS="$PGCONF_OPTS --pgoption $OPTARG" ;;
s) run_shell=1 ;;
v) PG_VERSIONS="$OPTARG" ;;
*) help 1 ;;
......@@ -155,7 +158,7 @@ for v in $PG_VERSIONS; do
pg_createcluster \
${NONROOT:+-d "$WORKDIR/data/$v/regress"} \
${NONROOT:+-l "$WORKDIR/log/postgresql-$v-regress.log"} \
${CREATE_OPTS:-} --start $v regress -- \
${CREATE_OPTS:-} ${PGCONF_OPTS:-} --start $v regress -- \
--username="$PGUSER" --pwfile="$PWFILE" ${INITDB_OPTS:-}
# in fakeroot, the username will likely default to "postgres" otherwise
)
......
......@@ -54,6 +54,11 @@ Extra options to pass to B<pg_createcluster>.
Extra initdb options to pass to B<pg_createcluster>.
=item B<-o> I<guc>B<=>I<value>
Configuration option to set in the C<postgresql.conf> file, passed to
B<pg_createcluster>.
=item B<-s>
Launch a shell inside the virtual environment when I<command> fails.
......
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