Commit 883f48a9 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

caddy-frontend: Fix configuration validation script

As caddy_configuration_state provides information with exit code use it
directly in the if instead of running it with $(), which stops execution when
configuration is not changed.

Improve checking for too old result - do not remove the file, instead check
for too old result and then recalculate.

/reviewed-on nexedi/slapos!589
parent 43678525
......@@ -98,7 +98,7 @@ md5sum = 061cc244558fd3af2b6bacf17cae5555
[template-validate-script]
filename = templates/validate-script.sh.in
md5sum = 89839a3f4ab71cab459afd1c27d00326
md5sum = f26e11574f266c7437c9c89e3c93825a
[template-configuration-state-script]
filename = templates/configuration-state-script.sh.in
......
......@@ -5,9 +5,12 @@ set -e
LAST_STATE_FILE={{ last_state_file }}
# force validation each 2 hours
[ -f $LAST_STATE_FILE ] && find $LAST_STATE_FILE -mmin +120 -delete
configuration_state=$({{ caddy_configuration_state }})
if [ ! -f $LAST_STATE_FILE ] || $configuration_state ; then
old_found=1
if [ -f $LAST_STATE_FILE ] ; then
old_found=$(find $LAST_STATE_FILE -mmin +120 | wc -l)
fi
if [ "$old_found" -eq 1 ] || {{ caddy_configuration_state }} ; then
# do not catch errors during validation
set +e
{{ wrapper }} -validate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment