summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2017-09-21 18:52:20 +0200
committerYehonal <yehonal.azeroth@gmail.com>2017-09-21 18:52:20 +0200
commit22c6ba9fa61221381d499ce5f2c8b520d2f6fcaf (patch)
tree6e0369b49da2a5efff9e7bba627b350bb5242d28 /bin
parentce6b9de51a7fcf5f0bb4423be4fd273446546792 (diff)
Bash: implemented installer script for server and modules (beta)
+ minor fixes
Diffstat (limited to 'bin')
-rw-r--r--bin/bash_shared/includes.sh4
-rw-r--r--bin/compiler/README.md8
-rwxr-xr-xbin/compiler/compiler.sh8
-rw-r--r--bin/compiler/includes/functions.sh6
-rw-r--r--bin/db_assembler/includes/functions.sh2
-rw-r--r--bin/installer/includes/functions.sh105
-rw-r--r--bin/installer/includes/includes.sh14
-rw-r--r--bin/installer/includes/os_configs/linux.sh4
-rw-r--r--bin/installer/includes/os_configs/osx.sh6
-rw-r--r--bin/installer/includes/os_configs/windows.sh17
-rw-r--r--bin/installer/main.sh77
11 files changed, 243 insertions, 8 deletions
diff --git a/bin/bash_shared/includes.sh b/bin/bash_shared/includes.sh
index c8a419073a..8dd3c9821c 100644
--- a/bin/bash_shared/includes.sh
+++ b/bin/bash_shared/includes.sh
@@ -1,3 +1,5 @@
+[[ ${GUARDYVAR:-} -eq 1 ]] && return || readonly GUARDYVAR=1 # include it once
+
# force default language for applications
LC_ALL=C
@@ -17,6 +19,8 @@ source "$AC_PATH_CONF/config.sh.dist" # "hack" to avoid missing conf variables
if [ -f "$AC_PATH_CONF/config.sh" ]; then
source "$AC_PATH_CONF/config.sh" # should overwrite previous
+else
+ echo "NOTICE: file <$AC_PATH_CONF/config.sh> has not been found, you should create and configure it."
fi
#
diff --git a/bin/compiler/README.md b/bin/compiler/README.md
index c50dae2ec2..a4759ee232 100644
--- a/bin/compiler/README.md
+++ b/bin/compiler/README.md
@@ -19,6 +19,14 @@ first of all, if you need some custom configuration you have to copy and rename
./3-build.sh
+## compiler.sh
+
+compiler.sh script contains an interactive menu to clean/compile/build. You can also run actions directly by command lines specifying the option.
+Ex:
+ ./compiler.sh 3
+
+It will start the build process (it's equivalent to ./3-build.sh)
+
## Note:
For an optimal development process and **really faster** compilation time, is suggested to use clang instead of gcc
diff --git a/bin/compiler/compiler.sh b/bin/compiler/compiler.sh
index f813be803b..cb89bfb705 100755
--- a/bin/compiler/compiler.sh
+++ b/bin/compiler/compiler.sh
@@ -5,9 +5,9 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
function all() {
- clean
- configure
- build
+ comp_clean
+ comp_configure
+ comp_build
}
function run_option() {
@@ -19,7 +19,7 @@ function run_option() {
}
comp_options=("Clean" "Configure" "Build" "All")
-comp_functions=("clean" "configure" "build" "all")
+comp_functions=("comp_clean" "comp_configure" "comp_build" "all")
runHooks "ON_AFTER_OPTIONS" #you can create your custom options
diff --git a/bin/compiler/includes/functions.sh b/bin/compiler/includes/functions.sh
index 5113391dff..4dfaa46038 100644
--- a/bin/compiler/includes/functions.sh
+++ b/bin/compiler/includes/functions.sh
@@ -1,5 +1,5 @@
-function clean() {
+function comp_clean() {
echo "Cleaning build files"
CWD=$(pwd)
@@ -13,7 +13,7 @@ function clean() {
cd $CWD
}
-function configure() {
+function comp_configure() {
CWD=$(pwd)
cd $BUILDPATH
@@ -39,7 +39,7 @@ function configure() {
}
-function build() {
+function comp_build() {
[ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2))
echo "Using $MTHREADS threads"
diff --git a/bin/db_assembler/includes/functions.sh b/bin/db_assembler/includes/functions.sh
index 8b4119d014..da0415948a 100644
--- a/bin/db_assembler/includes/functions.sh
+++ b/bin/db_assembler/includes/functions.sh
@@ -220,7 +220,7 @@ function dbasm_db_import() {
}
function dbasm_import() {
- dbasm_run $1 $2 $2
+ dbasm_run $1 $2 $3
with_base=$1
with_updates=$2
diff --git a/bin/installer/includes/functions.sh b/bin/installer/includes/functions.sh
new file mode 100644
index 0000000000..2b8e9e976f
--- /dev/null
+++ b/bin/installer/includes/functions.sh
@@ -0,0 +1,105 @@
+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*)
+ # TODO: implement different configurations by distro
+ source "$AC_PATH_INSTALLER/includes/os_configs/linux.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() {
+ git pull origin $(git rev-parse --abbrev-ref HEAD)
+}
+
+function inst_resetRepo() {
+ 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_assembleDb {
+ dbasm_import true true true
+}
+
+function inst_allInOne() {
+ inst_configureOS
+ inst_updateRepo
+ inst_compile
+ inst_assembleDb
+}
+
+function inst_module_search {
+ search=""
+ 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 ..."
+ 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";
+ done
+
+ echo "";
+ echo "";
+}
+
+function inst_module_install {
+ if [ -z "$1" ]; then
+ echo "Type the name of the module to install"
+ read -p "Insert name: " res
+ fi
+
+ git clone "https://github.com/azerothcore/$res" "modules/$res" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"
+
+ echo "";
+ echo "";
+}
+
+function inst_module_update {
+ if [ -z "$1" ]; then
+ echo "Type the name of the module to update"
+ read -p "Insert name: " res
+ fi
+
+ cd "modules/$res"
+
+ #git reset --hard master
+ #git clean -f
+ git pull origin master && echo "Done"
+
+ cd "../../"
+
+ echo "";
+ echo "";
+}
+
+function inst_module_remove {
+ if [ -z "$1" ]; then
+ echo "Type the name of the module to remove"
+ read -p "Insert name: " res
+ fi
+
+ rm -rf "modules/$res" && echo "Done"
+
+ echo "";
+ echo "";
+} \ No newline at end of file
diff --git a/bin/installer/includes/includes.sh b/bin/installer/includes/includes.sh
new file mode 100644
index 0000000000..fdede154f1
--- /dev/null
+++ b/bin/installer/includes/includes.sh
@@ -0,0 +1,14 @@
+CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source "$CURRENT_PATH/../../bash_shared/includes.sh"
+
+AC_PATH_INSTALLER="$AC_PATH_BIN/installer"
+
+if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then
+ source "$AC_PATH_INSTALLER/config.sh" # should overwrite previous
+fi
+
+source "$AC_PATH_BIN/compiler/includes/includes.sh"
+source "$AC_PATH_BIN/db_assembler/includes/includes.sh"
+
+source "$AC_PATH_INSTALLER/includes/functions.sh"
diff --git a/bin/installer/includes/os_configs/linux.sh b/bin/installer/includes/os_configs/linux.sh
new file mode 100644
index 0000000000..020e194776
--- /dev/null
+++ b/bin/installer/includes/os_configs/linux.sh
@@ -0,0 +1,4 @@
+
+
+sudo apt-get install git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server
+sudo apt-get install libace-6.* libace-dev \ No newline at end of file
diff --git a/bin/installer/includes/os_configs/osx.sh b/bin/installer/includes/os_configs/osx.sh
new file mode 100644
index 0000000000..5ea43f641d
--- /dev/null
+++ b/bin/installer/includes/os_configs/osx.sh
@@ -0,0 +1,6 @@
+ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
+brew update
+
+brew install openssl readline cmake ace coreutils bash bash-completion md5sha1sum
+
diff --git a/bin/installer/includes/os_configs/windows.sh b/bin/installer/includes/os_configs/windows.sh
new file mode 100644
index 0000000000..9a5e13f6da
--- /dev/null
+++ b/bin/installer/includes/os_configs/windows.sh
@@ -0,0 +1,17 @@
+echo "WARNING: Installer Script for Windows is not fully supported yet. Work in progress.."
+echo "!!README!!: Please install openssl and mysql libraries manually following our wiki"
+
+# 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 5.6
+
+choco install -y --skip-checksums cmake git git.install microsoft-build-tools
+choco install -y --skip-checksums mysql --version 5.6.12
+
+echo "!!README!!: Please remember to install openssl and mysql libraries manually following our wiki"
diff --git a/bin/installer/main.sh b/bin/installer/main.sh
new file mode 100644
index 0000000000..a71bca1996
--- /dev/null
+++ b/bin/installer/main.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+
+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: '
+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"
+ )
+
+function _switch() {
+ case $1 in
+ "First Installation")
+ inst_allInOne
+ ;;
+ "Configure OS dep")
+ inst_configureOS
+ ;;
+ "Update Repository")
+ inst_updateRepo
+ ;;
+ "Reset & Clean Repository")
+ inst_resetRepo
+ ;;
+ "Compile")
+ inst_compile
+ ;;
+ "Clean & Compile")
+ inst_cleanCompile
+ ;;
+ "Assemble & Import DB")
+ inst_assembleDb
+ ;;
+ "Module Search")
+ inst_module_search $2
+ ;;
+ "Module Install")
+ inst_module_install $2
+ ;;
+ "Module Update")
+ inst_module_update $2
+ ;;
+ "Module Remove")
+ inst_module_remove $2
+ ;;
+ "Sub Menu >> Compiler")
+ bash "$AC_PATH_BIN/compiler/compiler.sh"
+ ;;
+ "Sub Menu >> DB Assembler")
+ bash "$AC_PATH_BIN/db_assembler/db_assembler.sh"
+ ;;
+ "Quit")
+ echo "Goodbye!"
+ exit
+ ;;
+ *) echo invalid option;;
+ esac
+}
+
+# run option directly if specified in argument
+[ ! -z $1 ] && _switch "${options[$cmdopt-1]}" && exit 0
+
+select opt in "${options[@]}"
+do
+ _switch "$opt"
+ break
+done
+done