provisioning tool for building opinionated architecture
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/bin/bash
# GET DOMAIN : https://eu.api.ovh.com/createToken/?GET=/domain*&POST=/domain*&PUT=/domain*&DELETE=/domain*
function set_base {
BASE_URL="https://eu.api.ovh.com/1.0" source ./.ovh-credential }
function build_url_list_records { zone="$1" result="${BASE_URL}/domain/zone/$zone/record"
fieldType="${2:-}" subDomain="${3:-}" any="$fieldType$subDomain"
[[ -n $any ]] && result+="?" [[ -n $fieldType ]] && result+="fieldType=$fieldType&" [[ -n $subDomain ]] && result+="subDomain=$subDomain&" result=${result::-1}
echo "$result" }
function list_records { zone="$1" fieldType="${2:-}" subDomain="${3:-}"
query=$(build_url_list_records "$zone" "$fieldType" "$subDomain") method="GET" body="" tstamp=$(date +%s) sha=$(echo -n "$AS+$CK+$method+$query+$body+$tstamp" | shasum | cut -d ' ' -f 1) signature="\$1\$$sha"
curl -s \
-X $method \
-H "Content-type: application/json" \
-H "X-Ovh-Application: $AK" \
-H "X-Ovh-Consumer: $CK" \
-H "X-Ovh-Signature: $signature" \
-H "X-Ovh-Timestamp: $tstamp" \
"$query" | yq .[] # values of array }
function get_record { zone="$1" record="$2" method="GET" query="${BASE_URL}/domain/zone/$zone/record/$record" body="" tstamp=$(date +%s) sha=$(echo -n "$AS+$CK+$method+$query+$body+$tstamp" | shasum | cut -d ' ' -f 1) signature="\$1\$$sha"
curl -s \
-X $method \
-H "Content-type: application/json" \
-H "X-Ovh-Application: $AK" \
-H "X-Ovh-Consumer: $CK" \
-H "X-Ovh-Signature: $signature" \
-H "X-Ovh-Timestamp: $tstamp" \
"$query" | yq -o=props }
##----------- ## -- MAIN -- ##-----------
. "$MIAOU_BASEDIR/lib/init.sh"
set_base for i in $(list_records "$1" CNAME "$2"); do get_record "$1" "$i" done
|