#!/bin/perl -w
use JSON::XS;
$token=$ARGV[0];
$domain=$ARGV[1];
$ip=$ARGV[2];
$dns = from_json(`/opt/bin/curl --insecure -H "PddToken: $token" https://pddimp.yandex.ru/api2/admin/dns/list?domain=$domain`);
if ($dns->{'records'}[1]{'subdomain'} eq '@' ) {
$was = $dns->{'records'}[1]{'content'};
if ($ip ne $was) {
$id = $dns->{'records'}[1]{'record_id'};
$res=`/opt/bin/curl --insecure -H \"PddToken: $token\" -d domain=$domain\\\&record_id=$id\\\&content=$ip https://pddimp.yandex.ru/api2/admin/dns/edit`;
print $res;
} else { print "IP address is same: $ip"; }
} else { print "Record [1] is not @";}
|