|
@ -32,7 +32,7 @@ kong_deploy() { |
|
|
_debug _cfullchain "$_cfullchain" |
|
|
_debug _cfullchain "$_cfullchain" |
|
|
|
|
|
|
|
|
#Get uuid linked to the domain |
|
|
#Get uuid linked to the domain |
|
|
uuid=$( _get "$KONG_URL/apis?request_host=$_cdomain" | _normalizeJson | _egrep_o '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
|
|
|
|
|
|
|
|
uuid=$(_get "$KONG_URL/apis?request_host=$_cdomain" | _normalizeJson | _egrep_o '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
|
|
if [ "$uuid" = "" ]; then |
|
|
if [ "$uuid" = "" ]; then |
|
|
_err "Unable to get Kong uuid for domain $_cdomain" |
|
|
_err "Unable to get Kong uuid for domain $_cdomain" |
|
|
_err "Make sure that KONG_URL is correctly configured" |
|
|
_err "Make sure that KONG_URL is correctly configured" |
|
@ -62,15 +62,14 @@ kong_deploy() { |
|
|
#Check if ssl plugins is aready enabled (if not => POST else => PATCH) |
|
|
#Check if ssl plugins is aready enabled (if not => POST else => PATCH) |
|
|
ssl_uuid=$(_get "$KONG_URL/apis/$uuid/plugins" | _egrep_o '"id":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"[a-zA-Z0-9\-\,\"_\:]*"name":"ssl"' | _egrep_o '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
|
|
ssl_uuid=$(_get "$KONG_URL/apis/$uuid/plugins" | _egrep_o '"id":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"[a-zA-Z0-9\-\,\"_\:]*"name":"ssl"' | _egrep_o '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') |
|
|
_debug ssl_uuid "$ssl_uuid" |
|
|
_debug ssl_uuid "$ssl_uuid" |
|
|
if [ "$ssl_uuid" = "" ] |
|
|
|
|
|
then |
|
|
|
|
|
|
|
|
if [ "$ssl_uuid" = "" ]; then |
|
|
#Post certificate to Kong |
|
|
#Post certificate to Kong |
|
|
response=$(_post "$content" "$KONG_URL/apis/$uuid/plugins" "" "POST") |
|
|
response=$(_post "$content" "$KONG_URL/apis/$uuid/plugins" "" "POST") |
|
|
else |
|
|
else |
|
|
#patch |
|
|
#patch |
|
|
response=$(_post "$content" "$KONG_URL/apis/$uuid/plugins/$ssl_uuid" "" "PATCH") |
|
|
response=$(_post "$content" "$KONG_URL/apis/$uuid/plugins/$ssl_uuid" "" "PATCH") |
|
|
fi |
|
|
fi |
|
|
if ! [ "$( echo "$response" | _egrep_o "ssl" )" = "ssl" ]; then |
|
|
|
|
|
|
|
|
if ! [ "$(echo "$response" | _egrep_o "ssl")" = "ssl" ]; then |
|
|
_err "An error occured with cert upload. Check response:" |
|
|
_err "An error occured with cert upload. Check response:" |
|
|
_err "$response" |
|
|
_err "$response" |
|
|
return 1 |
|
|
return 1 |
|
|