From 5d719eca63ece7ff56d29c98ea4e0843613bcbba Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Mon, 1 Nov 2021 15:57:05 +0100 Subject: [PATCH] save config diffs --- bin/create_config.sh | 12 +++++++++++- deploy_app.sh | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/create_config.sh b/bin/create_config.sh index eb45e9c..b26f89a 100755 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -9,6 +9,7 @@ # 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-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" tmpfile=/tmp/myreplacement.tmp 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 # ---------------------------------------------------------------------- @@ -123,7 +128,12 @@ if [ $? -eq 0 ]; then fi # --- 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 --- Output file: diff --git a/deploy_app.sh b/deploy_app.sh index 8fe2f66..d11589c 100755 --- a/deploy_app.sh +++ b/deploy_app.sh @@ -9,6 +9,7 @@ # 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-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(){ downloadfile="${tmpdir}/${IMLCI_PROJECT}.tgz" 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 @@ -239,7 +242,13 @@ function deploy(){ # - send success message as email/ slack/ [another fancy tool] test $isupdate -eq 0 && echo $skipmessage 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 ) } -- GitLab