summaryrefslogtreecommitdiff
path: root/apps/installer/main.sh
blob: b0772f76cf0bcabd5cb93d052f4831539f149b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash

# AzerothCore Dashboard Script
#
# This script provides an interactive menu system for AzerothCore management
# using the unified menu system library.
#
# Usage:
#   ./acore.sh                    - Interactive mode with numeric and text selection
#   ./acore.sh <command> [args]   - Direct command execution (only text commands, no numbers)
#
# Interactive Mode:
#   - Select options by number (1, 2, 3...), command name (init, compiler, etc.),
#     or short alias (i, c, etc.)
#   - All selection methods work in interactive mode
#
# Direct Command Mode:
#   - Only command names and short aliases are accepted (e.g., './acore.sh compiler build', './acore.sh c build')
#   - Numeric selection is disabled to prevent confusion with command arguments
#   - Examples: './acore.sh init', './acore.sh compiler clean', './acore.sh module install mod-name'
#
# Menu System:
#   - Uses unified menu system from bash_shared/menu_system.sh
#   - Single source of truth for menu definitions
#   - Consistent behavior across all AzerothCore tools

CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
source "$AC_PATH_APPS/bash_shared/menu_system.sh"

# Menu: single ordered source of truth (no functions in strings)
# Format: "key|short|description"
menu_items=(
    "init|i|First Installation"
    "install-deps|d|Configure OS dep"
    "pull|u|Update Repository"
    "reset|r|Reset & Clean Repository"
    "setup-db|r|Install db only"
    "compiler|c|Run compiler tool"
    "module|m|Module manager (search/install/update/remove)"
    "client-data|gd|download client data from github repository (beta)"
    "run-worldserver|rw|execute a simple restarter for worldserver"
    "run-authserver|ra|execute a simple restarter for authserver"
    "docker|dr|Run docker tools"
    "version|v|Show AzerothCore version"
    "service-manager|sm|Run service manager to run authserver and worldserver in background"
    "quit|q|Exit from this menu"
)


# Menu command handler - called by menu system for each command
function handle_menu_command() {
    local key="$1"
    shift

    case "$key" in
        "init")
            inst_allInOne
            ;;
        "install-deps")
            inst_configureOS
            ;;
        "pull")
            inst_updateRepo
            ;;
        "reset")
            inst_resetRepo
            ;;
        "setup-db")
            inst_dbCreate
            ;;
        "compiler")
            bash "$AC_PATH_APPS/compiler/compiler.sh" "$@"
            ;;
        "module")
            bash "$AC_PATH_APPS/installer/includes/modules-manager/module-main.sh" "$@"
            ;;
        "client-data")
            inst_download_client_data
            ;;
        "run-worldserver")
            inst_simple_restarter worldserver
            ;;
        "run-authserver")
            inst_simple_restarter authserver
            ;;
        "docker")
            DOCKER=1 bash "$AC_PATH_ROOT/apps/docker/docker-cmd.sh" "$@"
            exit
            ;;
        "version")
            printf "AzerothCore Rev. %s\n" "$ACORE_VERSION"
            exit
            ;;
        "service-manager")
            bash "$AC_PATH_APPS/startup-scripts/src/service-manager.sh" "$@"
            exit
            ;;
        "quit")
            echo "Goodbye!"
            exit
            ;;
        *)
            echo "Invalid option. Use --help to see available commands."
            return 1
            ;;
    esac
}

# Run the menu system
menu_run_with_items "ACORE DASHBOARD" handle_menu_command -- "${menu_items[@]}" -- "$@"