latest sources commit
This commit is contained in:
253
apps/installer/includes/functions.sh
Normal file
253
apps/installer/includes/functions.sh
Normal file
@@ -0,0 +1,253 @@
|
||||
function inst_configureOS() {
|
||||
echo "Platform: $OSTYPE"
|
||||
case "$OSTYPE" in
|
||||
solaris*) echo "Solaris is not supported yet" ;;
|
||||
darwin*) source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;;
|
||||
linux*)
|
||||
# If $OSDISTRO is set, use this value (from config.sh)
|
||||
if [ ! -z "$OSDISTRO" ]; then
|
||||
DISTRO=$OSDISTRO
|
||||
# If available, use LSB to identify distribution
|
||||
elif command -v lsb_release >/dev/null 2>&1 ; then
|
||||
DISTRO=$(lsb_release -is)
|
||||
# Otherwise, use release info file
|
||||
else
|
||||
DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
|
||||
fi
|
||||
|
||||
case $DISTRO in
|
||||
# add here distro that are debian or ubuntu based
|
||||
# TODO: find a better way, maybe checking the existance
|
||||
# of a package manager
|
||||
"neon" | "ubuntu" | "Ubuntu")
|
||||
DISTRO="ubuntu"
|
||||
;;
|
||||
"debian" | "Debian")
|
||||
DISTRO="debian"
|
||||
;;
|
||||
*)
|
||||
echo "Distro: $DISTRO, is not supported. If your distribution is based on debian or ubuntu,
|
||||
please set the 'OSDISTRO' environment variable to one of these distro (you can use config.sh file)"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
DISTRO=${DISTRO,,}
|
||||
|
||||
echo "Distro: $DISTRO"
|
||||
|
||||
# TODO: implement different configurations by distro
|
||||
source "$AC_PATH_INSTALLER/includes/os_configs/$DISTRO.sh"
|
||||
;;
|
||||
bsd*) echo "BSD is not supported yet" ;;
|
||||
msys*) source "$AC_PATH_INSTALLER/includes/os_configs/windows.sh" ;;
|
||||
*) echo "This platform is not supported" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function inst_updateRepo() {
|
||||
cd "$AC_PATH_ROOT"
|
||||
if [ ! -z $INSTALLER_PULL_FROM ]; then
|
||||
git pull "$ORIGIN_REMOTE" "$INSTALLER_PULL_FROM"
|
||||
else
|
||||
git pull "$ORIGIN_REMOTE" $(git rev-parse --abbrev-ref HEAD)
|
||||
fi
|
||||
}
|
||||
|
||||
function inst_resetRepo() {
|
||||
cd "$AC_PATH_ROOT"
|
||||
git reset --hard $(git rev-parse --abbrev-ref HEAD)
|
||||
git clean -f
|
||||
}
|
||||
|
||||
function inst_compile() {
|
||||
comp_configure
|
||||
comp_build
|
||||
}
|
||||
|
||||
function inst_cleanCompile() {
|
||||
comp_clean
|
||||
inst_compile
|
||||
}
|
||||
|
||||
function inst_allInOne() {
|
||||
inst_configureOS
|
||||
inst_compile
|
||||
dbasm_import true true true
|
||||
}
|
||||
|
||||
function inst_getVersionBranch() {
|
||||
local res="master"
|
||||
local v="not-defined"
|
||||
local MODULE_MAJOR=0
|
||||
local MODULE_MINOR=0
|
||||
local MODULE_PATCH=0
|
||||
local MODULE_SPECIAL=0;
|
||||
local ACV_MAJOR=0
|
||||
local ACV_MINOR=0
|
||||
local ACV_PATCH=0
|
||||
local ACV_SPECIAL=0;
|
||||
local curldata=$(curl -f --silent -H 'Cache-Control: no-cache' "$1" || echo "{}")
|
||||
local parsed=$(echo "$curldata" | "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.compatibility.*.[version,branch]')
|
||||
|
||||
semverParseInto "$ACORE_VERSION" ACV_MAJOR ACV_MINOR ACV_PATCH ACV_SPECIAL
|
||||
|
||||
if [[ ! -z "$parsed" ]]; then
|
||||
readarray -t vers < <(echo "$parsed")
|
||||
local idx
|
||||
res="none"
|
||||
# since we've the pair version,branch alternated in not associative and one-dimensional
|
||||
# array, we've to simulate the association with length/2 trick
|
||||
for idx in `seq 0 $((${#vers[*]}/2-1))`; do
|
||||
semverParseInto "${vers[idx*2]}" MODULE_MAJOR MODULE_MINOR MODULE_PATCH MODULE_SPECIAL
|
||||
if [[ $MODULE_MAJOR -eq $ACV_MAJOR && $MODULE_MINOR -le $ACV_MINOR ]]; then
|
||||
res="${vers[idx*2+1]}"
|
||||
v="${vers[idx*2]}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$v" "$res"
|
||||
}
|
||||
|
||||
function inst_module_search {
|
||||
|
||||
local res="$1"
|
||||
local idx=0;
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Type what to search or leave blank for full list"
|
||||
read -p "Insert name: " res
|
||||
fi
|
||||
|
||||
local search="+$res"
|
||||
|
||||
echo "Searching $res..."
|
||||
echo "";
|
||||
|
||||
readarray -t MODS < <(curl --silent "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" \
|
||||
| "$AC_PATH_DEPS/jsonpath/JSONPath.sh" -b '$.items.*.name')
|
||||
while (( ${#MODS[@]} > idx )); do
|
||||
mod="${MODS[idx++]}"
|
||||
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$mod/master/acore-module.json")
|
||||
|
||||
if [[ "$b" != "none" ]]; then
|
||||
echo "-> $mod (tested with AC version: $v)"
|
||||
else
|
||||
echo "-> $mod (no revision available for AC v$AC_VERSION, it could not work!)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "";
|
||||
echo "";
|
||||
}
|
||||
|
||||
function inst_module_install {
|
||||
local res
|
||||
if [ -z "$1" ]; then
|
||||
echo "Type the name of the module to install"
|
||||
read -p "Insert name: " res
|
||||
else
|
||||
res="$1"
|
||||
fi
|
||||
|
||||
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json")
|
||||
|
||||
if [[ "$b" != "none" ]]; then
|
||||
Joiner:add_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"
|
||||
else
|
||||
echo "Cannot install $res module: it doesn't exists or no version compatible with AC v$ACORE_VERSION are available"
|
||||
fi
|
||||
|
||||
echo "";
|
||||
echo "";
|
||||
}
|
||||
|
||||
function inst_module_update {
|
||||
local res;
|
||||
local _tmp;
|
||||
local branch;
|
||||
local p;
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Type the name of the module to update"
|
||||
read -p "Insert name: " res
|
||||
else
|
||||
res="$1"
|
||||
fi
|
||||
|
||||
_tmp=$PWD
|
||||
|
||||
if [ -d "$J_PATH_MODULES/$res/" ]; then
|
||||
read v b < <(inst_getVersionBranch "https://raw.githubusercontent.com/azerothcore/$res/master/acore-module.json")
|
||||
|
||||
cd "$J_PATH_MODULES/$res/"
|
||||
|
||||
# use current branch if something wrong with json
|
||||
if [[ "$v" == "none" || "$v" == "not-defined" ]]; then
|
||||
b=`git rev-parse --abbrev-ref HEAD`
|
||||
fi
|
||||
|
||||
Joiner:upd_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly" || echo "Cannot update"
|
||||
cd $_tmp
|
||||
else
|
||||
echo "Cannot update! Path doesn't exist"
|
||||
fi;
|
||||
|
||||
echo "";
|
||||
echo "";
|
||||
}
|
||||
|
||||
function inst_module_remove {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Type the name of the module to remove"
|
||||
read -p "Insert name: " res
|
||||
else
|
||||
res="$1"
|
||||
fi
|
||||
|
||||
Joiner:remove "$res" && echo "Done, please re-run compiling" || echo "Cannot remove"
|
||||
|
||||
echo "";
|
||||
echo "";
|
||||
}
|
||||
|
||||
|
||||
function inst_simple_restarter {
|
||||
echo "Running $1 ..."
|
||||
bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1"
|
||||
echo
|
||||
#disown -a
|
||||
#jobs -l
|
||||
}
|
||||
|
||||
function inst_download_client_data {
|
||||
# change the following version when needed
|
||||
local VERSION=v16
|
||||
|
||||
echo "#######################"
|
||||
echo "Client data downloader"
|
||||
echo "#######################"
|
||||
|
||||
# first check if it's defined in env, otherwise use the default
|
||||
local path="${DATAPATH:-$AC_BINPATH_FULL}"
|
||||
local zipPath="${DATAPATH_ZIP:-"$path/data.zip"}"
|
||||
|
||||
dataVersionFile="$path/data-version"
|
||||
|
||||
[ -f "$dataVersionFile" ] && source "$dataVersionFile"
|
||||
|
||||
# create the path if doesn't exists
|
||||
mkdir -p "$path"
|
||||
|
||||
if [ "$VERSION" == "$INSTALLED_VERSION" ]; then
|
||||
echo "Data $VERSION already installed. If you want to force the download remove the following file: $dataVersionFile"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Downloading client data in: $zipPath ..."
|
||||
curl -L https://github.com/wowgaming/client-data/releases/download/$VERSION/data.zip > "$zipPath" \
|
||||
&& echo "unzip downloaded file in $path..." && unzip -q -o "$zipPath" -d "$path/" \
|
||||
&& echo "Remove downloaded file" && rm "$zipPath" \
|
||||
&& echo "INSTALLED_VERSION=$VERSION" > "$dataVersionFile"
|
||||
}
|
||||
22
apps/installer/includes/includes.sh
Normal file
22
apps/installer/includes/includes.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
[[ ${INSTALLER_GUARDYVAR:-} -eq 1 ]] && return || readonly INSTALLER_GUARDYVAR=1 # include it once
|
||||
|
||||
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd )
|
||||
|
||||
source "$CURRENT_PATH/../../bash_shared/includes.sh"
|
||||
|
||||
AC_PATH_INSTALLER="$AC_PATH_APPS/installer"
|
||||
|
||||
J_PATH="$AC_PATH_DEPS/acore/joiner"
|
||||
J_PATH_MODULES="$AC_PATH_MODULES"
|
||||
|
||||
source "$J_PATH/joiner.sh"
|
||||
|
||||
if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then
|
||||
source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous
|
||||
fi
|
||||
|
||||
source "$AC_PATH_APPS/compiler/includes/includes.sh"
|
||||
|
||||
source "$AC_PATH_DEPS/semver_bash/semver.sh"
|
||||
|
||||
source "$AC_PATH_INSTALLER/includes/functions.sh"
|
||||
18
apps/installer/includes/os_configs/debian.sh
Normal file
18
apps/installer/includes/os_configs/debian.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
if ! command -v lsb_release &>/dev/null ; then
|
||||
sudo apt-get install -y lsb-release
|
||||
fi
|
||||
|
||||
DEBIAN_VERSION=$(lsb_release -sr)
|
||||
|
||||
sudo apt-get update -y
|
||||
|
||||
sudo apt-get install -y gdbserver gdb unzip curl \
|
||||
libncurses-dev libreadline-dev clang g++ \
|
||||
gcc git cmake make ccache
|
||||
|
||||
if [[ $DEBIAN_VERSION -eq "10" ]]; then
|
||||
sudo apt-get install -y default-libmysqlclient-dev libssl-dev libreadline-dev libncurses-dev mariadb-server
|
||||
libboost-system1.6*-dev libboost-filesystem1.6*-dev libboost-program-options1.6*-dev libboost-iostreams1.6*-dev \
|
||||
else # Debian 8 and 9 should work using this
|
||||
sudo apt-get install -y libmysqlclient-dev libssl1.0-dev mysql-server
|
||||
fi
|
||||
29
apps/installer/includes/os_configs/osx.sh
Normal file
29
apps/installer/includes/os_configs/osx.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
##########################################
|
||||
## workaround for python upgrade issue https://github.com/actions/runner-images/issues/6817
|
||||
rm /usr/local/bin/2to3 || true
|
||||
rm /usr/local/bin/2to3-3.10 || true
|
||||
rm /usr/local/bin/2to3-3.11 || true
|
||||
rm /usr/local/bin/idle3 || true
|
||||
rm /usr/local/bin/idle3.10 || true
|
||||
rm /usr/local/bin/idle3.11 || true
|
||||
rm /usr/local/bin/pydoc3 || true
|
||||
rm /usr/local/bin/pydoc3.10 || true
|
||||
rm /usr/local/bin/pydoc3.11 || true
|
||||
rm /usr/local/bin/python3 || true
|
||||
rm /usr/local/bin/python3.10 || true
|
||||
rm /usr/local/bin/python3.11 || true
|
||||
rm /usr/local/bin/python3-config || true
|
||||
rm /usr/local/bin/python3.10-config || true
|
||||
rm /usr/local/bin/python3.11-config || true
|
||||
##########################################
|
||||
|
||||
brew update
|
||||
|
||||
##########################################
|
||||
## workaround for cmake already being installed in the github runners
|
||||
if ! command -v cmake &>/dev/null ; then
|
||||
brew install cmake
|
||||
fi
|
||||
##########################################
|
||||
|
||||
brew install openssl@3 readline boost@1.82 bash-completion curl unzip mysql@8.1 ccache
|
||||
29
apps/installer/includes/os_configs/ubuntu.sh
Normal file
29
apps/installer/includes/os_configs/ubuntu.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
if ! command -v lsb_release &>/dev/null ; then
|
||||
sudo apt-get install -y lsb-release
|
||||
fi
|
||||
|
||||
UBUNTU_VERSION=$(lsb_release -sr);
|
||||
|
||||
sudo apt update
|
||||
|
||||
# shared deps
|
||||
sudo apt-get -y install ccache clang cmake curl google-perftools libmysqlclient-dev make unzip
|
||||
|
||||
if [[ $CONTINUOUS_INTEGRATION || $DOCKER ]]; then
|
||||
sudo add-apt-repository -y ppa:mhier/libboost-latest && sudo apt update && sudo apt-get -y install build-essential cmake-data \
|
||||
libboost1.74-dev libbz2-dev libncurses5-dev libmysql++-dev libgoogle-perftools-dev libreadline6-dev libssl-dev libtool \
|
||||
openssl zlib1g-dev
|
||||
else
|
||||
case $UBUNTU_VERSION in
|
||||
"20.04")
|
||||
sudo apt-get install -y g++ gdb gdbserver gcc git \
|
||||
libboost-all-dev libbz2-dev libncurses-dev libreadline-dev \
|
||||
libssl-dev mysql-server
|
||||
;;
|
||||
*)
|
||||
sudo add-apt-repository -y ppa:mhier/libboost-latest && sudo apt update && sudo apt-get install -y g++ gdb gdbserver gcc git \
|
||||
libboost-all-dev libbz2-dev libncurses-dev libreadline-dev \
|
||||
libssl-dev mysql-server
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
30
apps/installer/includes/os_configs/windows.sh
Normal file
30
apps/installer/includes/os_configs/windows.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
# install chocolatey before
|
||||
|
||||
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
|
||||
|
||||
# install automatically following packages:
|
||||
# cmake
|
||||
# git
|
||||
# microsoft-build-tools
|
||||
# mysql
|
||||
|
||||
INSTALL_ARGS=""
|
||||
|
||||
if [[ $CONTINUOUS_INTEGRATION ]]; then
|
||||
INSTALL_ARGS=" --no-progress "
|
||||
else
|
||||
{ # try
|
||||
choco uninstall -y -n cmake.install cmake # needed to make sure that following install set the env properly
|
||||
} || { # catch
|
||||
echo "nothing to do"
|
||||
}
|
||||
|
||||
choco install -y --skip-checksums $INSTALL_ARGS git visualstudio2022community
|
||||
fi
|
||||
|
||||
choco install -y --skip-checksums $INSTALL_ARGS cmake.install -y --installargs 'ADD_CMAKE_TO_PATH=System'
|
||||
choco install -y --skip-checksums $INSTALL_ARGS visualstudio2022-workload-nativedesktop
|
||||
choco install -y --skip-checksums $INSTALL_ARGS openssl --version=3.1.1
|
||||
choco install -y --skip-checksums $INSTALL_ARGS boost-msvc-14.3 --version=1.82.0
|
||||
choco install -y --skip-checksums $INSTALL_ARGS mysql --version=8.0.31
|
||||
|
||||
99
apps/installer/main.sh
Normal file
99
apps/installer/main.sh
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_PATH/includes/includes.sh"
|
||||
|
||||
PS3='[Please enter your choice]: '
|
||||
options=(
|
||||
"init (i): First Installation" # 1
|
||||
"install-deps (d): Configure OS dep" # 2
|
||||
"pull (u): Update Repository" # 3
|
||||
"reset (r): Reset & Clean Repository" # 4
|
||||
"compiler (c): Run compiler tool" # 5
|
||||
"module-search (ms): Module Search by keyword" # 6
|
||||
"module-install (mi): Module Install by name" # 7
|
||||
"module-update (mu): Module Update by name" # 8
|
||||
"module-remove: (mr): Module Remove by name" # 9
|
||||
"client-data: (gd): download client data from github repository (beta)" # 10
|
||||
"run-worldserver (rw): execute a simple restarter for worldserver" # 11
|
||||
"run-authserver (ra): execute a simple restarter for authserver" # 12
|
||||
"docker (dr): Run docker tools" # 13
|
||||
"quit: Exit from this menu" # 14
|
||||
)
|
||||
|
||||
function _switch() {
|
||||
_reply="$1"
|
||||
_opt="$2"
|
||||
|
||||
case $_reply in
|
||||
""|"i"|"init"|"1")
|
||||
inst_allInOne
|
||||
;;
|
||||
""|"d"|"install-deps"|"2")
|
||||
inst_configureOS
|
||||
;;
|
||||
""|"u"|"pull"|"3")
|
||||
inst_updateRepo
|
||||
;;
|
||||
""|"r"|"reset"|"4")
|
||||
inst_resetRepo
|
||||
;;
|
||||
""|"c"|"compiler"|"5")
|
||||
bash "$AC_PATH_APPS/compiler/compiler.sh" $_opt
|
||||
;;
|
||||
""|"ms"|"module-search"|"6")
|
||||
inst_module_search "$_opt"
|
||||
;;
|
||||
""|"mi"|"module-install"|"7")
|
||||
inst_module_install "$_opt"
|
||||
;;
|
||||
""|"mu"|"module-update"|"8")
|
||||
inst_module_update "$_opt"
|
||||
;;
|
||||
""|"mr"|"module-remove"|"9")
|
||||
inst_module_remove "$_opt"
|
||||
;;
|
||||
""|"gd"|"client-data"|"10")
|
||||
inst_download_client_data
|
||||
;;
|
||||
""|"rw"|"run-worldserver"|"11")
|
||||
inst_simple_restarter worldserver
|
||||
;;
|
||||
""|"ra"|"run-authserver"|"12")
|
||||
inst_simple_restarter authserver
|
||||
;;
|
||||
""|"dr"|"docker"|"13")
|
||||
DOCKER=1 bash "$AC_PATH_ROOT/apps/docker/docker-cmd.sh" "${@:2}"
|
||||
exit
|
||||
;;
|
||||
""|"v"|"version"|"14")
|
||||
# denoRunFile "$AC_PATH_APPS/installer/main.ts" "version"
|
||||
printf "AzerothCore Rev. %s\n" "$ACORE_VERSION"
|
||||
exit
|
||||
;;
|
||||
""|"quit"|"15")
|
||||
echo "Goodbye!"
|
||||
exit
|
||||
;;
|
||||
""|"--help")
|
||||
echo "Available commands:"
|
||||
printf '%s\n' "${options[@]}"
|
||||
;;
|
||||
*) echo "invalid option, use --help option for the commands list";;
|
||||
esac
|
||||
}
|
||||
|
||||
while true
|
||||
do
|
||||
# run option directly if specified in argument
|
||||
[ ! -z $1 ] && _switch $@ # old method: "${options[$cmdopt-1]}"
|
||||
[ ! -z $1 ] && exit 0
|
||||
|
||||
echo "==== ACORE DASHBOARD ===="
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
_switch $REPLY
|
||||
break
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user