cli
cli copied to clipboard
implement civo domain records update
Instead of requiring users to "remove and recreate" domain records, it would be nice to implement an "update" action.
Proposed usage:
civo domain record update domain.com -n thing.domain.com -v "0.0.0.0"
Currently you have to pragmatically find the record id to remove the existing record, then recreate it which is... not great...
#!/bin/bash
export DOMAIN="domain.com"
export TARGET="subdomain"
export EV4="$(curl -q -4 ifconfig.me 2>/dev/null)"
export EV6="$(curl -q -6 ifconfig.me 2>/dev/null)"
echo "My external IP is $EV4 / $EV6"
EV4ID=$(civo domain record ls $DOMAIN -o json | jq -r ".[] | select(.name==\"$TARGET\") | .id")
EV4IP=$(civo domain record ls $DOMAIN -o json | jq -r ".[] | select(.name==\"$TARGET\") | .value")
if [[ $EV4IP == $EV4 ]]; then
echo "No updates needed"
else
civo domain record remove $DOMAIN $EV4ID -y
civo domain record create $DOMAIN -n ${TARGET}.${DOMAIN} -e A -v $EV4
fi