Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
vultr api v2 ddns shell scripts
#!/bin/bash
BIN_DIR=/mnt/jffs2/plug/app/busybox
export PATH=$BIN_DIR/bin:$BIN_DIR/sbin:$BIN_DIR/usr/bin:$BIN_DIR/usr/sbin
DOMAIN=''
NAME=''
APIKEY=''
CAFILE="/mnt/jffs2/hw/etc/ssl/certs/ca-certificates.crt"
CURL_BIN="/mnt/jffs2/plug/app/bin/curl"
IPV4=$(ifconfig ppp257 | grep 'inet addr' | awk '{print $2}' | awk -F ':' '{print $2}')
record_response_json=$($CURL_BIN --cacert $CAFILE -s -X GET -H "Authorization: Bearer ${APIKEY}" "https://api.vultr.com/v2/domains/$DOMAIN/records")
records_id=$(echo $record_response_json | sed -E "s/.+\,\{\"id\":\"([a-f0-9-]+)\".+\"$NAME\".+/\1/g")
$CURL_BIN --cacert $CAFILE -s -X PATCH -H "Authorization: Bearer ${APIKEY}" "https://api.vultr.com/v2/domains/$DOMAIN/records/$records_id" -H "Content-Type: application/json" --data "{\"name\":\"$NAME\",\"type\":\"A\",\"data\":\"$IPV4\",\"ttl\":120, \"priority\":0}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment