|
|
@ -2,18 +2,21 @@ |
|
|
|
|
|
|
|
|
|
|
|
get_domain() { |
|
|
|
local cfg="$1" |
|
|
|
|
|
|
|
e "$cfg" | cfg-get-value domain 2>/dev/null && return 0 |
|
|
|
|
|
|
|
## is service name a regex ? |
|
|
|
if [[ "$BASE_SERVICE_NAME" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then |
|
|
|
echo "$BASE_SERVICE_NAME" |
|
|
|
local cfg="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$SERVICE_NAME" "$MASTER_BASE_SERVICE_NAME" "$@")" \ |
|
|
|
domain |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
cat "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
err "You must specify a ${WHITE}domain$NORMAL option in relation. (${FUNCNAME[@]})" |
|
|
|
return 1 |
|
|
|
domain=$(e "$cfg" | cfg-get-value domain 2>/dev/null) || true |
|
|
|
if [ "$domain" ]; then |
|
|
|
echo "$domain" | tee "$cache_file" |
|
|
|
elif [[ "$BASE_SERVICE_NAME" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then |
|
|
|
echo "$BASE_SERVICE_NAME" | tee "$cache_file" |
|
|
|
else |
|
|
|
err "You must specify a ${WHITE}domain$NORMAL option in relation. (${FUNCNAME[@]})" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -115,14 +118,27 @@ export -f is_protocol_enabled |
|
|
|
|
|
|
|
|
|
|
|
_get_ssl_option_value() { |
|
|
|
local cfg="$1" target_relation rn ts rc td |
|
|
|
e "$cfg" | cfg-get-value ssl 2>/dev/null && return 0 |
|
|
|
local cfg="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$SERVICE_NAME" "$MASTER_BASE_SERVICE_NAME" "$@")" \ |
|
|
|
target_relation rn ts rc td |
|
|
|
|
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
cat "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
if ssl_cfg=$(e "$cfg" | cfg-get-value ssl 2>/dev/null); then |
|
|
|
if [[ "$ssl_cfg" =~ ^False|None$ ]]; then |
|
|
|
ssl_cfg="" |
|
|
|
fi |
|
|
|
echo "$ssl_cfg" | tee "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
target_relation="cert-provider" |
|
|
|
while read-0 rn ts rc td; do |
|
|
|
[ "$rn" == "${target_relation}" ] || continue |
|
|
|
info "A cert-provider '$ts' declared as 'ssl' value" |
|
|
|
echo "$ts" |
|
|
|
echo "$ts" | tee "$cache_file" |
|
|
|
return 0 |
|
|
|
done < <(get_service_relations "$SERVICE_NAME") |
|
|
|
|
|
|
|