Commit a09773c5 authored by Christoph Berg's avatar Christoph Berg

Add --bindir and --old-bindir options to pg_ctlcluster and pg_upgradecluster, resp.

parent ffa597f7
......@@ -6,7 +6,7 @@
#
# (C) 2005-2009 Martin Pitt <mpitt@debian.org>
# (C) 2009 Cyril Bouthors <cyril@bouthors.org>
# (C) 2013-2014 Christoph Berg <myon@debian.org>
# (C) 2013-2015 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
......@@ -320,11 +320,14 @@ sub promote {
# main
#
my ($bindir);
exit 1 unless GetOptions ('o|options=s' => \@postmaster_auxoptions,
'f|force' => \$force,
'm|mode=s' => \$mode,
'foreground' => \$foreground,
'stdlog' => \$stdlog,
'bindir=s' => \$bindir,
);
if ($mode =~ /^(s(mart)?|f(ast)?|i(mmediate)?)$/) {
......@@ -334,6 +337,8 @@ if ($mode =~ /^(s(mart)?|f(ast)?|i(mmediate)?)$/) {
exit 1;
}
($bindir) = $bindir =~ /^(\/.*)$/ if $bindir; # untaint
# accept both "version cluster action" and "version[-/]cluster action"
if (@ARGV < 2 or (@ARGV < 3 and $ARGV[0] !~ m![-/]!)) {
print "Usage: $0 <version> <cluster> <action>\n";
......@@ -451,7 +456,7 @@ if( $> != $info{'owneruid'} ) {
(getpwuid $info{'owneruid'})[0].') or root';
}
$pg_ctl = get_program_path 'pg_ctl', $version;
$pg_ctl = $bindir ? "$bindir/pg_ctl" : get_program_path ('pg_ctl', $version);
if ($action =~ /^(start|stop|restart|reload|status|promote)$/) {
no strict 'refs';
......@@ -553,6 +558,10 @@ Start B<postgres> in foreground, without daemonizing via B<pg_ctl>.
When B<--foreground> is in use, redirect stderr to the standard logfile in
C</var/log/postgresql/>. (Default when not run in foreground.)
=item B<--bindir> I<directory>
Path to B<pg_ctl>. (Default is C</usr/lib/postgresql/>I<version>C</bin>.)
=item B<-o>|B<--options> I<option>
Pass given I<option> as command line option to the C<postgres> process. It is
......
......@@ -252,7 +252,7 @@ my $method = 'dump';
my $link = 0;
my ($locale, $lc_collate, $lc_ctype, $lc_messages, $lc_monetary, $lc_numeric,
$lc_time, $logfile);
$lc_time, $logfile, $old_bindir);
GetOptions ('v|version=s' => \$newversion,
'locale=s' => \$locale,
'lc-collate=s' => \$lc_collate,
......@@ -265,6 +265,7 @@ GetOptions ('v|version=s' => \$newversion,
'm|method=s' => \$method,
'k|link' => \$link,
'rename=s' => \$newcluster,
'old-bindir=s' => \$old_bindir,
) or exit 1;
$method eq 'dump' or $method eq 'upgrade' or error 'method must be "dump" or "upgrade"';
......@@ -280,6 +281,7 @@ $link and $method eq 'dump' and error 'cannot use --link with --method=dump';
($lc_numeric) = $lc_numeric =~ /^([\w@._-]+)$/ if $lc_numeric;
($lc_time) = $lc_time =~ /^([\w@._-]+)$/ if $lc_time;
($logfile) = $logfile =~ /^([^\n]+)$/ if $logfile;
($old_bindir) = $old_bindir =~ /^(\/.*)$/ if $old_bindir;
if ($#ARGV < 1) {
print "Usage: $0 [OPTIONS] <old version> <cluster name> [<new data directory>]\n";
......@@ -328,7 +330,9 @@ if ($method eq 'dump' or ($method eq 'upgrade' and not $info{'running'})) {
$old_hba_modified = 1;
print "Restarting old cluster with restricted connections...\n";
my @argv = ('pg_ctlcluster', $version, $cluster, 'start');
my @argv = ('pg_ctlcluster',
($old_bindir ? ("--bindir=$old_bindir") : ()),
$version, $cluster, 'start');
error "Could not restart old cluster" if system @argv;
get_encoding $version, $cluster unless ($encoding); # if the cluster was not running before, get encoding now
......@@ -566,7 +570,7 @@ if (!fork) {
my $pg_upgrade = get_program_path 'pg_upgrade', $newversion;
$pg_upgrade or error "pg_upgrade $newversion not found";
my @argv = ($pg_upgrade,
'-b', "$PgCommon::binroot$version/bin",
'-b', ($old_bindir || "$PgCommon::binroot$version/bin"),
'-B', "$PgCommon::binroot$newversion/bin",
'-d', $info{'pgdata'},
'-D', $newinfo{'pgdata'},
......@@ -802,6 +806,10 @@ L<pg_upgrade(1)> for details.
Use a different name for the upgraded cluster.
=item B<--old-bindir> I<directory>
Passed to B<pg_upgrade>.
=back
=head1 HOOK SCRIPTS
......
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