Skip to content
Snippets Groups Projects
Commit c395c94b authored by Martin Pitt's avatar Martin Pitt
Browse files

Add support for configuring the start/stop behavior in start.conf:

- debian/init.d-functions: Only start/stop the cluster in 'auto' mode.
- pg_ctlcluster: Only operate in 'auto' and 'manual' modes, print an error
  in 'disabled' mode.
- pg_createcluster: Create a default start.conf file.
- architecture.html, pg_createcluster POD: Document the file and the
  possible options.
- Closes: #224047
parent f566ceaf
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ Transition bugs:
Important features:
- Tool for manipulating pg_hba.conf
- Add selftest for pg_wrapper env vars (PGHOST, PGPORT, PGUSER)
- Add selftest for start.conf
Wishlist:
- add programs for web applications, which configure pg_hba.conf:
......@@ -32,11 +33,5 @@ Wishlist:
required pg_hba.conf line to stdout and exits with 1. If pg_hba.conf has a
scrambled format that cannot be parsed by pg_*_hba, the scripts exit with 2.
- add "start" configuration file to cluster directory:
absent or "auto" -> start with init.d
"manual" -> no automatic start with init.d
"disabled" -> cluster cannot be started at all
(#224047, suggestion from Dale Kemp)
8.1 features:
- check for obsolete 8.1 configuration items
......@@ -101,7 +101,11 @@ default version/cluster and database; overrides
installed). If this directory contains <code>autovacuum.conf</code>, this is
used as the cluster specific autovacuum daemon configuration; if it does not
exist, <code>/etc/postgresql-common/autovaccum.conf</code> is used as a
fallback.</td>
fallback. If this directory contains <code>start.conf</code>, that file
configures the startup mode of the cluster: <i>audo</i> (start/stop in init
script), <i>manual</i> (do not start/stop in init script, but manual control
with <code>pg_ctlcluster</code> is possible), <i>disabled</i>
(<code>pg_ctlcluster</code> is not allowed).</td>
</tr>
</table>
......
......@@ -7,8 +7,16 @@ postgresql-common (29) unstable; urgency=low
Closes: #333803
* pg_createcluster: Do not enable SSL on 7.4 clusters since enabling it
without enabling the TCP socket breaks.
-- Martin Pitt <mpitt@debian.org> Wed, 26 Oct 2005 19:53:17 +0100
* Add support for configuring the start/stop behavior in start.conf:
- debian/init.d-functions: Only start/stop the cluster in 'auto' mode.
- pg_ctlcluster: Only operate in 'auto' and 'manual' modes, print an error
in 'disabled' mode.
- pg_createcluster: Create a default start.conf file.
- architecture.html, pg_createcluster POD: Document the file and the
possible options.
- Closes: #224047
-- Martin Pitt <mpitt@debian.org> Thu, 27 Oct 2005 23:01:23 -0400
postgresql-common (28) unstable; urgency=high
......
......@@ -21,6 +21,14 @@ do_ctl_all() {
[ -e "$c/pgdata" ] || continue
name=$(basename "$c")
# evaluate start.conf
if [ -e "$c/start.conf" ]; then
start=$(sed 's/#.*$//; /^[[:space:]]*$/d; s/^\s*//; s/\s*$//' "$c/start.conf")
else
start=auto
fi
[ "$start" = "auto" ] || continue
if [ "$USE_LSBINIT" ]; then
log_begin_msg "$3 $name"
pg_ctlcluster -s "$2" "$name" $1
......
......@@ -255,6 +255,22 @@ if (-f "$pgdata/PG_VERSION") {
$newcluster = 1;
}
# create default "start" file
if (open F, ">$confdir/start.conf") {
print F "# Automatic startup configuration
# auto: automatically start/stop the cluster in the init script
# manual: do not start/stop in init scripts, but allow manual startup with
# pg_ctlcluster
# disabled: do not allow manual startup with pg_ctlcluster (this can be easily
# circumvented and is only meant to be a small protection for
# accidents).
manual";
close F;
} else {
error "could not create $confdir/start.conf: $!";
}
# move conffiles, setup permissions
move_conffile "$datadir/pg_hba.conf", $confdir, $owneruid, $ownergid, "640";
move_conffile "$datadir/pg_ident.conf", $confdir, $owneruid, $ownergid, "640";
......@@ -355,10 +371,11 @@ Given a major PostgreSQL I<version> (like "7.4" or "8.0") and a cluster I<name>
(which must be unique for all clusters of one particular version), it creates
the necessary configuration files in
C</etc/postgresql/>I<version>C</>I<name>C</>; in particular these are
C<postgresql.conf>, C<pg_ident.conf>, C<pg_hba.conf>, a symbolic link
C<pgdata> which points to the actual data directory I<data dir> (which defaults
to C</var/lib/postgresql/>I<version>C</>I<name>C</>), and a symbolic link
C<log> which points to the log file (by default,
C<postgresql.conf>, C<pg_ident.conf>, C<pg_hba.conf>, a postgresql-common
specific configuration file C<start.conf> (see B<STARTUP CONTROL> below), a
symbolic link C<pgdata> which points to the actual data directory I<data dir>
(which defaults to C</var/lib/postgresql/>I<version>C</>I<name>C</>), and a
symbolic link C<log> which points to the log file (by default,
C</var/log/postgresql/postgresql->I<version>C<->I<name>C<.log>).
To enable easy integration of B<pg_autovacuum> for Servers prior to 8.1, this
......@@ -437,6 +454,35 @@ not started.
=back
=head1 STARTUP CONTROL
The C<start.conf> file in the cluster configuration directory controls the
start/stop behavior of that cluster's postmaster process. The file can contain
comment lines (started with '#'), empty lines, and must have exactly one
line with one of the following keywords:
=over 4
=item B<auto>
The postmaster process is started/stopped automatically in the init script.
This is also the default if the file is missing.
=item B<manual>
The postmaster process is not handled by the init script, but manually
controlling the cluster with L<pg_ctlcluster(1)> is permitted.
=item B<disable>
Neither the init script nor L<pg_ctlcluster(1)> are permitted to start/stop the
cluster. Please be aware that this will not stop the cluster owner from calling
lower level tools to control the postmaster process; this option is only meant
to prevent accidentially controlling the postmaster during maintenance and to
prevent accidents, not more.
=back
=head1 SEE ALSO
L<pg_ctlcluster(8)>, L<pg_lsclusters(1)>, L<pg_wrapper(1)>
......
......@@ -329,6 +329,25 @@ if( $> != $info{'owneruid'} ) {
(getpwuid $info{'owneruid'})[0].')';
}
# check start.conf file
my $start = 'auto';
my $start_conf = $info{'configdir'} . '/start.conf';
if (-e $start_conf) {
open F, $start_conf or error "Could not open $start_conf";
while (<F>) {
s/#.*$//;
s/^\s*//;
s/\s*$//;
next unless $_;
$start = $_;
last;
}
close F;
error 'Cluster is disabled' if $start eq 'disabled';
error 'Invalid mode in start.conf' if $start ne 'auto' && $start ne 'manual';
}
$pg_ctl = get_program_path 'pg_ctl', $version;
$pg_autovacuum = get_program_path 'pg_autovacuum', $version;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment