API set server hostname

B3rt

Verified User
Joined
Oct 12, 2007
Messages
81
Is there a DA API command for setting up the server hostname?

If so I cannot find it (used forum search and knowledgebase), can someone advise me about this?
 
The DA API has nothing to do with set your server hostname.
So I don't think there is a option for it in DA
 
Of-course directadmin has to do with the server hostname.

The hostname must also be set within the directpanel itself, see:
Administrator Settings --> Server's Hostname
The value here I wish to set using the API options.
 
Ahhh that is what you mean, I though you mean the 'hostname' of the server itself.
But the server's hostname should already be correctly when you install it, unless you change the hostname later after installing DA.
 
I'm not going to test it, but wouldn't Server's Hostname in DirectAdmin change the actual servers hostname?
 
First change the hostname in DirectAdmin, then from a shell login type:
Code:
$ hostname
If DirectAdmin has changed it, then the hostname command will return the new hostname.

Then you'll know.

Jeff
 
I know how to change manually a hostname.

I wish to automate this so the hostname can be changed from an other service panel where me manage all our servers without having to login into the server itself using the DA interface our commandline.
For this option is a API specially made for, the only thing is the API has to support this.
 
Even if the API does not support it you can still write a script to login to the gui DirectAdmin interface and change it.
 
The hostname.sh script in de scripts map does not set the hostname within DirectAdmin.
So if you update the hostname it using the script it is still NOT updated within the panel itself, this results that the message system of DA starts mailing that the server hostname is not correctly setup.
 
Hello,

Although there is no CMD_API_ADMIN_SETTINGS function in DA, you can still call CMD_ADMIN_SETTINGS with an API script. This would do everything for you with regards to the hostname.

The catch is that you must pass all variable that the form uses, which may be difficult to obtain since there is no API... but if the hostname change was only for new systems and rarely done, then you could just pick default values, along with the new hostname, and ns1/ns2 values, etc.. and submit it to CMD_ADMIN_SETTINGS with your script. The output would be html, so no likely readable, but there are not usually any errors with saving this form.

Note, that when changing the hostname, you must also ensure that the hostname resolves. I'd recommend adding a new zone into the dns (DNS Admin) with the full name of the hostname, eg: "domain = server.hostname.com", as this will also create an MX record which is needed for mail delivery from system accounts.

John
 
Hello,

Although there is no CMD_API_ADMIN_SETTINGS function in DA, you can still call CMD_ADMIN_SETTINGS with an API script. This would do everything for you with regards to the hostname.

The catch is that you must pass all variable that the form uses, which may be difficult to obtain since there is no API... but if the hostname change was only for new systems and rarely done, then you could just pick default values, along with the new hostname, and ns1/ns2 values, etc.. and submit it to CMD_ADMIN_SETTINGS with your script. The output would be html, so no likely readable, but there are not usually any errors with saving this form.

Note, that when changing the hostname, you must also ensure that the hostname resolves. I'd recommend adding a new zone into the dns (DNS Admin) with the full name of the hostname, eg: "domain = server.hostname.com", as this will also create an MX record which is needed for mail delivery from system accounts.

John

Finally, I found this old post and that is not documented anywhere in directadmin API. Also this CMD_ADMIN_SETTINGS only have 1 result in Google.

CMD_API_ADMIN_SETTINGS.JPG
Would you include this in documentation? I was struggling why the API did not output anything (but it works) until I found this post.

Edit: Or maybe I should not use CMD_ADMIN_SETTINGS at all (because my aim is to develop a plugin that communicate with da files). Maybe it is better to write into directadmin.conf as suggested from this https://forum.directadmin.com/threads/is-there-a-cmd_api_admin_settings.57615/post-294980
 
Last edited:
Back
Top