Last active
May 30, 2018 14:58
-
-
Save geakstr/eb5f42a57ba36a5b988d to your computer and use it in GitHub Desktop.
Update IP for "A" record in Yandex PDD through API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get your token from | |
# https://pddimp.yandex.ru/token/index.xml?domain=yourdomain.com | |
token="put token" | |
# Get DNS information from | |
# https://pddimp.yandex.ru/nsapi/get_domain_records.xml?token=your_token_here&domain=yourdomain.com | |
record_id="put record id from 'id' attr" | |
domain="put domain from 'domain' attr without subdomain (!) sub.domain.com → domain.com" | |
subdomain="put subdomain from 'subdomain' attr" | |
ttl="put desired ttl" | |
# Path to file which store ip | |
old_ip_file="/home/geakstr/upd_ya_pdd/ip.txt" | |
################################################################### | |
old_ip=$(cat $old_ip_file) | |
cur_ip=$(/usr/bin/curl -sL http://icanhazip.com) | |
if [ "$cur_ip" != "$old_ip" ] | |
then | |
echo $cur_ip > $old_ip_file | |
ya_pdd_url="https://pddimp.yandex.ru/nsapi/edit_a_record.xml?" | |
query_url="${ya_pdd_url}token=${token}&record_id=${record_id}&domain=${domain}&subdomain=${subdomain}&ttl=${ttl}&content=${cur_ip}" | |
ya_pdd_response=$(/usr/bin/curl -sL $query_url) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment