This is an automated email from the ASF dual-hosted git repository.

zstan pushed a commit to branch ignite-3.1.0
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-3.1.0 by this push:
     new 933d78f3374 IGNITE-26457 Add backup config files when upgrade (#6789)
933d78f3374 is described below

commit 933d78f337466e1f175494fa852d3a4b683d11f6
Author: Lozmanov <[email protected]>
AuthorDate: Thu Oct 16 21:42:53 2025 +0500

    IGNITE-26457 Add backup config files when upgrade (#6789)
---
 packaging/db/linux/postInstall.sh | 36 ++++++++++++++++++++++++++++++++++++
 packaging/db/linux/preInstall.sh  |  9 +++++++++
 2 files changed, 45 insertions(+)

diff --git a/packaging/db/linux/postInstall.sh 
b/packaging/db/linux/postInstall.sh
index c392fb7b66f..e03afb030ab 100644
--- a/packaging/db/linux/postInstall.sh
+++ b/packaging/db/linux/postInstall.sh
@@ -54,8 +54,44 @@ setup_host_name() {
   fi
 }
 
+escape_forward_slashes() {
+  echo "$1" | sed 's;/;\\/;g'
+}
+
+replace_or_append_property_in_file() (
+  LHS="$(escape_forward_slashes "$1")"
+  RHS="$(escape_forward_slashes "$2")"
+  sed -i "/^$LHS=/{h;s/=.*/=$RHS/};\${x;/^$/{s//$LHS=$RHS/;H};x}" "$3"
+)
+
+replace_or_append_properties() (
+  replace_or_append_property() {
+    LHS="$(echo "$1" | cut -d'=' -f1)"
+    RHS="$(echo "$1" | cut -d'=' -f2-)"
+    replace_or_append_property_in_file "$LHS" "$RHS" "$2"
+  }
+  while IFS='' read -r LINE || [ -n "${LINE}" ]; do
+    case "$LINE" in
+      *=*) replace_or_append_property "$LINE" "$2" ;;
+    esac
+  done < "$1"
+)
+
+persist_properties() {
+  if [ -f '@CONF_DIR@/backup/vars.env' ]; then
+    if [ -f '@CONF_DIR@/vars.env.rpmnew' ]; then
+      mv '@CONF_DIR@/vars.env.rpmnew' '@CONF_DIR@/vars.env'
+    fi
+    replace_or_append_properties '@CONF_DIR@/backup/vars.env' 
'@CONF_DIR@/vars.env'
+  fi
+  if [ -f '@CONF_DIR@/backup/ignite-config.conf' ]; then
+    cp -f "@CONF_DIR@/backup/ignite-config.conf" 
"@CONF_DIR@/ignite-config.conf"
+  fi
+}
+
 setup_directories
 setup_service_files
+persist_properties
 setup_host_name
 
 echo
diff --git a/packaging/db/linux/preInstall.sh b/packaging/db/linux/preInstall.sh
index e21edac9d88..ac226705fcb 100644
--- a/packaging/db/linux/preInstall.sh
+++ b/packaging/db/linux/preInstall.sh
@@ -16,4 +16,13 @@
 # limitations under the License.
 #
 
+preserve_existing_config() {
+  if [ -f "@CONF_DIR@/vars.env" ]; then
+    mkdir -p "@CONF_DIR@/backup"
+    cp -f "@CONF_DIR@/vars.env" "@CONF_DIR@/backup/"
+    cp -f "@CONF_DIR@/ignite-config.conf" "@CONF_DIR@/backup/"
+  fi
+}
+
 source_user_group
+preserve_existing_config

Reply via email to