fix: set default value
All checks were successful
ci / docker (push) Successful in 23s

This commit is contained in:
Tine Jozelj 2023-07-18 15:57:49 +02:00
parent 2090f83dac
commit ad59cc44db
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -exuo pipefail
api_host="https://api.digitalocean.com/v2" api_host="https://api.digitalocean.com/v2"
sleep_interval=${SLEEP_INTERVAL:-300} sleep_interval=${SLEEP_INTERVAL:-300}
@ -85,17 +85,19 @@ configure_record() {
done done
} }
while ( true ); do while ( true )
do
domain_records=$(curl -s -X GET \ domain_records=$(curl -s -X GET \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
$dns_list"?per_page=200") $dns_list"?per_page=200")
for service in ${services[@]}; do for service in ${services[@]}
do
echo "Trying with $service..." echo "Trying with $service..."
ipv4="$(curl -4 -s -f $service)" ipv4="$(curl -4 -s -f $service || echo "")"
ipv6="$(curl -6 -s -f $service)" ipv6="$(curl -6 -s -f $service || echo "")"
test -n "$ipv4$ipv6" && break test -n "$ipv4$ipv6" && break
done done
@ -103,13 +105,15 @@ while ( true ); do
echo "Found IPv4 address $ipv4" echo "Found IPv4 address $ipv4"
echo "Found IPv6 address $ipv6" echo "Found IPv6 address $ipv6"
if [[ -z $ipv4 ]]; then if [[ -z $ipv4 ]]
then
echo "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.." echo "IPv4 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
else else
configure_record $ipv4 "A" configure_record $ipv4 "A"
fi fi
if [[ -z $ipv6 ]]; then if [[ -z $ipv6 ]]
then
echo "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.." echo "IPv6 wasn't retrieved within allowed interval. Will try $sleep_interval seconds later.."
else else
configure_record $ipv6 "AAAA" configure_record $ipv6 "AAAA"