Skip to content

Commit

Permalink
add certificate to all routes with same domainname
Browse files Browse the repository at this point in the history
fixes #14
  • Loading branch information
ibotty committed Apr 28, 2017
1 parent cbc5683 commit 782eb6b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions libexec/get_certificate
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ set -euo pipefail

DOMAINNAME="$1"
SELFLINK="$2"
keyfile_="$(keyfile "$DOMAINNAME")"
certfile_="$(certfile "$DOMAINNAME")"
fullchainfile_="$(fullchainfile "$DOMAINNAME")"

pidfile=$LETSENCRYPT_DATADIR/get_certificate.pid

get_old_certificate() {
if ! [ -f "$certfile_" ] || ! [ -f "$keyfile_" ] || ! [ -f "$fullchainfile_" ]
then
get_certs_from_route "$DOMAINNAME" "$SELFLINK"\
|| echo "no old certificate found"
fi
get_certs_from_route "$DOMAINNAME" "$SELFLINK"\
|| echo "no old certificate found"
}

check_api_key() {
Expand Down Expand Up @@ -65,6 +60,11 @@ setup_well_known_route() {
return 1
}

routes_with_domain() {
local tmpl='.items[].metadata.selfLink'
get_routes "$(domain_selector "$DOMAIN")" | jq -er "$tmpl"
}

# Try to get lock
exec 201>"$pidfile"
flock -x 201
Expand All @@ -77,5 +77,7 @@ else
setup_well_known_route
trap cleanup_well_known_route EXIT
get_new_certificate "$DOMAINNAME"
add_certificate_to_route "$DOMAINNAME" "$SELFLINK"
for selflink_ in $(routes_with_domain); do
add_certificate_to_route "$DOMAINNAME" "$selflink_"
done
fi

0 comments on commit 782eb6b

Please sign in to comment.