Refactor issue certs
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
# See README.md for more details
|
# See README.md for more details
|
||||||
#
|
#
|
||||||
# Copyright 2020 Bryan Roessler <bryanroessler@gmail.com>
|
# Copyright 2020 Bryan Roessler <bryanroessler@gmail.com>
|
||||||
#
|
|
||||||
|
|
||||||
unset SITES_DIR USEREMAIL DOMAIN_FILES DOMAIN_GROUPS DEPLOY_CMD_PREFIX ISSUE_CMD_PREFIX DEBUG GROUP
|
unset SITES_DIR USEREMAIL DOMAIN_FILES DOMAIN_GROUPS DEPLOY_CMD_PREFIX ISSUE_CMD_PREFIX DEBUG GROUP
|
||||||
|
|
||||||
@@ -156,57 +155,56 @@ load_domains() {
|
|||||||
|
|
||||||
issue_and_deploy_certs() {
|
issue_and_deploy_certs() {
|
||||||
|
|
||||||
local domain_root domain domain_group
|
local group_root domain_root domain domain_group
|
||||||
local -a issue_cmd=()
|
|
||||||
local -a deploy_cmd=()
|
|
||||||
|
|
||||||
if [[ -v GROUP ]]; then
|
|
||||||
for domain_group in "${DOMAIN_GROUPS[@]}"; do
|
|
||||||
unset i
|
|
||||||
for domain in $domain_group; do # we want to split on whitespace
|
|
||||||
[[ "$domain" == "" ]] && continue
|
|
||||||
# Get the webroot from the first domain
|
|
||||||
if [[ ! -v i ]]; then
|
|
||||||
local i="set"
|
|
||||||
domain_root=$(get_webroot "$domain")
|
|
||||||
issue_cmd=("${ISSUE_CMD_PREFIX[@]}" "-w" "$domain_root")
|
|
||||||
fi
|
|
||||||
issue_cmd+=("-d" "$domain" "-d" "www.$domain")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Issue certificate for entire domain group
|
for domain_group in "${DOMAIN_GROUPS[@]}"; do
|
||||||
echo "Running:" "${issue_cmd[@]}"
|
local -a issue_cmd=("${ISSUE_CMD_PREFIX[@]}")
|
||||||
if ! "${issue_cmd[@]}"; then
|
local -a deploy_cmd=("${DEPLOY_CMD_PREFIX[@]}")
|
||||||
echo "Failed to issue certificate"
|
local i="set"
|
||||||
fi
|
# Issue certificates
|
||||||
# Deploy certificates one by one
|
for domain in $domain_group; do # we want to split on whitespace
|
||||||
for domain in $domain_group; do
|
[[ "$domain" == "" ]] && continue
|
||||||
deploy_cmd=("${DEPLOY_CMD_PREFIX[@]}" "-w" "$domain_root" "-d" "$domain")
|
if [[ -v GROUP ]]; then
|
||||||
echo "Running:" "${deploy_cmd[@]}"
|
if [[ "$METHOD" == "webroot" && -v i ]]; then
|
||||||
"${deploy_cmd[@]}"
|
group_root=$(get_webroot "$domain")
|
||||||
done
|
issue_cmd+=("-w" "$group_root")
|
||||||
done
|
unset i
|
||||||
else
|
fi
|
||||||
for domain_group in "${DOMAIN_GROUPS[@]}"; do
|
# Append domains to issue command that we will call after the loop
|
||||||
# Issue and deploy certificates one by one
|
issue_cmd+=("-d" "$domain" "-d" "www.$domain")
|
||||||
for domain in $domain_group; do # we want to split on whitespace
|
# Issue certificate for single domain
|
||||||
issue_cmd=("${ISSUE_CMD_PREFIX[@]}" "-d" "$domain" "-d" "www.$domain")
|
else
|
||||||
[[ "$METHOD" == "webroot" ]] && domain_root=$(get_webroot "$domain") && issue_cmd=("${issue_cmd[@]}" "-w" "$domain_root")
|
local -a issue_cmd=("${ISSUE_CMD_PREFIX[@]}")
|
||||||
deploy_cmd=("${DEPLOY_CMD_PREFIX[@]}" "-d" "$domain") # I think we only need to deploy to the domain, not subdomains
|
domain_root=$(get_webroot "$domain")
|
||||||
[[ "$METHOD" == "webroot" ]] && deploy_cmd=("${deploy_cmd[@]}" "-w" "$domain_root")
|
issue_cmd+=("-d" "$domain" "-d" "www.$domain")
|
||||||
|
[[ "$METHOD" == "webroot" ]] && issue_cmd+=("-w" "$domain_root")
|
||||||
echo "Running:" "${issue_cmd[@]}"
|
echo "Running:" "${issue_cmd[@]}"
|
||||||
if ! "${issue_cmd[@]}"; then
|
if ! "${issue_cmd[@]}"; then
|
||||||
echo "Failed to issue certificate for $domain"
|
echo "Failed to issue certificate for domain: $domain"
|
||||||
err=1
|
err=1
|
||||||
fi
|
fi
|
||||||
echo "Running:" "${deploy_cmd[@]}"
|
fi
|
||||||
if ! "${deploy_cmd[@]}"; then
|
|
||||||
echo "Failed to deploy certificate for $domain"
|
|
||||||
err=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
# Issue certificate for group of domains
|
||||||
|
if [[ -v GROUP ]]; then
|
||||||
|
echo "Running:" "${issue_cmd[@]}"
|
||||||
|
if ! "${issue_cmd[@]}"; then
|
||||||
|
echo "Failed to issue certificate for domain group: $domain_group"
|
||||||
|
err=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Deploy certificates one domain at a time
|
||||||
|
for domain in $domain_group; do
|
||||||
|
deploy_cmd=("${DEPLOY_CMD_PREFIX[@]}" "-d" "$domain") # I think we only need to deploy to the domain, not subdomains (e.g. www.)
|
||||||
|
echo "Running:" "${deploy_cmd[@]}"
|
||||||
|
if ! "${deploy_cmd[@]}"; then
|
||||||
|
echo "Failed to deploy certificate for $domain"
|
||||||
|
err=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user