找回密码
 立即注册
搜索
查看: 1040|回复: 12

MangOs搭建魔兽世界私服

[复制链接]

991

主题

92

回帖

5万

积分

管理员

积分
55422
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!. G( c# h2 X5 i4 k
考虑再三,我选择了CentOs来做游戏的服务端操作系统。
- m- n/ w$ X0 g, i4 D% \$ `+ n通过Git获得Mangos的源码之后自行编译搭建服务器。# I2 E' q5 x& f; b# z" g. c4 Z6 u
这么做处于几方面的考虑。
9 b  F/ R4 Y' s5 H% \$ @
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。) A3 ~* Y4 D0 S
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
2 l& s' N7 P0 y$ L. W% v. G5 \! a把该打的补丁都给打了(yum update)
& A  U! p# ^% s" G完了之后,咱们安装一些基础的组件和环境。  C" O% C4 w2 _/ b, }5 t7 ^! E* [) z
Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel0 A8 y% o; H  _6 i
如果有些组件提示没找到,无所谓。继续往下。
4 a* Q4 R8 t" q4 Y我编译安装的第一个版本是cmangos。
9 w* R0 [3 I4 V7 r0 u" @这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。9 n# f2 |$ ]6 x) e
cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
- n# g* d2 d6 _4 @8 r编译参数中:
4 T; O/ x$ M( t% H& gDCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。  _) j+ w6 T& ^% q' g
DBUILD_EXTRACTORS是指是否安装地图提取工具
  ^  `4 f) `2 o6 h- Y! qDBUILD_PLAYERBOT是指是否打开机器人6 |# h. ^. ?: O2 q5 B
这里我做科普2:
5 A! t0 G/ s/ `# B首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。
; F; f1 ~! S& @: l: d既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。
  a4 n  k* g$ e3 U: M3 y( _4 ]7 a至于那个机器人吗?那是个笑话,请自行忽略。
' K: W# N& A* R. \我们继续,我把整理好的搭建步骤列一个明细:; B  ^  T! }' Q* A; \
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。4 h) ^" ?% z% x+ Q( T+ B. d
这中间,我把一些别人不会告诉你的关键步骤做科普3:  L# g/ z" v& G. B
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)
    % }1 v2 o; w6 Y! v7 _
