Skip to content

Commit 31195f0

Browse files
authored
IGNITE-26457 Add backup config files when upgrade (#6789)
1 parent 5aa7b56 commit 31195f0

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

packaging/db/linux/postInstall.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,44 @@ setup_host_name() {
5454
fi
5555
}
5656

57+
escape_forward_slashes() {
58+
echo "$1" | sed 's;/;\\/;g'
59+
}
60+
61+
replace_or_append_property_in_file() (
62+
LHS="$(escape_forward_slashes "$1")"
63+
RHS="$(escape_forward_slashes "$2")"
64+
sed -i "/^$LHS=/{h;s/=.*/=$RHS/};\${x;/^$/{s//$LHS=$RHS/;H};x}" "$3"
65+
)
66+
67+
replace_or_append_properties() (
68+
replace_or_append_property() {
69+
LHS="$(echo "$1" | cut -d'=' -f1)"
70+
RHS="$(echo "$1" | cut -d'=' -f2-)"
71+
replace_or_append_property_in_file "$LHS" "$RHS" "$2"
72+
}
73+
while IFS='' read -r LINE || [ -n "${LINE}" ]; do
74+
case "$LINE" in
75+
*=*) replace_or_append_property "$LINE" "$2" ;;
76+
esac
77+
done < "$1"
78+
)
79+
80+
persist_properties() {
81+
if [ -f '@CONF_DIR@/backup/vars.env' ]; then
82+
if [ -f '@CONF_DIR@/vars.env.rpmnew' ]; then
83+
mv '@CONF_DIR@/vars.env.rpmnew' '@CONF_DIR@/vars.env'
84+
fi
85+
replace_or_append_properties '@CONF_DIR@/backup/vars.env' '@CONF_DIR@/vars.env'
86+
fi
87+
if [ -f '@CONF_DIR@/backup/ignite-config.conf' ]; then
88+
cp -f "@CONF_DIR@/backup/ignite-config.conf" "@CONF_DIR@/ignite-config.conf"
89+
fi
90+
}
91+
5792
setup_directories
5893
setup_service_files
94+
persist_properties
5995
setup_host_name
6096

6197
echo

packaging/db/linux/preInstall.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@
1616
# limitations under the License.
1717
#
1818

19+
preserve_existing_config() {
20+
if [ -f "@CONF_DIR@/vars.env" ]; then
21+
mkdir -p "@CONF_DIR@/backup"
22+
cp -f "@CONF_DIR@/vars.env" "@CONF_DIR@/backup/"
23+
cp -f "@CONF_DIR@/ignite-config.conf" "@CONF_DIR@/backup/"
24+
fi
25+
}
26+
1927
source_user_group
28+
preserve_existing_config

0 commit comments

Comments
 (0)