summaryrefslogtreecommitdiff
path: root/apps/installer
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2018-07-15 22:40:49 +0200
committerYehonal <yehonal.azeroth@gmail.com>2018-07-15 22:51:17 +0200
commit85388901cf6a69659569ad751767fd7108b25a3c (patch)
treea004b01dfd378841c2ee473023313ade212118d7 /apps/installer
parent07a451e1402cf8a7c24cf6196d541d304f5dcff2 (diff)
Rewrite of bash system
+ Implemented new dashboard menu + some fixes for db_assembler + new module installation process with version check via json files + some fixes to modules installer + implemented simple crossplatform worldserver and authserver restarters + new compiler script + client data downloader (beta) + various other fixes
Diffstat (limited to 'apps/installer')
-rw-r--r--apps/installer/includes/functions.sh116
-rw-r--r--apps/installer/includes/includes.sh26
-rw-r--r--apps/installer/main.sh101
3 files changed, 182 insertions, 61 deletions
diff --git a/apps/installer/includes/functions.sh b/apps/installer/includes/functions.sh
index 3aa0b6baf2..987fe5e3c8 100644
--- a/apps/installer/includes/functions.sh
+++ b/apps/installer/includes/functions.sh
@@ -44,10 +44,6 @@ function inst_cleanCompile() {
inst_compile
}
-function inst_assembleDb {
- dbasm_import true true true
-}
-
function inst_allInOne() {
inst_configureOS
inst_updateRepo
@@ -55,19 +51,66 @@ function inst_allInOne() {
inst_assembleDb
}
+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 {
- 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
-
- search="+$res"
fi
- echo "Searching ..."
+
+ local search="+$res"
+
+ echo "Searching $res..."
echo "";
- for i in `curl -s "https://api.github.com/search/repositories?q=org%3Aazerothcore${search}+fork%3Atrue+topic%3Acore-module+sort%3Astars&type=" | grep \"name\" | cut -d ':' -f 2-3|tr -d '",'`; do
- echo "-> $i";
+ 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 v$v)"
+ else
+ echo "-> $mod (no revision available for AC v$AC_VERSION, it could not work!)"
+ fi
done
echo "";
@@ -75,30 +118,50 @@ function inst_module_search {
}
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
- git clone "https://github.com/azerothcore/$res" "$AC_PATH_ROOT/modules/$res" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"
+ 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
- cd "$AC_PATH_ROOT/modules/$res"
+ _tmp=$PWD
- #git reset --hard master
- #git clean -f
- git pull origin master && echo "Done"
+ if [ -d "$J_PATH_MODULES/$res/" ]; then
+ cd "$J_PATH_MODULES/$res/"
+ branch=`git rev-parse --abbrev-ref HEAD`
- cd "../../"
+ Joiner:upd_repo "https://github.com/azerothcore/$res" "$res" "$branch" && 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 "";
@@ -108,10 +171,29 @@ 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
- rm -rf "$AC_PATH_ROOT/modules/$res" && echo "Done"
+ Joiner:remove "$res" && echo "Done, please re-run compiling" || echo "Cannot remove"
echo "";
echo "";
+}
+
+
+function inst_simple_restarter {
+ echo "Running $1 in background..."
+ bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$BINPATH" "$1" &
+}
+
+function inst_download_client_data {
+ path="$BINPATH/data"
+ if [ -e "$path/.git/" ]; then
+ # if exists , update
+ git --git-dir="$path/.git/" rev-parse && git --git-dir="$path/.git/" pull origin master | grep 'Already up-to-date.' && changed="no"
+ else
+ # otherwise clone
+ git clone "https://github.com/wowgaming/client-data" -c advice.detachedHead=0 -b master --depth=1 $path
+ fi
} \ No newline at end of file
diff --git a/apps/installer/includes/includes.sh b/apps/installer/includes/includes.sh
index 16ba795792..a0dad11cb5 100644
--- a/apps/installer/includes/includes.sh
+++ b/apps/installer/includes/includes.sh
@@ -1,9 +1,31 @@
-CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+[[ ${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_VER_REQ="v0.8.3"
+J_PATH="$AC_PATH_APPS/drassil/joiner"
+J_PATH_MODULES="$AC_PATH_MODULES"
+
+#install/update and include joiner
+if [ ! -d "$J_PATH/.git" ]; then
+ git clone https://github.com/drassil/joiner "$J_PATH" -b master
+ git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
+else
+ # legacy code, with new rev of joiner the update process is internally handled
+ _cur_branch=`git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" rev-parse --abbrev-ref HEAD`
+ _cur_ver=`git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" name-rev --tags --name-only $_cur_branch`
+ if [ "$_cur_ver" != "$J_VER_REQ" ]; then
+ git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" rev-parse && git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" fetch --tags origin master --quiet
+ git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
+ fi
+fi
+source "$AC_PATH_APPS/drassil/joiner/joiner.sh"
+
if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then
source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous
fi
@@ -11,4 +33,6 @@ fi
source "$AC_PATH_APPS/compiler/includes/includes.sh"
source "$AC_PATH_APPS/db_assembler/includes/includes.sh"
+source "$AC_PATH_DEPS/semver_bash/semver.sh"
+
source "$AC_PATH_INSTALLER/includes/functions.sh"
diff --git a/apps/installer/main.sh b/apps/installer/main.sh
index 44fc65efb0..e9ee7a3918 100644
--- a/apps/installer/main.sh
+++ b/apps/installer/main.sh
@@ -4,75 +4,90 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
-cmdopt=$1
-
-while true
-do
-echo "===== INSTALLER SCRIPT ====="
-PS3='Please enter your choice: '
+PS3='[Please enter your choice]: '
options=(
- "First Installation" "Configure OS dep" "Update Repository" "Reset & Clean Repository"
- "Compile" "Clean & Compile" "Assemble & Import DB" "Module Search" "Module Install" "Module Update" "Module Remove"
- "Sub Menu >> Compiler" "Sub Menu >> DB Assembler"
- "Quit"
+ "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
+ "db-assembler (a): Run db assembler tool" # 6
+ "module-search (ms): Module Search by keyword" # 7
+ "module-install (mi): Module Install by name" # 8
+ "module-update (mu): Module Update by name" # 9
+ "module-remove: (mr): Module Remove by name" # 10
+ "client-data: (gd): download client data from github repository (beta)" # 11
+ "run-worldserver (rw): execute a simple restarter for worldserver" # 12
+ "run-authserver (ra): execute a simple restarter for authserver" # 13
+ "quit: Exit from this menu" # 14
)
function _switch() {
- case $1 in
- "First Installation")
+ _reply="$1"
+ _opt="$2"
+
+ case $_reply in
+ ""|"i"|"init"|"1")
inst_allInOne
;;
- "Configure OS dep")
+ ""|"d"|"install-deps"|"2")
inst_configureOS
;;
- "Update Repository")
+ ""|"u"|"pull"|"3")
inst_updateRepo
;;
- "Reset & Clean Repository")
+ ""|"r"|"reset"|"4")
inst_resetRepo
;;
- "Compile")
- inst_compile
+ ""|"c"|"compiler"|"5")
+ bash "$AC_PATH_APPS/compiler/compiler.sh" $_opt
;;
- "Clean & Compile")
- inst_cleanCompile
+ ""|"a"|"db-assembler"|"6")
+ bash "$AC_PATH_APPS/db_assembler/db_assembler.sh" $_opt
;;
- "Assemble & Import DB")
- inst_assembleDb
+ ""|"ms"|"module-search"|"7")
+ inst_module_search "$_opt"
;;
- "Module Search")
- inst_module_search $2
+ ""|"mi"|"module-install"|"8")
+ inst_module_install "$_opt"
;;
- "Module Install")
- inst_module_install $2
+ ""|"mu"|"module-update"|"9")
+ inst_module_update "$_opt"
;;
- "Module Update")
- inst_module_update $2
+ ""|"mr"|"module-remove"|"10")
+ inst_module_remove "$_opt"
;;
- "Module Remove")
- inst_module_remove $2
+ ""|"gd"|"client-data"|"11")
+ inst_download_client_data
;;
- "Sub Menu >> Compiler")
- bash "$AC_PATH_APPS/compiler/compiler.sh"
+ ""|"rw"|"run-worldserver"|"12")
+ inst_simple_restarter worldserver
;;
- "Sub Menu >> DB Assembler")
- bash "$AC_PATH_APPS/db_assembler/db_assembler.sh"
+ ""|"ra"|"run-authserver"|"13")
+ inst_simple_restarter authserver
;;
- "Quit")
+ ""|"quit"|"14")
echo "Goodbye!"
exit
;;
- *) echo invalid option;;
+ ""|"--help")
+ echo "Available commands:"
+ printf '%s\n' "${options[@]}"
+ ;;
+ *) echo "invalid option, use --help option for the commands list";;
esac
}
-# run option directly if specified in argument
-[ ! -z $1 ] && _switch "${options[$cmdopt-1]}"
-[ ! -z $1 ] && exit 0
-
-select opt in "${options[@]}"
+while true
do
- _switch "$opt"
- break
-done
+ # run option directly if specified in argument
+ [ ! -z $1 ] && _switch $@ # old method: "${options[$cmdopt-1]}"
+ [ ! -z $1 ] && exit 0
+
+ select opt in "${options[@]}"
+ do
+ echo "==== ACORE DASHBOARD ===="
+ _switch $REPLY
+ break
+ done
done