Skip to content

Commit

Permalink
fix(domains): update git check cert script
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbertoli committed Jun 13, 2021
1 parent a11fa8b commit 2cbb50c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions letsencrypt/domains.sls
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ create-initial-cert-{{ setname }}-{{ domainlist | join('+') }}:
- cwd: {{ letsencrypt.cli_install_dir }}
{% endif %}
- unless:
{% if letsencrypt.use_package %}
- fun: cmd.run
python_shell: true
cmd: |
{{ check_cert_cmd }} {{ setname }} \
-d {{ domainlist|join(' -d ') }} | \
/bin/grep -q "Certificate Name: {{ setname }}"
{% else %}
- {{ check_cert_cmd }} {{ setname }} {{ domainlist | join(' ') }}
{% endif %}
- require:
{% if letsencrypt.use_package %}
- pkg: letsencrypt-client
Expand Down
8 changes: 4 additions & 4 deletions letsencrypt/files/check_letsencrypt_cert.sh.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
{% from "letsencrypt/map.jinja" import letsencrypt with context %}

FIRST_CERT=$1

CERT_NAME=$1
shift
for DOMAIN in "$@"
do
openssl x509 -in {{ letsencrypt.config_dir.path }}/live/$FIRST_CERT/cert.pem -noout -text | grep DNS:${DOMAIN} > /dev/null || exit 1
openssl x509 -in {{ letsencrypt.config_dir.path }}/live/$CERT_NAME/cert.pem -noout -text | grep DNS:${DOMAIN} > /dev/null || exit 1
done
CERT=$(date -d "$(openssl x509 -in {{ letsencrypt.config_dir.path }}/live/$FIRST_CERT/cert.pem -enddate -noout | cut -d'=' -f2)" "+%s")
CERT=$(date -d "$(openssl x509 -in {{ letsencrypt.config_dir.path }}/live/$CERT_NAME/cert.pem -enddate -noout | cut -d'=' -f2)" "+%s")
CURRENT=$(date "+%s")
REMAINING=$((($CERT - $CURRENT) / 60 / 60 / 24))
[ "$REMAINING" -gt "30" ] || exit 1
Expand Down

0 comments on commit 2cbb50c

Please sign in to comment.