File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff 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+
5792setup_directories
5893setup_service_files
94+ persist_properties
5995setup_host_name
6096
6197echo
Original file line number Diff line number Diff line change 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+
1927source_user_group
28+ preserve_existing_config
You can’t perform that action at this time.
0 commit comments