• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Plesk API - dns.sh - how ?

madsere

Regular Pleskian
Nameservers changed for all sites on one of my Plesk servers and I now have to modify all the NS records.

Rather than spending the rest of my life doing the point and click shuffle I was trying to use the dns.sh script from ftp://download1.sw-soft.com/Plesk/Plesk7.5/Doc/plesk-7.5r-sdk-html/docs/cu/unix/ch08.html - but the documentation might as well have been in Russian.

dns.sh command <domain_name> [-a -ip | -ns -nameserver | -mx -mailexchanger -priority | -cname -canonical | -ptr -subnet | -txt -domain ]

Logically I'd expect something like

dns.sh -d mydomain.com -ns myoldnameserver.com

to delete an old nameserver entry but it complains about missing -nameserver. Adding that just gives another error. Maybe one of the Plesk gurus can clarify the syntax (and fix the documentation) ?
 
The dns.sh is for creating one DNS record at a time. Examples:

dns.sh --add "domain.com" -a "mail" -ip "xx.yy.zz.aa"

dns.sh --add "domain.com" -a "webmail" -ip "xx.yy.zz.aa"

dns.sh --add "domain.com" -mx "mail" -mailexchanger "domain.com" -priority "10"

These would create 3 records.

Each option such as -mx <value> may require an additional option, in this case -priority <value>

Their docs could use a lot more polishing, but if you read it very very literally, you'll get it.


dns.sh command <domain_name> [-a -ip | -ns -nameserver | -mx -mailexchanger -priority | -cname -canonical | -ptr -subnet | -txt -domain ]
(remember, the pipe char means 'or')
This means that on each run of the command, you would pick one of the following combinations (and only a single combination):

-a -ip
-ns -nameserver
-mx -mailexchanger -priority
-cname -canonical
-ptr -subnet
-txt -domain

And whichever one you pick, you must include all parts (mx has 3 parts). So if you want to create 10 DNS records, you will have to do 10 calls to dns.sh with the appropriate arguments...

Clear as mud, right? Hope this helps.
 
I think perhaps my question wasn't clear enough.

I just wanted to know the proper syntax for adding/deleting NS records. Some trial and error and I found it to be this:

dns.sh --del <zone> -ns "" -nameserver <nameserver>
dns.sh --add <zone> -ns "" -nameserver <nameserver>

It is curious that the -ns switch must have an empty quote for this command to work, but this is how it works for me.
 
Originally posted by madsere
I think perhaps my question wasn't clear enough.

I just wanted to know the proper syntax for adding/deleting NS records. Some trial and error and I found it to be this:

dns.sh --del <zone> -ns "" -nameserver <nameserver>
dns.sh --add <zone> -ns "" -nameserver <nameserver>

It is curious that the -ns switch must have an empty quote for this command to work, but this is how it works for me.

This is due to fact that names after -ns and other similar options are relative to the domain name. See the corresponding actions in web-interface.
 
Back
Top