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?
 

daveyw

Verified User
Joined
Jan 5, 2008
Messages
702
Location
/dev/null
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
 

B3rt

Verified User
Joined
Oct 12, 2007
Messages
81
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.
 

daveyw

Verified User
Joined
Jan 5, 2008
Messages
702
Location
/dev/null
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.
 

Arieh

Verified User
Joined
May 27, 2008
Messages
1,206
Location
The Netherlands
I'm not going to test it, but wouldn't Server's Hostname in DirectAdmin change the actual servers hostname?
 

nobaloney

NoBaloney Internet Svcs - In Memoriam †
Joined
Jun 16, 2003
Messages
26,119
Location
California
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
 

B3rt

Verified User
Joined
Oct 12, 2007
Messages
81
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.
 

floyd

Verified User
Joined
Mar 29, 2005
Messages
5,310
Even if the API does not support it you can still write a script to login to the gui DirectAdmin interface and change it.
 

B3rt

Verified User
Joined
Oct 12, 2007
Messages
81
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.
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,987
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
 
Top