i am searching the way to handle virutalmin/webmin such that whenever i create a virtual server an entry is made in the /etc/hosts file and when the server is deleted the entry in the /etc/hosts file is deleted
i have been trying to change some code in the create-domain.pl scripts that are executed when a virtual server is created .
but i have not been able to do that
please give some help in this regard
You don’t need to modify Virtualmin code (and shouldn’t, because it’ll just get overwritten every time you upgrade). Virtualmin can execute scripts for you on creation and modification of virtual servers.
Look in Module Configuration in the "Actions upon server and user creation". You can write a script to update hosts, and use the VIRTUALSERVER_DOM to know the hostname and VIRTUALSERVER_IP to know the IP in your script. Other variables are available, see the help for those options. (The options are "Command to run before making changes to a server" and "Command to run after making changes to a server"…there are matching options for aliases, as well.)
I am just cruious as to why you would want to modify the hosts file every time a new virtual server is added…?