diff options
author | Andrew Cady <d@jerkface.net> | 2020-09-14 17:49:57 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-09-14 17:49:57 -0400 |
commit | 34cfe1d99b9a69ece674a0ad7cf6db4a7dd1171d (patch) | |
tree | b8675c54d486a954e978748bbf8bb218786ff94e | |
parent | 4f29525793bdfc20eb11ce508a14c715544fdb46 (diff) |
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.
-rw-r--r-- | selfpublish.sh | 27 |
1 files 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 | |||
261 | 261 | ||
262 | wait_for_certificate_issuance() | 262 | wait_for_certificate_issuance() |
263 | { | 263 | { |
264 | local f state | 264 | local f state reloaded_apache= |
265 | f=/etc/apache2/md/domains/"$1"/md.json | 265 | f=/etc/apache2/md/domains/"$1"/md.json |
266 | local set=$- | 266 | local set=$- |
267 | set +x | 267 | set +x |
268 | echo -n Waiting for certificate... >&2 | 268 | echo -n Waiting for certificate... >&2 |
269 | while true | 269 | while true |
270 | do | 270 | do |
271 | if [ -e "$f" ] && | 271 | if [ -e "$f" ] && state=$(sed -ne 's/^ *"state": *\([0-9]\+\),/\1/p' "$f") |
272 | state=$(sed -ne 's/^ *"state": *\([0-9]\+\),/\1/p' "$f") && | 272 | then |
273 | [ "$state" = 2 ] | 273 | case "$state" in |
274 | then | 274 | 1) |
275 | if ! [ "$reloaded_apache" ] | ||
276 | then | ||
277 | as_root systemctl reload apache2 | ||
278 | reloaded_apache=y | ||
279 | fi | ||
280 | ;; | ||
281 | 2) | ||
275 | set -$set | 282 | set -$set |
283 | echo ' Done waiting for certificate.' >&2 | ||
276 | return | 284 | return |
277 | fi | 285 | ;; |
278 | sleep 1 | 286 | esac |
279 | echo -n . >&2 | 287 | fi |
288 | |||
289 | sleep 1 | ||
290 | echo -n . >&2 | ||
280 | done | 291 | done |
281 | } | 292 | } |
282 | 293 | ||