diff --git a/bin/create_config.sh b/bin/create_config.sh index eb45e9c1fe7f1a80c1d677233187f0cacebe487d..b26f89a2c8c62f0ca73f8e81eb7a916d3980d87f 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 8fe2f668f12bb6ea7d381e724e79d52765ed3707..d11589cf1ef9848740f328c7abdfa10258c27bae 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 ) }