tiancheng91 / collection

笔记
https://github.com/tiancheng91/collection/issues
21 stars 1 forks source link

ddns #44

Open tiancheng91 opened 3 years ago

tiancheng91 commented 3 years ago
#!/bin/sh

ACCESS_TOKEN=#YOUR_TOKEN
DOMAIN=#YOUR-DOMAIN
RECORD_IDS=#(RECORD_ID_1 RECORD_ID_2 RECORD_ID_n)

IP=$(curl -s http://checkip.amazonaws.com/)

for ID in "${RECORD_IDS[@]}"
do
  curl \
    -fs -o /dev/null \
    -X PUT \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -d "{\"data\":\"$IP\"}" \
    "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$ID"
done