Is there an API call to reload rndc? I have a cpanel plugin im developing which modifies dns but it looks like named isn't being reloaded.
Is there an API call to reload rndc? I have a cpanel plugin im developing which modifies dns but it looks like named isn't being reloaded.
Anything that edits DNS zones will restart named (add/remove sub/parked/addon domains, edit dns zones, etc). However, thos may not be useful unless you want to mess with the account. You could make your own api2 call that connects to dnsadmin by creating /usr/local/cpanel/Cpanel/DNSAPI.pm:
Now, I pulled the askdnsadmin function call from /usr/local/cpanel/Cpanel/DnsUtils.pm so you'll have to go through that module to see how the %RELOADLIST is built for what to send as the zones to reload but it should do the trick.Code:package Cpanel::DNSAPI; BEGIN{ push( @INC, '/usr/local/cpanel'); } use Cpanel::DnsUtils::AskDnsAdmin (); sub api2 { my $func = shift; my %API; $API{'reload'}{'func'} = 'api2_reload'; $API{'reload'}{'engine'} = 'hasharray'; return \%{ $API{$func} }; } sub api2_reload{ my %OPTS = @_; my $domain_to_reload = $OPTS{'domain'}; #sanitize this as you don't know what the code in dnsadmin looks like #original usage is below, my usage is not tested #my %RELOADLIST = shift; #Cpanel::DnsUtils::AskDnsAdmin::askdnsadmin( 'RELOADZONES', 0, join( ',', keys %RELOADLIST ) ); Cpanel::DnsUtils::AskDnsAdmin::askdnsadmin( 'RELOADZONES', 0, $domain_to_reload ); } 1;
You could then call it with:
Code:https://domain.com:2083/xml-api/cpanel?cpanel_xmlapi_module=DNSAPI&cpanel_xmlapi_func=reload&cpanel_xmlapi_apiversion=2&domain=thedomain.tld
Now, there's also a call for ZoneEdit::resetzone which will reload named but it likely will wipe out your changes: ZoneEdit Module Documentation
You'll want to make sure you're using the ZoneEdit functions to edit the DNS zone or it will likely be rebuilt without your changes at some future point.
Late reply but whatevs,
So I am using cptt and the ZoneEdit functions in TT and rndc is not being reloaded. Any ideas?
http://mattharris.org
System Administrator
It's reloading fine on my test box:
add_zone_record:
output:Code:https://domain.com:2083/cpsessXXXXXXXXXX/xml-api/cpanel?cpanel_xmlapi_module=ZoneEdit&cpanel_xmlapi_func=add_zone_record&domain=domain.com&name=domain.com&type=TXT&txtdata=test
Code:<cpanelresult> <apiversion>2</apiversion> <data> <name>result</name> <newserial>2012080201</newserial> <status>1</status> <statusmsg> Bind reloading on hostname using rndc zone: [domain.com] </statusmsg> </data> <event> <result>1</result> </event> <func>add_zone_record</func> <module>ZoneEdit</module> </cpanelresult>
edit_zone_record:
Code:https://domain.com:2083/cpsessXXXXXXXXXX/xml-api/cpanel?cpanel_xmlapi_module=ZoneEdit&cpanel_xmlapi_func=edit_zone_record&domain=domain.com&Line=31&type=TXT&txtdata=updated
output:
Code:<cpanelresult> <apiversion>2</apiversion> <data> <name>result</name> <newserial>2012080202</newserial> <status>1</status> <statusmsg> Bind reloading on hostname using rndc zone: [domain.com] </statusmsg> </data> <event> <result>1</result> </event> <func>edit_zone_record</func> <module>ZoneEdit</module> </cpanelresult>
You should note that if you're doing this programmatically, you'll need to wait for the nameserver reload to complete which could take up to a minute. If you have another function immediately looking at the zone, it will fail as that's going to happen in milliseconds.