Commit ebbcef4c authored by Christoph Berg's avatar Christoph Berg

Make all scripts honor PGSYSCONFDIR (defaulting to

/etc/postgresql-common).
parent cd343313
......@@ -39,12 +39,15 @@ sub error {
}
# configuration
my $mapfile = "/etc/postgresql-common/user_clusters";
our $confroot = '/etc/postgresql';
if ($ENV{'PG_CLUSTER_CONF_ROOT'}) {
($confroot) = $ENV{'PG_CLUSTER_CONF_ROOT'} =~ /(.*)/; # untaint
}
my $common_confdir = "/etc/postgresql-common";
our $common_confdir = "/etc/postgresql-common";
if ($ENV{'PGSYSCONFDIR'}) {
($common_confdir) = $ENV{'PGSYSCONFDIR'} =~ /(.*)/; # untaint
}
my $mapfile = "$common_confdir/user_clusters";
my $binroot = "/usr/lib/postgresql";
my $defaultport = 5432;
......
postgresql-common (142) UNRELEASED; urgency=low
* Make all scripts honor PGSYSCONFDIR (defaulting to
/etc/postgresql-common).
-- Christoph Berg <myon@debian.org> Thu, 11 Apr 2013 13:46:18 +0200
postgresql-common (141) experimental; urgency=low
[ Christoph Berg ]
......
......@@ -462,28 +462,28 @@ if ($newcluster && -e '/etc/ssl/certs/ssl-cert-snakeoil.pem' &&
}
# SSL client certificate CA
if ($newcluster && -e '/etc/postgresql-common/root.crt') {
if ($newcluster && -e "$PgCommon::common_confdir/root.crt") {
# check if we have a cert in there or just the boilerplate installed by our postinst
open F, '/etc/postgresql-common/root.crt';
open F, "$PgCommon::common_confdir/root.crt";
my $val;
read F, $val, 4096;
if ($val =~ /^-----BEGIN CERTIFICATE-----/m) {
if ($version >= '9.2') {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf',
'ssl_ca_file', '/etc/postgresql-common/root.crt';
'ssl_ca_file', "$PgCommon::common_confdir/root.crt";
} else {
symlink '/etc/postgresql-common/root.crt', $datadir.'/root.crt';
symlink "$PgCommon::common_confdir/root.crt", $datadir.'/root.crt';
}
}
}
# SSL client certificate revocation list
if ($newcluster && -e '/etc/postgresql-common/root.crl') {
if ($newcluster && -e "$PgCommon::common_confdir/root.crl") {
if ($version >= '9.2') {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf',
'ssl_crl_file', '/etc/postgresql-common/root.crl';
'ssl_crl_file', "$PgCommon::common_confdir/root.crl";
} else {
symlink '/etc/postgresql-common/root.crl', $datadir.'/root.crl';
symlink "$PgCommon::common_confdir/root.crl", $datadir.'/root.crl';
}
}
......
......@@ -348,12 +348,12 @@ my $pg_restore = get_program_path 'pg_restore', $newversion;
# check whether upgrade scripts exist; if so, verify that pg_restore supports
# -X no-data-for-failed-tables.
my $upgrade_scripts = (-d '/etc/postgresql-common/pg_upgradecluster.d' &&
`run-parts --test /etc/postgresql-common/pg_upgradecluster.d`);
my $upgrade_scripts = (-d "$PgCommon::common_confdir/pg_upgradecluster.d" &&
`run-parts --test $PgCommon::common_confdir/pg_upgradecluster.d`);
if ($upgrade_scripts) {
if (`$pg_restore --help` !~ qr/no-data-for-failed-tables/) {
error '/etc/postgresql-common/pg_upgradecluster.d has upgrade scripts, but $pg_restore does not support the "-X no-data-for-failed-tables" option.'
error "$PgCommon::common_confdir/pg_upgradecluster.d has upgrade scripts, but $pg_restore does not support the \"-X no-data-for-failed-tables\" option."
}
}
......@@ -365,8 +365,8 @@ if ($upgrade_scripts) {
@argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster,
'-a', $newversion, '-a', 'init',
'/etc/postgresql-common/pg_upgradecluster.d');
error '/etc/postgresql-common/pg_upgradecluster.d script failed' if system @argv;
"$PgCommon::common_confdir/pg_upgradecluster.d");
error "$PgCommon::common_confdir/pg_upgradecluster.d script failed" if system @argv;
exit 0;
}
wait;
......@@ -650,8 +650,8 @@ if ($upgrade_scripts) {
@argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster,
'-a', $newversion, '-a', 'finish',
'/etc/postgresql-common/pg_upgradecluster.d');
error '/etc/postgresql-common/pg_upgradecluster.d script failed' if system @argv;
"$PgCommon::common_confdir/pg_upgradecluster.d");
error "$PgCommon::common_confdir/pg_upgradecluster.d script failed" if system @argv;
exit 0;
}
wait;
......
......@@ -76,7 +76,8 @@ for d in /etc/postgresql /var/lib/postgresql /var/log/postgresql /var/run/postgr
fi
mount -n -t tmpfs -o mode=755 tmpfs $d
done
pg_service="/etc/postgresql-common/pg_service.conf"
: ${PGSYSCONFDIR:=/etc/postgresql-common}
pg_service="$PGSYSCONFDIR/pg_service.conf"
# clean up created clusters and directories after us
cleanup () {
set +e
......@@ -133,7 +134,7 @@ for v in $PG_VERSIONS; do
-c \"ALTER USER postgres PASSWORD '$PGPASSWORD'; SHOW port\"" postgres)
# record cluster information in service file
cat >> /etc/postgresql-common/pg_service.conf <<EOF
cat >> $PGSYSCONFDIR/pg_service.conf <<EOF
[$v]
host=localhost
port=$port
......
......@@ -239,6 +239,12 @@ is usually C</etc/postgresql/>, but for testing/development purposes you can
change this to point to e. g. your home directory, so that you can use the
postgresql-common tools without root privileges.
=item B<PGSYSCONFDIR>
This is the location of PostgreSQL's and postgresql-common's global
configuration (e. g. C<pg_service.conf>, L<user_clusters(5)>). The default is
C</etc/postgresql-common/>.
=back
=head1 FILES
......
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