mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-07 21:01:37 +00:00
feat(Config): Implement configuration severity policy and logging mechanism (#23284)
This commit is contained in:
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" ]]
|
||||
}
|
||||
Reference in New Issue
Block a user