summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-02-26 16:51:45 +0100
committerPavel Raiskup <praiskup@redhat.com>2015-02-26 17:31:38 +0100
commita8a3f7cbb9e46d946d9c0d7f8e8d547ad35a5a2c (patch)
tree00180696a9ec77489aac96c20e92c1829c58f5f0
parentf7f516372e2218daf18a79241d1fd271faa237cc (diff)
downloadpostgresql-setup-a8a3f7cbb9e46d946d9c0d7f8e8d547ad35a5a2c.tar.gz
postgresql-setup-a8a3f7cbb9e46d946d9c0d7f8e8d547ad35a5a2c.tar.xz
postgresql-setup-a8a3f7cbb9e46d946d9c0d7f8e8d547ad35a5a2c.zip
configuration: SCL hacks
Its now configurable what software collections will be enabled for pg_upgrade run, in case it is needed (new 'scls' option). Similarly, pg_upgrade needs to be told to send unix_socket_directories instead of unix_socket_directory to PostgreSQL server built for RHEL. * etc/postgresql-setup/upgrade/postgresql.conf: Add configuration examples for new options. * postgresql-setup.in (parse_upgrade_setup): Parse 'scls' and 'redhat_sockets_hack' options. (upgrade): Adjust the environment of 'su - postgres' call to pg_upgrade, optionally.
-rw-r--r--NEWS3
-rw-r--r--etc/postgresql-setup/upgrade/postgresql.conf8
-rw-r--r--postgresql-setup.in40
3 files changed, 49 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index adbfef8..b516bae 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ New in 3.0 version
* Legacy scripts are now generated from single template file, also are
simplified a bit.
+* There are now options (by upgrade configuration file) how to upgrade from an
+ PG stack running in SCL (Software Collections)
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New in 2.0 version
diff --git a/etc/postgresql-setup/upgrade/postgresql.conf b/etc/postgresql-setup/upgrade/postgresql.conf
index db58470..49d58b5 100644
--- a/etc/postgresql-setup/upgrade/postgresql.conf
+++ b/etc/postgresql-setup/upgrade/postgresql.conf
@@ -16,3 +16,11 @@ engine /usr/bin
# Just to feed ./postgresql-setup --upgrade-ids help output
description "In-place upgrade from Fedora 19 (PostgreSQL 9.2)"
+
+# What software collections must be enabled for successful upgrade.
+scls "postgresql92"
+
+# Red Hat back-patches unix_socket_directories into major versions 9.2+, which
+# is different from upstream (9.3+). You may need to let pg_upgrade know that
+# it works against server 9.2 built by Red Hat.
+redhat_sockets_hack yes
diff --git a/postgresql-setup.in b/postgresql-setup.in
index dadb615..fc377ff 100644
--- a/postgresql-setup.in
+++ b/postgresql-setup.in
@@ -148,9 +148,11 @@ parse_upgrade_setup()
local upgrade_confdir="@sysconfdir@/@NAME_BINARYBASE@-setup/upgrade"
+ debug "using 'upgrade' confdir $upgrade_confdir"
test -d "$upgrade_confdir" || die "can't read confdir $upgrade_confdir"
- local my_vars="id comment data_default engine description major"
+ local my_vars="id comment data_default engine description major scls \
+ redhat_sockets_hack"
while read conffile
do
read_config_file "$conffile" "$my_vars"
@@ -162,6 +164,26 @@ parse_upgrade_setup()
debug "reading config $conffile"
for i in $my_vars; do
set_var "upgradefrom_$i" "\$__pg_conf_$i"
+
+ local cm="config file '$conffile'"
+ # 'scls' and 'redhat_sockets_hack' are used to adjust
+ # environment and could be bash-injected.
+ case "$i" in
+ scls)
+ test -z "$upgrade_from_scls" \
+ || [[ $upgrade_from_scls =~ ^[-a-zA-Z0-9_\ ]+$ ]] \
+ || die "$cm: bad '$i' value '$upgrade_from_scls'"
+ ;;
+ redhat_sockets_hack)
+ case "$upgradefrom_redhat_sockets_hack" in
+ yes|no|'')
+ ;;
+ *)
+ die "$cm: bad '$i' value"
+ ;;
+ esac
+ ;;
+ esac
done
return 0
fi
@@ -313,10 +335,24 @@ upgrade()
info $"Upgrading database."
+ scls_upgrade_hacks=
+ test -n "$upgradefrom_scls" && {
+ debug "scls [$upgradefrom_scls] will be enabled"
+ scls_upgrade_hacks="source scl_source enable $upgradefrom_scls ;"
+ }
+
+ test -n "$upgradefrom_redhat_sockets_hack" && {
+ debug "upgrading from redhat server"
+ socket_hacks="export REDHAT_PGUPGRADE_FROM_RHEL=yes ;"
+ }
+
# Create empty new-format database
if perform_initdb; then
# Do the upgrade
- $SU_POSTGRES -c "$PGENGINE/pg_upgrade \
+ $SU_POSTGRES -c "\
+ $scls_upgrade_hacks \
+ $socket_hacks \
+ $PGENGINE/pg_upgrade \
'--old-bindir=$upgradefrom_engine' \
'--new-bindir=$PGENGINE' \
'--old-datadir=$pgdataold' \