porkpiehat
New member
- Joined
- Jan 16, 2019
- Messages
- 2
Hi all,
I'm trying to automatically update DNS records from two external servers. They are subdomains of my normal domain (reseller hosting). There are PHP scripts to do this, but the servers do not have PHP installed - and I'm not planning on installing it. So bash it is.
In the Help there is an article on how to use the API through curl/bash. From the API help I found the right commands to do so. Yet, it does not work yet...
Getting a dump of the records works fine. When trying to add or delete a record, firstly a '0' is returned (usually a good sign), followed by a dump of the unchanged records. No error message whatsoever.
When I paste the command in my browser (when logged in to DirectAdmin), adding and deleting the record works just fine.
Any thoughts on this?
The bash script:
I'm trying to automatically update DNS records from two external servers. They are subdomains of my normal domain (reseller hosting). There are PHP scripts to do this, but the servers do not have PHP installed - and I'm not planning on installing it. So bash it is.
In the Help there is an article on how to use the API through curl/bash. From the API help I found the right commands to do so. Yet, it does not work yet...
Getting a dump of the records works fine. When trying to add or delete a record, firstly a '0' is returned (usually a good sign), followed by a dump of the unchanged records. No error message whatsoever.
When I paste the command in my browser (when logged in to DirectAdmin), adding and deleting the record works just fine.
Any thoughts on this?
The bash script:
Code:
#!/bin/bash
# User and server details
user="username"
password="password"
server="https://webserver.hosting.com:portnumber"
domain="mydomain.com"
subdomain="test"
# Retrieve DNS records
#curl --request POST --user $user:$password --data 'package=unlimited' $server/CMD_API_DNS_CONTROL?domain=$domain
#echo $?
# Delete
curl --request POST --user $user:$password --data 'package=unlimited' --max-time 15\
$server/CMD_API_DNS_CONTROL?domain=$domain&action=select&arecs0=name=$subdomain
echo $?
# Add
curl --request POST --user $user:$password --data 'package=unlimited' --max-time 15\
$server/CMD_API_DNS_CONTROL?domain=$domain&action=add&type=A&name=$subdomain&value=8.8.8.8
echo $?