]> git.proxmox.com Git - pmg-api.git/commitdiff
adapt postgresql.conf template to variable version
authorStoiko Ivanov <s.ivanov@proxmox.com>
Thu, 8 Aug 2019 13:36:11 +0000 (15:36 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 9 Aug 2019 06:45:05 +0000 (08:45 +0200)
pass the postgres major version in template_vars->{postgres}->{version} and
use that in the template. Additionally use the version for the config file
location.

The start and end tags are changed to '<*' and '*>' since the original
postgresql.conf contains an occurence of the default start tag '[%' which
would need to get escaped

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/Config.pm
src/templates/postgresql.conf.in

index 996d4854a2a20d012c1de305a51eb1e5954ec721..a62d9e42dd7c39226b02665b6f18f1f73a72d8c3 100755 (executable)
@@ -661,6 +661,7 @@ use PVE::INotify;
 use PVE::JSONSchema;
 
 use PMG::Cluster;
+use PMG::Utils;
 
 PMG::Config::Admin->register();
 PMG::Config::Mail->register();
@@ -1263,6 +1264,7 @@ sub get_template_vars {
        };
        warn "parse http_proxy failed - $@" if $@;
     }
+    $vars->{postgres}->{version} = PMG::Utils::get_pg_server_version();
 
     return $vars;
 }
@@ -1399,7 +1401,8 @@ sub rewrite_config_freshclam {
 sub rewrite_config_postgres {
     my ($self) = @_;
 
-    my $pgconfdir = "/etc/postgresql/11/main";
+    my $pg_maj_version = PMG::Utils::get_pg_server_version();
+    my $pgconfdir = "/etc/postgresql/$pg_maj_version/main";
 
     my $changes = 0;
 
index c13fe20caddbb6608e0decaee3746d8fb2191c17..1dc6791d32658c87fa09f01417f98c7f8edfb2a8 100644 (file)
@@ -1,3 +1,4 @@
+[% TAGS <* *> -%]
 # -----------------------------
 # PostgreSQL configuration file
 # -----------------------------
 # The default values of these variables are driven from the -D command-line
 # option or PGDATA environment variable, represented here as ConfigDir.
 
-data_directory = '/var/lib/postgresql/11/main'         # use data in another directory
+data_directory = '/var/lib/postgresql/<* postgres.version *>/main'             # use data in another directory
                                        # (change requires restart)
-hba_file = '/etc/postgresql/11/main/pg_hba.conf'       # host-based authentication file
+hba_file = '/etc/postgresql/<* postgres.version *>/main/pg_hba.conf'   # host-based authentication file
                                        # (change requires restart)
-ident_file = '/etc/postgresql/11/main/pg_ident.conf'   # ident configuration file
+ident_file = '/etc/postgresql/<* postgres.version *>/main/pg_ident.conf'       # ident configuration file
                                        # (change requires restart)
 
 # If external_pid_file is not explicitly set, no extra PID file is written.
-external_pid_file = '/var/run/postgresql/11-main.pid'                  # write an extra PID file
+external_pid_file = '/var/run/postgresql/<* postgres.version *>-main.pid'                      # write an extra PID file
                                        # (change requires restart)
 
 
@@ -460,7 +461,7 @@ log_timezone = 'localtime'
 
 # - Process Title -
 
-cluster_name = '11/main'                       # added to process titles if nonempty
+cluster_name = '<* postgres.version *>/main'                   # added to process titles if nonempty
                                        # (change requires restart)
 #update_process_title = on
 
@@ -476,7 +477,7 @@ cluster_name = '11/main'                    # added to process titles if nonempty
 #track_io_timing = off
 #track_functions = none                        # none, pl, all
 #track_activity_query_size = 1024      # (change requires restart)
-stats_temp_directory = '/var/run/postgresql/11-main.pg_stat_tmp'
+stats_temp_directory = '/var/run/postgresql/<* postgres.version *>-main.pg_stat_tmp'
 
 
 # - Statistics Monitoring -