refactor(Core/Conf): Removal of unnecessary .dist file loading (#14707)

* Remove .dist file requirement

* Remove unnecessary string cast

* Add required variables for CI build configs

* More required variables

* Add some more default variables to reduce log output

* One last default value to cut down log spam

* Rewrite conf file bash script

This should use the standard .dest file as a template

* Change dir we copy the dest files from

* actually use the correct file name

* need to use double quotes for variables

* add missing username

* set the correct datadir

* Attempt to fix dbimport

Co-authored-by: Foereaper <foereaper@elunatech.com>
This commit is contained in:
Foereaper
2023-01-21 14:48:22 +01:00
committed by GitHub
parent 30c29303db
commit 5fa027a222
2 changed files with 13 additions and 26 deletions

View File

@@ -3,19 +3,13 @@ CONFIG_FOLDER=${2:-"etc"}
BIN_FOLDER=${3-"bin"}
MYSQL_ROOT_PASSWORD=${4:-""}
# copy dist files to conf files
cp ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf.dist ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
echo "LoginDatabaseInfo = \"localhost;3306;root;$MYSQL_ROOT_PASSWORD;acore_auth\"" >> ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
# worldserver or dbimport
if [[ $APP_NAME != "authserver" ]]; then
{
echo "WorldDatabaseInfo = \"localhost;3306;root;$MYSQL_ROOT_PASSWORD;acore_world\""
echo "CharacterDatabaseInfo = \"localhost;3306;root;$MYSQL_ROOT_PASSWORD;acore_characters\""
} >> ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
fi
# replace login info
sed -i "s/127.0.0.1;3306;acore;acore/localhost;3306;root;$MYSQL_ROOT_PASSWORD/" ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
if [[ $APP_NAME == "worldserver" ]]; then
echo "DataDir = \"./data/\"" >> ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
sed -i 's/DataDir = \".\"/DataDir = \".\/data"/' ./env/dist/$CONFIG_FOLDER/$APP_NAME.conf
git clone --depth=1 --branch=master --single-branch https://github.com/ac-data/ac-data.git ./env/dist/$BIN_FOLDER/data
fi

View File

@@ -32,7 +32,6 @@ namespace
std::vector<std::string> _args;
std::unordered_map<std::string /*name*/, std::string /*value*/> _configOptions;
std::mutex _configLock;
bool _usingDistConfig = false;
// Check system configs like *server.conf*
bool IsAppConfig(std::string_view fileName)
@@ -255,8 +254,8 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
{
if (showLogs)
{
LOG_ERROR("server.loading", "> Config: Missing property {} in all config files, at least the .dist file must contain: \"{} = {}\"",
name, name, Acore::ToString(def));
LOG_ERROR("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file.",
name, _filename, name, Acore::ToString(def));
}
return def;
@@ -285,8 +284,8 @@ std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std
{
if (showLogs)
{
LOG_ERROR("server.loading", "> Config: Missing option {}, add \"{} = {}\"",
name, name, def);
LOG_ERROR("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file.",
name, _filename, name, def);
}
return def;
@@ -341,7 +340,7 @@ std::vector<std::string> ConfigMgr::GetKeysByString(std::string const& name)
std::string const ConfigMgr::GetFilename()
{
std::lock_guard<std::mutex> lock(_configLock);
return _usingDistConfig ? _filename + ".dist" : _filename;
return _filename;
}
std::vector<std::string> const& ConfigMgr::GetArguments() const
@@ -377,18 +376,12 @@ void ConfigMgr::Configure(std::string const& initFileName, std::vector<std::stri
bool ConfigMgr::LoadAppConfigs(bool isReload /*= false*/)
{
// #1 - Load init config file .conf.dist
if (!LoadInitial(_filename + ".dist", isReload))
// #1 - Load init config file .conf
if (!LoadInitial(_filename, isReload))
{
return false;
}
// #2 - Load .conf file
if (!LoadAdditionalFile(_filename, true, isReload))
{
_usingDistConfig = true;
}
return true;
}