Submitted by novoops on Tue, 07/07/2009 - 23:36
I'm trying to get domain information from virtualmin for a php file. Specifically, I want to retrieve the description for a domain. It appears that I should be able to use list-domains.pl to get this info. This would seem to be a better alternative than parsing the map.dom file and then then corresponding data file for the domain (in virtual-server/domains), which is restricted by permissions anyway.
However, attempting to execute the list-domains.pl script results in a return code of 1, and the following error message:
Error: Script was not run with full path (failed to find /usr/local/webmin/virtual-server/list-domains.pl under )
-----
Script was not run with full path (failed to find /usr/local/webmin/virtual-server/list-domains.pl under )
-----
In case you're wondering, I'm calling the script using...
exec("/usr/local/webmin/virtual-server/list-domains.pl", $output, $error);
This seems to be related to a similar error I was getting and reported in https://www.virtualmin.com/node/10463.
Any suggestions?
Status:
Closed (fixed)
Comments
You'll need to use the remote API for things not running as root (Apache doesn't run as root, nor would anything running under mod_fcgid+suxec).
So, you'd make a web request like this:
https://user:passwd@localhost:10000/virtual-server/remote.cgi?program=li...
Where user:passwd is the authentication details of any user with remote access privileges, including root, probably.
API docs are coming back online shortly.
The virtualmin command will eventually be usable by any Virtualmin user (and with their correct permissions), but that requires a bit of a redesign of the API interface, so it'll be a couple of revisions in the future, at least.
Submitted by JamieCameron on Wed, 07/08/2009 - 00:42 Comment #3
Joe is correct - if your PHP script is not run as root, you will need to make an HTTP call, as documented at : http://www.virtualmin.com/documentation/id,remote_http_api/
Submitted by novoops on Wed, 07/08/2009 - 11:28 Comment #4
Thanks. I'll take a good look at the API docs.
FWIW (and in hopes it helps someone else in the future), I had to do a few other things to get that API command to work:
I'm running webmin on an alternate port, so obviously I needed to use the correct port instead of port 10000
I had webmin only listening on a specific external IP, so I needed to add 127.0.0.1 as well
When testing it I was using wget, which needed the
--no-check-certificate
option to avoid issues with the fact that my SSL certificate is for secure.mydomain.com, and obviously not for "localhost".Submitted by JamieCameron on Wed, 07/08/2009 - 11:59 Comment #5
Cool, glad you got it working. If you need more details about each domain, you can add &multiline= to the URL.
Submitted by novoops on Wed, 07/08/2009 - 12:35 Comment #6
Very nice.
All I really need is the 'Description' field. I'm using it for parked domains; the "landing page" for such sites shows the description as the "name" for the site. It works perfectly.
If I were to use the 'multiline' option as well, it'd be best to use it with the 'domain=' option, so that I can get just the info I need. I've tested it and it too works quite well.
It look like any "Custom Fields" aren't included, however, in the multiline output. That's too bad, because that would be very nice. I could then add special options and/or flags in that field when parking a domain that could adjust the behavior of the "landing page" for that domain.
I know third-party webmin modules can be written, but can third-party virtualmin modules be written as well? I don't really have the time for it now, but perhaps one day it might be nice to setup a module just to make my management of these parked domains a bit easier. Who knows, perhaps it could help some other as well.
Submitted by JamieCameron on Wed, 07/08/2009 - 12:38 Comment #7
If you want to get custom fields, you should use the list-custom API command instead.
And yes, you can write third-party Virtualmin modules, typically in the form of plugins, as documented at http://www.virtualmin.com/documentation/id,writing_virtualmin_plugins/
Submitted by Issues on Wed, 07/22/2009 - 14:18 Comment #8
Automatically closed -- issue fixed for 2 weeks with no activity.