else if in custom DNS config with dns_a.conf

flexconcept

New member
Joined
Nov 21, 2013
Messages
2
In dns_a.conf I try to assign a address depending on a chosen package.
Is it possibe to use some kind of multple If-THEN ELSE statement?
This idea is not working:

mail=|IP|
localhost=127.0.0.1
|*if PACKAGE="DNS1"|
|DOMAIN|.=37.23.10.39
www=37.23.10.39
|*else if PACKAGE="DNS2"|
www=arabla.cloudapp.net.
|*else if PACKAGE="DNS3"|
|DOMAIN|.=12.134.156.7
www=12.134.156.7
|*else|
|*if IS_IPV6!="yes"|
|DOMAIN|.=|IP|
www=|IP|
mail=|IP|
|*endif|
|*endif|
 
I suggest you to contact DirectAdmin Support via e-mail or via safesubmit to ask them which TOKEN should be avaible for this, so, if there is any they will probably add it as Feature Request for next release.

Regards
 
Hello,

You're close, but the if-then-else doesn't suppoet "else if" nor embedded if's, so you need to do a few extra steps.
You've also got some lines that don't make any sense, as all value to the right must be IPs, and mail should be within the check of the IPV6 IP:
Code:
localhost=127.0.0.1
|?CUST=no|


|*if PACKAGE="DNS1"|
|?CUST=yes|
|DOMAIN|.=37.23.10.39
www=37.23.10.39
|*endif|


|*if PACKAGE="DNS2"|
|?CUST=yes|
|DOMAIN|.=1.2.3.4
www=1.2.3.4
|*endif|


|*if PACKAGE="DNS3"|
|?CUST=yes|
|DOMAIN|.=12.134.156.7
www=12.134.156.7
|*endif|


|*if IS_IPV6="yes"|
|?CUST=yes|
|*endif|


|*if CUST="no"|
|DOMAIN|.=|IP|
www=|IP|
mail=|IP|
|*endif|


OR (I can't recall if this template allows it), but something like this, which uses the default template, but only changes the IP:
Code:
|*if PACKAGE="DNS1"|
|?IP=37.23.10.39|
|*endif|
|*if PACKAGE="DNS2"|
|?IP=1.2.3.4|
|*endif|
|*if PACKAGE="DNS3"|
|?IP=12.134.156.7|
|*endif|
localhost=127.0.0.1
|*if IS_IPV6!="yes"|
|DOMAIN|.=|IP|
mail=|IP|
pop=|IP|
www=|IP|
ftp=|IP|
smtp=|IP|
|*endif|
keeping in mind that this *only* affects the dns. It doesn't change the IPs set in the VirtualHosts for Apache, so that may cause issues if you've not accounted for it.

John
 
Back
Top