Skip to content
Snippets Groups Projects
Commit 5d719eca authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

save config diffs

parent a136a4e4
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# 2020-12-15 v0.0 <axel.hahn@iml.unibe.ch> # 2020-12-15 v0.0 <axel.hahn@iml.unibe.ch>
# 2021-05-07 v1.0 <axel.hahn@iml.unibe.ch> multiple replacement files # 2021-05-07 v1.0 <axel.hahn@iml.unibe.ch> multiple replacement files
# 2021-05-27 v1.1 <axel.hahn@iml.unibe.ch> Warn on missing replacements; handle Ruby vars with single and double quotes # 2021-05-27 v1.1 <axel.hahn@iml.unibe.ch> Warn on missing replacements; handle Ruby vars with single and double quotes
# 2021-11-01 v1.2 <axel.hahn@iml.unibe.ch> save config diffs for deploy_app.sh
# ====================================================================== # ======================================================================
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -24,6 +25,10 @@ test -z "$replacefile" && replacefile="replace*.txt" ...@@ -24,6 +25,10 @@ test -z "$replacefile" && replacefile="replace*.txt"
tmpfile=/tmp/myreplacement.tmp tmpfile=/tmp/myreplacement.tmp
usage="`basename $0` TEMPLATE-FILE OUTFILE [optional: REPLACE-DATA-FILE]" usage="`basename $0` TEMPLATE-FILE OUTFILE [optional: REPLACE-DATA-FILE]"
# cfgdiff is set in setProfile in ../deploy_app.sh while running through a profile
# if create_config.sh is used standalone we hide the output
test -z "${cfgdiff}" && cfgdiff=/dev/null
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -123,7 +128,12 @@ if [ $? -eq 0 ]; then ...@@ -123,7 +128,12 @@ if [ $? -eq 0 ]; then
fi fi
# --- create target file # --- create target file
mv -f "${tmpfile}" "${outfile}" diff "${tmpfile}" "${outfile}" >> ${cfgdiff}
if [ $? -eq 0 ]; then
_warn "INFO: no changes."
else
mv -f "${tmpfile}" "${outfile}" || exit 4
fi
echo echo
echo --- Output file: echo --- Output file:
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# 2021-05-14 v0.3 <axel.hahn@iml.unibe.ch> add params (list, force, help) # 2021-05-14 v0.3 <axel.hahn@iml.unibe.ch> add params (list, force, help)
# 2021-05-27 v0.4 <axel.hahn@iml.unibe.ch> FIX first install # 2021-05-27 v0.4 <axel.hahn@iml.unibe.ch> FIX first install
# 2021-07-08 v0.5 <axel.hahn@iml.unibe.ch> added function "runas" # 2021-07-08 v0.5 <axel.hahn@iml.unibe.ch> added function "runas"
# 2021-11-01 v0.6 <axel.hahn@iml.unibe.ch> save config diffs
# ====================================================================== # ======================================================================
...@@ -69,6 +70,8 @@ function setprofile(){ ...@@ -69,6 +70,8 @@ function setprofile(){
downloadfile="${tmpdir}/${IMLCI_PROJECT}.tgz" downloadfile="${tmpdir}/${IMLCI_PROJECT}.tgz"
downloadtmp="${tmpdir}/${IMLCI_PROJECT}.tgz.tmp" downloadtmp="${tmpdir}/${IMLCI_PROJECT}.tgz.tmp"
cfgdiff="${tmpdir}/${IMLCI_PROJECT}_cfgdiff.txt"
test -f "${cfgdiff}" && rm -f "${cfgdiff}"
} }
# output a colored infoline with date and given message # output a colored infoline with date and given message
...@@ -239,7 +242,13 @@ function deploy(){ ...@@ -239,7 +242,13 @@ function deploy(){
# - send success message as email/ slack/ [another fancy tool] # - send success message as email/ slack/ [another fancy tool]
test $isupdate -eq 0 && echo $skipmessage test $isupdate -eq 0 && echo $skipmessage
test $isupdate -eq 0 || run_task "${profiledir}/tasks_postinstall.sh" test $isupdate -eq 0 || run_task "${profiledir}/tasks_postinstall.sh"
grep . $cfgdiff
if [ $? -eq 0 ]; then
run_task "${profiledir}/tasks_postchanges.sh"
else
echo SKIP: No config file was changed.
fi
cd $( dirname $0 ) cd $( dirname $0 )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment