|
@@ -21,9 +21,10 @@ package com.l2jserver.cli.command.database;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.Scanner;
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
+import org.aeonbits.owner.Mutable;
|
|
|
|
+
|
|
import com.l2jserver.cli.command.AbstractCommand;
|
|
import com.l2jserver.cli.command.AbstractCommand;
|
|
-import com.l2jserver.cli.config.Configs;
|
|
|
|
-import com.l2jserver.cli.config.DatabaseConfiguration;
|
|
|
|
|
|
+import com.l2jserver.cli.config.Configuration;
|
|
import com.l2jserver.cli.dao.AbstractDatabaseDAO;
|
|
import com.l2jserver.cli.dao.AbstractDatabaseDAO;
|
|
import com.l2jserver.cli.dao.GameServerDatabaseDAO;
|
|
import com.l2jserver.cli.dao.GameServerDatabaseDAO;
|
|
import com.l2jserver.cli.dao.LoginServerDatabaseDAO;
|
|
import com.l2jserver.cli.dao.LoginServerDatabaseDAO;
|
|
@@ -36,45 +37,46 @@ import picocli.CommandLine.Option;
|
|
/**
|
|
/**
|
|
* Database install command.
|
|
* Database install command.
|
|
* @author Zoey76
|
|
* @author Zoey76
|
|
|
|
+ * @version 1.0.0
|
|
*/
|
|
*/
|
|
@Command(name = "install")
|
|
@Command(name = "install")
|
|
public class DatabaseInstallCommand extends AbstractCommand {
|
|
public class DatabaseInstallCommand extends AbstractCommand {
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
"-l",
|
|
"-l",
|
|
- "--location"
|
|
|
|
|
|
+ "--sql-location"
|
|
}, required = true, description = "Files location")
|
|
}, required = true, description = "Files location")
|
|
private String path;
|
|
private String path;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
- "-h",
|
|
|
|
- "--host"
|
|
|
|
- }, description = "Database host")
|
|
|
|
- private String host;
|
|
|
|
|
|
+ "-dv",
|
|
|
|
+ "--database-driver"
|
|
|
|
+ }, description = "Database Driver")
|
|
|
|
+ private String driver;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
- "-p",
|
|
|
|
- "--port"
|
|
|
|
- }, description = "Database port")
|
|
|
|
- private Integer port;
|
|
|
|
|
|
+ "-url",
|
|
|
|
+ "--database-url"
|
|
|
|
+ }, description = "Database URL")
|
|
|
|
+ private String url;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
"-u",
|
|
"-u",
|
|
- "--user"
|
|
|
|
- }, description = "Database user")
|
|
|
|
|
|
+ "--database-user"
|
|
|
|
+ }, description = "Database User")
|
|
private String user;
|
|
private String user;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
"-pw",
|
|
"-pw",
|
|
- "--password"
|
|
|
|
- }, description = "Database password")
|
|
|
|
|
|
+ "--database-password"
|
|
|
|
+ }, description = "Database Password")
|
|
private String password;
|
|
private String password;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
- "-d",
|
|
|
|
- "--db"
|
|
|
|
- }, description = "Database name")
|
|
|
|
- private String database;
|
|
|
|
|
|
+ "-pool",
|
|
|
|
+ "--connection-pool"
|
|
|
|
+ }, description = "Connection Pool")
|
|
|
|
+ private String connectionPool;
|
|
|
|
|
|
@Option(names = {
|
|
@Option(names = {
|
|
"-m",
|
|
"-m",
|
|
@@ -99,8 +101,6 @@ public class DatabaseInstallCommand extends AbstractCommand {
|
|
|
|
|
|
final AbstractDatabaseDAO databaseDAO = databaseDAO();
|
|
final AbstractDatabaseDAO databaseDAO = databaseDAO();
|
|
|
|
|
|
- databaseDAO.ensureDatabaseUsage();
|
|
|
|
-
|
|
|
|
databaseDAO.createDump();
|
|
databaseDAO.createDump();
|
|
|
|
|
|
databaseDAO.updates(mode, sqlPath);
|
|
databaseDAO.updates(mode, sqlPath);
|
|
@@ -127,36 +127,36 @@ public class DatabaseInstallCommand extends AbstractCommand {
|
|
private AbstractDatabaseDAO databaseDAO() {
|
|
private AbstractDatabaseDAO databaseDAO() {
|
|
switch (serverType) {
|
|
switch (serverType) {
|
|
case GAME: {
|
|
case GAME: {
|
|
- overrideConfigs(Configs.gameServer().db());
|
|
|
|
|
|
+ overrideConfigs(Configuration.gameServer());
|
|
return new GameServerDatabaseDAO();
|
|
return new GameServerDatabaseDAO();
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
case LOGIN: {
|
|
case LOGIN: {
|
|
- overrideConfigs(Configs.loginServer().db());
|
|
|
|
|
|
+ overrideConfigs(Configuration.loginServer());
|
|
return new LoginServerDatabaseDAO();
|
|
return new LoginServerDatabaseDAO();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void overrideConfigs(DatabaseConfiguration databaseConfiguration) {
|
|
|
|
- if (host != null) {
|
|
|
|
- databaseConfiguration.withHost(host);
|
|
|
|
|
|
+ private void overrideConfigs(Mutable databaseConfiguration) {
|
|
|
|
+ if (driver != null) {
|
|
|
|
+ databaseConfiguration.setProperty("DatabaseDriver", driver);
|
|
}
|
|
}
|
|
|
|
|
|
- if (port != null) {
|
|
|
|
- databaseConfiguration.withPort(port);
|
|
|
|
|
|
+ if (url != null) {
|
|
|
|
+ databaseConfiguration.setProperty("DatabaseURL", url);
|
|
}
|
|
}
|
|
|
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
- databaseConfiguration.withUser(user);
|
|
|
|
|
|
+ databaseConfiguration.setProperty("DatabaseUser", user);
|
|
}
|
|
}
|
|
|
|
|
|
if (password != null) {
|
|
if (password != null) {
|
|
- databaseConfiguration.withPassword(password);
|
|
|
|
|
|
+ databaseConfiguration.setProperty("DatabasePassword", password);
|
|
}
|
|
}
|
|
|
|
|
|
- if (database != null) {
|
|
|
|
- databaseConfiguration.withName(database);
|
|
|
|
|
|
+ if (connectionPool != null) {
|
|
|
|
+ databaseConfiguration.setProperty("DatabaseConnectionPool", connectionPool);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|