48 lines
1.7 KiB
48 lines
1.7 KiB
# -*- mode: shell-script -*-
|
|
|
|
yaml_opt_bash_env() {
|
|
local prefix="$1" key value
|
|
while read-0 key value; do
|
|
new_prefix="${prefix}_${key^^}"
|
|
if [[ "$(echo "$value" | shyaml get-type)" == "struct" ]]; then
|
|
echo "$value" | yaml_opt_bash_env "${new_prefix}"
|
|
else
|
|
printf "%s\0%s\0" "${new_prefix/-/_}" "$value"
|
|
fi
|
|
done < <(shyaml key-values-0)
|
|
}
|
|
|
|
|
|
yaml_opt_bash_env_ignore_first_level() {
|
|
local prefix="$1" key value
|
|
while read-0 key value; do
|
|
new_prefix="${prefix}_${key^^}"
|
|
if [[ "$(echo "$value" | shyaml get-type)" == "struct" ]]; then
|
|
echo "$value" | yaml_opt_bash_env "${new_prefix}"
|
|
fi
|
|
done < <(shyaml key-values-0)
|
|
}
|
|
|
|
|
|
will_need_http_access() {
|
|
local domains args_domains remaining
|
|
[ "$challenge_type" == "http" ] || return 1
|
|
[ "${remainder_args[0]}" == "crt" ] || return 1
|
|
[ "${remainder_args[1]}" == "create" ] || return 1
|
|
|
|
[ -d "$SERVICE_DATASTORE/etc/letsencrypt/live/${remainder_args[2]}" ] || return 0
|
|
|
|
info "Querying ${remainder_args[2]} for previous info..."
|
|
out=$(compose run --rm letsencrypt crt info "${remainder_args[2]}" 2>&1 >/dev/null) || return 0
|
|
domains=$(printf "%s" "$out" | shyaml get-value domains) || return 0
|
|
|
|
domains=$(printf "%s " $domains | tr " " "\n" | sort)
|
|
args_domains=$(printf "%s " ${remainder_args[*]:2} | tr " " "\n" | sort)
|
|
info domains: "$domains"
|
|
info args_domain: "$args_domains"
|
|
remaining=$(printf "%s" "$out" | shyaml get-value remaining) || return 0
|
|
## XXXvlab: not using the variables to decide number of max days remaining
|
|
## for asking new certificate
|
|
[ "$domains" != "$args_domains" ] || [ "$remaining" -lt 30 ]
|
|
|
|
}
|