From 34cfe1d99b9a69ece674a0ad7cf6db4a7dd1171d Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 14 Sep 2020 17:49:57 -0400 Subject: Improve wait_for_certificate It seems that when state=1, it means we need to reload apache. When state=2 we are done. This might break the script. I did not create a new certificate to test it. --- selfpublish.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/selfpublish.sh b/selfpublish.sh index 5e43f7a..18884a0 100644 --- a/selfpublish.sh +++ b/selfpublish.sh @@ -261,22 +261,33 @@ END wait_for_certificate_issuance() { - local f state + local f state reloaded_apache= f=/etc/apache2/md/domains/"$1"/md.json local set=$- set +x echo -n Waiting for certificate... >&2 while true do - if [ -e "$f" ] && - state=$(sed -ne 's/^ *"state": *\([0-9]\+\),/\1/p' "$f") && - [ "$state" = 2 ] - then + if [ -e "$f" ] && state=$(sed -ne 's/^ *"state": *\([0-9]\+\),/\1/p' "$f") + then + case "$state" in + 1) + if ! [ "$reloaded_apache" ] + then + as_root systemctl reload apache2 + reloaded_apache=y + fi + ;; + 2) set -$set + echo ' Done waiting for certificate.' >&2 return - fi - sleep 1 - echo -n . >&2 + ;; + esac + fi + + sleep 1 + echo -n . >&2 done } -- cgit v1.2.3