improve sh

This commit is contained in:
Rodolfo Berrios
2024-02-16 16:13:06 -03:00
parent 763fa1a31d
commit e08ec6bf90
11 changed files with 37 additions and 57 deletions

View File

@@ -1,5 +1,7 @@
#!/bin/bash
curl --request POST \
#!/usr/bin/env bash
set -e
echo "* Creating ${HOSTNAME} CNAME record at CloudFlare"
CLOUDFLARE_IDENTIFIER=$(curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/dns_records \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${CLOUDFLARE_TOKEN}" \
@@ -9,4 +11,10 @@ curl --request POST \
"type": "CNAME",
"proxied": true,
"ttl": 3600
}' | jq -r '.result.id'
}' | jq -r '.result.id')
if [ "${CLOUDFLARE_IDENTIFIER}" == null ]; then
echo "CloudFlare integration failure"
exit 1
fi
echo "CLOUDFLARE_IDENTIFIER=${CLOUDFLARE_IDENTIFIER}" >>${NAMESPACE_FILE}
echo "[OK] Hostname created @ ${CLOUDFLARE_IDENTIFIER}"