Konstantinos-infogeek
7/7/2015 - 12:13 AM

Sentora Create DNS

Sentora Create DNS

use sentora_core;

DELIMITER //
CREATE PROCEDURE `registerDNS`(in IP VARCHAR(50), HOST VARCHAR(50), USER_ID INT)
BEGIN
	insert into SENTORA_CORE.X_DNS (
		dn_acc_fk,
        dn_name_vc,
        dn_vhost_fk,
        dn_type_vc,
        dn_host_vc,
        dn_ttl_in,
        dn_target_vc,
        dn_texttarget_tx,
        dn_priority_in,
        dn_weight_in,
        dn_port_in)
    VALUES
    (USER_ID, HOST, USER_ID, 'A', '@', 3600, IP,'NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'A', 'mail', 86400, IP,'NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'CNAME', 'www', 3600, '@','NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'CNAME', 'ftp', 3600, '@','NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'SPF', 'mail', 3600, CONCAT_WS('','v=spf1 a mx ip4:',IP ,' mx:mail.', HOST,' -all'),'NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'SPF', '@', 3600, CONCAT_WS('','v=spf1 a mx ip4:',IP ,' mx:mail.', HOST,' -all'),'NULL', 0, 0, 0),
	(USER_ID, HOST, USER_ID, 'TXT', 'mail', 3600, CONCAT_WS('','v=spf1 a mx ip4:',IP ,' mx:mail.', HOST,' -all'),'NULL', 0, 0, 0),
    (USER_ID, HOST, USER_ID, 'TXT', '@', 3600, CONCAT_WS('','v=spf1 a mx ip4:',IP ,' mx:mail.', HOST,' -all'),'NULL', 0, 0, 0);
END //

Sentora, a stored procedure

Better of if you want more complete dns records through ssh console or phpmyadmin!

Create it like that:

mysql -u root -p < createDNS.sql

And call it like that:

CALL registerDNS( 'xxx.xxx.xxx.xxx', 'domain.com', [user_id]);

Probably there are some mistakes, but it works!