Skip to content
Snippets Groups Projects
Commit ebbcef4c authored by Christoph Berg's avatar Christoph Berg :satellite:
Browse files

Make all scripts honor PGSYSCONFDIR (defaulting to

/etc/postgresql-common).
parent cd343313
No related branches found
No related tags found
No related merge requests found
...@@ -39,12 +39,15 @@ sub error { ...@@ -39,12 +39,15 @@ sub error {
} }
# configuration # configuration
my $mapfile = "/etc/postgresql-common/user_clusters";
our $confroot = '/etc/postgresql'; our $confroot = '/etc/postgresql';
if ($ENV{'PG_CLUSTER_CONF_ROOT'}) { if ($ENV{'PG_CLUSTER_CONF_ROOT'}) {
($confroot) = $ENV{'PG_CLUSTER_CONF_ROOT'} =~ /(.*)/; # untaint ($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 $binroot = "/usr/lib/postgresql";
my $defaultport = 5432; 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 postgresql-common (141) experimental; urgency=low
[ Christoph Berg ] [ Christoph Berg ]
......
...@@ -462,28 +462,28 @@ if ($newcluster && -e '/etc/ssl/certs/ssl-cert-snakeoil.pem' && ...@@ -462,28 +462,28 @@ if ($newcluster && -e '/etc/ssl/certs/ssl-cert-snakeoil.pem' &&
} }
# SSL client certificate CA # 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 # 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; my $val;
read F, $val, 4096; read F, $val, 4096;
if ($val =~ /^-----BEGIN CERTIFICATE-----/m) { if ($val =~ /^-----BEGIN CERTIFICATE-----/m) {
if ($version >= '9.2') { if ($version >= '9.2') {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 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 { } else {
symlink '/etc/postgresql-common/root.crt', $datadir.'/root.crt'; symlink "$PgCommon::common_confdir/root.crt", $datadir.'/root.crt';
} }
} }
} }
# SSL client certificate revocation list # 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') { if ($version >= '9.2') {
PgCommon::set_conf_value $version, $cluster, 'postgresql.conf', 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 { } 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; ...@@ -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 # check whether upgrade scripts exist; if so, verify that pg_restore supports
# -X no-data-for-failed-tables. # -X no-data-for-failed-tables.
my $upgrade_scripts = (-d '/etc/postgresql-common/pg_upgradecluster.d' && my $upgrade_scripts = (-d "$PgCommon::common_confdir/pg_upgradecluster.d" &&
`run-parts --test /etc/postgresql-common/pg_upgradecluster.d`); `run-parts --test $PgCommon::common_confdir/pg_upgradecluster.d`);
if ($upgrade_scripts) { if ($upgrade_scripts) {
if (`$pg_restore --help` !~ qr/no-data-for-failed-tables/) { 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) { ...@@ -365,8 +365,8 @@ if ($upgrade_scripts) {
@argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster, @argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster,
'-a', $newversion, '-a', 'init', '-a', $newversion, '-a', 'init',
'/etc/postgresql-common/pg_upgradecluster.d'); "$PgCommon::common_confdir/pg_upgradecluster.d");
error '/etc/postgresql-common/pg_upgradecluster.d script failed' if system @argv; error "$PgCommon::common_confdir/pg_upgradecluster.d script failed" if system @argv;
exit 0; exit 0;
} }
wait; wait;
...@@ -650,8 +650,8 @@ if ($upgrade_scripts) { ...@@ -650,8 +650,8 @@ if ($upgrade_scripts) {
@argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster, @argv = ('run-parts', '--lsbsysinit', '-a', $version, '-a', $cluster,
'-a', $newversion, '-a', 'finish', '-a', $newversion, '-a', 'finish',
'/etc/postgresql-common/pg_upgradecluster.d'); "$PgCommon::common_confdir/pg_upgradecluster.d");
error '/etc/postgresql-common/pg_upgradecluster.d script failed' if system @argv; error "$PgCommon::common_confdir/pg_upgradecluster.d script failed" if system @argv;
exit 0; exit 0;
} }
wait; wait;
......
...@@ -76,7 +76,8 @@ for d in /etc/postgresql /var/lib/postgresql /var/log/postgresql /var/run/postgr ...@@ -76,7 +76,8 @@ for d in /etc/postgresql /var/lib/postgresql /var/log/postgresql /var/run/postgr
fi fi
mount -n -t tmpfs -o mode=755 tmpfs $d mount -n -t tmpfs -o mode=755 tmpfs $d
done 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 # clean up created clusters and directories after us
cleanup () { cleanup () {
set +e set +e
...@@ -133,7 +134,7 @@ for v in $PG_VERSIONS; do ...@@ -133,7 +134,7 @@ for v in $PG_VERSIONS; do
-c \"ALTER USER postgres PASSWORD '$PGPASSWORD'; SHOW port\"" postgres) -c \"ALTER USER postgres PASSWORD '$PGPASSWORD'; SHOW port\"" postgres)
# record cluster information in service file # record cluster information in service file
cat >> /etc/postgresql-common/pg_service.conf <<EOF cat >> $PGSYSCONFDIR/pg_service.conf <<EOF
[$v] [$v]
host=localhost host=localhost
port=$port port=$port
......
...@@ -239,6 +239,12 @@ is usually C</etc/postgresql/>, but for testing/development purposes you can ...@@ -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 change this to point to e. g. your home directory, so that you can use the
postgresql-common tools without root privileges. 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 =back
=head1 FILES =head1 FILES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment