Hi all,<p>
Webmin’s XML-RPC api allows you to call low-level module functions remotely … basically, the API is the same as if you were writing your own module that was calling functions locally. For example, to list and create aliases you could use a program like this :<p>
[pre]
#!/usr/bin/perl
Demo program to list mail aliases, and either create or delete one
use Frontier::Client;
use Data::Dumper;
chop($url = cat url.txt
);
eval {
$server = Frontier::Client->new(‘url’ => $url);
};
$@ && die "Failed to create server : $@";
$conf = $server->call("sendmail::get_sendmailcf");
$afile = $server->call("sendmail::aliases_file", $conf);
$aliases = $server->call("sendmail::list_aliases", $afile);
print "Found ",scalar(@$aliases)," mail aliasesn";
($already) = grep { $_->{‘name’} eq ‘foobar’ } @$aliases;
if ($already) {
print "Alias foobar -> $already->{'values'}->[0] exists, deleting itn";
$server->call("sendmail::delete_alias", $already);
print "Done deletionn";
}
else {
print "Adding alias foobarn";
$alias = { 'name' => 'foobar',
'enabled' => 1,
'values' => [ "jcameron@webmin.com" ],
};
$server->call("sendmail::create_alias", $alias, $afile);
}
[/pre]
This code assumes that a file containing the Webmin URL exists in url.txt, formatted like :<p>
http://root:password@webminserver:10000/xmlrpc.cgi<p>
As you can see, this is pretty low-level … many function calls are needed to perform even a basic task. Virtualmin offers an HTTP-based API that operates at a higher level, but it doesn’t yet extend to clustering.<p>