mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
feat(Config): Implement configuration severity policy and logging mechanism (#23284)
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
function registerHooks() { acore_event_registerHooks "$@"; }
|
||||
function runHooks() { acore_event_runHooks "$@"; }
|
||||
|
||||
#shellcheck source=../../conf/dist/config.sh
|
||||
source "$AC_PATH_CONF/dist/config.sh" # include dist to avoid missing conf variables
|
||||
function acore_common_loadConfig() {
|
||||
#shellcheck source=../../conf/dist/config.sh
|
||||
source "$AC_PATH_CONF/dist/config.sh" # include dist to avoid missing conf variables
|
||||
|
||||
# first check if it's defined in env, otherwise use the default
|
||||
USER_CONF_PATH=${USER_CONF_PATH:-"$AC_PATH_CONF/config.sh"}
|
||||
# first check if it's defined in env, otherwise use the default
|
||||
USER_CONF_PATH=${USER_CONF_PATH:-"$AC_PATH_CONF/config.sh"}
|
||||
|
||||
if [ -f "$USER_CONF_PATH" ]; then
|
||||
source "$USER_CONF_PATH" # should overwrite previous
|
||||
else
|
||||
echo "NOTICE: file <$USER_CONF_PATH> not found, we use default configuration only."
|
||||
fi
|
||||
if [ -f "$USER_CONF_PATH" ]; then
|
||||
source "$USER_CONF_PATH" # should overwrite previous
|
||||
else
|
||||
echo "NOTICE: file <$USER_CONF_PATH> not found, we use default configuration only."
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Load modules
|
||||
|
||||
@@ -25,4 +25,6 @@ export AC_PATH_MODULES="$AC_PATH_ROOT/modules"
|
||||
|
||||
export AC_PATH_DEPS="$AC_PATH_ROOT/deps"
|
||||
|
||||
export AC_BASH_LIB_PATH="$AC_PATH_DEPS/acore/bash-lib/src"
|
||||
|
||||
export AC_PATH_VAR="$AC_PATH_ROOT/var"
|
||||
|
||||
@@ -16,6 +16,8 @@ source "$AC_PATH_DEPS/acore/bash-lib/src/event/hooks.sh"
|
||||
# shellcheck source=./common.sh
|
||||
source "$AC_PATH_SHARED/common.sh"
|
||||
|
||||
acore_common_loadConfig
|
||||
|
||||
if [[ "$OSTYPE" = "msys" ]]; then
|
||||
AC_BINPATH_FULL="$BINPATH"
|
||||
else
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# shellcheck source=../../../deps/acore/bash-lib/src/common/boolean.sh
|
||||
source "$AC_BASH_LIB_PATH/common/boolean.sh"
|
||||
|
||||
# Set SUDO variable - one liner
|
||||
SUDO=""
|
||||
|
||||
@@ -135,7 +138,8 @@ function comp_compile() {
|
||||
echo "Done"
|
||||
;;
|
||||
linux*|darwin*)
|
||||
local confDir=${CONFDIR:-"$AC_BINPATH_FULL/../etc"}
|
||||
local confDir
|
||||
confDir=${CONFDIR:-"$AC_BINPATH_FULL/../etc"}
|
||||
|
||||
# create the folders before installing to
|
||||
# set the current user and permissions
|
||||
@@ -145,6 +149,8 @@ function comp_compile() {
|
||||
mkdir -p "$confDir"
|
||||
mkdir -p "$confDir/modules"
|
||||
|
||||
confDir=$(realpath "$confDir")
|
||||
|
||||
echo "Cmake install..."
|
||||
$SUDO cmake --install . --config $CTYPE
|
||||
|
||||
@@ -161,18 +167,25 @@ function comp_compile() {
|
||||
$SUDO setcap cap_sys_nice=eip "$AC_BINPATH_FULL/authserver"
|
||||
fi
|
||||
|
||||
[[ -f "$confDir/worldserver.conf.dist" ]] && \
|
||||
cp -v --no-clobber "$confDir/worldserver.conf.dist" "$confDir/worldserver.conf"
|
||||
[[ -f "$confDir/authserver.conf.dist" ]] && \
|
||||
cp -v --no-clobber "$confDir/authserver.conf.dist" "$confDir/authserver.conf"
|
||||
[[ -f "$confDir/dbimport.conf.dist" ]] && \
|
||||
cp -v --no-clobber "$confDir/dbimport.conf.dist" "$confDir/dbimport.conf"
|
||||
|
||||
for f in "$confDir/modules/"*.dist
|
||||
do
|
||||
[[ -e $f ]] || break # handle the case of no *.dist files
|
||||
cp -v --no-clobber "$f" "${f%.dist}";
|
||||
done
|
||||
if ( isTrue "$AC_ENABLE_CONF_COPY_ON_INSTALL" ) then
|
||||
echo "Copying default configuration files to $confDir ..."
|
||||
[[ -f "$confDir/worldserver.conf.dist" && ! -f "$confDir/worldserver.conf" ]] && \
|
||||
cp -v "$confDir/worldserver.conf.dist" "$confDir/worldserver.conf"
|
||||
[[ -f "$confDir/authserver.conf.dist" && ! -f "$confDir/authserver.conf" ]] && \
|
||||
cp -v "$confDir/authserver.conf.dist" "$confDir/authserver.conf"
|
||||
[[ -f "$confDir/dbimport.conf.dist" && ! -f "$confDir/dbimport.conf" ]] && \
|
||||
cp -v "$confDir/dbimport.conf.dist" "$confDir/dbimport.conf"
|
||||
|
||||
for f in "$confDir/modules/"*.dist
|
||||
do
|
||||
[[ -e $f ]] || break # handle the case of no *.dist files
|
||||
if [[ ! -f "${f%.dist}" ]]; then
|
||||
echo "Copying module config $(basename "${f%.dist}")"
|
||||
cp -v "$f" "${f%.dist}";
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Done"
|
||||
;;
|
||||
|
||||
9
apps/installer/includes/config/config-main.sh
Normal file
9
apps/installer/includes/config/config-main.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd )
|
||||
|
||||
# shellcheck source=./config.sh
|
||||
source "$CURRENT_PATH/config.sh"
|
||||
|
||||
acore_dash_config "$@"
|
||||
|
||||
60
apps/installer/includes/config/config.sh
Normal file
60
apps/installer/includes/config/config.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd )
|
||||
|
||||
# shellcheck source=../../../bash_shared/includes.sh
|
||||
source "$CURRENT_PATH/../../../bash_shared/includes.sh"
|
||||
# shellcheck source=../includes.sh
|
||||
source "$CURRENT_PATH/../includes.sh"
|
||||
# shellcheck source=../../../bash_shared/menu_system.sh
|
||||
source "$AC_PATH_APPS/bash_shared/menu_system.sh"
|
||||
|
||||
function acore_dash_configShowValue() {
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: show <VAR_NAME>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local varName="$1"
|
||||
local varValue="${!varName}"
|
||||
if [ -z "$varValue" ]; then
|
||||
echo "$varName is not set."
|
||||
else
|
||||
echo "$varName=$varValue"
|
||||
fi
|
||||
}
|
||||
|
||||
function acore_dash_configLoad() {
|
||||
acore_common_loadConfig
|
||||
echo "Configuration loaded into the current shell session."
|
||||
}
|
||||
|
||||
# Configuration management menu definition
|
||||
# Format: "key|short|description"
|
||||
config_menu_items=(
|
||||
"show|s|Show configuration variable value"
|
||||
"load|l|Load configurations variables within the current shell session"
|
||||
"help|h|Show detailed help"
|
||||
"quit|q|Close this menu"
|
||||
)
|
||||
|
||||
# Menu command handler for configuration operations
|
||||
function handle_config_command() {
|
||||
local key="$1"
|
||||
shift
|
||||
|
||||
case "$key" in
|
||||
"show")
|
||||
acore_dash_configShowValue "$@"
|
||||
;;
|
||||
"load")
|
||||
acore_dash_configLoad
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function acore_dash_config() {
|
||||
menu_run_with_items "CONFIG MANAGER" handle_config_command -- "${config_menu_items[@]}" -- "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -183,3 +183,5 @@ function inst_download_client_data {
|
||||
&& echo "Remove downloaded file" && rm "$zipPath" \
|
||||
&& echo "INSTALLED_VERSION=$VERSION" > "$dataVersionFile"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd )
|
||||
|
||||
# shellcheck source=../../bash_shared/includes.sh
|
||||
source "$CURRENT_PATH/../../bash_shared/includes.sh"
|
||||
|
||||
AC_PATH_INSTALLER="$AC_PATH_APPS/installer"
|
||||
@@ -9,14 +10,14 @@ AC_PATH_INSTALLER="$AC_PATH_APPS/installer"
|
||||
J_PATH="$AC_PATH_DEPS/acore/joiner"
|
||||
J_PATH_MODULES="$AC_PATH_MODULES"
|
||||
|
||||
# shellcheck source=../../../deps/acore/joiner/joiner.sh
|
||||
source "$J_PATH/joiner.sh"
|
||||
|
||||
if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then
|
||||
source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous
|
||||
fi
|
||||
|
||||
# shellcheck source=../../compiler/includes/includes.sh
|
||||
source "$AC_PATH_APPS/compiler/includes/includes.sh"
|
||||
|
||||
# shellcheck source=../../../deps/semver_bash/semver.sh
|
||||
source "$AC_PATH_DEPS/semver_bash/semver.sh"
|
||||
|
||||
# shellcheck source=../includes/functions.sh
|
||||
source "$AC_PATH_INSTALLER/includes/functions.sh"
|
||||
|
||||
@@ -59,7 +59,6 @@ else
|
||||
C_GREEN=''
|
||||
C_YELLOW=''
|
||||
C_BLUE=''
|
||||
C_MAGENTA=''
|
||||
C_CYAN=''
|
||||
fi
|
||||
|
||||
@@ -174,42 +173,8 @@ function inst_module_list() {
|
||||
# Usage: ./acore.sh module <search|install|update|remove> [args...]
|
||||
# ./acore.sh module # Interactive menu
|
||||
function inst_module() {
|
||||
# If no arguments provided, start interactive menu
|
||||
if [[ $# -eq 0 ]]; then
|
||||
menu_run_with_items "MODULE MANAGER" handle_module_command -- "${module_menu_items[@]}" --
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Normalize arguments into an array
|
||||
local tokens=()
|
||||
read -r -a tokens <<< "$*"
|
||||
local cmd="${tokens[0]}"
|
||||
local args=("${tokens[@]:1}")
|
||||
|
||||
case "$cmd" in
|
||||
""|"help"|"-h"|"--help")
|
||||
inst_module_help
|
||||
;;
|
||||
"search"|"s")
|
||||
inst_module_search "${args[@]}"
|
||||
;;
|
||||
"install"|"i")
|
||||
inst_module_install "${args[@]}"
|
||||
;;
|
||||
"update"|"u")
|
||||
inst_module_update "${args[@]}"
|
||||
;;
|
||||
"remove"|"r")
|
||||
inst_module_remove "${args[@]}"
|
||||
;;
|
||||
"list"|"l")
|
||||
inst_module_list "${args[@]}"
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown module command: $cmd. Use 'help' to see available commands."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
menu_run_with_items "MODULE MANAGER" handle_module_command -- "${module_menu_items[@]}" -- "$@"
|
||||
return $?
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -45,6 +45,7 @@ menu_items=(
|
||||
"docker|dr|Run docker tools"
|
||||
"version|v|Show AzerothCore version"
|
||||
"service-manager|sm|Run service manager to run authserver and worldserver in background"
|
||||
"config|cf|Configuration manager"
|
||||
"quit|q|Exit from this menu"
|
||||
)
|
||||
|
||||
@@ -100,6 +101,9 @@ function handle_menu_command() {
|
||||
bash "$AC_PATH_APPS/startup-scripts/src/service-manager.sh" "$@"
|
||||
exit
|
||||
;;
|
||||
"config")
|
||||
bash "$AC_PATH_APPS/installer/includes/config/config-main.sh" "$@"
|
||||
;;
|
||||
"quit")
|
||||
echo "Goodbye!"
|
||||
exit
|
||||
|
||||
@@ -751,5 +751,5 @@ EOF
|
||||
|
||||
run inst_module "unknown-command"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "Unknown module command" ]]
|
||||
[[ "$output" =~ "Invalid option" ]]
|
||||
}
|
||||
@@ -50,6 +50,8 @@ fi
|
||||
# Main restart loop
|
||||
while true; do
|
||||
STARTING_TIME=$(date +%s)
|
||||
|
||||
echo "AC_CONFIG_POLICY: $AC_CONFIG_POLICY"
|
||||
|
||||
# Use starter script to launch the binary with all parameters
|
||||
"$STARTER_SCRIPT" "$BINPATH" "$BINFILE" "$GDB_FILE" "$CONFIG" "$SYSLOG" "$SYSERR" "$GDB_ENABLED" "$CRASHES_PATH"
|
||||
|
||||
Reference in New Issue
Block a user