domain.setDomainUser(commandLine.getOptionValue("user"));
domain.setDomainPassword(commandLine.getOptionValue("password"));
// Init the server
ServerHandler serverHandler = ServerHandler.getInstance(domain);
Server server = serverHandler.getServer();
server.initLocalServer();
// Check if there is a template
File template = null;
if (commandLine.hasOption("template")) {
String templateName = commandLine.getOptionValue("template");
if (templateName != null) {
template = new File(templateName);
if (!template.exists()) {
System.err.println("Domain template '" + template.getAbsolutePath() + "' does not exist!");
System.exit(1);
}
}
}
// Check if there is a port base
int portBase = -1;
if (commandLine.hasOption("portbase")) {
String portbaseStr = commandLine.getOptionValue("portbase");
if (portbaseStr != null) {
portBase = Integer.parseInt(portbaseStr);
if (portBase <= 0) {
System.err.println("Invalid portbase '" + portbaseStr + "'!");
}
}
}
boolean checkPorts = true;
if (commandLine.hasOption("checkports")) {
String checkPortsStr = commandLine.getOptionValue("checkports");
if (checkPortsStr != null) {
checkPorts = Boolean.parseBoolean(checkPortsStr);
}
}
// Create the domain
CommandResult result = server.createDomain(domain.getDomainName(), portBase, template, domain.getDomainUser(), domain.getDomainPassword(), checkPorts);
if (!result.isOk()) {
System.err.println(result.getResult());
}
System.exit(result.getExitCode());
}