放几个链接仅做Mark:
- k& x8 [: y3 K5 s7 }7 @Cmake3 安装
% ^6 ]5 @: R, hhttps://blog.csdn.net/weixin_38883338/article/details/86408749
9 a! S5 d1 G6 C- X) @+ qGcc 60 R/ u# g( p- u2 l6 W
https://blog.csdn.net/Al_xin/article/details/92438055
* J: D; B  R4 R& t4 E) K+ }7 ]5 T# j- TACE6.3.3+ z- ?- @8 |: k8 G
https://blog.csdn.net/u010587274/article/details/50965369
7 H. @0 L5 }9 j: O& m5 RGit源码和数据库编译安装服务器: r$ m7 H# W1 H& @% h4 O
git clone git://github.com/cmangos/mangos-classic.git mangos
6 {! P- d" O7 sgit clone git://github.com/cmangos/classic-db.git
$ B  h0 W. }9 ]& z3 iACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
" R  Z! j+ L/ _$ b) g我们来说一下服务器的配置。4 [1 v+ d' ~+ u7 m
在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
# k# F; O0 N" K7 Y" T3 X
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)9 S; j  C8 {/ `% _3 L8 U" v
有几个关键点,我整理如下:
3 P! p% v+ j; o  `4 O. r( }
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。5 k; t) X* Q/ T  x0 q7 m2 H
参数名称:
8 O4 c0 O( d# Z/ ^' U# [地图目录4 V! B! E2 ?3 U3 k8 ?  R% z
DataDir = “../data” 7 D* Y% w; `0 x- E$ R8 P
日志目录8 m1 Q0 e/ U4 W
LogsDir = “../logs”
+ K/ y- G( Q2 n' t- F! L% m5 o2 N游戏欢迎语
5 w! }: J& S* O) pMotd= “游戏欢迎语”
! U5 I0 A6 r( j: c' J出生等级* H' ^( q* ]/ W
StartPlayerLevel = 1
' |" P: h/ g2 }8 `8 D8 h3 u- ~出生携带金钱1000G. d% g4 e0 l) q
StartPlayerMoney = 10000000
6 k! L1 A0 q) `) z杀怪经验5倍
: |9 q2 b9 T8 E/ v6 I; h# P" _: dRate.XP.Kill    = 5
9 b3 g' r$ N& b9 u' ?! y9 Z任务经验15倍7 g% x$ E6 W- n8 L
Rate.XP.Quest   = 15
) \0 C# Q  A: g8 Q, G& d$ X探索地图10倍
* k/ T" g3 W8 @. sRate.XP.Explore = 10
3 t. @0 R  y1 T% r数据库连接(应该有3-4条之多,按下面格式修改即可)
7 J7 m1 Z5 o# M) \LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”
! L( P% a  O$ e0 F, P  y配置结束,就是启动。
2 B9 w$ T' V5 j2 P( [# h因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。
+ p) g$ j: n! e8 a3 C7 Z我们需要开启如下端口:
& }( x3 q" d0 ^. v8085,9600,3724
  q3 W- {+ r! j8 e把他们添加到你防火墙的白名单即可。
2 [& U0 O; p& `4 M5 d6 z(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)
, Z% G) e4 Z* V+ h* B一些收尾工作:& {4 N. }7 {+ b( h# ~6 \: K
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。) W- l1 U1 p. Z  x: y

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

server.zip

148 Bytes, 下载次数: 7, 下载积分: 金钱 -5

database.zip

10.65 MB, 下载次数: 7, 下载积分: 金钱 -5

ACE-6.4.7.tar.gz

12 MB, 下载次数: 7, 下载积分: 金钱 -5

ACE-6.3.3.tar.gz

11.87 MB, 下载次数: 6, 下载积分: 金钱 -5

cmake-3.0.0.tar.gz

5.24 MB, 下载次数: 8, 下载积分: 金钱 -5

rarlinux-x64-5.0.0.tar.gz

1.08 MB, 下载次数: 8, 下载积分: 金钱 -5

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git2 O/ Y2 m6 N% k
git clone https://github.com/mangostwo/server.git: l6 @& t  |: O* o2 B5 c
git clone https://github.com/mangostwo/database.git; F" {2 {6 Q% l5 f/ P8 q0 _
' x8 v) Z! a# t( L  O; ?
  1. <div><span class="hl hl-1">wget</span> https://cmake.org/files/v3.0/cmake-3.0.0.tar.gz</div><div>tar xvf cmake-3.0.0.tar.gz && cd cmake-3.0.0/</div><div>./<span class="hl hl-1">bootstrap</span></div><div>gmake</div><div>gmake install</div><div>/usr/local/bin/cmake --version</div><div>yum remove cmake -y</div><div>ln -s /usr/local/bin/cmake /usr/bin/</div><div>cmake --version</div>
复制代码
  1. yum -y install centos-release-scl# C- e% \% M5 v& w1 ~3 I4 {8 o, |
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils' ?+ D, y% B; |3 h5 k
  3. scl enable devtoolset-7 bash' z7 f5 U6 F6 S% n3 v* c) y
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile9 C8 t  o' N, s4 `3 J! U' {
  5. # 查看安装的包
    # v  M+ B. R. _( n, F6 p- {. V# x
  6. scl -l ( @- B! i4 \& U$ I6 ]
  7. yum -y install rh-python351 U( Y% D; Y8 e; o( G- x
  8. scl enable rh-python35 bash2 ?6 J1 s* [7 i8 {% K( W+ s$ a7 ~
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile- G# \: g" W; r

  10. ) h3 D. v, t0 p, I
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz. I! r* E1 t; N6 A$ t) g+ d# D! c
  2. tar -xvf ACE-6.3.3.tar.gz
    / v7 Y/ t( I; O6 z; W. F0 ^
  3. vi /etc/profile# w7 t+ V- g- ]9 M& K5 ^- e
  4. #在文本尾部添加:' }: e) Z4 P# F9 J7 {# t
  5. export ACE_ROOT=/root/ACE_wrappers( B. B. ]. f, |/ \" X
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    5 k" u7 W+ e/ q! I# p
  7. vi /root/ACE_wrappers/ace/config.h! K. \) o: c+ n, a% t1 e
  8. #写入如下内容:8 @, Y0 W0 |4 d  K, F
  9. <code>#include "ace/config-linux.h"
    ' Z' E0 y6 Z' A
  10. </code>
    0 M5 I1 F' Q5 S5 G0 w1 t
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU  C8 ~0 A5 C2 ]. a- d
  12. 写入如下内容:5 k0 y9 i( U. ^6 \* x% [2 U; r
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>/ n% B+ J* |/ ?% q) f
  14. <code>INSTALL_PREFIX = /usr/local</code>
    3 @: d1 D' h. `
  15. % }6 W! `$ t0 G0 |
  16. chmod 775 -R /root/ACE_wrappers
    3 }% E. U1 r1 ?$ Y4 B& f# ~/ R
  17. cd /root/ACE_wrappers/
    1 u2 R4 C: Q9 j, l1 a( D
  18. make
    " F% A6 z. v! P# V! M/ H
  19. make install
    ' R% U6 q. W7 ]  ~! e# C: t8 q- ^
复制代码
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 17:20:43 | 显示全部楼层
  1. wget -c https://raw.githubusercontent.com/mangostwo/server/master/linux/getmangos.sh && bash getmangos.sh
复制代码
  1. #!/bin/bash# }) q' f- h3 [2 j
  2. ###############################################################################3 B6 q' g) P/ i9 n8 [
  3. # MaNGOS Build Automation Script                                              #
    / f2 U- E( P& A4 P9 l6 O
  4. # Written By: Ryan Ashley                                                     #
    6 A1 w; P( X4 ?; F) M2 M0 d; k
  5. # Updated By: Cedric Servais                                                  #" f% m% e0 i+ {9 F5 i4 c
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #. j" r3 J0 W  ]6 ~' `6 f
  7. #                                                                             #" Z( P  {- f5 w
  8. # This program is free software; you can redistribute it and/or modify        #
    , h, _7 E. x" D- f
  9. # it under the terms of the GNU General Public License as published by        #3 w; b' C4 @1 G: q
  10. # the Free Software Foundation; either version 2 of the License, or           #
    ! e/ H* Y7 C4 k4 @
  11. # (at your option) any later version.                                         #  P. P- m$ [0 ]- ?. l
  12. #                                                                             #5 k! Z( q5 l' H2 T3 i8 ~
  13. # This program is distributed in the hope that it will be useful,             #
    . k( f) Q7 @& L; g# ^% i# [5 g
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #4 C+ P3 `+ l' D0 D" w1 b
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #1 d1 o& \) n1 E) c9 l% {: ?7 \7 M
  16. # GNU General Public License for more details.                                #% d, a3 }$ U1 E; B
  17. #                                                                             #( n+ d+ I0 G6 K& {/ r2 t! w
  18. # You should have received a copy of the GNU General Public License           #
    2 y& P. h1 D/ h4 U! v1 U4 K
  19. # along with this program; if not, write to the Free Software                 #
    ; A  o: J2 ]. Q* {3 ~
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #9 i7 H3 w; ]& K
  21. ###############################################################################
    ' ~+ X- |1 Y; J/ D; C% ]

  22. & _+ j2 I: j% R1 c) x
  23. # Global variables
    ; C6 n6 S+ h( g) i
  24. DLGAPP="whiptail"# z! h- N) Z: ~8 v0 C
  25. VERSION="2"
    % U. U& t# d/ r1 h
  26. ROOTPATH="$HOME"
    1 c" w7 u4 i1 H- B, Z
  27. SRCPATH="$HOME/mangos/src"
    1 i% r4 q# w, \! {
  28. INSTPATH="$HOME/mangos"
    ( T( ~7 Z; o' a& X
  29. DB_PREFIX="two"6 {: n: ]: d  \+ r  F% S
  30. USER="mangos"
    8 v; ^" P  Q( B) L' ]# A3 S
  31. P_SOAP="0"! Q/ [7 A6 r8 l( o; F8 e
  32. P_DEBUG="0"
    9 }# C) v/ f5 Z& G) R
  33. P_STD_MALLOC="1"
    . N9 o# H' Q+ E: X2 {
  34. P_ACE_EXTERNAL="1"
    ) b0 R& M' O6 A+ W
  35. P_PGRESQL="0"" Z( R; {8 j0 o, Z: g
  36. P_TOOLS="0"$ ~# B; |) r- ^/ L3 o  n
  37. P_SD3="1"
    0 W0 b2 l. \  W( F$ ~
  38. P_ELUNA="1"3 {6 v; w3 z2 ]% ~8 F
  39. P_BOTS="0"' j% _8 h# F$ f* H( a) E$ X% ?
  40. CMAKE_CMD="cmake"
    7 O2 O% e1 F" U; |0 |; ?1 h8 A2 E

  41. + i" i' p9 a( Z, U# [+ C  k

  42. 9 V! ?2 x4 m6 k( ^
  43. function UseCmake3()
      {. m/ u# U2 i3 `- F- h6 \
  44. {
    ) }5 w( }+ ?8 Y- e
  45.     # set the command to cmake3 if its there
    % p$ G1 }2 q4 |+ V
  46.     which cmake3
    1 ]' ~& m5 t& l  x
  47.     if [ $? -eq 0 ]; then8 |; O9 C: i9 q$ v+ `
  48.         CMAKE_CMD="cmake3"
    5 \( t5 ^, x# S* a
  49.     fi
    , k/ b/ ]& f$ D" @# T) n7 V
  50. }* d: g! Y/ h0 |: Q) ?/ W) \6 D

  51. ( N& ~2 ?$ x% J, k2 h2 m
  52. # Function to test for dialog6 m" L% L5 g# W7 r" M! c/ m
  53. function UseDialog()# O- b  x4 R  }: f6 z# i
  54. {
    * T. u0 @/ |5 _" Y) t
  55.   # Search for dialog
    4 A; k" j8 v5 h3 v& m
  56.   which dialog
    ( O. x) a& H7 m& A% O9 P

  57. / `. s1 N3 c& k& L& H
  58.   # See if dialog was found
    , }  s( a/ x; A8 `2 u
  59.   if [ $? -eq 0 ]; then; h5 l  H$ X3 Y2 W% E
  60.     DLGAPP="dialog"
    2 P# l3 H( r+ d9 j3 A5 d
  61.   fi5 r6 E( `3 z; _
  62. }* m, [2 |4 P5 ?* m

  63. - h& \+ i$ U7 P% X3 P5 ^
  64. # Function to test if the user is root or not/ A  S1 [: v9 g0 F! I# r
  65. function CheckRoot()
    ) Y+ E4 h" k+ p
  66. {, G6 `" N! H9 X! C: |$ x# c# U' ?
  67.   if [ "$(id -u)" != "0" ]; then& r; u4 T5 d; [* i: d
  68.       Log "This script can only be used as root!" 14 J; }  l7 p; `
  69.       exit 1
    ) M" v9 w+ c+ g& h& S0 E& N/ S# R, m
  70.   else
    % R% C2 B- Q! E5 }# b
  71.       Log "User is root, check passed" 0! y- ~' t' s# [2 p/ F
  72.   fi
    % g8 W$ |/ h3 |0 S' b3 B: f
  73. }0 h8 m4 [' N; k: e5 J) Y
  74. 3 d+ Q; R0 R. c% H$ z
  75. # Function to detect the repos* s. z- R) X' O) F7 ~5 b% ~
  76. function DetectLocalRepo()7 a1 Z- k/ h) O4 I, p2 O% i
  77. {# `3 U+ }9 a& N9 j+ Q$ V) V
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"4 F0 X! q% m+ p
  79. 2 M: @$ Q( Y% ?: Z! F2 d/ d1 O+ g
  80.   # First see if the Windows stuff is in place
    ; t/ E- l' f) F, I# Z
  81.   if [ ! -d ../win ]; then0 N. Z8 ]& c* h5 a: |1 d
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0
    # \# V, ]+ w8 j
  83.     return 0' v, v: O7 {5 X
  84.   fi
    % G. m6 y, A. Y7 I4 p
  85. ; q+ N% y6 a9 j5 ~/ a9 M
  86.   # See if the sources dircetory exists
    . l8 w; y" C& i4 n+ ?" L
  87.   if [ ! -d ../src ]; then
    8 s3 G5 e9 c. }! u9 S- [
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 02 `4 x! }/ H+ r! j( {( d% q
  89.     return 0, q; V& r  U' j6 ?0 G% L
  90.   fi
    ) G) E. S. t+ [
  91. # w: N- j& R* w, C( U
  92.   # Check for the CMake directory' p% a' t, p# Y) k  }
  93.   if [ ! -d ../cmake ]; then
    $ G4 B5 i: ]: V  q4 x# }9 B5 J6 x
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 0& U3 `0 K% g  m
  95.     return 0# [% q5 i% _' ~3 C) N
  96.   fi
    ( R: d6 k4 j6 _$ ^5 [

  97. 3 A3 Y' I" v0 a* w
  98.   # Set the default paths based on the current location! D. g& @) s: Z! J* o, T
  99.   SRCPATH=$( dirname $CUR_DIR )% H2 v* {9 e5 y1 V
  100.   SRCPATH=$( dirname $SRCPATH )
    / g3 b; \1 m) u+ a7 L% C- K6 V2 K3 a

  101.   t, v: I5 }( x+ a
  102.   # Log the detected path+ G7 S# E0 k8 D! }; S2 l* x
  103.   Log "Detected cloned repository in $SRCPATH" 0, i+ H2 n4 t$ N' y. e  s& L
  104. }* A' X5 k, K& u
  105. - N" Q  |  d' z5 P9 B

  106. $ j2 \# {1 W% C2 `9 Y4 F" Q
  107. ( F/ p) l$ @' e
  108. # Function to log results6 i2 d3 x, P7 v- v0 H. a$ t/ U
  109. function Log()7 k! Z+ X2 x) F1 l
  110. {
    2 [  P2 v  G! S5 T" M
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )
    ) W; |# g  |0 t! w3 N: p
  112. / m4 g6 [3 J9 v8 G: Q/ v
  113.   # Check the number of parameters7 {1 Z1 G) J- @
  114.   if [ $# -ne 2 ]; then
    & X; Q- [5 [. {2 H6 c% P2 w$ a
  115.     echo "Logging usage: Log <message> <echo flag>"
    : C! I) G3 B) b9 B$ C  k6 x- {
  116.     return 1
    " D* E! X' ]5 E' n; C# D% r: i2 q) A
  117.   fi
    6 F( i  F- i% \" f" h  @- C

  118. ' T$ V$ E  `0 ~8 }% u
  119.   # Echo to the console if requested
    ) [; a9 S9 P. M. f
  120.   if [ $2 -eq 1 ]; then, R' V+ G1 c" z: r# I6 R
  121.     echo "$1"
    , |  [7 r% a7 a: K) Y! f# r  R
  122.   fi, i; e9 o9 }# x2 b
  123. 5 z* G- }( H+ H5 T/ F9 {' P
  124.   # Append the string to the log
    6 p& T* I& c( Z. ^( q% Q
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log
    8 m# ]6 G% }0 @/ b
  126. }
    ! H% V' K" C$ l  ]* ^
  127. 0 d( A' T+ N6 i0 x

  128. ) ]& u: U" }8 W* t/ |

  129. ( O  U1 n% Z. {2 i8 E& S5 P
  130. # Function to install prerequisite libraries
      V( J# u8 t0 N  |3 R! I" h
  131. function GetPrerequisites(): f; Z; A/ b8 \- t4 c; S
  132. {
    ) B+ n8 w2 [; d4 q* p& h& z
  133.   # First, we need to check the installer.* Z9 q8 }# \2 x" c
  134.   installer=0* Q( ?# i7 C# i* y5 t& _

  135. : u' K' A5 v6 Z$ i; C- ~9 U
  136.   which apt-get% J2 k% ?" X3 l( X- D1 N+ k7 Z& s

  137. , g! z3 m" v( g+ J- A
  138.   if [ $? -ne 0 ]; then0 Z4 |3 C6 M3 m
  139.     Log "apt-get isn't the installer by default" 1
    ' c$ T. P2 R  a2 n
  140.   else
    , a# t: l4 c1 G( a9 G) ?
  141.     installer=18 N' `' e7 v8 j" p2 d- |
  142.   # On a fresh OS boot (EC2) libace was not found without first updating ) P/ P) z7 u/ Q8 t( n0 U. W& l" Y& M
  143.     apt-get update -y && apt-get -y install git lsb-release curl2 V7 T8 j+ e! s3 \1 a0 `
  144.   fi
    5 M: k* u( @: t/ N& ^

  145. 4 @8 C3 ?  g7 \2 B* x
  146.   which yum
    6 V2 j4 \: F% ?! H4 d# h

  147. ' ?+ F* j+ N0 @) {3 Q
  148.   if [ $? -ne 0 ]; then
    0 a( X$ H: Q/ S; i8 w/ w3 I
  149.     Log "yum isn't the installer by default" 1
    : [' C' G$ C) x
  150.   else1 i6 I# P3 [  Z: D% G" I
  151.     installer=1
    ! K1 \0 j/ H  j2 Y. H
  152.     yum -y install git redhat-lsb curl; @. y8 y& r! A
  153.   fi
    # b4 D) d8 R; j5 Q+ B9 A

  154. / P0 `: S9 X; k3 |# S: I% }1 L1 v
  155.   which aptitude
    0 j1 U( V6 f+ Z. W) l1 j
  156.   if [ $? -ne 0 ]; then
    " k7 h. E7 h, n4 C" }0 {7 d9 I' U
  157.     Log "aptitude isn't the installer by default" 18 B9 f  f! I1 i
  158.   else: ^& B& G$ |, a5 u* E, ^$ R
  159.     installer=1
    ; B5 y7 `4 _* ^0 I
  160.     aptitude -y install git lsb-release curl
    . O7 f8 |1 E9 g8 C/ I1 [) ?9 U3 |
  161.   fi
    * S$ C1 y& v% k
  162. 9 \. n: X  z  b2 Y1 e% S
  163.   # Then, let's check that we have the necessary tools to define the OS version.( W) C, Q9 V$ }) p5 W2 P
  164.   which lsb_release5 t0 K) b  F) T0 A
  165. 2 D% x* f: ?0 F1 R6 f+ C
  166.   if [ $? -ne 0 ]; then
    # V2 k& o) n/ M3 M+ R: S2 X
  167.     Log "Cannot define your OS distribution and version." 1
    3 ~9 s5 E, R2 f/ m5 X4 ?& _6 _
  168.     return 0
    , C2 P/ u+ ]( I# b1 J! A0 }, `
  169.   fi
    0 Y  g$ x; n* z3 X- u5 w
  170. ) }' `! o0 r3 l0 b
  171.   local OS=$(lsb_release -si)0 I% C; y' }) s* X3 j1 f
  172.   local VER=$(lsb_release -sc)/ u9 {( a' N1 T4 E
  173.   local OS_VER=17 e2 ^% r4 D! ]+ H! O( D
  174. : _7 o, d% S' m3 |2 `
  175.   # Ask the user to continue
    , H2 K- J/ ~% t4 `2 O. N) v
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    0 V# U9 v7 f, X9 Z! s' {
  177.     --yesno "Would you like to install the required build and development packages?" 8 60
    * A' q, X2 D$ U% k0 g  o: {5 M9 h
  178. " A5 ?6 m) c: B, {! I
  179.   # Check the user's response. O, P# o# X6 [# E  H
  180.   if [ $? -ne 0 ]; then# D8 [( J  Z- e
  181.     Log "User declined to install required tools and development libraries." 1
    7 \) ^. Z. n4 M6 M7 }
  182.     return 01 x4 V5 u6 R! I. L' b0 J+ |- c: z& b
  183.   fi: Q' m! n6 `) x7 n5 Z/ Q

  184. 6 T  d5 S. k0 e) p5 u+ x7 A
  185.   # Inform the user of the need for root access8 k2 c! h; G! p* C6 w$ K
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \1 U% M, q9 K1 k1 U; R9 O# u
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    % j9 N2 H/ p/ c

  188. 4 r# Y# i1 w( P* X9 \  @
  189.   # Check the user's response
    3 I8 K, U7 W8 s, G# h) a" o3 Z8 R
  190.   if [ $? -ne 0 ]; then
    9 b; Z) X: U! h! v$ L, E
  191.     Log "User declined to proved root access for package installation." 1; r( M* f3 X+ p4 O& X7 e
  192.     return 0; E6 I3 B5 Y% C  o* n
  193.   fi
    4 I  H4 m5 q! `  O& Q( c1 x. D

  194. ! _4 r- w$ d4 K$ A+ ?8 t
  195.   # Handle OS3 ^) c" y- `4 v# m, u: |% I2 g' s' N
  196.   case ${OS} in( r* Y6 r% r6 M: [2 u) n  p& X
  197.     "LinuxMint")
    7 {& r' e! V5 R# C9 {- P
  198.       case ${VER} in
    ! X( [+ j6 a) T* X" S
  199.         "sarah")( A8 P( k+ N; p" G: _  |* C  c
  200.           # Linux Mint 18 - Ubuntu Xenial based
    5 s0 z% D, [; t! g# a. e# G
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    1 C) a4 J4 ?( C4 B
  202.           ;;: A3 |9 Z. O! W% l, q& u
  203.         "rosa")
    9 c( B4 S/ r" k  s
  204.           # Linux Mint 17.3 - Ubuntu Trusty based6 e+ Y8 G' p* \- m( a
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root, O; x2 B, z# N# E! }" e. w
  206.           ;;5 m. I# m- M/ m( m% \
  207.         "rafaela")
    8 Z6 Z3 G* t8 U& u7 }
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    - L6 t* {+ F  n
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    0 @% r* b" f3 p
  210.           ;;2 n+ B  f+ ^+ [+ I
  211.         "rebecca")( r; |5 J. w2 V' X
  212.           # Linux Mint 17.1 - Ubuntu Trusty based& d# |- v% u1 P2 q$ j) B
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root3 L! x2 k; f6 E; F/ Z% @2 l. J
  214.           ;;
    3 j! ~5 u( O# ^9 D, j% b" L
  215.         "qiana")$ o' Y9 ]- k4 ]; c0 R3 K! B
  216.           # Linux Mint 17 - Ubuntu Trusty based& I% ]  `/ v) C! k0 Y( u
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    . V7 s1 Z* Q% [3 ^- D
  218.           ;;
    " z' I% G- N# h4 L
  219.         "maya")
    4 t  G. R; B* V; ^
  220.           # Linux Mint 13 - Ubuntu Precise based
    & V2 L0 j. z9 N' |6 [
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    5 u! H4 p' o1 v( O
  222.           ;;
    ) m6 c4 C# a8 }9 W/ `
  223.         "betsy")* U" |0 a3 v9 f
  224.           # LMDE 2 - Debian Jessie based1 I7 ]# ]+ U) [5 I; P; E7 E
  225.           su -c "aptitude -y install build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev libace-6.2.8 libssl-dev libmysqlclient-dev libtool zliblg-dev" root
    9 {/ f0 r" i' l9 S  R7 T5 E
  226.           ;;
      e5 Q% _  K# ~2 f, M* w( p
  227.         *)
    ' R3 @9 _2 O% i/ s* Q. c. A8 S
  228.           OS_VER=0; T4 b; t% v1 n0 A
  229.           ;;
    , K$ f1 O% L/ l* P  y
  230.       esac( g  u* k* y5 u8 f2 J3 d! r! V
  231.       ;;1 E4 e. U4 R# u
  232.     "Ubuntu")+ k, _) e8 J* w, X1 J
  233.       case ${VER} in0 x/ V) y) D+ I& q& Q1 p
  234.         "precise")6 N! p$ B3 V" ^5 g' S4 ?) r: ]
  235.           # Ubuntu 12.04 LTS
    & `- W4 W0 V$ n( M4 v4 S! V0 K
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    3 ^9 G/ Q: B. M" P, n
  237.           ;;, ~7 Y; a6 V& }& I9 w
  238.         "trusty")5 h, i+ c8 w2 G9 y, g
  239.           # Ubuntu 14.04 LTS
    ( I" M% m  G! e& N" N& g
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root0 o9 T' R& m6 l- T. ~
  241.           ;;3 _9 S3 B! P7 B: e# D% C% h+ K# C/ j
  242.         "xenial")9 k  w" L$ f; f: k
  243.           # Ubuntu 16.04 LTS
    8 u- t/ _# ^2 W7 |2 n! O
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    0 M% ?  e- W$ \3 a
  245.           ;;
    ; J  ^5 N8 f  ?( q6 m7 M! _
  246.         "yakkety"); }( T: s% k, p- u( B
  247.           # Ubuntu 16.10+ }" K# p9 C8 ]9 }0 ?. A
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    , B  M0 U+ q" x# o* s
  249.           ;;  t! ~# H! B# ?8 x
  250.     "zesty"), G( a  O* h0 d9 H7 J
  251.       # Ubuntu 17.04
    ' R7 t# `) p( r+ e+ x' h
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    $ j' Q; I* G  s% |1 n8 m
  253.       ;;: a) D2 M8 r& z" X! W
  254.     "artful")
    $ m% g% o5 }  Z& D
  255.       # Ubuntu 17.10
    7 C; i8 v! s* B/ m- l! T
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ) w$ r- a: M  ?& p7 w$ |- x4 S
  257.       ;;
    " ~% O/ g2 r* b8 l6 \" u
  258.     "bionic")
    + ?: ]0 O2 {+ J& N! L
  259.       # Ubuntu 18.04 LTS
    & K. F9 I' f' v. R5 z( `" W
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    8 W, P8 b0 n! n! e1 d& ?
  261.       ;;
    / i7 T! D) L; \! `* P7 N" T- F
  262.     "disco")
    + l7 Q$ b/ J+ G
  263.       # Ubuntu 19.04
    : }- q+ u1 s7 C3 Z: x
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    + u* k7 O1 b, ?; V; F5 K2 n5 N
  265.       ;;/ X  ~; P% D' j, i4 v* M3 W- ~
  266.     "focal")- a: ^; W) U* ^7 q5 t! H# m, }
  267.       # Ubuntu 20.04) Z7 Y: g- t2 b" c5 p! H6 j
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root: p7 k; U' P2 ?
  269.       ;;5 K4 F; p7 t. Q
  270.         *)0 t! _1 @- T) j) _0 r: p( N
  271.           OS_VER=0
    # |- C$ B. y3 b, w) h1 N
  272.           ;;0 j3 x, r7 c- g- U
  273.       esac
      w; l+ c. K: h% h0 b1 Z0 |$ g
  274.       ;;
    7 p$ E& ~6 x# C7 S
  275.     "Debian")# i1 u4 m# F: c4 M. o: P6 _1 R. t
  276.       case ${VER} in6 G& c5 d4 p1 |' D+ P! }  T" R
  277.         "jessie")
    . A" |) ]# m1 r8 S
  278.           # Debian 8.0 "current"
    ' h1 X3 q7 l9 X) k$ }
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root8 z* B( z4 J$ u+ u
  280.           ;;- u9 i6 I5 _# |4 F6 h' F
  281.         "stretch")
    0 u0 _' d2 Y; _6 ?8 V
  282.           # Debian Next9 A8 f# o* O$ z) |7 k5 C
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    ( W5 P7 w6 Z6 `# W' }+ }) A
  284.           ;;
    1 R- q3 k* j, ~' S& I
  285.         *)
    + u& j* f# T0 I* b, i
  286.           OS_VER=0
    * R6 I8 G' f: s2 C2 H+ T; P
  287.           ;;, f# i6 m  m/ J; i
  288.       esac
    0 w; `5 i/ n. Z- w6 X( G
  289.       ;;
    8 R& F, K+ J/ Z  H
  290.     "RedHatEntrepriseServer")- O& G# q# X! X- D
  291.       case ${VER} in8 C9 r( w0 K0 q8 V+ B7 b  g4 K: g# k: z
  292.         "santiago")
    , w( g; |4 S/ M& ~" B/ f, y# a
  293.           # Red Hat 6.x
    9 h, x: O2 q; }* m% g1 Y' ]4 U! ~
  294.           su -c "yum -y install curl build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev ace-6.3.3 libssl-dev libmysqlclient-dev libtool zliblg-dev" root
    + t" i( ?& {2 x# d; D$ w4 T" E+ X; _
  295.           ;;
    3 H/ i1 ]8 G+ S* m3 F: s
  296.         "maipo")
    / d* T9 Y! X7 Z- X
  297.           # Red Hat 7.x
    # L) }1 e2 P" d) @( \' N
  298.           su -c "yum -y install curl build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev ace-6.3.3 libssl-dev libmysqlclient-dev libtool zliblg-dev" root; C+ o. G1 j% [5 @4 V
  299.           ;;8 g  `6 N5 j) T5 f
  300.         *): ]- s! w0 A' R- h
  301.           OS_VER=0
      A- H8 P, ~2 o0 l7 }# T& r( e
  302.           ;;
    8 I# q0 P8 w' `; k- `
  303.       esac
    0 V) E' k, ?9 B, S" N; S+ @
  304.       ;;
    / ?* ~' ~$ d, B: ?% z: q5 g  ~
  305.     "CentOS")
    3 v: @! @9 T$ |" f
  306.       case ${VER} in$ N) Z4 B' v2 d* @
  307.         "Core"); m' z( G1 A( V$ B) B$ n' p
  308.           # Default CentOS - Adding necessary RPM third-party.& _9 u. t4 u3 Y; V+ [. q( O- d
  309.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro/CentOS_7/x86_64/ace-6.3.3-55.1.x86_64.rpm
    / T& J: ~' D* j% E  ^
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm' ]: P/ \% ]+ Y2 ]5 a
  311.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro:/versioned/CentOS_7/x86_64/mpc-6.3.3-42.1.x86_64.rpm+ ^" q; S, G) v  `6 S3 v
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm4 D& ^: k) \) `; h5 |5 Q
  313.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro/CentOS_7/x86_64/ace-devel-6.3.3-55.1.x86_64.rpm
    3 v) q+ J( b! i) b7 {% A1 F
  314.           su -c "yum -y install epel-release"
    ; ~/ @/ S% E3 |' ?/ ]6 ~' m
  315.           su -c "yum -y install curl autoconf automake cmake3 ace-devel ace-6.3.3 openssl-devel mysql-devel libtool gcc-c++ bzip2-devel" root
    4 G  ^5 X* Q+ K. w
  316.           ;;( Z% o0 D3 t4 U! y2 s- t9 C- w1 B
  317.         *)% g+ e! o, |# r% T' V
  318.           OS_VER=0
    * S  ^/ x9 j$ x7 _' f9 B
  319.           ;;. g. I8 ~4 M  s6 F! S% `
  320.       esac
    % ?% }; h5 ^) S+ y( b
  321.       ;;
    2 S! [8 Q, k; `
  322.     "Fedora")* G6 z7 @; k! o% v* p
  323.       case ${VER} in
    - @) z6 ]4 `1 _, e$ U5 j6 ~$ u
  324.         "TwentyFive")3 `5 q$ N2 U3 o8 G% B) I% ~; C: k
  325.           # Fedora 25 - Adding necessary RPM third-party.* ]  c/ x6 _; V8 g1 `7 C' F
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root
    # f, [' c; f8 |# E6 n) ?
  327.           # Getting and building ACE. Not provided in RPM for Fedora...
      [/ G9 p( }. N1 X. @/ G* O6 ]4 \" z3 v' d
  328.           rm -rf ACE-6.3.3.tar.bz2# |6 D5 u- V) n+ S$ c, F% m& e
  329.           rm -rf ACE_wrappers
    6 U3 _# y% ~! D$ ~6 e& ]
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2
      `) z& y$ p4 T% E0 {8 \  y
  331.           tar xjvf ACE-6.3.3.tar.bz2( [0 p* K% {2 Z$ `
  332.           export ACE_ROOT=/root/ACE_wrappers
    " V# {. u/ S  M( W( F1 \' n
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h- h1 S% D1 I. p) M. a, d
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    ' f' C, ~" r8 d3 p- S4 p
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    2 c$ c0 t5 D+ L
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    % {4 ~" y7 x" A, u
  337.           CD $ACE_ROOT7 w3 J( W) A# U% X& F7 m, u& h
  338.           make
    ( W, H- A' c1 }4 X  F. S
  339.           make install
    9 Z' x8 T5 m8 ^
  340.           cd ~
    2 x6 p& p  @! f
  341.           # Installing remaining dependencies..
    - X6 R% B5 {$ P
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root' ~- Q; M3 q& U
  343.           ;;8 o7 H2 p) x2 E
  344.         *)
    ( g7 L6 L* g9 F
  345.           OS_VER=0/ ~. ^. ?6 i" W9 d: w
  346.           ;;
    7 P; Q  g/ z+ \+ p
  347.       esac
    % f( \$ V# ?, f' m9 O9 X
  348.       ;;
      g4 i( [! e9 B8 P3 K
  349.     *)
    $ I+ b5 i! E# J+ h$ G! F
  350.       OS_VER=0% X/ y4 ?; X0 b; h: q! e0 a
  351.       ;;
    ) {" s  a' N# ]' V2 K) d# }
  352.   esac
    / y% i# b" H. [9 V
  353. 1 k# d2 G) ]/ W& W% o$ i. g
  354.   # See if a supported OS was detected4 n7 \! E" S/ o
  355.   if [ ${OS_VER} -ne 0 ]; then
    * b1 u% I# ^$ F( F$ N  [
  356.     # Log success
      x; J  N6 o$ L6 |
  357.     Log "The development tools and libraries have been installed!" 1
    4 z6 m; p2 o: H
  358.   else) Q$ H  y5 `# s5 r5 e
  359.     # Note the error3 K, Z8 A$ R2 I% e( B/ F8 t2 f5 ]
  360.     Log "Could not identify the current OS. Nothing was installed." 1; [+ C; v0 h& C- O. s, z
  361.   fi  {. e% D9 N7 z6 {& s
  362. }
      [) t9 T. y* T( v. F1 v' M( q2 v- T
  363. 6 `3 a* z3 d. e7 Z7 u

  364. 2 Q& J; _% t2 b6 A
  365. # @* _7 O( Y0 Y4 B/ Z/ w
  366. # Function to get the WoW version* `* N5 `6 q) s$ W, F
  367. function GetRelease()' I, }) W0 [1 X# x; o
  368. {
    7 L  G9 x" _! Q# Q; P2 `
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    7 T% u0 x1 X# c/ W; }& J
  370.     --menu "Select a version of WoW" 0 0 5 \% E5 |! T" X6 \5 F! d5 J
  371.     0 "Original Release (Vanilla)" \
    4 g7 Q6 E1 T# t* \4 c  p5 |; N$ F; U
  372.     1 "The Burning Crusade" \$ b+ `% c0 f- {0 N
  373.     2 "Wrath of The Lich King" \
    ; O; U5 F& B2 i+ n0 t% c5 |
  374.     3 "Cataclysm" \) ~4 |, K& a0 d; c7 s8 O9 v7 p
  375.     4 "Mists of Pandaria" \" P3 G5 y. g+ Z$ o5 v/ q) Q
  376.     5 "Warlords of Draenor" \
    ! X0 J) C+ N% u& c4 x
  377.     3>&2 2>&1 1>&3)& P5 G- @0 j2 h% b' Z; d

  378. % G% u4 n) P8 g2 l2 M5 x, k1 y
  379.   # Exit if cancelled1 C. ~. n6 I' V" f% o1 k  w
  380.   if [ $? -ne 0 ]; then
    3 |* J% l- n" L
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1
    : t" a+ J3 n$ K3 ?- h/ ?8 w$ h
  382.     exit 0& j4 e0 j' H8 i1 Z( B3 K, V
  383.   fi! M# k! @3 I! {. R; x. y. Q

  384. ( m0 j6 x7 p9 X
  385.   # Set some defaults based on the release
    0 I* q4 ]- ?/ M& _9 u" d
  386.   case "$VERSION" in9 F5 R: m+ M# V& ]; {
  387.     0): ?4 ]  h" u- J; O8 e
  388.       SRCPATH="$ROOTPATH/zero/src"
    7 X$ ?: R8 D* A  H" d1 x
  389.       INSTPATH="$ROOTPATH/zero"
    $ E' `, @2 ]+ x1 j( ?
  390.       DB_PREFIX="zero"
    ) f- x  Q6 R" f
  391.       ;;
    ; V" j8 }* M$ L0 C

  392. ; V3 y) O0 h0 `2 x& d
  393.     1)
    % i6 I% O" v* [4 R( _7 o
  394.       SRCPATH="$ROOTPATH/one/src"
    ( ]; r& S- w: t0 A% h
  395.       INSTPATH="$ROOTPATH/one"
    % C$ `! O0 k, j! _* I  r
  396.       DB_PREFIX="one"
    . |3 b/ c* H$ {( X. l1 p+ ?- }
  397.       ;;
    8 c( S  I& ^9 ?( w. E" A# q
  398. 9 j. J* d+ h9 l  k" ^
  399.     2); s5 Q- J& s& e" A5 ]0 y
  400.       SRCPATH="$ROOTPATH/two/src"5 i9 X5 [! x1 A. b+ }7 Y
  401.       INSTPATH="$ROOTPATH/two"
    6 K6 T* G  i( ^* c* h8 I
  402.       DB_PREFIX="two"
    & Z) d* |4 q  [! i
  403.       ;;
    ) ~, A% M7 R1 a; ?7 J, L. W0 B
  404. * S& K' G5 p9 Z; `' e' j
  405.     3)+ I7 a! s: ?* d2 `$ r/ m( t
  406.       SRCPATH="$ROOTPATH/three/src"2 Y9 }8 I4 |$ S0 P; J5 k2 i6 T
  407.       INSTPATH="$ROOTPATH/three"9 v; c; R5 t0 M" P
  408.       DB_PREFIX="three"! W$ D$ K4 r8 F0 V7 R
  409.       ;;6 N1 b: S: h4 F8 b9 Y; m

  410. * R3 C! r3 z2 G
  411.     4)  L+ V7 r. w* `! R
  412.       SRCPATH="$ROOTPATH/four/src"
    1 \7 z4 W% E3 l9 y7 C1 G  k
  413.       INSTPATH="$ROOTPATH/four"
    / D. e3 e  W' k
  414.       DB_PREFIX="four"1 U7 B7 b8 y. H' R
  415.       ;;+ z& t9 P* a# Q. q. j( ]  p
  416.     5)4 _2 W: v# M7 T/ C5 m, J" y
  417.       SRCPATH="$ROOTPATH/five/src"
    $ M( @5 i6 H- n: V" e
  418.       INSTPATH="$ROOTPATH/five", }+ P: u5 y6 ?9 F- t
  419.       DB_PREFIX="five"$ r* h5 E2 v8 Z5 L
  420.       ;;' d- t/ r7 \$ y+ R; q' \
  421.     *)
    ! f& v' @* l6 x& E: n% U
  422.       Log "Error: Unknown version selected!" 1) \6 h: z% h- K& Q. [3 q( v: e
  423.       exit 1
    ! m; U9 O) l) Q4 L) d3 z9 S
  424.       ;;
    0 w1 |. Q2 [. T; }4 P. `% Y
  425.   esac: c4 y, s9 R# G
  426. ( c6 v0 G- ~# ]2 y7 l) S
  427.   # Now set the correct source path if the repo has been cloned already' p7 f! _, F3 j; s
  428.   DetectLocalRepo
    6 k9 q. _0 @3 g: u' J  n" |* I6 O
  429. }  k3 p' ]; Y% [4 w; X3 b: Q3 O
  430. . ^, g& V% \$ z; y
  431. # Function to setup the technical user. e4 w( `0 m; R/ r; S$ {
  432. function GetUser()& ^  K! J. X8 P8 C
  433. {1 f1 f# ]) H$ u4 c8 |5 d0 ]
  434.   local TMPUSER="$USER"% \- V0 {. F6 e+ {: k5 {. k
  435. ; t& v( n4 K. H1 _/ o
  436.   # Set the user2 z9 T; s3 i6 I6 P* h
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \; p9 q+ @+ O/ q5 {# X6 d( |  x
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)5 Y7 J" V/ j) Y! D8 q: ~: i
  439. 6 U% S% q& T& w
  440.   # Exit if cancelled
    1 u1 q9 o8 [, f1 j0 f! |7 ^
  441.   if [ $? -ne 0 ]; then3 l, z; A  ~8 @' \
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    $ {$ N  j6 D6 I" L. k
  443.     exit 0
    7 z/ {& Q; h' L/ H: K! d* [/ v/ L$ M
  444.   fi: n( Q) s8 e1 \+ v7 L& c3 R2 g

  445. 3 Z+ r$ s9 F, Z, G! B  I+ z
  446.   # Change the user only if it was modified
    4 D6 D* w- A' A4 Q8 N& Z. g) V
  447.   if [ ! -z "$TMPUSER" ]; then
    4 S% ~3 V- t# Z" Q1 E: `
  448.     USER="$TMPUSER"( @( `2 \: W" R
  449.   fi
    ; }  v% g; b: J% B! U5 e8 H! V

  450. & W- d- A* {3 J& C5 [
  451.   # Validate user
    ! y: I' K2 F! {" S6 U5 P
  452.   id $USER > /dev/null 2>&1# x6 W9 b  K+ ^' S9 F- M
  453.   if [ $? -ne 0 ]; then
    ( Y. j5 o; I( F' ?( D
  454.     Log "Creating user: $USER" 1& F* ~8 S/ ?! Q* i0 I
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    , a+ {7 d3 K+ b, [, \( e% n. i
  456. 3 W: Z1 q4 B& }/ i: r8 C! a
  457.     if [ $? -ne 0 ]; then
    / K; \* r. W' X. Y; c' G7 R0 x( g
  458.       Log "Error: Failed to create the specified user!" 1
    # Z& s( J" ~; S7 O0 }7 R
  459.       exit 1, c6 g! g  \; |" s: J( R" N
  460.     fi( r# k) |. k, e8 X5 s
  461. 7 n, `" N3 {9 N& W8 }, Y* Z) C
  462.         usermod -L $USER > /dev/null 2>&10 n. g6 P8 g+ W8 @) T5 s# F! ?
  463.   else1 t$ g; ]) S/ X& c' Y5 |9 \4 y
  464.     # User already exist, asking to keep the user3 F# B7 |3 |4 ]* `) B
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \& ~+ D& A% J$ J
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60
    & B1 D; x" v: I) a9 r& b
  467. / e& {; E4 T  F* ?+ m! A: [, n' v" h
  468.     if [ $? -ne 0 ]; then
    1 X+ r3 A0 _, E9 n: m4 f' j
  469.       Log "Removing user: $USER" 1
    $ F5 e9 I8 Y, ~0 J+ h+ r
  470.       userdel -r $USER > /dev/null 2>&1- y! F/ E0 I7 ]) T

  471. , h7 O; C; f3 S5 c3 u
  472.       Log "Creating user: $USER" 1$ h/ Q; p8 z  o6 A+ l
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1
    ' b8 I0 o' W/ ]# P+ j$ k# p0 n

  474. & N- @7 w& U# u$ N
  475.       if [ $? -ne 0 ]; then2 E" t% x+ Z3 \) l' j1 i$ v3 Q
  476.         Log "Error: Failed to create the specified user!" 1
    - o: {3 C& j* a" y* S
  477.         exit 18 [* P8 i- \( o  c- m3 Q
  478.       fi
    ) W% D8 d/ H. s2 X8 Y: k8 t
  479. : v" t' w9 ^0 A) ^5 R) x5 @
  480.           usermod -L $USER > /dev/null 2>&18 i, G8 L9 P$ O* u( H" `
  481.     fi" x' l# O5 S+ |9 V0 X
  482.   fi
    3 u- v- Q. s  _) b

  483. ' V$ J# x* p, V2 J
  484.   ROOTPATH="/home/"$USER
    $ R/ Q6 t6 Y8 o( o% d
  485.   Log "User: $USER" 0
    * u# r1 T' f9 W9 |* D4 f# J* |
  486. }+ b4 z( ~" D9 q# h* o, O

  487. - z0 ^& }' p  p( d' I1 R
  488. # Function to get the source and installation paths/ f, B- M, j6 n* ?
  489. function GetPaths()
    , U9 X( A; d; z4 j! q$ b3 ]$ Y" s
  490. {5 j. t3 h6 Q/ T3 I2 \$ @
  491.   local TMPPATH="$HOME"
    2 J/ p2 k7 w( I& J

  492. 3 t% e( M% ~& y  ~! @
  493.   # Set the source path
    5 K5 ^; S" m, K* L+ _
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \
    6 \3 \6 `5 N' @& z& g* r& r
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)
    $ T* J1 p# L& n- T9 w0 C( V" W

  496. 3 a! Z' D! C7 e6 g3 N7 i- d" v1 c9 S& j7 @
  497.   # Exit if cancelled5 V' ^+ V' A- h" h, W
  498.   if [ $? -ne 0 ]; then
    ( u& r1 _5 B+ H3 c. }
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1
    % y2 b  u6 q: k  S' E+ t7 V  m
  500.     exit 0. c& M% l" C+ z% N( m
  501.   fi
    2 ^1 ~: s. ?! x8 P3 i$ S
  502. + T9 v4 q3 ^2 F6 T7 d
  503.   # Change the path only if it was modified
    - c( q6 d4 O9 j! ~, G
  504.   if [ ! -z "$TMPPATH" ]; then
    - t5 n' r- R$ m, q- o
  505.     SRCPATH="$TMPPATH"# I2 ^/ _" y: l- {( q& z
  506.   fi
    * H9 O. O1 R+ B8 N/ m' N; s
  507. 0 C1 g4 @( b2 \8 `7 f+ y8 b0 b
  508.   # Validate source path
    $ j* z6 Z9 N* C) i( L  D2 @
  509.   if [ ! -d "$SRCPATH" ]; then
    0 [4 z( w& K) R" e; \
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    ' M4 u( q) O8 o" j/ \5 q7 v$ V; y
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60
    " y4 S- e2 c3 r" b3 j
  512. . C' q2 P; S1 x) N/ y  u$ e
  513.     if [ $? -eq 0 ]; then: g- T. J% Z9 V' z7 u
  514.       Log "Creating source path: $SRCPATH" 18 j: p- F8 F) t
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    8 C; [; \# L+ d
  516. ; R: j) a& G* K
  517.       # Check to see if the directory was created" u( X) H0 `5 g& ^1 ^
  518.       if [ $? -ne 0 ]; then1 l) O' A* K* \% z  ^& O
  519.         Log "Error: Failed to create the specified source-code directory!" 1& L1 P! z* W" s2 C
  520.         exit 1
    ( ^* u  ^4 K7 F2 i) c' D% l
  521.       fi
    5 b% P! b3 ^  r8 {; g
  522.     else  L3 l/ q4 G; ?/ E6 p9 a
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1
    & Q) ?2 R! p! i  i/ Y/ W# q
  524.       exit 0
    , l- M2 [; t# ]7 o4 h! H, W- s' U5 ?
  525.     fi4 S- j* y7 I) V+ t  }
  526.   else
    6 s5 }  |/ q+ K0 W! X! Q8 i8 U
  527.     # Check for old sources8 n# R7 s0 v4 v/ A0 a( X
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then
    . y, S9 v$ m1 b9 I
  529.       # Ask to remove the old sources
    5 T1 x) E& e0 @, q4 _
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \9 I! f: E7 ?: [7 o
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60
    4 ]5 n; e9 M* y% y& Z: ?

  532. + x7 ?$ R  T; x
  533.       # Remove the old sources if requested
    " X6 W9 e: @3 h* s+ Y. }: w5 G
  534.       if [ $? -eq 0 ]; then& p- X9 @- F  i/ d0 ^5 s
  535.         Log "Removing old sources from: $SRCPATH/*" 1
    9 F4 y8 J; D) W* }4 E
  536.         rm -rf $SRCPATH/*
    . b) o: Y6 _% `5 m# n/ G4 `; r) V

  537. # j( m# c) a+ x! f. k
  538.         # Check for removal failure
    6 _  p4 j3 D- k# s" b8 y
  539.         if [ $? -ne 0 ]; then
    9 o- C2 W3 u; o/ e
  540.           Log "Error: Failed to remove old sources!" 1
    # G& b1 D' x  Z1 u  [' I
  541.           exit 1
    $ A1 l% s6 U$ `4 o
  542.         fi
    . \/ M# x$ }4 x* n; `
  543.       fi
    & @$ s( T! s& h! z) P- i" q
  544.     fi9 h0 M6 e6 n! j) m$ J; Y$ W
  545.   fi
    % R2 M- O, @2 E. ?6 E: o
  546. 3 p& S0 g, G+ V2 L/ u0 ]
  547.   # Set the installation path/ K- s* n- X5 \1 f% M; u
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \
    ; i, B% d( v2 }" h% T6 D' \* p
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    ; `8 r. V; Z  v
  550. & E6 c- Y( x6 O3 @
  551.   # Exit if cancelled5 n5 \: [$ q& }
  552.   if [ $? -ne 0 ]; then2 R$ S9 L4 p0 t
  553.     Log "Install path selection cancelled. Only the source path has been created." 1" I5 f/ l4 L6 x0 ]$ X
  554.     exit 0
    1 C; i5 f! e  A3 b& }7 ^
  555.   fi
    6 R' \3 H7 G7 O3 V9 i- ^
  556.   a8 e# X* x4 ]% i# n' n; X
  557.   # Change the path only if it was modified
    . \1 o5 F( I  }
  558.   if [ ! -z "$TMPPATH" ]; then; o  h( y6 g! i3 l  _
  559.     INSTPATH="$TMPPATH"' @- w  d% J( s6 _* r: ^5 x$ x1 G
  560.   fi8 T! j8 b6 ?) c: w$ M) K

  561. ) w% Z& I7 K# r; w6 b2 N
  562.   # Validate install path2 \; |4 x! \0 t0 P3 ~4 \7 a/ u# B
  563.   if [ ! -d "$INSTPATH" ]; then% L6 g; R2 J7 [; J& q* }
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    & l- i' Q- S  {* b1 \- N
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    ) J2 O9 n( ]2 t' n3 c
  566. 6 U6 F( p0 F) U9 r3 A
  567.     if [ $? -eq 0 ];then
    ' s( ^; ~8 z+ [9 p& M' d) U4 ^! ?
  568.       Log "Creating install path: $INSTPATH" 1# v/ D* P5 y9 s- ^
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
    9 ^2 _, p/ X7 L  g
  570. & r4 D. `: ?1 H8 I2 Y/ e
  571.       # Check to see if the directory was created
    & t, x. v% K8 F6 Y7 h' L* S
  572.       if [ $? -ne 0 ]; then6 Y' B% t5 v% w5 }# B
  573.         Log "Error: Failed to create the specified installation directory!" 1
    , F9 ^0 c. I3 P) f' m9 X
  574.         exit 1
    / f4 z) j" f# o: r
  575.       fi
    ' C) |1 T- S! q1 a# U7 U; h
  576.     else
    / t, w1 ]% j9 e) J" c
  577.       Log "Install path creation cancelled. Only the source path has been created.", \  W0 w; q6 l, v+ H9 P
  578.       exit 0
    : f0 L4 Y% s6 I. ?- t
  579.     fi
    . `* u9 @2 Z* V& M" q1 {* N  G& |: x
  580.   else
    3 F8 Z2 [( h0 X! [) O5 g4 L4 ]! k
  581.     # Check for an old installation8 r" m( v3 M# {0 q$ f8 g' A
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then0 e' {/ x8 K5 x2 L
  583. & s7 U: Y; V7 t  U
  584.       # Ask to remove the old installation2 R1 B; D8 y, j% C
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    " [3 S& T$ \3 c% R( f
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 03 w- }% [+ y% S% u' l) d' e

  587. 6 U) I8 |" @3 Q8 ?; M
  588.       # Check the user's response7 p5 R( S. C1 T7 h* `3 F
  589.       if [ $? -eq 0 ]; then& U; W1 t+ v6 E0 h' ?
  590.         Log "Removing old MaNGOS installation..." 18 b1 `# I; D$ T' q* }: Q+ p) S% b
  591. 9 y0 h" d5 j2 v$ o" q
  592.         # Clean up the binaries& g& L5 N9 |' s, h) }: Q0 N# U
  593.         if [ -d "$INSTPATH/bin" ]; then
    1 o/ f) a: S' |3 D
  594.           rm -rf $INSTPATH/bin
    + i$ n% c& y7 W9 N
  595.         fi3 U( k! ?0 C% \

  596. 1 ^( O% b* X+ i) }
  597.         # Clean up the old includes; p; g% i( A- r3 U3 ?  |
  598.         if [ -d "$INSTPATH/include" ]; then* ]- Y  I- s8 a4 i1 ^) P* ?2 l0 B
  599.           rm -rf $INSTPATH/include
    * v; t- I) S2 P" q' N! G* C
  600.         fi
    + d& e3 T' M  m& p/ e/ ^# F4 _
  601. ) y- E- D  \( n5 c8 O& L
  602.         # Clean up the library files; [) @: m* Q  G& w
  603.         if [ -d "$INSTPATH/lib" ]; then9 D0 t& W$ }0 [
  604.           rm -rf $INSTPATH/lib
    % M" G# D2 l1 y" O" @
  605.         fi
    6 o) C6 u' H- J! [
  606. 5 r) ^6 \+ ?" A0 q4 j
  607.         # Clean up the old logs6 ]: |0 v/ q3 K: J- z
  608.         if [ -d "$INSTPATH/logs" ]; then
    $ B  t1 x+ P- _) {" C
  609.           rm -rf $INSTPATH/logs/*
    ! q6 X  H9 E1 C/ t$ T2 _/ I! [% h; \: D
  610.         fi
    9 O0 I8 e. G5 C; i* I
  611.       fi
    6 E4 ^- a5 M5 Z
  612.     fi6 k: N6 U1 h' a
  613.   fi
    6 p. V7 l( [! r' |6 {3 X
  614. 0 a/ d+ l3 N0 v
  615.   # Log the settings
    6 T8 v& H, ~$ ?
  616.   Log "Install path: $INSTPATH" 0
    " a1 {$ Y3 L+ U. \1 M: V
  617.   Log "Source path: $SRCPATH" 0# ~1 Z. H6 z& P
  618. }( K& _! h) G8 h- h" M, [) C

  619.   `7 M$ t5 @1 ^2 Y2 p* c. q
  620. 1 e" W4 k! c7 d+ Q3 e- y
  621. ! I0 _0 h( w/ ~; {  G" l
  622. # Function to clone or update sources8 l2 o. V* H# @5 K4 b8 u
  623. function GetMangos()
      ]: q! B! T8 l
  624. {
    / @0 O8 ~! ~$ |3 u
  625.   local CLONE="0"  A2 E2 R' p! i4 z$ C1 y( M! h
  626.   local BRANCH=""
    6 C7 q" w% M' I1 N- X+ K/ B
  627. . D. C7 y, ?& w5 }
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \3 w( r* U+ C8 r1 o2 u' s+ y4 w
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \
    . i) a) E  d& G& P0 i, \
  630.     0 "Clone a fresh copy of MaNGOS" \! C. J4 G- c: g$ A, C' N6 \- O
  631.     1 "Update your existing copy of MaNGOS" \) y& o1 [! v% Q$ f1 C
  632.     2 "Use existing copy" \
    , K1 W  @2 d* z* M
  633.     3>&2 2>&1 1>&3)
      @0 s% h* v7 H+ {6 N3 [: |
  634. - H& q- }* M% ]* n7 H' Q3 I
  635.   # Exit if cancelled; q1 j, }. U- ^; X# b( ^
  636.   if [ $? -ne 0 ]; then
    7 t, A  j, i0 P5 w8 J; Y8 e
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1
    + Z# ~/ i' Z5 u& v! x" P3 d! z( }
  638.     exit 0
    3 ^: o* q1 L! n( H6 z+ c" H( ^6 h
  639.   fi' Y% Q2 I% D# F( }4 S

  640. * |  X; q9 e& x# R5 c
  641.   # Clone from scratch if selected2 O7 Y& s8 M! z
  642.   if [[ $CLONE = *0* ]]; then6 T+ |; e* f# r5 V7 d& ~
  643.     # Pull a different branch?! b& n% I9 r; l) K
  644.     case "$VERSION" in6 ^2 [- j% e. }& k$ l; s. w: M( ~, G
  645.       0), N: f3 v0 ~5 {3 M# @$ q2 k9 y: n/ J8 U
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')0 J/ |5 n# p3 J- ^' j4 ]$ r0 ]
  647.         ;;- r, {& T+ {6 @) v1 |6 u' x
  648.       1)
    , {! B  y. j" g+ O
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')3 R( c2 X2 _& n* V/ j
  650.         ;;
    7 R' f1 Z6 d: \/ {8 K
  651.       2)
    , R1 m' _" M" s! M7 C$ m) {
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    # j, d; [& H1 W  ~6 m8 ^
  653.         ;;1 o6 L& @/ C9 Q1 m
  654.       3)
    0 m$ U( s6 O0 h* }" q" Q5 u! e
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')9 j1 u' h  Q- V+ f7 P
  656.         ;;( ?6 S3 x! U3 `  {0 e" k0 K  Q4 B' [
  657.       4)
      @% g1 I) w* F) `
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    0 Z. q/ e3 `" a: R4 R
  659.         ;;& q, r, H+ b; `# E
  660.       *)
    7 _* [8 Q& z7 T" l5 B% M
  661.         Log "Error: Unknown version to select branch" 1
    / _' M5 _& x; f- G
  662.         ;;
    ) Y, K. {( o5 `0 @+ r
  663.     esac
    " |" k" w8 C% h% ^& w5 ~* i
  664. . E0 ?) p9 s& Q- C4 s
  665.     COUNTER=1
    * M/ _- I, N* o) G! R* q; ]0 `
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog
    ) z1 e( M+ r( R; t# K0 L+ d
  667.     for i in $releases; do
    / j3 Q8 ^2 H6 K
  668.       if [ $COUNTER -eq 1 ]; then
    * {; R- ?# T. P' I: G( T
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "4 W+ Q% [  N: F( Y
  670.         BRANCH=$i  g6 m' X5 o2 x* y
  671.       else( g. H1 R0 R6 i- V! ^4 [
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "
    6 f% ]% G* I+ P5 {- H6 T6 x
  673.       fi
    " @0 d. P% W+ Y$ u* B. S5 U; b* R
  674.       let COUNTER=COUNTER+1
    % ~: @7 I& ~; ~- L
  675.     done
    . e- i, i5 `+ N9 S$ w
  676. . e- u7 W0 w7 P  f7 a! C" P% k" a% {
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \
    $ P0 ]5 A' G  M7 z9 N
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    ! r% f3 Z1 I, B' {- S2 E  m
  679.       $RADIOLIST \
    0 \4 Y# j5 r% W& C$ P& U
  680.       3>&2 2>&1 1>&3)
      N- Y( w+ ]' Z) E
  681. * Z4 I/ D0 P* a! w5 P: k
  682.     # Exit if cancelled) N. ?7 N; U$ \
  683.     if [ $? -ne 0 ]; then
    0 u+ ]8 K: o) e/ n: p0 L4 D3 }
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1% _. D' a8 k2 S
  685.       exit 0* X. P8 e% e, B& v0 l& j
  686.     fi# F; d* I7 \( ?& B. H

  687. 6 |8 E- V0 i; F) [
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')
    ! S) Q9 T. E3 h; f

  689. 6 L  g8 Y$ L( w, P& z9 c
  690.     # Set the branch. i( f9 v& _" ]
  691.     if [ -z "$BRANCH" ]; then
    # X7 i1 k+ F6 p, x
  692.       BRANCH="$releases | awk '{print $1}'"3 u7 B0 ^3 `$ Y1 G
  693.     fi* u  a% H$ K$ f4 C, A
  694. + ~0 S" O2 d( y9 A+ V) O
  695.     # Clone the selected version
    & G2 S( s, S5 O2 i7 e* o
  696.     case "$VERSION" in6 ^6 T& D+ i7 M4 {; l! A5 A
  697.       0). }- J) H- V# A; y; l! H) q
  698.         Log "Cloning Zero branch: $BRANCH" 1" k3 _0 ~7 K/ Q5 b$ X" D' _
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive
    % X' M& h5 V, j
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive; G: U5 W' ~% I. h. G  N
  701.         ;;
    ' H9 w  K- X) X

  702. . \  M4 \8 l. e
  703.       1), G/ ^! E+ q: R" Z  _
  704.         Log "Cloning One branch: $BRANCH" 1
    ' L8 K+ U$ B: A2 f% ]
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive
      w, t: m; K# Y2 Z' x, X& |
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive" D4 ^' W6 Z% c4 t
  707.         ;;
    + L# K$ f6 I8 E, i: H% Y
  708. - J: s: o8 d$ ~+ q. I  F3 w
  709.       2)
    $ I: k) H" [3 X& D0 v, K
  710.         Log "Cloning Two branch: $BRANCH" 12 [3 f1 G/ w' b9 Y+ d( l( T
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive' j/ }( q9 |, w! C6 X* w
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive; A! e3 G+ s1 _7 J& ?5 x
  713.         ;;5 l- G5 J: j) ^/ z2 u
  714. ( L" x& T4 x' n" u
  715.       3)/ x5 `3 s# n8 V2 v0 n% p
  716.         Log "Cloning Three branch: $BRANCH" 1
    ! c. N* B6 p$ V# \: a) k2 l; O* j
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    % Z. a2 |1 N3 T9 B3 ?/ t3 q* d
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
    ( q4 A2 \) F) C: ]- X1 D$ X% E
  719.         ;;
    / i) }- ^9 ~1 u' r5 B

  720. $ g0 n& u: `: T$ N) O" o
  721.       4)
    ) e2 m0 n8 z8 ], g
  722.         Log "Cloning Four branch: $BRANCH" 1  L7 x+ a! A" T, [/ c
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive4 K; o& W5 u3 T) |
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive
    / D! H1 |( u+ p( O8 y
  725.         ;;
    " q; P1 K3 i7 l

  726. " V1 u5 e- F: F: S5 f* ~% l& y$ O
  727.       *)! k2 G7 M5 @  X: ?  n
  728.         Log "Error: Unknown release selected for cloning!" 1$ p7 J6 ]6 x3 o- V+ _
  729.         exit 1" ^, r5 G; C' n. C5 g3 I
  730.         ;;
    & [& J; u% e) U6 j8 @5 q; c6 z
  731.     esac% u1 I) v# ~3 ?% {# h
  732. , a8 d' K1 j; k3 p$ b. b
  733.     # Log success
    2 q; N; s- U/ d; n4 B
  734.     Log "Cloned the selected repository!" 1
    , I  g' J* j) {" W
  735.   fi+ V9 J# i3 p1 B  y- t
  736. : C. P' f" \7 Q- k8 r+ |: y% J1 I- d
  737.   # Update the local repositories if selected5 o/ @3 Q' H: f. T$ _8 A
  738.   if [[ $CLONE = *1* ]]; then, S- f% }% Y+ ?  d5 z
  739.     Log "Updating your local repository..." 1
    ; q: A, v/ M* @- h

  740. " H8 z/ a" ?- P0 _7 D
  741.     # Update the core sources
    $ b# c1 y9 z. c# Q& F
  742.     cd "$SRCPATH/server"
    & f& D* [' J4 x8 V* p3 C2 d) L
  743.     git pull6 V9 x+ Q( m) F& ^$ h3 Q
  744. - y  E' n% l8 }
  745.     # Now update the database sources5 n( ^& B  ?9 |5 o5 e
  746.     cd "$SRCPATH/database"8 w. S3 |) `$ h1 I1 Z0 X6 s( A
  747.     git pull( k1 i1 ~0 [; z4 e

  748. 9 ^& i5 B$ w! J; n  X- W
  749.     # Log success* M) U8 I1 g/ b" E1 G
  750.     Log "Updated the local respository!" 1; Q  w8 E9 S2 W* c& B4 e
  751.   fi. k2 R% S. ]4 ]! d* E+ x
  752. , G. B/ G6 M- e6 l# r* }4 ~
  753.   # use existing repository% x1 s# N2 ~2 C
  754.   if [[ $CLONE = *2* ]]; then7 o9 L7 a) m) n% V% Z6 L
  755.     Log "Using existing local repository" 1" A& \  n; y$ C- U/ U
  756.   fi  O: z% ~; ~/ p- x* L
  757. }
    " j+ Y1 ]( N% z# o1 ^0 O

  758. 4 h! P( A" B  R; o

  759. * G: @$ c  s% D; U
  760. 0 F0 O% v9 q8 `- M% k
  761. # Function to set the build options7 J; J. y% T. F: t( b4 S; M  O
  762. function GetBuildOptions()6 D8 L5 |+ Q; x' M) d4 q' V
  763. {; N' V, I$ E1 t" L( r
  764.   # Select build options
      {, [1 I( ~7 |, Y- s1 y( d/ D
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \8 N' |0 }8 _6 O& Y: A- F
  766.     --title "Build Options" \
    & _* Z7 z4 c; I
  767.     --checklist "Please select your build options" 0 56 7 \1 _0 X/ l% E. g
  768.     1 "Enable Debug" Off \$ m+ I- E% \$ v
  769.     2 "Use Standard Malloc" On \, K1 [/ @" E4 ?3 f6 w" u" V
  770.     3 "Use External ACE Libraries" On \2 f8 D' \" ^! y: Y
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    9 x# H3 ~4 r, I, q
  772.     5 "Build Client Tools" On \. `' J) C& {: d/ q
  773.     6 "Use SD3" On \, o4 k7 O( q( M1 r; d
  774.     7 "Use Eluna" On \/ U& _# `) z6 Y% P  r% ?
  775.     8 "Use SOAP" Off \& M# d* L$ j; Z, j% z
  776.     9 "Use Player Bots AI" Off \
    ) @; f2 y" ?* T$ N' w3 U2 F+ L
  777.     3>&2 2>&1 1>&3)- ^& F: D. Y$ q) A$ _
  778. * J: A! K' C% G1 i9 K
  779.   if [ $? -ne 0 ]; then
    7 t/ S4 D, m1 U- r; d  l
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    & g& l: A# k) a, F6 U- z2 p
  781.     return 0
    5 b0 w6 N& y, B7 r0 K  [
  782.   fi
    , J' O; z2 w. G0 u7 B5 m

  783. + a' S# y& S0 b
  784.   # See if debug was selected9 Y5 I* q4 ]9 r+ Q5 _5 r! n
  785.   if [[ $OPTIONS == *1* ]]; then
    8 T) W+ M  `* S) l' }
  786.     P_DEBUG="1"
    0 ?' j, [0 [5 c0 g' z
  787.   else
    4 D. D. h; g5 U
  788.     P_DEBUG="0"
    , t( p7 Y/ N3 {, U
  789.   fi4 v+ O# H6 a$ X3 k

  790. / }* ~% v' X! [5 z
  791.   # See if standard malloc was selected+ f1 M4 r+ |: n" n; J4 o
  792.   if [[ $OPTIONS == *2* ]]; then
    " a% m+ d# B$ k# D5 \  R
  793.     P_STD_MALLOC="1"* l5 {3 f/ U6 ~8 y% S: U9 V, h
  794.   else
    8 F7 Z6 N5 o8 Y, {' ]
  795.     P_STD_MALLOC="0") Z0 W/ g/ p% m; n5 z& }1 p- }+ G
  796.   fi. E' ]* N2 h/ H: h5 }# a

  797. : N/ P( M, e1 j8 N
  798.   # See if external ACE was selected% r8 F4 T6 f' I5 L- L6 [' m5 [- j
  799.   if [[ $OPTIONS == *3* ]]; then0 e$ {$ Z. t+ K( X' c
  800.     P_ACE_EXTERNAL="1"
    - V) F3 R3 `# e% g. x4 k, T' x  ?% D
  801.   else) |* J& X" [/ y
  802.     P_ACE_EXTERNAL="0"/ i3 Y/ \& U3 z. _
  803.   fi
    ! \2 d+ b8 L; G% c% W" a, ?6 Q) w! h
  804. / T9 @/ l4 G" L
  805.   # See if PostgreSQL was selected
    1 x' E( d" g5 s; r' c# d$ p, a
  806.   if [[ $OPTIONS == *4* ]]; then% v  Q& C( x8 h  F5 M. ]
  807.     P_PGRESQL="1"+ y0 k. `) N( C6 Y3 c  Z$ ^* t
  808.   else
    0 ]3 R5 G! F! S! b( K/ V
  809.     P_PGRESQL="0"" Y( E( p' l5 i* ~  J1 q8 F! j
  810.   fi
    2 v! N; y9 E, R8 g0 }, x

  811. ' y; [2 j/ L& ~9 Y$ g
  812.   # See if the client tools were selected# H! x1 F; [7 C/ F1 V4 ~
  813.   if [[ $OPTIONS == *5* ]]; then
    6 A, s3 ~( k; F" u: y$ H6 H7 T( R- e
  814.     P_TOOLS="1"
    , ~3 }. T& h: `. ?
  815.   else( u- ]* w/ r) o8 C" E5 ^
  816.     P_TOOLS="0"
    1 C2 U/ L- L0 U, m  u
  817.   fi
    " t  Q2 t: O5 i- c" @; @/ u; |/ M9 d

  818. * V  i0 M2 P3 z8 U  f
  819.   # See if SD3 will be used
    0 J9 q5 M7 Q) x
  820.   if [[ $OPTIONS == *6* ]]; then1 m+ @& u) w3 v, `
  821.     P_SD3="1"; x- Q0 A! `5 W' m7 V$ X
  822.   else% B; I- V" G+ D* ~
  823.     P_SD3="0"
    + c/ @, p# t7 C: {1 z, K
  824.   fi
    2 ~, M3 @$ P5 e, a. r
  825. ( r' H+ R* @3 Y0 c( z7 X
  826.   # See if Eluna will be used5 y$ I& W3 \6 a
  827.   if [[ $OPTIONS == *7* ]]; then9 ~, D: f8 g& w2 H
  828.     P_ELUNA="1"
    / ?1 [' S3 T2 ?( K7 ^. q
  829.   else
    4 n# }3 S$ k2 w9 b; [& n
  830.     P_ELUNA="0"6 ~, g- {% C) Q: v7 d
  831.   fi
    % G8 m1 I+ j1 w3 g
  832. 1 g5 n" G1 W8 d0 H4 t* E8 b, x
  833.   # See if SOAP will be used
    1 B( g8 B( G2 y: z* M9 g3 N
  834.   if [[ $OPTIONS == *8* ]]; then& E' y: @: P$ w. L8 S' h
  835.     P_SOAP="1"
    4 N* G/ m* U0 c7 u  L
  836.   else
    4 Y: q; ~9 _' g
  837.     P_SOAP="0"
    , h3 _! b/ ]9 i1 P6 t# h$ r6 }
  838.   fi8 k" _% l$ ]. l- Y) R9 t
  839. 8 ^* |& ]6 t8 h; R
  840.   if [[ $OPTIONS == *9* ]]; then
    6 {1 i: k. A  B5 z2 y/ a! a* H- D
  841.     P_BOTS="1"
    , `, w$ V. t" D/ U6 Z
  842.   else% M8 a$ d6 G+ }$ _& G6 i
  843.     P_BOTS="0"1 }% Z2 N; R- F7 I% U( i( W+ c) Z
  844.   fi1 }+ w( c- u2 G, Z8 s" P2 Q
  845. 5 Y% L  x9 S3 |/ Z3 D/ R
  846.   # Verify that at least one scripting library is enabled+ p3 Z. E2 U" G9 Z5 d  J
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then
    , G. K) V/ M4 e* U( j
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1
    % V3 }# O6 W/ E( G) H% _" ~
  849.     exit 1
    ( `5 q* u" M2 j: K* c
  850.   fi
    , w- N9 D4 ?2 M, q$ A7 P
  851. }( v6 X2 J% Y+ ^

  852. 5 W1 m0 }6 o( b3 x
  853. * V/ |4 E$ z' @9 M

  854.   @6 f  L( o; ~, K3 [7 l3 T
  855. # Function to build MaNGOS
    6 I1 \* X& u1 T3 c
  856. function BuildMaNGOS()
    0 W/ k. b/ g. ^) E
  857. {6 A9 y* C& c6 Y. A- P( w. Z4 O
  858.   # Last chance to cancel building
    0 O; y5 m) k4 o0 a6 O: ^
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \, t- q, {, U0 g% L* C
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 602 I) A# ]6 Y8 W5 [$ d* Q* P
  861. / ]4 g) u+ i8 G# @
  862.   # Check the user's answer
    4 N; S, _9 s, t7 j7 w1 A
  863.   if [ $? -ne 0 ]; then
    1 y* r6 E$ ?# A  ~3 a
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    # j* e% L* W  R( Z
  865.     exit 0
    ; g) M7 l$ ?! Y5 E  \
  866.   fi; n. ^9 J5 @2 h1 R( g

  867. / h- M5 z- ]8 N1 h1 h  ^6 M
  868.   # See if the build directory exists and clean up if possible! N7 _7 F& I( |* r: S
  869.   if [ -d "$SRCPATH/server/linux" ]; then7 |6 s8 H: ?# N. N; ]8 R! y
  870.     # See if a makefile exists and clean up
    6 v7 Q. \+ P9 {4 R6 _
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then: X9 f) V" _4 p% ^
  872.       Log "Cleaning the old build..." 1
    ( U. C8 d! d, m! ?9 l7 L
  873.       cd "$SRCPATH/server/linux"
    " ?. [2 e1 f% v" X( e5 e
  874.       make clean
    4 Q7 Q3 g1 x8 `! W8 G" i7 Y
  875.     fi
    0 v7 t4 e! g7 `8 |' ]
  876.   fi
    / R8 i# o0 M) R+ ]: X( {+ ]
  877. ) A  G4 \2 H5 a7 |' ~" D
  878.   # Attempt to create the build directory if it doesn't exist  p2 C- Z8 u4 e/ C# A8 I
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    ! p# m  h6 K# X; l: U
  880.     mkdir "$SRCPATH/server/linux"6 ]4 w& z% g* a. }+ P8 _
  881. 7 Q) ^( {% t& o) f5 t
  882.     # See if creation was successful
      b4 u  q; n3 k  g
  883.     if [ $? -ne 0 ]; then" R' V8 U; W( v% R. s/ g3 U) Q6 F
  884.       Log "Error: Failed to create the build directory!" 1
    0 a8 T" B% {' e' I; v( P
  885.       exit 1+ a9 ?# g% ?( H+ c- I0 G% m
  886.     fi! X$ v% T& [: e: V& }
  887.   fi
    ! @" y8 S' {0 V( y
  888. : f, T2 n7 J" t& y6 O
  889.   # Attempt to configure and build MaNGOS
    , E2 J2 A4 y- \5 ~. z
  890.   Log "Building MaNGOS..." 0$ V& S$ A4 q- r; |2 U. D9 c
  891.   cd "$SRCPATH/server/linux"# s3 N1 K- ]4 V& z- v+ f/ \
  892.   # make sure we are using the cmake3, K# n  t& i. S0 {' t! A
  893.   UseCmake3, Q6 N$ S7 F/ I, B# }
  894.   $CMAKE_CMD .. -DDEBUG=$P_DEBUG -DUSE_STD_MALLOC=$P_STD_MALLOC -DACE_USE_EXTERNAL=$P_ACE_EXTERNAL -DPOSTGRESQL=$P_PGRESQL -DBUILD_TOOLS=$P_TOOLS -DSCRIPT_LIB_ELUNA=$P_ELUNA -DSCRIPT_LIB_SD3=$P_SD3 -DSOAP=$P_SOAP -DPLAYERBOTS=$P_BOTS -DCMAKE_INSTALL_PREFIX="$INSTPATH"; i+ I  n7 i. l6 s
  895.   make. |3 ^4 A9 c5 O* m5 h( a  f1 e  @: |
  896. ( J' [4 |6 m, ^- e1 S  Q) q3 q. D
  897.   # Check for an error, T+ i" L3 r& @5 N# A& H( U- J
  898.   if [ $? -ne 0 ]; then( N( x7 I5 r5 c! n3 v
  899.     Log "There was an error building MaNGOS!" 1  C7 K/ F4 X' z% O
  900.     exit 1* ^4 V6 s2 f9 s6 s6 n  l& B% B* n/ U
  901.   fi: }& x3 I4 @  A

  902. - ?  X" Z, a. T1 P
  903.   # Log success
    , I5 E  s7 }. U! p3 h: N$ n0 _
  904.   Log "MaNGOS has been built!" 0# ?% p) R3 E5 r
  905. }
    : K) B4 R; t2 }; T

  906.   f, l) j& F* X, |( a

  907. 0 [$ w! H7 X/ N: A$ j
  908. 9 K0 K  @. j- S0 w# E, E& q: F
  909. # Function to install MaNGOS9 P7 V$ ?1 T7 K% \4 H
  910. function InstallMaNGOS()
    : m1 a; ]+ I7 j0 Z
  911. {
    6 u& {+ w$ e5 X6 b+ S3 R! c+ {5 o
  912.   # Ask to install now
    9 z9 O" R3 l7 m5 T1 s" {! o
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    . P( K1 ]( t5 P5 X, e% x0 ?
  914.     --yesno "Do you want to install MaNGOS now?" 8 0
    9 x4 T- f( n) p. J+ k/ `  z

  915. " `0 |; L1 h- o& v- ^/ a4 {
  916.   # Return if no
    2 \. t( ~9 \% d
  917.   if [ $? -ne 0 ]; then
    4 }) |' a1 f  f$ ?0 \  q" {: {3 t
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    4 l) U, v; d# z# I
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60: S5 B, K: n- W- _6 Q1 V1 d: s

  920. 5 i5 M- {+ P% J3 @9 b( `
  921.     Log "MaNGOS has not been installed after being built." 1
    / g4 B. G/ ^* s1 a3 j
  922.     exit 0- ^5 g6 o% e4 l. V# C( J- i
  923.   fi
    ) o& h: K' e4 t4 ~" X0 Q8 j

  924. ' K; d6 v6 Y/ p" Y) ~8 R, V: e
  925.   # Install MaNGOS
    . n( k) g' h& Q$ L
  926.   cd "$SRCPATH/server/linux"( \2 |1 D+ [) G
  927.   make install- x' u9 p2 @/ z. I, ^/ K2 w
  928. ( M% x9 c: j/ k+ {- ?4 I4 [5 {
  929.   # Make sure the install succeeded
    & w1 x, V& Z- [+ P
  930.   if [ $? -ne 0 ]; then
    5 x- E  n! G1 S+ X$ N) C
  931.     Log "There was an error installing MaNGOS!" 11 _! p* ?# |) I( p
  932.     exit 1# h9 `: `9 x% ^
  933.   fi- s# v: H% B8 r) R8 ]; a
  934. }
    $ E6 D. n$ Y7 V
  935. # {0 |6 X$ F  t0 B
  936. # Function to apply database updates
    3 y$ o7 J9 |" Z  s  @
  937. function UpdateDatabases()' p* d/ T# }, Y& R/ y2 G. M
  938. {, p7 p  ^9 W6 l! ~8 ~, w! S4 a0 N
  939.   local DB_HOST="$1"
    $ _! @* e  Q7 B2 V
  940.   local DB_TYPE="$2"
    % W6 q1 E& V- l# [/ ~7 ~
  941.   local DB_COMMAND="$3"9 S( n. z3 G7 \1 T5 u& Y
  942.   local DB_USER="$4"
    8 Q) e6 E" V" {, J
  943.   local DB_UPW="$5"( f9 m- W' U+ M9 P
  944.   local DB_REALM="$6"
    / f9 t# o+ v8 ~$ W
  945.   local DB_WORLD="$7"2 g. {$ M' T2 @0 q8 p
  946.   local DB_TOONS="$8"3 Z1 s; w: N  t& k

  947. 0 W9 x+ n5 k4 i( N+ t
  948.   # Loop through the character files1 k4 a$ S) t5 X1 m
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do9 h0 O, f) l$ B9 }9 J; i
  950.     if [ ! -f "$pFile" ]; then7 q0 ]$ F  ?) t9 K  U8 C$ s
  951.       continue- r. G8 ~' O1 c( k7 D1 C  i
  952.     fi
    9 m% q  x+ n/ j
  953.     # Attempt to apply the update
    ! @4 e' P0 q- W! L
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1
    4 d" O( Q$ M" W/ H3 Z# ?5 F

  955. * q% r; P$ e! P% U
  956.     # Notify the user of which updates were and were not applied
    6 G+ T+ z$ c1 M+ t. ~9 }
  957.     if [ $? -ne 0 ]; then/ x: P5 n* ^, X
  958.        Log "Database update "$pFile" was not applied!" 0
    % d5 Y# ~/ n. {9 Y
  959.        Log "Database update "$pFile" was not applied!" 14 g4 S  ~8 I2 L! D: i- a* A
  960.     else
    7 A9 }5 a, k, a
  961.        Log "Database update "$pFile" was successfully applied!" 0) L1 ^- }  _$ s; k2 h/ v, h/ S
  962.        Log "Database update "$pFile" was successfully applied!" 1
    - k' t  {7 r* Q! Z1 `8 d
  963.     fi+ G% `7 X1 `4 O4 @
  964.   done7 _' E% w& e1 J7 h" M5 @  m

  965. 4 \. _! U- o# F0 ~9 ]/ \
  966.   # Loop through the realm files6 l. G6 O. ?( t  j, V+ ^
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    ( w4 F1 X+ K" Z  a9 D
  968.     if [ ! -f "$pFile" ]; then
      X% d( j7 m& E( V. G& t
  969.       continue
    + D9 x; Y8 A% r
  970.     fi; b  w7 A; T0 o5 u
  971.     # Attempt to apply the update
    " @: u( |" r8 Q7 R3 A# h
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1
    + W5 Y) m1 y8 X: ], [) f
  973. 9 a3 i: F6 \& H* N" j1 R- v
  974.     # Notify the user of which updates were and were not applied8 p: p# p4 Q0 f2 q9 F
  975.     if [ $? -ne 0 ]; then
    * p3 H" l7 D. o; n& }$ i, O2 i- G
  976.       Log "Database update "$pFile" was not applied!" 0
    6 Q" u7 t) H( S6 I6 k8 q/ u5 ]% m
  977.       Log "Database update "$pFile" was not applied!" 1
      y  p3 C( U* P& F3 M
  978.     else
    ! {. _8 k. l  P6 u; [1 D1 I
  979.       Log "Database update "$pFile" was successfully applied!" 0  e) j- j$ ^% `
  980.       Log "Database update "$pFile" was successfully applied!" 15 _! b; i' g3 ?1 Y2 w
  981.     fi) j3 K3 y  o. d4 h
  982.   done
    , T! B8 l3 ^: ]! ^* T* A4 g

  983. - L2 n. F' E$ }) i' p+ {
  984.   # Loop through the world files3 T9 |' c* p9 P8 h7 H: L$ D" b; Q
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    7 s3 D) Y0 d5 i8 A6 E) N+ R
  986.     if [ ! -f "$pFile" ]; then' t0 @) M$ A5 o
  987.       continue
    & u9 |3 }- x  f# x
  988.     fi% p3 c3 p& s/ L8 I9 V
  989.     # Attempt to apply the update
    1 X2 V, l1 e7 f
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&14 x( m% B( [, p$ f# B1 G  a- q7 X
  991. 2 N; T# T4 u  Q! J9 \4 r* R% u. G
  992.     # Notify the user of which updates were and were not applied
    * r, U' w# j# x; ?1 x" m
  993.     if [ $? -ne 0 ]; then4 H+ [* t0 _* B; O" y
  994.       Log "Database update "$pFile" was not applied!" 03 r! o7 c& z) h) i
  995.       Log "Database update "$pFile" was not applied!" 13 v) S2 C1 F2 Z$ ?2 n8 ~8 W2 U
  996.     else
    ( M' T& k. Y5 v& Z; `* Z! L" {; L
  997.       Log "Database update "$pFile" was successfully applied!" 0
    + p0 b7 z5 w9 K/ G
  998.       Log "Database update "$pFile" was successfully applied!" 1& G, k$ R) ^% l0 T% a' d4 w8 j* i5 h% j5 u
  999.     fi) A6 p7 Q  w% `/ Y& D4 q
  1000.   done7 s0 Z) |' c7 H% b" z8 i% @
  1001. }* I0 b' k# g1 H5 [: b2 I2 i

  1002. 6 w. `4 D  N8 `) F: ~0 [/ j
  1003. # Function to install or reinstall the databases6 z: Y' _/ n' Q/ Q6 O, R
  1004. function InstallDatabases()
    ( Z9 o2 E( @2 P) i# v; z
  1005. {! m) p& i" h* a" e( s& n, a
  1006.   local DB_HOST="$1"
    ' K4 q* {3 ]+ A. C
  1007.   local DB_TYPE="$2"
    ' O( i) N! F/ t: s# Z
  1008.   local DB_COMMAND="$3"4 g' }6 [- Y: i1 p9 B
  1009.   local DB_USER="$4"
    - X8 c; Z8 Q: O1 w
  1010.   local DB_UPW="$5"/ P, x1 r( d3 s$ J  G( H& H, q
  1011.   local DB_REALM="$6"
    9 x, r+ y. k3 {5 Q6 f
  1012.   local DB_WORLD="$7"
    2 R* f- x3 I) @6 y3 e/ F- X' [
  1013.   local DB_TOONS="$8"
    6 l( U2 G6 d0 J- V2 Z
  1014. 1 r7 ~, q0 b3 B0 R% q8 N
  1015.   # First create the realm database structure, v3 D9 K9 Q* T$ y  ?2 U6 z' a
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql' W/ r* L3 D( {; `. ^
  1017. ; T2 v+ X( z$ O; H0 E
  1018.   # Check for success  e( k2 @9 M/ ^" x# X
  1019.   if [ $? -ne 0 ]; then
      o" z; ]; c2 S- c! ^
  1020.     Log "There was an error creating the realm database!" 1
    4 [) b& x3 P- Z8 e: Z# R# G5 g% |! m
  1021.     return 1
    0 q. {; P5 `7 O- X
  1022.   else9 J4 h: r. g0 ?* Q4 b
  1023.     Log "The realm database has been created!" 1) Y- K  v- v5 y. m; X" E1 L
  1024.   fi
    5 ?9 F* F. l. e: \5 R# O: [! v
  1025. / z4 a$ X6 ^4 X7 c
  1026.   # Now create the characters database structure
    / ]2 L1 e4 I) `/ g% E
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql9 l' H: X, Z1 |

  1028. * x# ^/ l0 n0 f# A) s3 k  `
  1029.   # Check for success
    9 H  K0 l6 _' H) m
  1030.   if [ $? -ne 0 ]; then
    ! W% y3 X$ B0 n* W$ F$ w
  1031.     Log "There was an error creating the characters database!" 1
    ( X. Q% I! P* k% R' m
  1032.     return 1
    * C  G/ h! ]# q7 Q0 Z: j- V
  1033.   else7 u* V( t+ U4 f- I" o! ~
  1034.     Log "The characters database has been created!" 1
    - W$ b7 _+ J5 d- ?
  1035.   fi
    4 y4 Z, v5 |3 C9 Z! u" a
  1036. + M9 [# X' ?' [. I
  1037.   # Next create the world database structure& k4 p/ Y1 g+ u2 `. k
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql
      A! a- k+ @; o& X

  1039. 4 i- ]; n' R1 M$ i7 X+ {$ |1 ~
  1040.   # Check for success4 W+ E7 w2 F. p, @' y6 b
  1041.   if [ $? -ne 0 ]; then# b5 ^$ {/ Q8 @5 x/ J$ {
  1042.     Log "There was an error creating the world database!" 1/ Z& J$ D3 {+ |: H
  1043.     return 1
    : a7 P* o# q( E8 }
  1044.   else' r* a2 a7 t3 [+ {9 k2 E* I
  1045.     Log "The world database has been created!" 1
    # m7 O; W+ G4 g& y0 N. m
  1046.   fi
    3 E% j, v9 n0 l. K/ d: h6 C

  1047. 5 f+ R0 U# U/ J* X, S% C
  1048.   # Finally, loop through and build the world database database  ~/ B# T) |9 S2 c5 ?
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do# r6 [% p$ U6 w/ [. r2 w
  1050.     # Attempt to execute the SQL file/ I! K3 L7 {/ M) W1 J$ K# \
  1051.     $DB_COMMAND $DB_WORLD < $fFile
    ; R" U: `8 x/ X! Z5 Y

  1052. - k, z% y1 y7 \
  1053.     # Check for success
    ! J$ K7 t" a/ F1 {& F& V; ]1 L
  1054.     if [ $? -ne 0 ]; then. u* `" `; s* j3 L
  1055.       Log "There was an error processing "$fFile" during database creation!" 1- O, j4 [( P/ I0 c
  1056.       return 19 |& ]4 j. K! z( X4 i& B
  1057.     else: C( J' J( g0 S3 X/ ]% G3 R
  1058.       Log "The file "$fFile" was processed properly" 13 p5 f, t( I9 H- H  B0 Z, S
  1059.     fi5 S1 `( c( Y# t% K5 p: ?- a
  1060.   done
    / A  P$ ?$ a) v; d$ G8 s' d' s1 J
  1061. ( v4 H3 h8 K3 c/ }1 W
  1062.   # Now apply any updates; S7 _7 w# f  X, h$ M
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS, j- ~# S+ d& W1 n2 l3 u
  1064. }! m8 _8 i' U5 {6 Z- {! ?+ C
  1065. & i& r# B! q  X8 |# X5 ~
  1066. # Function to install or update the MySQL/MariaDB databases
    % ]9 Q  `6 Z# C+ u" V
  1067. function HandleDatabases()0 W) B' K/ p: h! w
  1068. {6 x# C6 z0 P& a% O* G
  1069.   local DBMODE="0"7 o. L4 \# a8 R- S2 ~
  1070.   local DB_TYPE="0"
    + V; G4 U/ p& O
  1071.   local DB_COMMAND=""# {7 K3 }+ H/ u9 E
  1072.   local DB_TMP="0"7 b7 T0 b3 c! f. @
  1073.   local DB_USER="mangos"
    ' w# N3 R# A4 F  `* ?0 h4 q( [) @& [
  1074.   local DB_UPW="mangos"
    / T" D7 M; X; v. F, U3 \
  1075.   local DB_HOST="localhost"% M2 |' |# R6 k' J  ~  y) ]% x8 m) `
  1076.   local DB_PORT="3306"
    # [$ f6 x# {% A6 z: z
  1077.   local DBSEL="3"* R* U  q+ P9 i
  1078.   local DB_REALM="_realm"
    ) W/ y. L: o+ R7 P- E  r  n
  1079.   local DB_WORLD="_world"
    8 |# Z1 H# l: ^: e  h. @
  1080.   local DB_TOONS="_characters"% C: k1 H; J/ P! i: a( r

  1081. 4 c! l. j( c: h+ t
  1082.   # Ask the user what to do here
    ! h/ r! L' S. x8 |. J
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \+ U2 Y! k' h8 ?1 S! z& L' G
  1084.     --menu "What would you like to do?" 0 0 3 \. p7 N; P/ T  }1 t2 L
  1085.     0 "Install clean databases" \' S9 l3 d' c8 b+ E  [
  1086.     1 "Update existing databases" \
    - E( _9 ?& Z" c/ t9 d6 X
  1087.     2 "Skip database work" \
    " T( J( J& W, o, S4 C
  1088.     3>&2 2>&1 1>&3)! I4 e9 D0 ]# O6 ?% g/ p

  1089. " g! p6 k1 T- f2 i" W* Z
  1090.   # Exit if cancelled
    4 U- ]$ p9 ?/ z
  1091.   if [ $? -ne 0 ]; then
    ; C; x2 S5 _; z
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1: [4 L+ W5 c1 f+ ?( c% E6 d1 W
  1093.     return 0
    ; R) P% o2 Z9 w5 W' P' L
  1094.   fi
    5 [' [. q7 H+ C" \

  1095. 5 e6 O+ S* R8 K4 {$ Z
  1096.   # Exit if skipping
    7 Q8 y- V$ |' o2 U; ^
  1097.   if [ "$DBMODE" = "2" ]; then
    8 [/ D; h9 \9 \5 B5 b8 o9 k
  1098.     Log "Skipping database work. Nothing has been modified." 1. e) f, J$ ~1 d
  1099.     return 0# b* X8 {. R; E/ @- u) p/ Z: u& g; `
  1100.   fi6 X2 L) V% E* `$ E4 |( g

  1101. " S3 C0 b" A$ @, \7 ?: ]! J
  1102.   # Ask the user the DB type
    . I) E3 t9 \% T2 Q- T# J
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \
    & X- T8 d1 q2 R! ]  T4 D4 R% _
  1104.     --menu "Which database are you using?" 0 0 3 \
    - t! C' T& D3 I3 \9 S8 C
  1105.     0 "MariaDB" \
    ) z' T$ Y2 u+ l
  1106.     1 "MySQL" \5 h6 i1 w. j8 @3 u3 C
  1107.     2 "PostgreSQL" \$ x( h. t* |" A  y6 |, m
  1108.     3>&2 2>&1 1>&3)
    * j# E! [& X" C1 C6 t
  1109. / V# l( V. D( ^; ]; h8 }9 F
  1110.   # Exit if cancelled
    9 M7 p" X% G0 U1 k6 V/ s
  1111.   if [ $? -ne 0 ]; then
    ; G' \. ]+ Z5 K6 [' y
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 1
    0 u; t7 o" t/ k1 [8 F0 Q
  1113.     return 0
    ! _/ F% d# {7 _5 X
  1114.   fi9 ]0 R- |$ O- F/ }* |( p& L( G8 G
  1115. " e, }% a$ h/ i+ ~
  1116.   # Get the database hostname or IP address& P) W, `$ G. [$ h- ]+ y! l
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \6 ~% O3 ~( q  x: @5 q9 \
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)
    ( T% P" R$ g. v3 G5 K- A. U
  1119. - }% N4 R7 q7 q2 i7 y& E
  1120.   # Exit if cancelled. g' ~5 \# f/ k- l$ \
  1121.   if [ $? -ne 0 ]; then6 h! R5 s* H9 L" p$ r2 Q& t
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 1
    % \1 j: L+ y& D# A& C+ Q* p
  1123.     return 0
    & }' Q7 N& s) I# u3 j$ {3 e, b6 q
  1124.   fi
    9 Q+ n- v" {/ @) P$ l* ~

  1125. , t2 M) G# w9 A: ~/ M- ^0 V( X  u
  1126.   # Set the hostname or IP address if one was specified
    9 I. |6 {6 e, I$ K! K. ]
  1127.   if [ ! -z "$DB_TMP" ]; then
    ! X" F8 f! D. h6 p
  1128.     DB_HOST="$DB_TMP"
    - v' q8 \! e' l5 w- B4 U
  1129.   fi
    1 N4 T/ G' [" y, C

  1130. ; J0 ]& g% J- j7 g$ C5 A
  1131.   # Get the database port
    ! |9 d+ {  o2 O
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \  f  Z( Y& e( U" v
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3). Y# [; X1 K/ f( _4 y  F$ r
  1134. 6 Q/ u  S: h7 r# w8 ~4 l+ o
  1135.   # Exit if cancelled
    % {1 ^" z5 ?$ J4 C6 D+ \
  1136.   if [ $? -ne 0 ]; then$ ^# v) [2 W3 y+ k3 i; j
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1
    5 C/ e+ w* Q4 g# @/ w( R" Q
  1138.     return 0
    ) o' D% W8 L' ?% P/ }9 s# E3 x
  1139.   fi
    $ t% L% A7 w- s& s* r

  1140. ) D+ O( @+ Z3 {' K5 V7 `% o
  1141.   # Set the port number if one was specified7 y" S0 F" D$ A  r
  1142.   if [ ! -z "$DB_TMP" ]; then. p# x  ~+ }  D- F2 Y+ h
  1143.     DB_PORT="$DB_TMP"
    * w; Q: I1 j$ ?
  1144.   fi- `; R  r1 o& H9 O* D* L8 @2 d$ m- q
  1145. 9 n) c# X5 K: u/ Y- Z7 D) X  F
  1146.   # Get the database user username
    & q* }/ L0 w: t4 |& x% f
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \
      x, L5 S9 m1 x( k
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)
    * \+ S6 L  ^5 u

  1149. 7 c# w' N9 ?0 e# F
  1150.   # Exit if cancelled
    ; W0 b& K" v& Z& U7 m$ Z
  1151.   if [ $? -ne 0 ]; then- i7 V' g' ?* P* [
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1
    - B6 _* x5 t5 k' W
  1153.     return 0
    . m1 V- P5 H) \
  1154.   fi& P4 a  _) y, j( F0 I$ k
  1155. & ^7 O/ G( Y, J" q$ V% R) w/ H
  1156.   # Set the user username if one was specified
    , K- v" @: O& a- k7 A
  1157.   if [ ! -z "$DB_TMP" ]; then" W, w8 N* V% H2 [& i  N
  1158.     DB_USER="$DB_TMP"
    5 p  X- B& S& M, z9 C8 I
  1159.   fi
    * E8 r: |) A0 X- W! [; J2 e

  1160. 7 q6 T) W) g+ s+ T5 \
  1161.   # Get the database user password; w- |7 K- U- q1 s6 {9 l
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \# e/ L& P$ m# K9 G0 E
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)8 c* d- q1 S6 ~& g

  1164. 4 M: F0 i& {, U
  1165.   # Exit if cancelled
    6 a3 p' ^& c. e: ?
  1166.   if [ $? -ne 0 ]; then" T# B# }5 J: w% w
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 15 u7 r9 [* n( G
  1168.     return 0
    & R/ ^6 Y; n9 \* V3 q& V/ u# T. `0 J
  1169.   fi5 [, D0 C* G6 \- s

  1170. / H3 \3 }+ L; b6 T# c
  1171.   # Set the user password if one was specified% D$ y+ J; W; a. Q/ L
  1172.   if [ ! -z "$DB_TMP" ]; then7 Y& M; p2 e, }
  1173.     DB_UPW="$DB_TMP"5 T7 c: M6 K4 F- T9 G% B' Z' I
  1174.   fi
    ; Q$ O5 o) V! [3 @6 m

  1175. 5 I% P5 n" r6 K" z6 Y/ V
  1176.   case "${DB_TYPE}" in
      n, Q! G8 L2 G
  1177.     "0")$ X! n7 o6 w9 c; M2 }) L
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "' K6 y4 E& @& d3 H7 E
  1179.         ;;: w% ~5 K, K/ k- L5 T4 q3 W- P
  1180.     "1")) ]' [0 p7 x4 ]3 i* N% S
  1181.         printf "Confirm your MySQL password\t, "7 K' ~3 l4 \+ j. r- n
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn
    2 \0 W; x; f2 n& A7 |7 ]9 Z
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    # H1 G3 S  B6 l& K4 Y$ h- r
  1184.         ;;
    7 b/ |* t; k: |, L6 D$ {
  1185.     "2")
    * G. y, L% v0 M3 B! A
  1186.         Log "Currently not supported." 10 l( t3 }! L, v& P) {
  1187.         return 0# U3 w. F& n$ S8 M  G  M8 l
  1188.         ;;8 L) s: F6 Z" Z2 n1 P
  1189.   esac1 Z0 ]0 x/ @. t6 i0 i

  1190. + h) a, m2 Y4 S/ `8 o5 C+ i
  1191.   # Setup database names based on release
    # q: z( T& g9 y0 Y2 J* l7 M* i# M) U
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"
    * y8 i/ i* f' g
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    ' u8 z  Q( p9 \6 f. }$ S
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"/ W( ]: L( M% M) k" Y2 h
  1195. 7 Z. g' G$ D* h! x
  1196.   # Install fresh databases if requested
    9 x& m: w- d2 G  g* u/ }
  1197.   if [ "$DBMODE" = "0" ]; then! A0 f( m+ ]* W' G8 k5 l
  1198.     # Ask which databases to install/reinstall
    3 d% S' z: X) w! G8 p- \1 K
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \
    " H6 a) C6 j6 @- k
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \
    ( n) \4 G* m) G( ]5 h  d9 c4 T
  1201.       0 "(Re)Install Realm Database" On \
    9 Z9 m8 l2 V5 ~8 P4 a! c- [
  1202.       1 "(Re)Install World Database" On \4 m; g+ e& y3 x8 R
  1203.       2 "(Re)Install Characters Database" On \
    . V/ J- f- n) f) D
  1204.       3 "Update the realmlist" On \' q8 E4 X8 d; k; z# c5 F4 R3 C( J
  1205.       3>&2 2>&1 1>&3)5 B: h: m$ [1 Z9 K2 V5 y
  1206. $ D3 f* H' t5 U* }
  1207.     # Exit if cancelled
    8 \# K8 {3 O6 N0 Z5 j& k7 V$ x
  1208.     if [ $? -ne 0 ]; then# B$ i  R2 I! \1 [4 _
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1$ ^8 X- x3 H+ J: i" o% N. J
  1210.       return 0
    , z; d0 g- ^& a% w0 E$ }0 o
  1211.     fi
    8 s* x- J+ o# ?: j* t& l9 o  T
  1212. 7 a. E8 o8 l: e6 c( c" n
  1213.     # Remove and create the realm DB if selected
    ' [1 G. Y3 m$ l4 \( Y$ r
  1214.     if [[ $DBSEL == *0* ]]; then, t; R. g; F5 P/ X: U3 ^
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"& a; z. v/ L( y  ]; H
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"
    + P8 n, ~: O1 P3 i
  1217.     fi
    + m; n5 x6 k" |' F( Q9 A) z$ C$ `
  1218. 0 u+ t  @; l5 k, K0 v* I* b" {' F
  1219.     # Remove and create the world DB if selected3 |  e5 t$ z- p  n1 J4 a* i/ T
  1220.     if [[ $DBSEL == *1* ]]; then% N5 w0 ^2 x% g4 w3 }
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;". B( L+ H) e' \( T" Q4 x. r
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"
    # q. o* O. f. ?& }
  1223.     fi
    * u. N5 T, [! k9 `: k- F8 {( E" A

  1224. & C6 K5 X) N2 P  G3 |. r
  1225.     # Remove and create the character DB if selected0 U* k/ T( u! I3 L% s
  1226.     if [[ $DBSEL == *2* ]]; then
    8 g- n' Y/ X6 v; i. D
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"
    2 O  ]" u1 r1 U
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"
    - r, c9 g$ J. L
  1229.     fi
    / c: K1 E0 R: _; y
  1230. 9 Y% y2 j8 p& q$ W, n8 Z
  1231.     # Validate success
    : |/ U2 m" v5 T8 }6 g# O% `
  1232.     if [ $? -ne 0 ]; then
    / P4 n: b* A  u! I
  1233.       Log "There was an error creating the databases!" 1, g& G4 b" U6 D4 f! S- |* X
  1234.       return 1
    0 ]2 V" T3 `1 l, [& i
  1235.     fi/ p& v" r' k/ |# S3 o5 Y
  1236. , l8 D# T$ W" b8 @, F* U
  1237.     # Finally, populate the databases, }9 P1 c3 `4 [
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    ; i5 H8 n3 i- A+ N& Y9 c
  1239. * R/ G% p, P9 W( R3 [* @2 h
  1240.     # Updating the realmlist
    % q( w  U. K6 O: I8 @6 \* g' _
  1241.     if [[ $DBSEL == *3* ]]; then
      V8 W% B2 B* V" }+ N9 L# u' ?1 v
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql
    & `3 {! A# ^) n' E2 Y4 V; |
  1243.     fi
    ' R  Y, Y9 @% O7 j6 L
  1244.   fi  ~, ~' Z/ p! @6 ~- g

  1245. 2 h- x6 f0 I7 d: `' U
  1246.   # Update the databases if requested
    $ \6 f/ m7 Y# n; Z$ ~* l( I
  1247.   if [ "$DBMODE" = "1" ]; then
    & U2 K& g  ~* h! \6 g* z
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    / s- p& w4 C5 Z3 z
  1249.   fi
    1 k. k( f- r% W8 `  X
  1250. }0 Z. |& ~7 C& ]) S% j

  1251. ' K+ }8 b: A1 ?  H' c( j
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
    0 L8 k0 y1 |' X5 B) O; l6 R
  1253. function ExtractResources) ?6 _% B! H  _# V  [
  1254. {
    9 C/ ]* [9 b5 U# ]  E1 @! v
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))2 D3 P. l6 ?$ J9 C% S; i% |! D

  1256. 5 C3 \  b2 t4 R/ l6 \& Y
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \" g+ i0 t0 ?0 B% f3 Z
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)
    ( i) g' F" g7 E% m. n2 U
  1259. ) m0 h/ _3 ~7 _
  1260.   if [ -z "$GAMEPATH" ]; then
    0 U+ c( {9 x& F7 t+ r' S) t. H
  1261.     GAMEPATH="$INSTGAMEPATH"- L+ O& z2 s  e
  1262.   fi( t' a- m# w) q6 v( V4 m9 D
  1263. / K6 }$ f2 P' `$ m
  1264.   if [ ! -d "$GAMEPATH" ]; then
    + D# \- l* b% ?- x& o, w
  1265.     Log "There is no game at this location" 1% _2 f/ E* ?: i6 J- p
  1266.     exit 1. M' ?$ b$ R% {, T( h$ ~
  1267.   fi
    + w5 P3 E' b6 x1 v! {
  1268. ! q' [2 W7 j- g' F6 b0 i
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \* _: K9 h( c6 U- ^8 d
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \% ^, _. ^1 M* I$ p2 ~" S
  1271.     1 "DBC and Maps" On \
    " k+ |: X) c5 ^5 L5 ]' d& r
  1272.     2 "Vmaps" On \
    $ z  j; O4 `$ [. E/ O! w: B+ M& }
  1273.     3 "Mmaps" On \$ g4 o+ u! e( Z' ~! W
  1274.     3>&2 2>&1 1>&3)
    % I" ?0 k7 @9 _& l: h2 E. ?6 t0 |

  1275. : A( h( K1 `2 i. L4 Q% R: T
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    ( [  }0 V- J, P; L
  1277.     Log "The client tools have not been built, cannot extract data" 18 K/ D9 O# I1 I) Z  a( v% X
  1278.     exit 1
    : [: Y1 B7 x, w5 d# t9 m8 l7 R( S
  1279.   fi: x* h9 H* J% P- V+ E8 y# ?7 X  \; T
  1280. 9 n7 Y8 c8 P  K1 o9 u( g& `
  1281. #TODO What if DBC are not yet generated ??$ u4 |9 O' a7 P* w7 M" U
  1282.   if [[ $ACTIONS == *1* ]]; then3 x7 n# Y3 n8 t+ w
  1283.     if [ -d "$GAMEPATH/dbc" ]; then! b$ f) F! v7 p
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \/ O& d" e) K; W
  1285.         --yesno "Do you want to generate them again?" 8 60
    : K8 r2 J# v5 a; Z: |8 g, u( z
  1286. # Z" i4 z* T' e9 @
  1287.       # Check the user's answer* _, R) E/ @1 ]( G+ y4 V( i
  1288.       if [ $? -eq 0 ]; then
    8 m) Y. I4 [* P: A( O% D
  1289.         Log "Deleting DBC and Maps previously generated." 19 V9 l+ Y6 X# B/ \, p8 Y
  1290.         rm -rf "$GAMEPATH/dbc"
    , T! v( N9 b# Y+ k0 a4 p2 g
  1291.         rm -rf "$GAMEPATH/maps"
    $ {& O, t$ P/ Z- h3 i* }1 b
  1292. 5 b5 D! ]/ R- ^: \5 f' A
  1293.         Log "Copying DBC and Maps extractor" 0
    ( V! ~& |$ i  T/ `0 ^" b& H
  1294.         rm -f "$GAMEPATH/map-extractor"4 P$ c8 `1 t9 n5 ^& Q7 ?9 n! v% U
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"+ }' F% A2 i( J* x- ?9 W# u( s& j

  1296. 9 ?9 x. ?/ k) O- I7 ?- r5 L
  1297.         Log "Extracting DBC and Maps" 0
    * r6 w! X$ H8 p: p% \6 I
  1298.         cd "$GAMEPATH"
    " u9 I9 [! H8 O) B) D
  1299.         ./map-extractor' Y! U9 d5 s( P8 Y
  1300. * @+ R5 q3 F) P0 N
  1301.         if [ $? -eq 0 ]; then
    7 a) Y7 i6 l$ g1 e& x0 Q
  1302.           Log "DBC and Maps are extracted" 0
    ! J7 R. ^! l$ q* g& r
  1303.           Log "Copying DBC and Maps files to installation directory" 0* b( M5 @) f: r+ E- b
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    8 K* U$ ?+ h- v# R/ D- D' m
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"  O. U! q/ L/ O; ^- Y
  1306.           rm -rf "$GAMEPATH/map-extractor"0 b2 Z& X! a; T7 Q' y
  1307.           Log "Changing ownership of the extracted directories"
    5 @# t( Y. i; f' Q, Q
  1308.           chown -R $USER:$USER "$INSTPATH"
    1 H/ b' n, c# T0 L) i+ S) c( S
  1309.         else
    8 @  z- [% F3 _: _
  1310.           Log "There was an issue while extracting DBC and Maps!" 1' F1 x0 `+ }# n8 [
  1311.           rm -rf "$GAMEPATH/map-extractor"
    4 V3 M" v) K/ l8 T5 [
  1312.           rm -rf "$GAMEPATH/dbc"
    8 r/ R" C& n0 B. ^9 }9 d+ A" M" R
  1313.           rm -rf "$GAMEPATH/maps"  O6 g6 F& R8 S- y4 y( A3 ?
  1314.           exit 11 Q* M- ^' ?: I7 m
  1315.         fi
    9 z3 g! N1 |; D2 }- E& h
  1316.       else
    % y: x" Y4 s4 f  c6 X
  1317.         Log "Copying DBC and Maps files to installation directory" 0
    ' k+ K. g1 i& g0 {
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"+ p6 L' T. M, }
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    ) _" R- B# w4 [3 l8 J8 I
  1320.       fi( C& D: O+ A/ o  _
  1321.     else
    + S9 I5 t0 c: [0 p3 ~% _# ~
  1322.     rm -rf "$GAMEPATH/map-extractor"! j1 o2 p( f4 W, y  [
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"  Y, `: i2 a! ^" W' y1 n+ y1 M* Q- I! G
  1324. 4 |( Q, c  V, D8 F! g0 [, o
  1325.     Log "Extracting DBC and Maps" 0* l5 n/ j- ~( x9 C/ i5 C% ]
  1326.     cd "$GAMEPATH"  p# Z! m% v0 @
  1327.     ./map-extractor
    ) q3 y8 G4 v! A, k) s& U5 |7 y

  1328. 5 t  ], ?) P/ T: r5 B
  1329.     if [ $? -eq 0 ]; then5 {8 h7 m" P" P
  1330.       Log "DBC and Maps are extracted" 0
    . K: P: q/ H2 b% g. N# W
  1331.       Log "Copying DBC and Maps files to installation directory" 0
    - E5 c# F% m6 N
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    " P$ o1 S* `0 Z1 J0 P8 q
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    9 d* _  ]" l  p+ i1 U+ X  ~- `; A
  1334.           rm -rf "$GAMEPATH/map-extractor". A4 [, T& [/ x! \
  1335.           Log "Changing ownership of the extracted directories"
    + J5 C9 U0 z; Q' h
  1336.           chown -R $USER:$USER "$INSTPATH", t; t( v8 B" N2 i. k/ t
  1337.         else& c1 \/ w5 F6 ]
  1338.           Log "There was an issue while extracting DBC and Maps!" 1
    0 G/ z/ t  a6 g" ]
  1339.           rm -rf "$GAMEPATH/map-extractor"
    . T! a" W' w- K3 X1 V4 w0 _3 g; {
  1340.           rm -rf "$GAMEPATH/dbc"/ l: [6 i; t( v& n6 C' p
  1341.           rm -rf "$GAMEPATH/maps") L9 J+ i6 m4 E  I+ h+ u! h/ j
  1342.           exit 1
    + c1 G: x% y  z2 B) e8 K- i- A; V
  1343.         fi
    , V  ^+ a- i2 Z
  1344.     fi" {4 y2 \) K* I0 T$ J. U4 }5 A9 a
  1345.   fi
    2 [0 W" Z! ^, w( W9 J' O
  1346. 6 k$ M* K, F% p3 q& J+ H0 Q8 |+ x
  1347.   if [[ $ACTIONS == *2* ]]; then
    ) S0 O3 Q" e" I5 _1 a2 D
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then6 h2 ^/ k" d5 g0 ?+ O! m5 M
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    8 D6 E3 e0 s- z" l
  1350.         --yesno "Do you want to generate them again?" 8 609 z0 v! _& E( b

  1351. & l+ k1 I5 [! H/ i5 ?; h! q7 m
  1352.       # Check the user's answer: N9 X# E+ K6 K6 E4 E: L
  1353.       if [ $? -eq 0 ]; then# k: c, Y9 I6 e1 _6 F( ^2 v
  1354.         Log "Deleting VMaps previously generated." 16 Y: u' P( \3 {4 j1 i
  1355.         rm -rf $GAMEPATH/vmaps+ G  v0 f+ p1 Z9 q* T
  1356.         Log "Copying VMaps extractor" 0
    1 H7 X5 P8 ^: Z$ r5 z7 L
  1357.         rm -f "$GAMEPATH/vmap-extractor"9 u9 z7 v! H+ j
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"8 Z! z- D! R  f( B' C

  1359. . P/ J* l8 z4 u# s/ f2 B9 z
  1360.         Log "Extracting VMaps" 0
    1 }: z( m! }* |5 V2 E! X
  1361.         cd $GAMEPATH% [' d$ Y; T7 t$ I; C8 a, m) ]3 ~
  1362.         # Make sure there is no previous vmaps generation that cause issue.6 G8 g& E: c* z3 y: w% Y5 b
  1363.         rm -rf Buildings
    # ^* m" z) H1 F6 a1 }# S: u( }
  1364.         ./vmap-extractor
    : b- o  k% c$ z* f- e3 J5 k

  1365. 7 F7 q& ]+ W) u! u/ A: z9 x, D
  1366.         if [ $? -eq 0 ]; then
    $ X2 b, B# a) o' Y9 p$ X
  1367.           Log "VMaps are extracted" 0; R" |+ Y# d7 e* \) ?
  1368.           Log "Copying VMaps files to installation directory" 0
    & i+ M$ [8 l# b; H, t( [' q2 m
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"4 _( X' s7 H3 i4 ]" j
  1370.           rm -rf "$GAMEPATH/vmap-extractor"" K. m( Z- ]8 B; v! d* M
  1371.           Log "Changing ownership of the extracted directories"5 f5 Z0 Z7 m6 W6 P! b+ m1 L  `
  1372.           chown -R $USER:$USER "$INSTPATH"* e8 W3 @% w6 m! }: ?
  1373.         else& O" }% k* V' i4 w& _
  1374.           Log "There was an issue while extracting VMaps!" 1
    + Q- S  t( l$ p
  1375.           rm -rf "$GAMEPATH/vmap-extractor"# I; [1 Y2 q% G; D! R
  1376.           rm -rf "$GAMEPATH/vmaps"
    1 f" q: B+ X" W% w
  1377.           exit 1/ }3 Y, A, F* T! A* k3 p
  1378.         fi3 y6 h6 v1 D& j* N
  1379.       else* o" a& h8 T  m5 V: w* p2 O* u
  1380.         Log "Copying VMaps files to installation directory" 03 h6 {0 g7 f& G3 H7 t" u
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    ) g; g* n; X) s: d+ b7 U
  1382.       fi
    ) ?7 v: P- x9 E! A  P
  1383.     else3 G! V+ U6 o: y. w9 E5 ]- g" |0 f2 n/ I
  1384.      Log "Copying VMaps extractor" 04 m0 _! Y+ D  ?8 E8 d* E& A: b
  1385.      rm -f "$GAMEPATH/vmap-extractor"' D) n% t+ M# Q, ]2 f4 h
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"+ ?' k% u0 g% `0 q) i+ a
  1387. 5 Q" r6 j7 C9 C) [2 U
  1388.      Log "Extracting VMaps" 0
    : c% \7 d  q0 [0 [& W! p
  1389.      cd $GAMEPATH
    2 ]0 \3 F/ f7 ]# W0 M0 j! X
  1390.      # Make sure there is no previous vmaps generation that cause issue.# e0 H/ i1 i# Z" |
  1391.      rm -rf Buildings0 B0 n" a- i9 ~
  1392.      ./vmap-extractor( i0 ]7 h2 e& K
  1393. 3 v; A+ L% \2 i6 F$ Y) r0 i
  1394.      if [ $? -eq 0 ]; then- l  a. q. t) S5 T! K% D' _
  1395.        Log "VMaps are extracted" 0
      e. c5 Y. B$ p$ b+ Z5 r/ U
  1396.        Log "Copying VMaps files to installation directory" 05 N% D. ~7 k7 [1 c, ^5 X
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    * ~4 I6 g/ `& S4 I6 F
  1398.        rm -rf "$GAMEPATH/vmap-extractor"7 R: s  \& p1 |: ^
  1399.        Log "Changing ownership of the extracted directories"
    * F# e. r" ]; V* j
  1400.        chown -R $USER:$USER "$INSTPATH"
    : d  D3 R; ]  Q
  1401.      else
    - c  c8 h6 a1 w
  1402.        Log "There was an issue while extracting VMaps!" 1  S8 o; g. B- p3 _
  1403.        rm -rf "$GAMEPATH/vmap-extractor"
    3 {& N- t: p  ^( V0 R" ?
  1404.        rm -rf "$GAMEPATH/vmaps"
    ' j  b0 c' m( f3 H- D
  1405.        exit 1$ w9 s' D6 o7 [$ C. L
  1406.      fi
    5 M( _4 W' I+ G) w0 }/ L' M6 a( I0 d  f- `
  1407.     fi
    ; I% `9 D- `% s. o* E
  1408.   fi
    * d  o! o  B: [5 g) R2 \" R

  1409. ) _9 e. [$ i4 X- @+ C. o
  1410.   if [[ $ACTIONS == *3* ]]; then! P4 {, X  t5 Y! l
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then2 o' D- ^' F1 [3 V5 s
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1/ w3 K4 W, N4 [8 z6 p
  1413.       exit 1
    ; n' W; Q. j0 M- K9 U% F/ K
  1414.     fi0 }- r4 k7 @: u7 q) Y' m$ \) N! l
  1415. : p" \$ e2 G$ C
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then1 V1 J0 o* a: W( G
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    6 M1 a0 v( A5 ~
  1418.         --yesno "Do you want to generate them again?" 8 60! O* z4 q2 n0 r
  1419. $ h" X- P) l" {3 k
  1420.       # Check the user's answer
    # p  }/ `- v( A. z$ S7 N$ X
  1421.       if [ $? -eq 0 ]; then
    7 g) L; A9 r7 A
  1422.         Log "Deleting MMaps previously generated." 1
    & a5 }% I8 ^4 {: ?, \1 _2 {
  1423.         rm -rf $GAMEPATH/mmaps% a7 F& ^6 q: f4 b) z/ G8 Y
  1424. 7 f# E. L2 c% L4 S- g+ M  D# {/ z: E- R- y
  1425.         Log "Copying MMaps extractor" 0/ b# P  E  W) `+ H! c# h) B
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    2 {7 I/ e: o3 s; S, b
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    6 Z' i$ t5 }$ }; y: V& O
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"  N) Y0 \  v# r+ C) O
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    - A" U5 k3 D* u7 r  {: [
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH". v8 Z/ R0 L/ v- f$ d+ A

  1431. # z& Q+ \" \1 Z  E
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \) Q! d" k0 `8 m% J, i
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3); |* t6 w. n* m4 L. D

  1434.   ^$ h; T( K6 N
  1435.         # User cancelled his choice, set default to 1.
    * d# ~2 c3 |0 l( T& ?
  1436.         if [ $? -ne 0 ]; then
    8 ^" I0 C, S* G0 |2 ^8 u! O
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1
    ( M2 R# r8 Z* h7 S
  1438.           CPU=1
    " V7 ^& @3 b* h2 s. e# a0 I0 i
  1439.         fi
    , W+ `& {! j. a" |" s+ Q- A
  1440. ( W  Q7 J% D/ t0 v; ~# P: H
  1441.         if [ -z "$CPU" ]; then
    2 r; P% F( N9 U3 ~
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1
    + L/ V7 }0 x7 a! z: B9 @: Y
  1443.           CPU=1
    : M6 I. i$ ~1 P/ R: @! W
  1444.         fi
    $ Q1 N. J' e' H
  1445. . ~" I( P, o' j7 K( V. ]) h
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then* R; V/ u( F- I& c
  1447.           Log "User entered invalid value. Max CPU set to 1." 15 r( Q3 ~6 }3 f8 }. p% p1 A& x& ]
  1448.           CPU=1
    ) ~/ _, c4 ^: _4 r8 v& S
  1449.         fi# y" S0 Y3 D; W5 Q

  1450. " T, p' E. x$ V) u8 ?  N
  1451.         Log "Extracting MMaps" 0- `# `0 e- k, e( Q5 P
  1452.         cd $GAMEPATH& T  b4 Q2 ^& Y$ ~$ L; G
  1453.         # Making sure we can execute the script
    , w& A, }8 ?5 F0 ^0 ~
  1454.         chmod 700 MoveMapGen.sh
      P$ n5 r- I1 V; U
  1455.         ./MoveMapGen.sh $CPU
    " g, M3 _2 b+ V# [

  1456. $ z9 K. `( w. _& o1 b
  1457.         if [ $? -eq 0 ]; then
    2 N( Y) b8 y/ A
  1458.           Log "MMaps are extracted" 05 ]" g1 v7 V' b% T  |. _8 O
  1459.           Log "Copying MMaps files to installation directory" 0
    8 w8 d; d* L6 ^9 h" C
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    9 H1 J! q" e; ]1 i. o$ T) B' C
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    5 D5 M, D6 U) A- W3 P
  1462.           rm -rf "$GAMEPATH/offmesh.txt"$ R# E: g+ X3 l1 C
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    # u. t0 y. q* q! z3 c: l- i
  1464.           rm -rf "$GAMEPATH/mmap-extractor"% q3 L. _/ v4 `
  1465.           Log "Changing ownership of the extracted directories"1 ?. [7 n. \* _
  1466.           chown -R $USER:$USER "$INSTPATH"
    ( l4 o, ^# a  s$ F; O9 e! W
  1467.         else& V, z! M6 V2 H. l5 \* j
  1468.           Log "There was an issue while extracting MMaps!" 1
    % U# @' K+ e$ o0 H# `' v
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"7 w/ ~' K/ i* ^9 ?9 X* x0 Q. d2 Y
  1470.           rm -rf "$GAMEPATH/mmaps"$ e( }0 T, n, s/ `( ^+ k
  1471.           rm -rf "$GAMEPATH/offmesh.txt"6 ?5 x4 b2 V- g1 V
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    5 t# ~  V! F  t* O( S( p
  1473.           rm -rf "$GAMEPATH/mmap-extractor"
    % v3 c$ X' v7 n+ K) U( g
  1474.           exit 1
    9 M+ q: Z/ q5 E% g3 X$ g
  1475.         fi
    6 P% G' V, n- R1 d* m
  1476.       else
    9 A" \. T( _1 ~6 A7 r3 J1 x
  1477.         Log "Copying MMaps files to installation directory" 0
    % W7 |! n& G% `! J0 R) l* I
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    ' `& ~6 p) g3 T$ ~
  1479.       fi# t" b6 x& |- ^% [/ a2 |
  1480.     else
    ) T- U* M2 e  l6 J
  1481.     Log "Copying MMaps extractor" 0
    , b6 Z- _7 _9 H8 l1 ~
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"
    ( G* m8 K% `% v" Y1 Y
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    , z: g* W3 D+ y' k4 Z7 y
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"
    4 ^) G0 W$ }) [- _8 M
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    7 T7 ?. @: v/ C, a# I, g/ [' j
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH". E( _, [; C$ x- W6 i
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    / M# ~. p! }& F
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)$ R. G( H: d- b: t# C! X) n. }

  1489. 0 q9 L$ M1 x2 m! e
  1490.         # User cancelled his choice, set default to 1.' ~+ v5 D. e- z/ O2 C9 H
  1491.         if [ $? -ne 0 ]; then
    : ^) f7 u' {3 p7 R( A
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1+ z4 \% M- \' F
  1493.           CPU=13 g# s/ X; m. h; n' t
  1494.         fi6 O  B# n. ~8 A) J: \7 A2 e- m  M! Q

  1495. 1 A  L0 t/ {* n7 N! |
  1496.         if [ -z "$CPU" ]; then
    * R8 x/ `+ Y, s# b
  1497.           Log "User didn't gave any value. Max CPU set to 1." 11 m7 f5 I0 m6 x
  1498.           CPU=1
    $ }) d" P! q5 `  s) [
  1499.         fi
    5 U2 Y( T# e4 A( w0 S
  1500. + v- l+ d6 @% @) Q; O+ N2 J
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then/ z* |$ Z7 b+ L  z: M
  1502.           Log "User entered invalid value. Max CPU set to 1." 1
    + X9 s! |+ _  Y( P& u/ I6 Y
  1503.           CPU=1/ A, X# G0 I' {$ X
  1504.         fi) W6 P4 F' @, l% e
  1505. 3 s; n% c+ e% g* |+ ?) O
  1506.         Log "Extracting MMaps" 0/ t$ v9 q6 |" {8 {' j% b
  1507.         cd $GAMEPATH. o# h! {0 b. b
  1508.         # Making sure we can execute the script. x& ?4 {- o. M  h! i: K' d
  1509.         chmod 700 MoveMapGen.sh6 `, g8 |9 K& m, e  T4 S
  1510.         ./MoveMapGen.sh $CPU! C- G9 C! L0 P% l  R1 q4 K

  1511. 3 I2 A1 b- L" b) u) C' |4 L
  1512.         if [ $? -eq 0 ]; then
    . \/ ?6 {3 ?4 ~& w, W
  1513.           Log "MMaps are extracted" 06 j7 B! X/ J# W
  1514.           Log "Copying MMaps files to installation directory" 0
    ) v0 K6 l9 M$ c/ A. }- @% r( t
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin", A2 `; }* K/ \* f! Z, C
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ) z* B% B" J5 b( {+ k
  1517.           rm -rf "$GAMEPATH/offmesh.txt"
    + o+ E" g* K2 O- T2 [6 w; B
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    2 ]- ^& W8 i% a
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    2 b4 Q; K4 Y+ t3 c) i- \* m
  1520.           Log "Changing ownership of the extracted directories"
    0 b, L6 ?5 I* G3 Q* }; ]; ]$ E- N
  1521.           chown -R $USER:$USER "$INSTPATH") {8 I+ {7 e# X$ b  l4 H
  1522.         else$ B+ D2 m- e. l
  1523.       Log "There was an issue while extracting MMaps!" 1
    . R- K  A. x7 c9 M* B! f9 g
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    : }+ t& N8 y& H8 ?" ?
  1525.           rm -rf "$GAMEPATH/mmaps"+ m; R! V4 z; ^2 ?, z. K6 G5 j
  1526.           rm -rf "$GAMEPATH/offmesh.txt"3 H7 c0 g1 m5 m. s1 R
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"2 h1 b  X* }* y) o8 j
  1528.           rm -rf "$GAMEPATH/mmap-extractor"
    5 G$ c* @7 E' Z  G  E
  1529.           exit 1
    8 i* k1 m+ s0 A
  1530.         fi% u9 y- R  V) C1 v% o
  1531.     fi9 [9 E, x% E8 z2 u1 W/ u
  1532.   fi
    # H' N. E. D5 a8 q& V& b
  1533. }* F& E! Q( Z1 x$ W' F8 n3 X- X. o

  1534. $ ]: d8 q& f+ k* u! K
  1535. # Function to create a Code::Blocks project
    : I5 w5 |/ S* j. ~7 V; B
  1536. function CreateCBProject
    * w* M% O# S' P" O8 C
  1537. {' r0 s$ R; B" @, C5 V* {* M
  1538.   # Create the dircetory if it does not exist
    1 Y$ _- N+ C+ Q& R5 M7 g6 f
  1539.   if [ ! -d $SRCPATH/server/linux ]; then1 f3 b9 Q/ ^0 U0 p
  1540.     mkdir $SRCPATH/server/linux
    $ g$ q( x# n, @$ r' }
  1541.   fi& k0 p$ E: L, X3 B+ |8 c
  1542. ! `) q( L, ]7 P5 t" y3 H( N
  1543.   # Now create the C::B project
    2 m! {' ]9 n( R: q1 M
  1544.   cd $SRCPATH/server/linux: |) @( J. u5 W6 J( H7 e% d
  1545.   # make sure we are using the cmake3
    + U  Z5 g& c- K7 L% w3 a
  1546.   UseCmake3: ^! c3 h6 l3 M* P
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    / m, m4 Y* O  h4 }7 _0 f2 R$ e
  1548. }9 P9 \$ k% x/ K. ^  ]" ]

  1549. - d! v' d  P# ^$ K( k' b" x
  1550. , T  \9 n- h* Z: l: i

  1551. / _; [# o1 H+ R) x+ m3 a  g
  1552. # Prepare the log4 h9 r% i5 b6 ?+ B& y
  1553. Log "+------------------------------------------------------------------------------+" 0' u3 F* j, h0 W
  1554. Log "| MaNGOS Configuration Script                                                  |" 0+ _+ A; J. D3 s. q
  1555. Log "| Written By: Ryan Ashley                                                      |" 0
    * F. A6 a$ Q8 a+ M) `: Y# m
  1556. Log "| Updated By: Cedric Servais                                                   |" 0
    , U: ?. Z3 n1 V5 a& R( M
  1557. Log "+------------------------------------------------------------------------------+" 0
    & S, {7 T; D9 M* F+ r& f8 C
  1558. 3 c2 V  V( a1 F0 A. H1 H! k
  1559. # Check if user who is running this is root
    ; V3 N9 _( J7 ]0 \: Z8 [# {! F
  1560. CheckRoot
    2 @2 ~3 S$ k9 R$ H; |9 j/ \5 `
  1561. 6 R' D) r; I) @, h
  1562. # Select which dialog to use
    & p1 b5 N2 g9 E% e9 s
  1563. UseDialog
    5 h  o: L, m' q. Z$ ^

  1564. ( v4 N" m: _+ H% i" ~
  1565. # Select which activities to do
    & _3 c& O1 S9 j( }
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \  V+ F. F' P# ~/ o) r
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \
    9 y8 B9 s# a' }6 G
  1568.   1 "Install Prerequisites" On \
    9 l% j  ?3 m" Y& U" k' o; I
  1569.   2 "Set Download And Install Paths" On \* K1 U; u0 V" a8 |+ I2 A
  1570.   3 "Clone Source Repositories" On \; \6 D7 w% l) v- d, Y0 R
  1571.   4 "Build MaNGOS" On \1 ~' R. i$ r5 A" ?3 }
  1572.   5 "Install MaNGOS" On \7 b$ K& T/ F4 ^$ X  H1 V3 S
  1573.   6 "Install Databases" On \
      J5 \! G, Y0 V1 l
  1574.   7 "Extract Resources" On \
    : s! }( l3 I0 l/ @% J$ A
  1575.   8 "Create Code::Blocks Project File" Off \  c- {) r( s! \& H" d8 T* v
  1576.   3>&2 2>&1 1>&3)& N- R# y+ \2 k; P, j- m

  1577. ; R9 E! F6 x9 d
  1578. # Verify that the options were selected/ `1 N( R$ H7 Z8 R, d/ B9 K+ M
  1579. if [ $? -ne 0 ]; then4 ?" H0 ^1 Q; W  _( U% D" r
  1580.   Log "All operations cancelled. Exiting." 1! D7 T# y# p7 r; _! ~1 n
  1581.   exit 0
    5 q* E4 Y, ~2 s& U7 B6 k
  1582. fi
    3 M# Z9 ^! m6 T; N! I7 w$ H. q- y
  1583. . t! B( G; O- o+ v/ @
  1584. # Install prerequisites?
    # n! s7 Q+ |% @& j3 q" S$ V
  1585. if [[ $TASKS == *1* ]]; then2 `; M' h/ W; a9 x+ {& Q: b& ^  o
  1586.   GetPrerequisites
    - j, e9 N. U2 Z# o
  1587. fi
    ( i6 ?9 Y% C" C3 O' c& O
  1588. 8 ^7 O+ S+ w) Y4 U( V& i
  1589. # Select release and set paths?
    * i$ C: g, C# j
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then) v+ x& K& A6 m* u# b
  1591.   GetUser
    : d/ Z" y0 ?6 Z3 \0 S: \" }
  1592.   GetRelease1 l1 l; o4 z! d4 c3 l: Q8 l9 l, J
  1593. fi, K) d/ q% c/ d7 j7 Q
  1594. $ L' F* P; D- x% b( K. M
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then9 ^. K+ F, V; _4 ^1 `3 ?  i% W+ q
  1596.   GetPaths
    2 j' c# y6 v" n' ^+ t
  1597. fi2 z! F( P% t& [. n
  1598. , T- U, R% \# D( l2 f7 Q
  1599. # Clone repos?
    7 z# C6 B7 k1 e! g8 R) R. `
  1600. if [[ $TASKS == *3* ]]; then+ U3 _$ w& n  y
  1601.   GetMangos
    * D. M* ^2 `& e8 n
  1602. fi% L% ?: j- |1 j- k6 k

  1603. 7 }- X9 s6 f# H. y* F& E9 ^& u+ x
  1604. # Build MaNGOS?
    7 q/ m, r8 d1 R
  1605. if [[ $TASKS == *4* ]]; then
    $ `- Q8 w  C. ]! x& H2 j
  1606.   GetBuildOptions
    6 S; y( p' u8 ]1 |, X
  1607.   BuildMaNGOS* p6 T' S2 H# l8 r
  1608. fi' F' @& f  Y7 u. H) v# x
  1609. , I5 g$ Z9 c) f; d% C. b) a  _
  1610. # Install MaNGOS?" @! h$ U/ f' _0 I6 x
  1611. if [[ $TASKS == *5* ]]; then
    9 c4 Q3 _& R: y* {+ q
  1612.   InstallMaNGOS
    - K3 ?' f; L! A5 ^1 ~0 Z, i# g
  1613. fi
    % X) }# B! i; M
  1614. % {; j8 M, `# S9 O" H; A
  1615. # Install databases?# S( B' p  B# z$ f2 C' \- T: h0 P
  1616. if [[ $TASKS == *6* ]]; then, ], m& c+ }& }: y
  1617.   HandleDatabases! _) Y5 X3 O% ]5 e; C! D
  1618. fi3 I4 g8 F  i1 q  H$ V$ U
  1619. . x0 s9 j6 N+ s$ y7 r/ u2 E- G! }
  1620. # Extract resources from the game?
    ; W# ?( {5 j# p& ~8 E0 B1 S- G
  1621. if [[ $TASKS == *7* ]]; then
    # U) V1 f3 Q& J: Z/ M+ b9 o+ l
  1622.   ExtractResources0 S! r" e3 P% E7 G* B* h: Y1 E
  1623. fi" C  \# Z1 h- [; {2 @

  1624. 2 T7 _7 `1 U* }+ ^1 M
  1625. # Create C::B project?
    # v4 Z/ p# j/ Z* Z7 ?2 d1 A) M( |
  1626. if [[ $TASKS == *8* ]]; then  r( L* M4 X  x# j8 X8 _
  1627.   CreateCBProject0 {! m. z# E* d9 V" @4 G
  1628. fi
    0 r4 ^2 F; a/ i6 ]

  1629. ) G& Y& ]8 G  j/ l
  1630. # If one of these actions has been performed, then we know the user.4 s4 ~3 B! A; \/ E& n, a- W
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    9 j/ H3 I9 A% {! o  a. O' ~& o# v
  1632.   Log "Changing ownership of the extracted directories" 1' m9 N- W1 {  x4 y$ |, g5 e4 `: O0 M
  1633.   chown -R $USER:$USER "$INSTPATH": f2 V( U6 @9 `0 I6 Y1 S% d
  1634. fi% G4 F, S0 T0 B$ o7 L5 j- b8 z& a
  1635. - F: k  k/ p3 f# S
  1636. # Display the end message
    ! F. v' P+ V. H. Z. b+ \7 `5 b# @: I
  1637. echo7 M) a2 D2 L" s- h# F1 @
  1638. echo "================================================================================"+ w3 ?4 {; Z9 l4 u, {
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"
    9 P# p0 X" \% v5 H( ^# T5 q
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"& j& Z) b0 S% T8 `0 g1 W0 r
  1641. echo "server. If you have not configured your databases yet, please do so before"
    ! x/ I' G  Z! m+ B% Z
  1642. echo "starting your server for the first time."! T% s5 B2 Q7 A5 Y* q+ U; u
  1643. echo "================================================================================"
    0 i! X; o. G5 a# L5 v
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh7 C1 F6 J- B3 s% }  S; c* ^  o  s& s
  2. ##############################################################################' ?1 y  d% z+ x
  3. # This utility assist you in setting up your mangos database.                #  v- c- U0 k. B  ?3 R* E
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #4 X& O# M- ]8 x0 r0 w9 @9 ^& _
  5. #                                                                            ## P& I! V% _8 L/ l# L+ |. M5 @
  6. ##############################################################################  J, J1 S: {9 _, s! e
  7. 7 L, {7 g4 B# `5 E% ]" i! U
  8. OLDRELEASE="Rel21"0 |( }3 Z; I1 B
  9. RELEASE="Rel22"
    ( {3 d8 y0 u. B7 N5 l3 ^( D
  10. DUMP="NO"% q" W; n8 E% Z, u8 f  g
  11.   |9 R" |6 x( i! Z- f
  12. dbname=""! G& Y1 y  z. i( H. ?3 H
  13. dbcommand=""
    8 @1 Z  J# {6 |% k. }7 V
  14. / Y8 ^6 {% x- x; ?- f5 L6 ~
  15. createcharDB="YES"1 ^5 M' j. u# C/ T* z- S
  16. createworldDB="YES"8 _1 T1 a; B) @$ _
  17. createrealmDB="YES"
    + K* b5 x, F3 ~/ m$ d4 b
  18. : \/ z+ K  j  e) c
  19. loadcharDB="YES"" d+ L( T1 G" Z: `6 A5 Q1 W
  20. loadworldDB="YES"" t5 U6 Y9 S* t0 l3 D9 Y' d
  21. loadrealmDB="YES"7 i$ s6 X3 W* m$ a( C0 e, P
  22. dbType="POPULATED"
    * F/ P3 [8 y, a) c. O

  23. , U$ j7 z7 ~  ?6 Y/ n7 T& K
  24. updatecharDB="YES"* f$ a% W8 R2 v- e
  25. updateworldDB="YES"
      R9 |0 {, u8 Y; p% O
  26. updaterealmDB="YES"* n* {' w7 m+ [9 _( z  P
  27. & l  w+ _* h0 h- [
  28. addRealmList="YES"
    / G" R2 `* w# ?& g  x! O
  29. ( H& C1 B+ x' H
  30. svr_def="localhost"
    9 E( Z2 N6 l9 D* E
  31. user_def="mangos"
    ( y  e+ X7 v' ]  {: O8 l
  32. pass_def="mangos"
      o4 @0 s- z1 O0 m: T9 z( O1 O
  33. port_def="3306"5 H( |* |2 D0 h- t+ F% t
  34. wdb_def="mangos2"
    ) }- ~% o9 F( f
  35. cdb_def="character2"
    : y2 H5 Y2 q$ h* v8 ~! x) n
  36. rdb_def="realmd"! K$ Z* R9 e: q6 d
  37. 6 o6 C7 k7 H1 ?& H7 x, ?; B
  38. printHelp()$ e1 f" [& g- D8 }) J. a# d% y
  39. {
    2 e" C  U% U2 ?" C" O% ~/ H
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"6 L5 ^5 ^$ z6 S0 z$ z! @2 p
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"
    - r: _1 y3 C1 [# h
  42.         printf "\t-u: Run only the updates of the database\n"
    + \6 |7 s2 p# c5 ~7 T
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"
    4 f& G( z) C: w, Q0 D8 i  l5 }
  44.         printf "\t-h: Display this help\n"6 J$ h/ T7 d# T9 U  ^* w
  45. }$ e; Q' P) s% Q7 R+ x3 D- t& A2 g
  46. " N, P2 L2 n$ i0 s! ^- i5 K
  47. printBanner()  P8 V8 ]( `7 g$ B" T: W
  48. {5 y: c& L; T7 v% o# ]; I
  49.         clear
    . ?4 N0 `- U9 ~9 q, i
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"
    ( u5 S* h- b8 }0 y' P
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"9 z: h1 s: a: Y. L+ G
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"# v/ S# p5 d" p+ h
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"
    * q0 o# D1 n, H
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"
    * i$ \) U$ H& {& J* |, ]- u7 }7 h
  55.         printf "\n"
    & ?& X( z" e" m6 K
  56.         printf " Database Setup and World Loader v0.03         \n"
    " J: l) _8 L: B1 D9 z
  57.         printf " ---------------------------------------------- \n"5 |: K! U( w1 b/ C
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"& j" O, l! ~! R1 E
  59.         printf " ---------------------------------------------- \n"
    ! m, Y! _' Z3 n0 L2 |
  60.         printf "\n"8 P9 B; G; |5 b9 l! I5 Q! w
  61.         printf "\n"+ B9 R3 L3 L: S8 ?; z
  62. }- X* j/ i7 Z9 l: w1 d% ^# U7 K

  63. 0 U$ V3 q6 ]/ o
  64. printActivities()
    . {$ n, T2 l$ [
  65. {+ L3 F  }& b. q+ |6 |
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"3 _4 }4 l4 ^5 ]) x" k, D# f; H
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n"4 ]+ P3 p- D5 \( y
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"
    5 N0 W9 D2 Q5 e' b) |
  69.         printf "\n"0 ]8 @! N5 z; b+ d
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"/ H( ?) D% _8 e% ]) o
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"        ! J% \$ ]/ w" A) g2 M) @
  72.         if [ "${loadworldDB}" = "YES" ]; then3 p( ~/ Y8 N* U# Q$ e
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"8 ~. G3 ^# {1 R9 j( _& E# {5 ^7 _: A/ w
  74.         fi
      r, h" f$ f& f4 q" ^& V8 A; @( ]
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"
    / E& Q3 g2 k- ]  ~6 Z
  76.         printf "\n"
    * \" T) t+ I8 V1 {* s* k
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"; D" A, e+ j/ ?: J$ D; v/ ?
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"3 V, @8 P# a+ o
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"" ?5 Z2 q, Y* R$ Y' O
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"        7 Y2 V0 R; i" i  B7 f& O
  81.         printf "\n"+ @2 _. P! N* j
  82.         printf "\t\t\t\tN - Next Step\n"
    9 c9 f9 p2 B3 p
  83.         printf "\t\t\t\tX - Exit\n"
    ( X: k0 ^6 P9 y; K# Z* x6 m
  84. }- _/ E- {7 S4 R) C) k% v% a/ N% Z5 q

  85. - U5 @1 k7 Z( R/ }
  86. determineDBName()
    : G0 [5 C# K4 N! r  q
  87. {
    # M! c6 t$ C% r! J2 Z$ o4 O/ s! a( r
  88.         if [ $(which mariadb) ]; then
    % Z1 A! G: w5 |" t
  89.                 printf "MariaDB found.\n"0 p" D: J7 l" ]; {$ I1 c
  90.                 dbname="MariaDB"
    - Q2 u# J3 [; S
  91.         elif [ $(which mysql) ]; then
    0 j9 h/ P# w/ O# e
  92.                 printf "MySQL found.\n"
    : @& Y, p8 X9 ^# M- [8 ?
  93.                 dbname="MySQL"- E1 Y1 e& b4 l
  94.         else. t* g2 f9 E' W/ `/ `' V
  95.                 printf "Did not find mariadb or mysql.\n") M0 L& B, C( F) C! E
  96.         fi0 U- I/ c- D( {9 F6 ]+ y$ p$ d  H% S
  97. }/ d1 W8 Z3 o, F( W% x7 R( ]

  98. & H7 R8 J$ y! a. n+ ^
  99. mysqlconfigeditor()
    9 z$ C4 L5 ^; C5 ?* r
  100. {
    3 i6 u. q( i: @: S! k
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"+ t( k% ]. v& c3 K8 a
  102. }
    * H7 m% g! V- v/ _! H; k
  103. $ \7 v7 N2 |2 M* G( v! K0 m* g
  104. determineDBCommand()5 g5 T$ u& j. ~+ o
  105. {2 o; r. \- c8 C4 c3 A0 |3 b* S
  106.         if [ $dbname = "MariaDB" ]; then8 @  ~2 j) e; w4 t3 h1 ~% P+ i; U7 v
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"( j- R$ U8 o( F; y0 E! x+ i: U
  108.         elif [ $dbname = "MySQL" ]; then$ {# j8 H1 ]- p. e
  109.                 dbcommand="mysql --login-path=local -q -s"- o- q6 {2 w# o' P
  110.         else; Z/ M9 b! c8 W  T8 ^- l0 X! o0 X
  111.                 printf "Did not find mariadb or mysql.\n"
    / N8 ^; F$ w' Y) n
  112.         fi
    ; H9 H6 J$ [3 z, n- S
  113. }
    ; o' E) A+ q+ Q; X9 q  Y4 Y

  114. . F# g, h* Z1 d) z  Y3 X$ ^5 d# j
  115. createCharDB()% s; O+ V' P( n3 O& {" w
  116. {, j% g- a; F. `. A- d
  117.         printf "Creating Character database ${cdb}\n"+ n4 n% t) H! u. S0 ~1 r! s/ w  p
  118.         $(${dbcommand} -e "Create database ${cdb}")
    / @2 J( G; X, b, ~
  119. ( o, y/ ^- ^5 F7 {
  120.         if [ "${loadcharDB}" = "YES" ]; then1 f2 b- m0 s% D
  121.                 loadCharDB
    $ T8 u$ s; G, ?9 L: w
  122.         fi
    / C$ t3 e: ~1 L8 P
  123. }
    : k, z( U4 N5 }( i1 {
  124. 4 P" |8 R! y3 M8 Z9 S2 z
  125. loadCharDB()
    ( ^6 h, F% w& ]# v/ E; \! l" U
  126. {$ w: [5 V8 E. j
  127.         printf "Loading data into character database ${cdb}\n". G$ I+ B5 q" a" X* t
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)
    & `; M1 G3 N) e5 g% s& W

  129. % M/ o0 A& Z$ A, q  ~) P
  130.         if [ "${updatecharDB}" = "YES" ]; then
    6 {# A& ?6 w( `9 x
  131.                 updateCharDB7 t1 N3 D2 p7 V+ s/ F; T/ u. K( U/ m
  132.         fi
    2 g. l# l$ D0 D" L1 _/ ]- C, z
  133. }1 C, C7 {0 E" C+ d) ^; E# q

  134. $ i8 X& _' W3 s, M7 S
  135. updateCharDB()
    # ], N& [& M% k0 K- Y4 ^" B
  136. {7 v3 A9 o5 w" q
  137.         printf "Updating data into the character database ${cdb}\n"
    ) G' `- v  q- E7 ]: }
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')7 i6 w7 E. O9 Q6 n8 s4 i; `
  139.         do
    + X/ D) s! h9 X
  140.                 file=$(echo ${file} | tr '|' ' ')5 T" a5 g2 ~, X8 L6 ^
  141.                 printf "Applying update ${file}\n"
    ; v) P6 u7 g1 ^" T) L2 Z
  142.                 ${dbcommand} "${cdb}" < "${file}"
    8 n3 S/ \% p! u0 o
  143.                 printf "File ${file} imported\n"
    ; [4 @9 v- k& ?0 Z2 {
  144.         done
    2 }" l/ D" U9 I; r9 R( ?9 z. ^
  145. * h5 Y, C9 ?/ }7 B
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    # y4 @2 e, G8 w% M+ X/ o
  147.         do6 k% \7 z$ I; g/ [+ @
  148.                 file=$(echo ${file} | tr '|' ' ')
    4 j0 O  J/ k2 X) [8 e! s
  149.                 printf "Applying update ${file}\n". I1 g4 H. f# b# A
  150.                 ${dbcommand} "${cdb}" < "${file}"# U3 @' H7 R4 O2 I: |, C
  151.                 printf "File ${file} imported\n"
    7 t- u" e* E7 v8 G2 |
  152.         done
    0 c2 Z& B9 D6 g4 I
  153. }
    6 A8 }7 g* j8 Z3 F4 M$ _/ @. E
  154. & W% @: G, l) @2 [$ Y
  155. createWorldDB()
    / ?, N" U+ J& z; q7 e- D
  156. {+ z1 z' z( }9 U& k
  157.         printf "Creating World database ${wdb}\n"
    2 z9 e8 ~, N. d8 G1 H& e
  158.         $(${dbcommand} -e "Create database ${wdb}")
    ) _" S) G) X% w7 H' W* L* C
  159. 5 F+ Q0 |+ z9 T. x
  160.         if [ "${loadworldDB}" = "YES" ]; then% }2 s- B! W' D: K+ q$ K
  161.                 loadWorldDB
    $ _/ P6 m" h" Q9 n
  162.         fi* i2 x/ E2 n. Z8 c
  163. }# F& @9 D# `$ E& X* Q
  164. 1 A# x1 |/ x) F* y- @
  165. loadWorldDB()( ^( {( I: _( i! o* [4 u  Z
  166. {
    4 S* v: Y* \& g9 x. x4 M
  167.         printf "Loading data into world database ${wdb}\n"
    8 u3 G* q: A2 S8 G2 z0 t3 @* d
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql), [. _  c% D9 b# t1 ^
  169. ( F! u3 R/ D: C) C  T
  170.         if [ "${dbType}" = "POPULATED" ]; then7 R8 k4 ~. p0 {3 H( V3 O% V% W
  171.                 populateWorldDB3 S# R& a& z1 e; B. i
  172.         fi: q! m6 P2 U# ^& F, N; Y+ N
  173. }( }& H, u# J+ F+ `! R1 w

  174. , P$ ^% r7 B( r; a  l9 ?
  175. populateWorldDB(). Z' T0 m, B8 \. K
  176. {/ V1 S+ Y8 N- |. o5 Y. O
  177.         printf "Importing World database ${wdb}\n"
    ' ~' v/ X, |  q' `$ r5 U
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    % z; T. H# x5 v# F0 C
  179.         do- M$ i- ]) ^) Q
  180.                 file=$(echo ${file} | tr '|' ' ')- N6 ^  s7 P0 ]% a9 L
  181.                 printf "Importing file ${file}\n"
    & T& \) Z+ q8 Z1 D1 L( x7 A( b
  182.                 $(${dbcommand} ${wdb} < ${file})7 n) z0 v1 _4 K$ ~" d3 x
  183.                 printf "File ${file} imported\n"
    6 C3 y% {, |1 i5 `! P) I
  184.         done
    ) D- ~, l4 S. Y/ \

  185. 8 K  T" M1 `( @1 B  V. u
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ') ; {( o( [. g$ n8 R/ m
  187.         do
    , Z4 s9 `" a& k  D
  188.                 file=$(echo ${file} | tr '|' ' ')
    * U! x+ T- @  a
  189.                 printf "Importing file ${file}\n"
    ' e) A% o6 K3 j
  190.                 $(${dbcommand} ${wdb} < ${file})" f+ t1 v. }) S, I3 V1 s: _
  191.                 printf "File ${file} imported\n"  p; [' y' S# }9 C( D3 c' s
  192.         done$ ]8 G! c6 D* N! o
  193. }
    8 M3 X. A/ y% k, U' J1 S2 u) s& g
  194. ' Q+ f: d* X3 |' K9 w1 Q; U" o1 x
  195. updateWorldDB()8 X/ U/ Y* k& D- k6 ?
  196. {
    ; I/ g- O+ {4 d; {
  197.     printf "Updating data into the World database ${wdb}\n"! E: `' b/ h- m2 r: G
  198.     for file in World/Updates/${OLDRELEASE}/*.sql
    / a$ y! G3 w% d
  199.     do
    " E! S+ b2 L9 j! ?$ s! g1 |
  200.         printf "Applying update ${file}\n"; E7 A& f9 x  N6 i; L' V$ T( I5 f
  201.         ${dbcommand} "${wdb}" < "${file}"
    9 |/ p/ T, x" i2 B4 ^
  202.         printf "File ${file} imported\n"
    . ~" L. q1 `5 y8 C
  203.     done
    0 x' M# u$ ~" g+ w# i& _

  204. 9 [; j, `4 Q6 X! U
  205.     for file in World/Updates/${RELEASE}/*.sql0 |1 m, t' w% Q
  206.     do
    6 q' q9 r5 j! y) Z
  207.         printf "Applying update ${file}\n". [1 Z) O$ B6 C/ _6 O
  208.         ${dbcommand} "${wdb}" < "${file}"
    ( j  S1 D9 I: |, b% _0 v
  209.         printf "File ${file} imported\n"
    % A9 y4 Z9 f  a; a. E: e% U
  210.     done
    ! G' i" k7 ?+ k' G
  211. }
    5 Y1 T$ K# {7 g4 x; i
  212. & P. t* W- e9 |1 \& }9 e( d
  213. createRealmDB()
    * e0 F) Y6 r( ]6 B8 j# O) M% `
  214. {
      o. w6 E$ v4 Z0 P
  215.         printf "Creating realm database ${rdb}\n"
    6 M( g8 s% l4 k& U# |- _5 \2 x7 d
  216.         $(${dbcommand} -e "Create database ${rdb}")
    1 g2 r0 T9 n' `5 k3 H
  217. ( {$ {' e! k! I6 M/ L% C
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    6 H/ J% h) x' r
  219.                 loadRealmDB
    $ H- o4 X7 _$ r  x
  220.         fi$ R& A$ E. R, G9 E5 {/ Y
  221. }
    : @, v8 T: M& p
  222. 2 s! E: @# W8 F0 K" g% Y  j. s
  223. loadRealmDB()
    ; B: |/ s- x* f1 R
  224. {( y$ ^* u3 i2 Z' e  g" E# b- R
  225.         printf "Loading data into realm database ${rdb}\n"        . ]9 p4 J! ~2 o3 ]6 o4 f
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)7 X) c+ m3 F! R" s
  227. }
    3 c, W% Y6 K5 f5 ^6 f
  228. 4 ]3 D4 {# V& n* D( g! o
  229. updateRealmDB()
    : x. q* k/ D: L" ~. V$ c
  230. {
    " G. p& \" a- t4 x0 k- b
  231.         printf "Updating data into the Realm database ${rdb}\n"2 x6 Y# m' {; y* o1 Y, i  l" Q
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    ! e& E: _7 g! g
  233.         do
    ; j- b0 D+ ~7 T$ @0 Q- |1 W, l6 d
  234.                 file=$(echo ${file} | tr '|' ' ')( G5 u# ~7 F7 ]# N9 D; U
  235.                 printf "Applying update ${file}\n"
    - g+ T" J- `# ]9 k) i+ c
  236.                 $(${dbcommand} ${rdb} < ${file})
    1 ~9 h+ }; F1 |# u' A$ ]4 l( z
  237.                 printf "File ${file} imported\n"& D( ]1 }  e5 _, m+ a
  238.         done
    ' H% q( O& w: \! }

  239. ! K2 e% A/ g0 a$ b
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    ) H) V% n. V5 y8 t3 [
  241.         do* X4 b" C7 L* y/ k
  242.                 file=$(echo ${file} | tr '|' ' ')$ B( K% p: _* [- J
  243.                 printf "Applying update ${file}\n"; B# o% W- }  C3 v, ?
  244.                 $(${dbcommand} ${rdb} < ${file})
    9 c  C, i0 U3 Y+ S  w9 e# R( }
  245.                 printf "File ${file} imported\n"
    1 L% i& {0 Q% i7 p% p
  246.         done
    ) T" `! o8 k& L) W2 N5 O# t5 n* \
  247. }2 B7 f9 |2 X- G6 T* D

  248. 1 ]+ {, I! E: I0 W+ ?
  249. addRealmList()" _0 ?7 i) a* ]: ^3 }1 O" ~- Q( Z
  250. {
    $ r. M# h: b/ C* r& T: X
  251.         printf "Adding realm list entries\n"3 ^; h! _6 L8 K+ y: q8 t
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)
    8 a8 |  ~' j! ]6 h. }5 y* q+ P( A/ c2 T+ W
  253. }$ w: X) B- h/ _# A: N+ |

  254. 9 D' Q& W! S8 P/ O
  255. activity=""
    / {. `8 Z; e. q
  256. . ]( D) K6 K3 u! I; B
  257. while getopts "suh" o; do# g- m, U6 d& i) e! e" _, j( l
  258.         case "${o}" in
    9 v- s8 X1 G$ ^: o& I% h
  259.                 s)
    / m) i; A3 L# q' k, a( c! H: {
  260.                         activity="N"2 ~: i- p3 U- y  ^0 W" J1 W
  261.                         printf "You selected silent mode\n"+ J! Z- o9 \7 m- [9 m
  262.                         ;;
    ; m0 J6 e0 \1 D1 q# T8 [6 {  O
  263.                 u)
    $ u1 w6 H7 b+ [( ?9 }
  264.                         createcharDB="NO"8 b- K5 E. I; t  R0 p* d
  265.                         createworldDB="NO"
    & t' V" P# z, r+ \% n- h. `
  266.                         createrealmDB="NO"& `% N/ k3 r" k( S1 U
  267. 4 J! {8 s" i4 Q, ~, P( ?
  268.                         loadcharDB="NO"% `% D; j. p3 w9 M" Y
  269.                         loadworldDB="NO"
    : X* P9 w' }$ u( h7 M# ?! n
  270.                         loadrealmDB="NO", ^  P1 P3 x& g& p
  271.                         dbType="EMPTY"
    : |4 _8 C  n4 W
  272.                         printf "You selected update only\n"
    2 Q# e" o% D9 n3 I9 x; W; D
  273.                         ;;; k2 [6 ^  g5 k5 E( P
  274.                 d)
    ' C( h$ k& y- r* l9 ?' E
  275.                         DUMP="YES"
    9 i9 ~) f) t1 C  V3 B
  276.                         ;;9 B  [) U' Z0 H$ R) Z$ g2 }
  277.                 h)
    ) \- h" R6 N  @4 b
  278.                         printHelp3 K3 J# R' h  C( V4 W
  279.                         exit 02 n3 _. N3 o, m" c) ^% q2 T
  280.                         ;;
    7 [+ P! L/ f8 H  _0 V0 r2 d
  281.         esac
    - ^7 s# T$ f, F0 D* _# O
  282. done
      S# G; F5 u: [8 r4 r2 w. @$ k
  283. 7 }7 u. x7 L0 V% C% \
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]7 ^1 g+ ]1 C7 N
  285. do0 _$ I7 I+ n' C- d" M' `1 H) G
  286.         printBanner
    - \+ T5 R& T2 {8 }/ D& L
  287.         printActivities% `& @9 o: _* F, L  S% i
  288.         printf "Please select an activity : "7 Q' A  G5 M! C- E/ G- i4 J- {4 q
  289.         read activity
      D0 b$ a0 G+ ?- E, v0 V5 ?; u6 ]
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )% Y# G0 x/ ?+ Y3 i
  291.         case ${activity} in& D! |% W) h6 r3 ?& l4 o
  292.                 "V")+ L# t6 S! a4 A) K
  293.                         if [ "${createcharDB}" = "YES" ]; then
    3 y4 `# m7 ?9 Y+ K$ R
  294.                                 createcharDB="NO"
    ( V0 S9 l0 b. k! u! x; u" P8 W( d
  295.                         else # Z/ f, A! w5 `5 o: `/ w9 B& }
  296.                                 createcharDB="YES"+ e0 O; ?! V/ \* H. U% x) b
  297.                         fi
    ( Y1 Z  F7 L6 t' u+ L9 x8 A/ i5 Z( `
  298.                         ;;
    8 C2 v1 @$ O* q+ ?
  299.                 "C"): k2 V) X1 F9 v2 `% n# T) e4 Q
  300.                         if [ "${loadcharDB}" = "YES" ]; then
    ' e8 _5 c% ^8 ]
  301.                                 loadcharDB="NO"! t- @0 e) n" I" G3 V+ p$ w2 O; W
  302.                         else & t; S+ F+ D  F8 t" |
  303.                                 loadcharDB="YES"
    4 k* K% ^( S' k8 k
  304.                         fi
    0 g/ X9 j/ z4 b( h, X0 K
  305.                         ;;' O  O* O( W6 h
  306.                 "B")
    ; @6 y+ J7 v. r$ H. }
  307.                         if [ "${updatecharDB}" = "YES" ]; then
    % \( N" \1 X. `9 v7 R4 v/ t
  308.                                 updatecharDB="NO"' C3 b/ o" ?/ p" z
  309.                         else
    # e& i4 g3 [. U; x
  310.                                 updatecharDB="YES"! y% ^7 Z- w* P9 a
  311.                         fi) W8 W' }" w* A
  312.                         ;;
    . a" _# S' i- x5 b3 \% r* Q
  313.                 "E")0 x4 T& D7 ]* N+ M/ }( e3 k- C, b
  314.                         if [ "${createworldDB}" = "YES" ]; then$ `! V, ?" v8 o, D. F/ R: R" ?7 Y
  315.                                 createworldDB="NO"$ h% ^2 z" f: v9 T( Z# L
  316.                         else
    ( H3 ~3 H7 ]( v, ?
  317.                                 createworldDB="YES"2 l  g- A8 j+ x8 o0 K5 p9 d2 ~
  318.                         fi        " u; N! |; Z2 a7 u; ]
  319.                         ;;6 _( y, }' `* z, ~" k, v
  320.                 "W")9 `- d9 _- q  p+ d4 v
  321.                         if [ "${loadworldDB}" = "YES" ]; then5 M2 l) G5 U. K+ e" z9 F1 G
  322.                                 loadworldDB="NO"- n8 H: C2 H% M5 E2 ~
  323.                         else
    # k$ c# L0 }9 x* n/ Y. ~
  324.                                 loadworldDB="YES"* [7 v/ o4 k3 G0 g* K0 R2 d
  325.                         fi       
    ; ?4 u' q! z9 @4 J$ I$ d
  326.                         ;;
    ! H! e, c/ `4 q- e  F
  327.                 "D")
    6 |0 I0 F7 A! S, _; b
  328.                         if [ "${dbType}" = "POPULATED" ]; then) w3 t6 u; [* p, H: l: `
  329.                                 dbType="EMPTY"
    3 v, p$ W3 C4 e8 p3 c- C
  330.                         else ; q* k4 x9 p# w1 ?9 ?. l6 b
  331.                                 dbType="POPULATED"
    1 M) n, d' A& \9 x
  332.                         fi                                   ]' g1 r( R# U' p
  333.                         ;;4 d$ }/ ~  c* [  M! c; Z
  334.                 "U")6 N( ~7 @5 l. E3 u' l
  335.                         if [ "${updateworldDB}" = "YES" ]; then
    " H# I6 Y* r* m- }( s
  336.                                 updateworldDB="NO"
    / V; H2 s% r1 B  q
  337.                         else : I) O0 S. Z9 X* k: f2 h/ Z( K$ {
  338.                                 updateworldDB="YES"0 L  k% J$ ^0 u( ?
  339.                         fi
    ( J7 ?3 u+ z0 }  ^' T, _
  340.                         ;;, k/ K& Q% c, g
  341.                 "T")$ o' ]# A4 }8 d3 U" Y, w
  342.                         if [ "${createrealmDB}" = "YES" ]; then
    ! s% F8 y* Q  t2 G$ v
  343.                                 createrealmDB="NO"+ `, M! a( `" o( d5 a' Q
  344.                         else * T4 w/ t3 l% c4 V
  345.                                 createrealmDB="YES"
      b% o0 G, `" N! }! x
  346.                         fi                                 ' k% E# m7 M1 H( I) \* l, h
  347.                         ;;* O4 N: C; Q& s# S8 G
  348.                 "R"), k& a$ F# U5 c: K" n% m
  349.                         if [ "${loadrealmDB}" = "YES" ]; then& V3 e# N4 K) P4 B$ B' f7 g) Z6 K
  350.                                 loadrealmDB="NO"                       
    ( p# _) J; W* v: c+ n  n
  351.                         else
    ) \/ m3 c5 _2 N8 y/ Z
  352.                                 loadrealmDB="YES") B" ~* e0 Z3 y6 c$ T
  353.                         fi
    : f% G* K# [3 K3 u- M0 D* S
  354.                         ;;: o$ i6 u& r4 @2 N+ X4 y
  355.                 "Y")- Z) u! O- @  x% T& x6 `/ ^' N
  356.                         if [ "${updaterealmDB}" = "YES" ]; then
    % X: a* f3 |( ^: D( v1 p( G
  357.                                 updaterealmDB="NO"" H& _  g0 i; i" ^2 K
  358.                         else 2 K& f+ ^& L# x2 p' R0 e
  359.                                 updaterealmDB="YES"
    . M% t8 x  i/ ~+ G5 G
  360.                         fi
    ; A* T7 j( n3 x3 W0 I8 i
  361.                         ;;1 I- E* t% s3 M. l; V) }; }9 O
  362.                 "L")/ R" M" _9 b! @/ X
  363.                         if [ "${addRealmList}" = "YES" ]; then( [1 w0 O7 T# Q( w" ]/ y
  364.                                 addRealmList="NO"
    7 _: E& o. F. D7 u$ c* _& R
  365.                         else 2 o" R3 g2 R$ D# n* r/ F* P% y' T
  366.                                 addRealmList="YES"
    1 M/ C) w9 Y! y, u
  367.                         fi
    9 N  V2 R0 `  F3 y4 M/ O
  368.                         ;;
    8 X- Z! S' u* V9 e8 @& E
  369.                 "X")
    / R3 t( f: A7 A( o$ K( j: e% q
  370.                         exit 0;;% n8 \; y  q( q+ B* c4 ^( W
  371.                 *)
    / m6 H% h9 Y% [. O4 J! s. @
  372.                         printf "Invalid selection";;
    . ~/ t/ m6 f8 o- b, x! m
  373.         esac' n' l1 p- Y5 y% t* m6 \
  374. done
    $ B6 o# w- C+ C' ~
  375. ( `/ {) ?+ V( x- C4 K
  376. printBanner
    8 q: _  v3 ^# ]2 s* e" c' z0 T0 _1 F
  377. determineDBName7 [# B+ g) a, K1 p
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "
    6 E% l" x3 i9 m6 {9 R6 b* f
  379. read svr
    # N( L$ I% @% U% B5 r  j2 X
  380. svr=${svr:-${svr_def}}
    . p7 e* T$ a* k: X8 B1 h) |# E
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "
    1 P! _3 M7 O( W0 O
  382. read user
    # x" ?! g& _8 [6 z- w$ k
  383. user=${user:-${user_def}}
    " O2 s, p1 u/ g% N+ j
  384. printf "What is your ${dbname} port ?\t[${port_def}]: ", L2 \( L# D" W0 j$ e2 w. _
  385. read port
    ( n- \2 j6 j9 d" L+ }; B; u
  386. port=${port:-${port_def}}" S/ R9 q& p$ ?, t  F
  387. if [ $dbname = "MariaDB" ]; then' n/ p0 ~2 |' ^! v# A0 ?
  388.         printf "What is your ${dbname} password ?\t []: "+ Y* w- g! q( E3 l
  389.         read pass
    0 `$ J( r2 E" R( S+ G4 r
  390.         pass=${pass:-${pass_def}}* q4 @: @* w( T/ Q
  391. elif [ $dbname = "MySQL" ]; then
    4 a* N( w' F  |- _, O8 S5 G
  392.         mysqlconfigeditor
      w5 G* O- O% @' D7 ^: j! F
  393.         $dbconfig
    ; G) c$ y! }. W- R( ^
  394. fi
    4 x" Q9 S" z$ J
  395. determineDBCommand3 C) L; k$ V( v8 i

  396. 6 Z! f; \! Y. U0 h+ _  I7 D1 S9 b' {
  397. if [ "${DUMP}" = "YES" ]; then
    9 u9 i, U8 H& m4 W. T4 n
  398.         printf "Enter it again \t[]: ". ?7 V- @' i6 T; z5 {
  399.         read pass0 r1 w7 @" {" f  W/ N2 h2 R# F; P9 T
  400. fi; a% O1 o+ y1 Q' A

  401.   k  e" [, d/ D" m/ G
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then
    7 r2 P$ u8 p5 D* E
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "
    , d* d0 Q) M/ b! a5 M  B, Y# A* v( ^
  404.         read cdb
    ; _2 c. {3 u4 |
  405.         cdb=${cdb:-${cdb_def}}
    . n. y9 ?: G& L8 B$ J
  406. fi# w% r% G. O) I/ x  F3 l0 \

  407. + s7 J+ ]: `& d( D/ I
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then& g! }2 }+ w9 u% p3 g* b9 t
  409.         printf "What is your World database name ?\t[${wdb_def}]: "; q; D, D' d1 L" z4 E. e$ I2 C7 |! t
  410.         read wdb
    ) q& B5 J; k% X) y
  411.         wdb=${wdb:-${wdb_def}}
    ! k' i- T, g( h7 _" P
  412. fi
    4 B6 G+ V7 a! x! o" s2 ^
  413. * W, q; a3 A7 b2 T! X
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then
    . e8 \' [0 b& A0 b  m/ {* [
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "
    8 [2 F0 ~3 X+ d! o! Z
  416.         read rdb1 e2 K% o) F! K
  417.         rdb=${rdb:-${rdb_def}}1 V1 A* k- B0 g, i
  418. fi
    - ?( g  `/ V' r' M

  419. 8 e$ H1 g/ A: t" S7 g/ C
  420. if [ "${createcharDB}" = "YES" ]; then
    : M9 W3 A# F/ s  V3 }) k% B1 x
  421.         createCharDB
    + \$ H0 b9 J( {( |
  422. fi
    $ S0 L, I0 m4 {! C/ N

  423. 0 R! l5 Z9 _9 I" K$ q- K$ B4 m% ]
  424. if [ "${createworldDB}" = "YES" ]; then3 S$ e) T/ D8 v) j
  425.         createWorldDB
    7 i1 f3 P, a2 ?3 E3 O9 ]- }. R( v
  426. fi
    9 y. V- ]* ?0 E! g9 M

  427. 5 N  H" h# m1 `* F
  428. if [ "${createrealmDB}" = "YES" ]; then
    0 w. V+ @) ]5 p9 Q
  429.         createRealmDB
    ) D2 T+ F: M9 d# C
  430. fi$ @; H! V% ^& M. {+ ^. Z
  431. 6 f" U1 O$ l; I- t% K: z3 v
  432. if [ "${updateworldDB}" = "YES" ]; then5 L9 ]- [$ @/ B% m( G
  433.         updateWorldDB
    3 f9 e) H7 x4 q
  434. fi
    - v( A% R# W3 x3 J6 B5 [
  435. . }. ^' S+ E% L" x8 K8 Y
  436. if [ "${updaterealmDB}" = "YES" ]; then
    5 _4 u" m. p& P# a! N! h' D4 y6 I
  437.         updateRealmDB
    , n; X" b/ K' T0 m  D+ O2 e
  438. fi6 |$ C) s% J. W8 l/ ?( ^7 b' Y
  439. 6 D# Q5 W7 U4 h9 h
  440. if [ "${addRealmList}" = "YES" ]; then
    8 I5 v8 e* S1 `% l2 I
  441.         addRealmList& ]1 ?( d9 X! M4 p# Q5 Q' u
  442. fi
    7 n, H0 t. Q: U7 D
  443. ; U% y1 ]& [3 r; f. f5 X+ f' i8 b
  444. if [ "${DUMP}" = "YES" ]; then: N7 `/ L& ?" K! ]1 {
  445.         printf "Dumping database information...\n"
    - q2 N5 r7 q3 y; q% f
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf
    " H0 `5 x6 U, d; v% q9 B
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf
    5 _7 U" ^4 s% j( @$ j
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf
    ; Q4 I8 U- q& c( F
  449. fi
    ' a  M4 }! T# e1 O
  450. 6 w: X: U  y3 Q) a/ M8 I
  451. printBanner
    ( W! R1 _* O) m2 ]3 K9 `
  452. printf "Database creation and load complete :-)\n"
    7 q% E! {2 k: J3 V. |
  453. printf "\n"
复制代码
7 t8 ~2 J9 w+ o2 l4 j% [
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令+ B9 Z$ x, O, ^& z( Y  `/ ^
' ^/ L  L( v( T0 i+ p
使用 Playerbot 密钥的指南:
" o8 U, c! l' v) w1 Y/ c
; p2 V" W4 p( n7 S标识符说明" o' `. i4 m2 }* w8 G$ A4 B; O
机器人名称    机器人的名称
# U* x; l# i2 V朋友    命名机器人或玩家角色# L* `5 ~  p$ n/ N0 A4 h) q
目标    选择目标玩家、尸体或NPC(非玩家角色)6 d, n! d4 r1 h
|    逻辑或* ^& T0 Q5 q( R6 W. D
&    逻辑与
) I& R9 w0 _) q..    多个实例& Q7 t3 H9 v6 J* T( Y+ x8 A# E$ {
/命令    MARCO 命令
( ~: A: x. Y. K, l3 w! U2 S/s    聊天:说
, ?* m' @+ V# C/ S& d& [6 W/p    聊天派对
2 x3 Q$ C7 k1 g: ^- }/t 机器人名称    聊天:TELL BOTNAME
: [6 a9 z0 {: t% X/w 机器人名称    聊天:告诉 BOTNAME
( |" f0 b+ w' P9 K) z! d<名称链接>    名字=" U) U# q3 m- c. [
(捷径)    为命令或子命令分配快捷方式3 k4 i6 C5 k5 U
' @7 m2 z- V- Y7 q; ~$ h" j7 p4 Y
可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明
; S- I& b5 D  D; T) I+ ~+ Z9 v% r.bot 添加 BOTBNAME    为世界添加角色
$ n8 `& a1 \; ].bot 删除 BOTNAME    从世界中删除角色
! n! z; ^- ]! _* ^6 X+ |
( @- s# k5 ]& t' L9 ^6 F# y当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)% K% \, i$ k$ z) t
.bot < co | 战斗命令 > BOTNAME    分配机器人角色# I6 G5 d' H/ Y( [; Q

. C3 U; m6 M' B6 [" v' R宏命令:
. p) d2 ~; C! V9 R7 I! H7 J2 L; K$ g句法    描述; Q  p, |2 p5 F% e; O
/邀请机器人名称    机器人将自动接受聚会邀请5 ]& l# F+ P8 z$ S3 J; F' H! V9 E( X
/uninvite BOTNAME    机器人将自动接受派对不邀请6 P! }6 n/ s. l; r+ l" Y

. U9 P( T& [, ~( Q% |  a* O0 a) lTELL/PARTY 命令:(某些命令可能不适用于某些内核)" o7 N- h9 J. I
句法    描述
0 ?0 e+ u: ^$ B9 m: x+ |协助目标    机器人协助列出的角色,在他们攻击时进行攻击。# _2 u% @; o+ s$ U
攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式
- a* b5 {4 q3 q拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..2 e  C! b: F* [5 E/ D
拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >../ g) z8 h% q& `0 e
拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..
% }2 Y9 v  w$ G9 U* x银行    命令机器人寻找附近的银行家并列出机器人的银行余额
/ T3 [8 \2 |6 u5 D9 h, A0 W% t银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
. R; ^. Y8 ^) s5 z; N# l/ p9 }银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..' N) P% `6 X$ s( w: g* }' q* B$ _0 x
(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..
. q0 ?+ a' M8 e3 L, s©ast SPELL    拼写 = >
1 i; E; p$ n0 f% |* n搜集    显示收集对象选项和当前收集状态
3 K% M* M/ m- z. }9 J收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
6 _; U3 v" X* S' U% q* t工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
% |; S/ A# [( k* p( b% E7 l1 u工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例5 h$ g! X  |! K' `. B1 F2 Y
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习/ w5 |" G, h3 U& `$ Y, n# R  w
工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习
8 F4 a( _4 E6 u8 h工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习' K& P& r/ X$ o! x
工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习
7 A7 v* z* T1 H工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习
% q  l) Z3 C9 q工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
/ Q% ^; v, l+ [工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习
3 x, x3 }  ?* O6 C" S7 e, [# U手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习
0 ]% \4 v, i) b; F1 m工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习# D  n6 F& l# y' \' y7 A# k
工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习0 c9 @" P; }$ J5 J/ f
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习
$ B( j" }' e6 t8 Z掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..5 T5 @) u1 J) P+ S- l9 s% d
全部放弃    当机器人库存变满时,丢弃所有低级物品。
# d$ S4 H$ E$ f3 E5 ^附魔    列出机器人学习的所有结界 1< Spell LINK >0 c& G& Z# J: m" W6 ?" a. z
附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中
; @  n* j4 E& w9 b  g(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品/ j* B, w5 l- w  ~
(e)quip auto on    打开自动装备,也立即检查
/ B, ~, Y1 {; D6 [6 Z(e) 装备自动关闭    关闭自动装备。
; G) T9 G0 d4 _& C3 V, u(e)quip auto 一次    运行一次自动装备,然后将其关闭。
0 e2 r' n: C# @2 [(e)quip 信息    显示装备自动切换状态(开/关)。. U6 e! {* O6 L: a+ Q8 Y" @  a* E& O: m
(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用" k* S$ h' g9 v- m
跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人
* J  m0 B& ?6 L跟随汽车    切换自动跟随距离(开/关), ^4 D2 @: J' G3 t0 r" F
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)
5 ]' `' T6 e4 {跟着远    机器人跟随,远离主人。0 I: v. T% r8 U, Q! u  o* O+ z
跟随附近    机器人跟随,更接近主人
4 i5 ~' _- ]2 a) _3 [# N- ?" Z3 |跟随重置    机器人跟随距离重置为原始默认值
! g* Y0 O8 e  w7 C4 S8 ]( F! [(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家
5 G- B( J1 E, c! N订单    显示机器人的战斗命令
  a4 l8 z9 ?6 B9 X- D. }8 |订单延迟<0-10>    在机器人开始战斗之前激活延迟。8 [& e3 }4 \: N; d" S
命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
' L3 c9 S5 P( |  f, T' x命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。
' _; n, y; O0 Q% F5 R3 I- q命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
, u8 K3 v- e4 K  E( o! E, ^命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。( T6 |5 v0 |: E6 }/ A
命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。: K- _9 ~3 \3 k2 B% O
订单恢复    将战斗命令恢复到注销前的状态。
+ R- L! ~) W0 Q& g4 H; c, o, H邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。
& c( S/ Z; K' b  M. f5 ymail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..8 q. ^$ L# ]4 k  i+ a7 c
邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..
  \0 g/ A* A& F/ }3 I* Q邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
0 j7 a7 m4 z0 {宠物遗弃    放弃活跃的猎人宠物。7 y8 h( Y! B! e9 B2 u  ]. t9 z' v  K
宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术) {5 z" K7 l9 L8 b$ {- u
宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色
# K& C+ o. U( I! M% @, v1 n宠物施放法术    拼写 = >3 Q+ G- b3 n, m% U  {# f  n
宠物切换法术    SPELL = >为给定的法术切换自动施法+ G2 o3 e$ Y% B) z; k- i; ~" ~
宠物状态    显示机器人宠物的当前反应模式
! s: x; j7 @, {; i4 {宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>5 C' l* B9 q6 X$ c3 b
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
7 U8 l$ g- \1 S* w( a( e处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素
3 M1 m' i7 E+ A4 o! A# u过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
1 Q8 X, J0 L$ h; e拉目标    以协调的队伍/袭击方式拉动目标。- V" ~3 ~4 A" C; K1 W2 [, e  F
拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。% j! Q* I9 ?6 f) K8 x6 P6 Q. \
准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。
. `6 b' u' F- o) s1 \! ]+ m6 g# e. b寻求    列出机器人当前的任务7 d7 k: H& u5 P& L" F
quest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..5 Q5 [+ \9 r. C7 o; @8 P8 M! t
quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >8 V$ ~6 @3 a+ z0 }0 \6 ^. t0 C, }
追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务& d7 V' r, ^$ b8 L& c
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象- M. p+ U8 \3 t' S% |
任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
* F* _- l" [1 p$ q2 f& Fquest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到
: K6 ]/ K' H, Z7 v4 ^修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
) v: D. A9 Q4 \5 W4 {2 W" }全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品  t; v9 y4 A4 {, ~3 o+ K+ |! W
重置    重置状态、命令和战利品清单
- b: j2 h4 A9 W* O- ?(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..6 s) C. H5 _8 q+ u& ]  m4 }
(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。# @" J  t- ^8 e
技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能( G' u- Q5 i( v: P$ `0 P( T
技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..4 a* d3 b/ b8 k2 p: L: O0 q
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..
0 m' q" p% d; s! |4 F技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术" Y3 B. I7 A1 O8 ?7 p) y5 I: k
咒语    显示机器人已知的所有法术
4 H" x9 @. Y+ k; I! E统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本) v6 w) a5 c7 L4 ]$ I1 M9 z4 A
停留    命令机器人站立而不跟随玩家
7 o  q, `. `1 ^& o% Q: H3 k: G2 o召唤    玩家附近的传送机器人
2 I2 ^2 U, m( S民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..  S* s5 I, l" n! d; {
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)7 [4 D2 i* u8 c: P0 V
使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)8 p; V8 z8 g/ p6 g5 Y
句法    描述6 ?# }" `* B1 [! y2 B# w
天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用
6 ]" B& j# B6 G, T. T  P3 r人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋
% n% D7 q# M- j& N0 `/ q5 K1 `+ P天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2) m3 z. c' `/ \1 Q' p5 t
人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
: N# Y1 y" {; ^, O; e( h# J9 ^天赋规格#    机器人将遵循此天赋规范。. E- b  ?3 P# T! W8 S! i+ a6 C- v

' D3 |- ~4 J1 O2 m6 W1 要选择 , 。
) O; e7 S) d) m. o4 C' n4 v( `9 `' U2 每个机器人的税收增加,每次重置天赋。# ?) n6 i/ r1 y# f8 K
" J/ N$ ^/ c. n, D8 c

4 m/ @4 L+ p) q+ O
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-30 08:33:50 | 显示全部楼层

Installing ACE on CentOS 7

Building MaNGOS on Linux requires ACE libraries. I could not find information on installing those here, so I will make a short HOWTO (copied from ACE documentation)% }7 x2 n' g8 h0 Q, L1 U' m
' }( S* h* P3 m1 u( ~7 v0 A9 N: _
1. Make a folder for ACE in your preferred location ( I use /opt)
' v% K4 i0 a/ Q  p5 \* T* B* y" _  W- O; \
mkdir /opt/ace && cd /opt/ace9 l: j# f+ m& W5 F8 B8 i

8 Q4 K, i6 o3 n2. Download and unpack ACE
. S( v. I. C6 g! H
0 a0 Y& d0 Y4 C" hwget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz
2 I0 @7 @# T. K) Ztar -xvf ACE-6.4.7.tar.gz8 }5 U* j, c( @  J9 v) F6 I" W
# T! c* j% i8 y: d4 B$ {. N* P
3. Add needed environment variables" `7 M, U% k9 `; @
! D3 S# B8 e+ k8 Y1 K
cat >> /etc/profile <<EOF  z* x) q4 A6 S9 A5 k  d4 m  D6 l4 L
export ACE_ROOT=/opt/ace/ACE_wrappers; o; [8 ^2 P+ S1 m' O
EOF; O. e. D/ V! R+ ]7 A/ _9 u$ i
source /etc/profile

2 l( g$ t8 w: g# @7 _/ v: k% H, e# @( }. K. Z
4. Add the desired headers4 ?+ r, a2 ~, n, t* k* i8 U3 d
9 z. ]3 l$ o) E  d. E
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF
1 L0 Z  ^8 \) T) N5 W: g1 Z9 A: U  U& ?#include "ace/config-linux.h"  a, j* N) D. [
EOF* e: L) k8 D, `8 U
cat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF, i& h* F* c; ~$ C3 \* h
INSTALL_PREFIX = /usr/local
$ `0 [9 n/ L" F6 Oinclude $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
  R( o& t: |+ H- n. R  c( p' }8 s( _/ ^EOF
' f" j! o. s! g* a
# m2 X( ^$ L' t
5. Build ACE
; f5 ^# v- U6 N# ]7 _, w# s8 P- k0 S1 V$ }% L2 m5 V1 R4 g8 t
cd /opt/ace/ACE_wrappers. e0 L8 {" U6 D3 [$ Y6 m1 j
make
  f+ W7 W! J' q' K0 dmake install

3 V; a9 e$ T9 o9 O$ W3 g6 e7 M3 r2 C1 r/ N/ O
6. Add the library to the public path
! l7 T& H! h# D% V6 S2 n
$ w6 t/ R$ G$ |cat > /etc/ld.so.conf.d/ace.conf <<EOF- ?# ]) ~( o* d0 R" b& q
/opt/ace/ACE_wrappers/lib' j4 n- _: I6 w: p$ c
EOF
8 Q8 O  R% t, ]/ Y/ x7 ^4 Tldconfig -v
# s  E/ f7 {  {* A8 _( t; A8 n4 k
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-30 09:58:27 | 显示全部楼层
/home/mangos/two/src/server/src/game
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-30 11:10:41 | 显示全部楼层
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client* U+ E6 `: `/ m- j  P; \
Torrent Download2 x' G- x/ X; f6 B; C
" E0 @& |; d3 E
These are clients that can get downloaded through a Torrent. We always recommend using a VPN, when you download the World of Warcraft – Wrath of the Lich King Game Client of 3.3.5. The reason is to avoid copyright infrightments from your ISP
! _4 S2 Q( q! A7 m& u4 _: I
, ?8 s; r- X( b' v    Torrent – Client from Dalaran WoW (Recommended)
( J/ o: z+ t* e    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)
5 E! ~6 A+ Z: [4 f* V# C7 J    Magnet – Client from TrueWoW6 S+ t2 c+ G, n7 K8 _

4 n( Y1 \8 ~% L3 \Direct Download3 B: J( N; ?$ {( Y+ y

7 J, V* }: F) ?# P( FBelow, you will find direct client download links. Instead of downloading through a torrent, it will download through a media upload service. If you can’t download through a Torrent, we recommend the ones below.
- j* w8 C" J7 ]& v' i0 {
# K5 F6 a* H7 }; D0 I5 Q1 e    Direct – English Windows client
! S, j3 D' R  V3 U1 |, x( {/ }+ G" D
3.3.5 Wotlk MacOS Client
4 ~2 B% S/ U4 r6 c5 F
$ Y: I- J$ t1 Y4 R0 J: GThe Mac users should of course also be able to play on a 3.3.5 Wotlk Mac Client. Therefore, you will be able to download below.: ^" T2 }! c, ^5 c, M' t
, b0 O) P4 C5 t2 T+ {
    Direct 3.3.5 MacOS Download – Client from Sunwell
; D3 k+ c8 D1 {- K    Direct – Client from Paragon-Servers (French)(Mac)
5 W  D1 L  W4 y; H, K6 D
1 s. B  j, w% e: A2 O# BModified Clients, LegionRemaster:
9 Q3 L% D+ O: Z5 T1 ^$ `0 k! x" G" ~% p; A8 V7 J) n7 {
    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis# ?% G6 I3 p* A& M3 V7 w' M
    LegionRemaster Patch (modified), n1 H; {/ X2 f1 f0 t! q! p
    LegionRemaster ReadMe (Custom)
2 v) C" n7 D' v$ e% Nhttps://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos! _6 v0 q6 R4 n1 Y
; }" x8 q; f( j
在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
/ I# p5 U* ~1 o* i3 y- K0 i, p# H. ]4 c$ l5 ~
本文 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。
$ a+ u! |% V% [5 Q* q
/ n, i* \4 C' k: m7 e! ?! r8 Z正文如下:
' a$ k" W( j6 a8 W- R" f3 }0 e2 v, T( m1 D: J
开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。& e: i. B) D4 Q% w

: J( x; F2 @# k4 x* x- ]暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。7 D  L! `+ v9 E+ d' r- A
( Q' P0 t5 s; g# s- G
而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。
3 _* a8 E6 S9 v# w8 z& w/ H% w
) g5 q, t' `; s& R! C  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。. K. s' j+ T+ S0 s! D* k
; o9 P2 a5 Q$ B9 w& J- ?% a
开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。& x7 X' E' O' b' U' L

8 h: |" t. Y, Z% Amangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。+ H; x  Q$ }6 g& |- t
& i; ]$ B+ ]" |( I  N
2 Z  j8 L# ^6 ~# X- N" N: n
为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。
" ]+ G! B3 x  A% y0 o0 v& m: e  l4 a1 V7 I! i  d( e
一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:
    * r$ p% P2 K% `% e
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:
      g' k, M7 e6 k$ x
    Brien
  • 开源数据库软件MySql
    ( P2 w. W/ q/ ]: ^2 N9 h官网:MySQL
    ! P6 L$ }% t4 x$ Y
    或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库9 G/ [  I" H( [5 [9 @% G
    官网:

    ! C/ E& {$ x6 x9 u& e我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。- V: }  v: V+ W5 A$ v" |8 K
    文件名:CompleteSDB156-Mangos3462.rar
    : v; @' q5 f+ h下载地址:- n# {6 @$ F0 ~! C4 D

    : b  O& j2 j$ p* K) I5 U+ Z
二、安装MySQL数据库,以及SQLyog客户端
  • 点击安装文件选择典型安装(Typical)
  • 配置数据库服务器"Configure the MySQL Server Now",选择标准配置"Standard Configuration"。
  • 确认安装成windows的服务程序和自动启动服务"Install as Windows Service"、"Launch the MySQL Server Automatically"。
  • 输入你的root用户的密码。可以打开的使用root远程管理数据库的选项,便于远程管理,和链接。
  • 应用你的设置。
  • 点击安装SQLyog的安装文件,安装到缺省路径,运行SQLyog。
  • 当SQLyog运行后,需要输入以下信息:
    • MySQL主机地址:可以输入你的本机IP地址或者"localhost"。
    • 用户名(UserName):root
    • 密码(Password):在第4步里面你配置的密码。
    • 数据库(database(s))输入:"realmd;mangos"/ V( X- N4 c) Y
    & x, c- B# b* ~) s2 R
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径
& R" B6 b# R" t
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。
    9 s0 Y) _: ^9 s4 X6 A( g. S
四、解压安装地图文件0 Q  b/ j' P" f) [  B
  • 把ad.exe放在魔兽世界的安装目录下,例如("C:\World of Warcraft")
  • 建立一个子目录叫maps,结构为:("C:\World of Warcraft\maps")
  • 运行ad.exe文件。耐心等待ad.exe把魔兽世界的地图信息提取到maps目录下。
  • 将maps子目录拷贝到"C:\MaNGOS"目录下,结构为:"C:\MaNGOS\maps",里面的地图文件大概有2400多个。
  • 可以安全的删除"C:\World of Warcraft"下的maps子目录了。% ~& _, k, [& G. b
五、解压安装提取的*.dbc文件
( O& r! D# u* \
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:' C- X2 B! t6 j- F# u, ~8 i
    mpqe /p dbc.MPQ DBFilesClient\*.dbc
  • mpqe工具将魔兽的游戏信息提取到了\MPQOUT\DBFilesClient目录下,整个结构为:("C:\World of Warcraft\data\MPQOUT\DBFilesClient")
  • 当mpqe运行结束后,可以将所有的*.dbc拷贝到你的mangos的dbc目录下:("C:\MaNGOS\dbc"),你大概有158个*.dbc文件。
  • 你可以安全删除魔兽世界下的dbc文件目录:("C:\World of Warcraft\data\MPQOUT")了。
    ! u' A5 r* f* Y) d0 M* i
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.
! T4 }- h; N* I% {9 l
  • 将下载的CompleteSDB156-Mangos3462.rar文件解压,里面有几个数据库文件。找到其中“realm-database-full.sql”和“mangos-full-for-rev3462.sql”文件。
  • 使用SQLyog连接到你的数据库。
  • 在左栏找到realmd ,点击右键选择"Restore from SQL Dump",找到“realm-database-full.sql”,导入数据库文件。
  • 同样找到mangos, 点击右键选择"Restore from SQL Dump",找到“mangos-full-for-rev3462.sql”,导入数据库文件。
    ( c; E5 h( z; _3 x
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。4 A2 k. \$ N4 t0 Z( e
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到) S& j3 U1 J; D6 r/ c3 A
    "LoginDatabaseInfo ="
    ' X( Q& E" Q, H( G3 ^/ g; ^7 [改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"! o* g" s5 T, d$ `
    这里的IP地址可以是你的IP,[password ]是你的密码。存盘。
  • 在mangos目录下打开mangosd .conf 文件,找到如下的内容,并设置如下:
    • DataDir = "."
    • WorldDatabaseInfo = "127.0.0.1;3306;root;[password ];mangos"
    • LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"' k+ L1 m8 S. R& e. B  m% X

    " o  x/ F( U- v7 _- M, m( @  ~
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。

9 i4 P4 m% S+ F3 ~6 V+ ~) ^' f9 g8 x# f7 ~
0 y; J+ O6 _+ _( X+ \4 y1 z& [
5.安装数据库
8 O: I/ J8 Q- A4 P* ], r! y4 V使用mysql建立 mangos 数据库# H9 {. K. y* \  \
& L9 w$ W4 K9 j$ b1 Q
a1)使用官方最小数据库,mysql用户名及数据权限等请自行设置( v3 w) u: H. u7 D) h, k
mysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据
0 E8 U$ N$ Y1 S/ N7 E; u" @& Z9 a  {1 G/ f* J2 d7 \
a2)使用sdb数据库,mysql用户名及数据权限等请自行设置
$ {& D* L6 `, d6 J- N假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
4 l/ z0 B4 ^, a6 Kmysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据/ x' i- y# ~' H. ?: u' m
: }$ f- z7 Y( T& E+ C5 t
b)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1
5 n4 V- l: z$ `  l% d6 B7 h5 r# J) [5 s* F6 V8 J, u6 R
6.编辑配置文件
% ~! Q; f, v- Q# T( v' T3 f/ H编辑 /usr/local/mangos/etc/mangosd.conf8 K5 b' X+ f8 p4 m8 _; W; l

6 t3 x4 ?' v" ]* u: ?2 }* J  ~a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"9 @7 |' T3 _4 r6 N, L# B1 m0 g
为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"! B/ H0 V* b* B

5 U5 F$ i- `+ ib)找到 Host = localhost
5 a$ C7 l3 t/ _8 T为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1* I9 s, M: L) j& W

/ v. \; j: U$ n  ^
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。
7 r! T# a, V7 h- {% e% \3 N& p9 W" h# r7 ~6 R
本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。: [' C$ ~; @5 C9 g% y4 q
& t7 i$ x: J! V' E  Q8 X
我们走吧..
8 _- h$ ?; K5 F1 I9 Z2 o; z" Q: T
4 H7 p3 q  X" s9 R设置数据库:
4 G, L- x+ `9 g2 \8 N0 ^
6 ?2 v) |1 ?" v: l- [7 l# MCentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。" \; p' s% Y' K! v  q6 K/ {- s: ^
8 U9 N3 u9 k: n. g$ d
启动一个终端,如果还没有,您需要成为“root”用户:# d9 {' ]' j' M3 W

0 n& T" |) T0 `+ N( A须藤苏 - 根' X  H3 i, C$ ~5 T
然后,安装 MariaDB:' l8 z+ ~1 ~- i
$ l6 L) ~% @* c0 p1 z: n, ?( k0 A1 p
yum -y 安装 mariadb-server
- N0 ~* v" b! @* b     安装 MariaDB 后,启动它:
! S' s& `+ q  e3 R* J
  b) C8 t* T" @! T  Y7 fsystemctl 启动 mariadb) F3 l' b3 w# d1 e
我建议您在启动时添加 mariadb 服务以自动执行它:
8 q, S! z/ I- b1 d% |% y  q. R1 I  D' ]$ \7 \; d4 \
systemctl 启用 mariadb
% _3 b( I6 s7 e2 R; ]2 G* p  w) t让我们保护您的 mariadb 安装,执行以下命令:! u+ N: M$ i1 Q, g( h$ z
& n$ Q" r/ H! u: F
mysql_secure_installation
3 V) X" ?: G. g3 p! h% c我建议您设置以下参数:
6 ?9 n! |' \& Y& h4 v; r  f& a* d6 z
设置 Root 密码
' q3 z9 O, g8 `删除匿名访问
" D" D1 }) J7 ]% A; e禁用 root 用户的远程访问+ N8 E+ S. Y6 d
删除测试数据库
: j- ~2 \9 C" U- C$ p  b- o" \重新加载权限4 Q% V6 l: T" ?3 U+ d
验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:
% C, q: U- a- K6 Z, G% c  C; v
mysqladmin -u root -p 版本5 G% X) Q; n5 i" t( z: X$ B
如果一切正常,您应该有如下输出:
+ N7 v; ~. R% F+ C9 T" c) e# x* w5 w
服务器版本 5.5.52-MariaDB
0 L# |3 p- l0 M0 ]- l! Q( ^协议版本 100 \) E0 |7 j5 V7 x
通过 UNIX 套接字连接本地主机7 ^- O- ]. H* t  l, B& W
UNIX 套接字 /var/lib/mysql/mysql.sock1 t$ N# X  f# ]- l( K
正常运行时间 x 秒1 m) E, p) O. i5 J+ P

- g8 w- U" H) z7 x  S7 z4 w4 W/ O6 K  k% L, u; J
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:. {) ?' A7 n' d* d- v

2 l# ]' A' e  ?* M" y7 ?mysql -u 根目录 -p
4 x: J; I4 p$ P  j0 Q, A. |0 z创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):
* L' P  m5 U5 U$ y2 ]+ j
7 O, ~$ x. V/ v8 F# P+ n创建用户“芒果” @ “本地主机”由“密码”识别;
7 O0 W/ Z- {8 h2 }6 J# C然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):
- U: p* Z$ G/ K! j! ~8 E: K, c" b' @
  \. [* ^2 R; U9 ?. V将*.* 上的所有特权授予“芒果” @ “本地主机” ;
; G6 ~% ^9 N( a6 r2 {% s退出终端:
" L1 }& t& X- B( n7 H) X! E7 t
' ~6 U, b0 H: h( F: X: C退出
$ K4 f' o: R( p5 Y恭喜,您已经在 CentOS 上设置了数据库的先决条件!" W- x6 a8 r& U( B; z/ Y
7 Y, p% b" c3 s  U0 i# Y) P) s

! l" \- o4 {5 Y7 ?
3 q1 X8 \% d9 z, w( \" i安装芒果:
: R' u& S: M3 U! t8 B; _) B& F) _
我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:
2 j" l) U9 M. u) r+ R/ K
5 Y2 X9 O4 r" T) ?* `, P* V* y# n光盘~
$ v1 F9 H' o. N# H让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:
' l( L3 y6 R! M# e. s6 U  i- D% H3 A+ k0 \+ @% Y/ L0 _
yum -y 安装 wget
) B  S  t9 [9 `6 D) x7 h" u* P现在,我们可以下载我们的安装程序:$ m! L  n: o8 H: Q4 m) k' g

: u7 u; a# W4 p7 ?* ^wget https://raw.githubusercontent.co ... /linux/getmangos.sh  K" W# P, u. W9 ?- A1 m, t: U
设置允许执行它的权限:  }- N8 e$ W+ A- ~4 x4 @

0 a) J5 T+ h0 k! t, Dchmod 700 getmangos.sh
8 A+ c# S: ]; l" Y并执行它:  I0 j7 N  {' r6 j+ y1 z1 c

2 ?, [. W1 ]# ?/ e./getmangos.sh
1 z7 y. W5 E7 w4 R! a在我们进一步讨论之前,对可用活动进行一些解释:
, z/ P+ @# ~" C; C8 T; e9 C" s' W+ k
. S- g# x& `" {  [& p' j2 p安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。) ]. C1 S( C* ~
设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。
$ A7 C; E' {0 C! F3 M克隆源存储库将帮助您克隆Mangos源。默认切换。7 j# m$ e- ~' x
Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。3 l' ^0 J) b% \, D
安装MaNGOS将帮助您安装MaNGOS。默认切换。  ~6 f" Z$ C7 J( A! ^
安装数据库将帮助您创建数据库模式。默认切换。& F, b! W6 ~8 E9 O6 F+ Q" `
提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。
% c2 S, f; a$ w: k# e5 A创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。
: d, g+ b- A2 B/ f* b现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。
* i5 ~  p; y9 l8 E
" w$ c, z5 v  O3 J  b* x用户选择:: _( W! @* e% o/ e
9 D8 g& Q' v+ E0 O; M
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。
4 S/ u5 C  n# e4 r0 h) x+ K4 W) O* o* C! ]; E; w
如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。
! q% R  {! K' J( Y# y! T7 E. Y6 n' i0 e2 e# A
选择魔兽版本:
! j+ D* x' j/ |; e5 {- [! ^# R, f' `) P. R1 f6 Z( k+ V
下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。
& l9 w) F8 m% Y( Q$ s: s2 f: o8 K, e( R2 ^* w. i( e3 ?8 }% e. d
源代码路径:
( ^+ ^+ y# ^+ U2 D6 {, K, U
" Z: K! W* Y. q0 ?7 O下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
% O7 @8 r1 m7 b4 u- e1 ^6 D) |0 z( s& o  W7 K8 E. i' k; ~
/home/芒果/zero/src
0 s+ h1 G" ]  J* w% t如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。3 Y/ L, i3 P. G5 O
) i8 o7 {) m  V# C" K1 ^
安装路径:
0 a/ B7 u- L0 x, O) P8 g
; }/ {4 q3 w; ]3 h下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:9 r/ e  e5 `3 I/ X7 |7 B
9 O& y0 B4 Y% c7 z( {3 D% O
/home/芒果/零
3 n( E5 T( S- G  v$ |; @如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。: D# U2 `& p) e/ l7 Z
/ ^3 b6 \7 `9 v( w+ [1 C- n7 Y
克隆或更新MaNGOS:
0 {' U: i; u0 t- H% p! z8 Y7 y3 y! D. c
3 q- Y) j8 W! T5 O脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。
! n- {: M& r' ^' R( K% O
$ y: ]+ u3 l; l3 A. o3 T- e& q安装程序现在正在克隆服务器和数据库存储库。
) A+ c1 `+ v; w0 L% V. ?6 \
# I, ]7 G3 m) B% X构建选项:
2 ~- J) O; h; \3 T* D* |* K
1 J% n: O5 k( j% d3 [您现在处于构建步骤。此屏幕上的一些解释:
3 v8 q, `. ^( w- I6 R; E6 g9 A. P/ x1 U9 W2 F
Enable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。5 O  J) j8 |1 ]; R
使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。4 l1 n& M# A; r+ w; F6 t5 i1 r4 C, j
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。
8 J: n' E# g& `( A0 J$ X5 K# y3 k使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-6-20 07:08 AM , Processed in 0.117226 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表