45 lines
1.5 KiB
Bash
45 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
APIKEY={{ api_key }}
|
||
|
NAME=$(hostname)
|
||
|
|
||
|
IPV4=$(curl -4s https://icanhazip.com/)
|
||
|
IPV6=$(ip -6 addr | grep mngtmpaddr | head -n 1 | awk '/inet6 / {gsub(/\/.*/,"",$2); print $2}')
|
||
|
|
||
|
if [[ $NAME == 'fogcutter' ]]; then
|
||
|
# apex (doesn't really matter which host this is run on)
|
||
|
curl \
|
||
|
--header "Authorization: Apikey $APIKEY" \
|
||
|
--header "Content-Type: application/json" \
|
||
|
--request PUT \
|
||
|
--data "{\"rrset_values\": [\"$IPV4\"]}" \
|
||
|
https://api.gandi.net/v5/livedns/domains/seaturtle.pw/records/@/A
|
||
|
curl \
|
||
|
--header "Authorization: Apikey $APIKEY" \
|
||
|
--header "Content-Type: application/json" \
|
||
|
--request PUT \
|
||
|
--data "{\"rrset_values\": [\"$IPV6\"]}" \
|
||
|
https://api.gandi.net/v5/livedns/domains/seaturtle.pw/records/@/AAAA
|
||
|
# fogcutter (for web apps)
|
||
|
curl \
|
||
|
--header "Authorization: Apikey $APIKEY" \
|
||
|
--header "Content-Type: application/json" \
|
||
|
--request PUT \
|
||
|
--data "{\"rrset_values\": [\"$IPV4\"]}" \
|
||
|
https://api.gandi.net/v5/livedns/domains/seaturtle.pw/records/$NAME/A
|
||
|
elif [[ $NAME == 'madone' ]]; then
|
||
|
curl \
|
||
|
--header "Authorization: Apikey $APIKEY" \
|
||
|
--header "Content-Type: application/json" \
|
||
|
--request PUT \
|
||
|
--data "{\"rrset_values\": [\"$IPV4\"]}" \
|
||
|
https://api.gandi.net/v5/livedns/domains/seaturtle.pw/records/$NAME/A
|
||
|
fi
|
||
|
|
||
|
curl \
|
||
|
--header "Authorization: Apikey $APIKEY" \
|
||
|
--header "Content-Type: application/json" \
|
||
|
--request PUT \
|
||
|
--data "{\"rrset_values\": [\"$IPV6\"]}" \
|
||
|
https://api.gandi.net/v5/livedns/domains/seaturtle.pw/records/$NAME/AAAA
|