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

MangOs搭建魔兽世界私服

[复制链接]
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!) k4 `4 z# T$ P- f
考虑再三,我选择了CentOs来做游戏的服务端操作系统。
7 |6 K/ ^' F! _/ b3 W通过Git获得Mangos的源码之后自行编译搭建服务器。
! S* J5 b! A7 G这么做处于几方面的考虑。; ]/ I4 l" k; Z; v
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。: E( [8 ^. P% d
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
3 K' Q2 @$ z: D6 u/ y把该打的补丁都给打了(yum update); L8 q. N/ e  N2 ~6 |% R6 q' P
完了之后,咱们安装一些基础的组件和环境。
; m  w3 \3 b, _. c4 ~Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel- J# D# z+ U+ k9 y0 I( W& ]" E0 {
如果有些组件提示没找到,无所谓。继续往下。9 a, B( C3 v2 G3 w$ `$ F8 ?7 c* L- _; S
我编译安装的第一个版本是cmangos。
: v# t5 I* s) E0 v" o这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。- ?* _$ j) z( o3 S" }
cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
- Z9 c8 M/ ~- l( v$ X1 t编译参数中:7 C4 W8 G/ k2 ?% S
DCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。) b: j& B; C+ {' H8 R
DBUILD_EXTRACTORS是指是否安装地图提取工具9 B# ^( I% W! p6 d/ O
DBUILD_PLAYERBOT是指是否打开机器人4 q& t: i0 M4 ^9 s3 \% g) C; p7 F
这里我做科普2:
! A; q, M6 Q. U1 \/ w+ H& O; z" t2 X首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。
7 ?8 T. i/ c! T8 ^5 Y既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。! C5 F# y. a5 p. s2 @
至于那个机器人吗?那是个笑话,请自行忽略。
+ F9 M* o( c+ W我们继续,我把整理好的搭建步骤列一个明细:
$ r$ N3 |2 ]; Q5 x# x0 b/ L
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。0 c' u' h$ ]3 P
这中间,我把一些别人不会告诉你的关键步骤做科普3:4 U5 k) U- O. H; G( B
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)8 k" m5 [1 m* e* w9 b
放几个链接仅做Mark:3 A9 v: x  [  q; p4 J; ]# k9 Q
Cmake3 安装! T: o& P7 u( a3 p# p6 x
https://blog.csdn.net/weixin_38883338/article/details/86408749
: P' y" F; u  A# xGcc 6+ r) g8 p5 h( Y# Q8 c/ ~4 s. `
https://blog.csdn.net/Al_xin/article/details/92438055
* a+ H' M- `) P; uACE6.3.3
0 [: g5 A! ?3 ]8 Hhttps://blog.csdn.net/u010587274/article/details/50965369! f5 F# G2 W6 j/ j0 o6 `8 D$ P
Git源码和数据库编译安装服务器
2 Z2 H1 l3 `, }3 H1 rgit clone git://github.com/cmangos/mangos-classic.git mangos
# M& \6 f" N" E2 A/ H3 e  mgit clone git://github.com/cmangos/classic-db.git" l& g& Y) c6 Y: ?) b
ACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
& k# w' k# y' m+ U我们来说一下服务器的配置。
5 Y8 Y$ c; `2 S) w2 B在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
7 ]' Y/ b' y4 f( K, i
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)
    * V$ X3 M# I( o1 z- s
有几个关键点,我整理如下:
+ p& B. z  P% g  q( X
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。6 ]9 u' [3 s/ U& M- a* c0 G7 x
参数名称:
4 u3 B1 Q0 ^0 {2 c2 f) @地图目录! h+ j& D; y" }% t
DataDir = “../data” . C/ C& r. T/ j
日志目录
6 q# p0 S; @- U% ILogsDir = “../logs”7 R% _) Q; m4 Q9 \" W- e# M- U, _
游戏欢迎语  ^" z! a0 D% y- w' e
Motd= “游戏欢迎语”/ J' N. z. s' n: F3 I. G- ]5 M% A
出生等级: V6 E  j$ b3 z* q1 o. O
StartPlayerLevel = 1
& r" m2 z5 r1 E出生携带金钱1000G
" W0 |5 i8 ]1 G8 ^- |StartPlayerMoney = 10000000
$ R7 k" D- r8 g, M" w7 {杀怪经验5倍
, D0 j; |; N9 q  Z; ~. pRate.XP.Kill    = 59 c& [! v# l; t) h5 }! J. t
任务经验15倍
) w6 P) u) Y$ T+ C2 IRate.XP.Quest   = 15( ~% P5 k7 W/ g4 Q' m9 R* g
探索地图10倍/ p/ c5 k2 O, M* L9 d% H
Rate.XP.Explore = 10
/ m) w& f. B, R: S9 y* k数据库连接(应该有3-4条之多,按下面格式修改即可)
$ P7 x. u! [) ^LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”
; _7 }# O, P* F# q; r, @配置结束,就是启动。: T; D1 A: `% F8 a  F" Z( W8 D4 W
因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。2 }8 y1 O: z% w. e: ]( a; b
我们需要开启如下端口:) f1 o" h) k) N1 J6 R  K: A) _7 G
8085,9600,3724, J( W+ @  r) N6 u
把他们添加到你防火墙的白名单即可。
% Y) {# S  T- K$ [0 `, q(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)
8 C; F& H6 O- ?6 q- `3 }一些收尾工作:' Q( L7 Q) Q& |8 s. t
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。: E8 d5 J4 h3 v( u8 w! }( p2 H

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

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

 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git+ q# L* l" }. L/ }
git clone https://github.com/mangostwo/server.git/ [9 \( i, A8 A% P3 A' M7 L1 C- s$ D
git clone https://github.com/mangostwo/database.git
: ?; Q( M- c9 u( Z0 a$ |. t, s. S9 I' k2 ^! t7 }1 M. K! i$ E7 J! r
  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, q' {. _; d/ a+ ^' Y
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils
    / ~- n1 F& V- [+ U' J
  3. scl enable devtoolset-7 bash
    % Q# R  ~3 u! `) _; W
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile7 C/ i: e3 {9 S
  5. # 查看安装的包  d: \" |/ [. W- F& g, q) B
  6. scl -l
    4 p7 z8 C: }, e3 w- O( Y
  7. yum -y install rh-python35
    8 ]- E0 }4 ~# @! K8 _# K% ^
  8. scl enable rh-python35 bash6 l  X1 \5 i! U4 U4 x+ z
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    : U' H+ I# x$ H3 W; X! a

  10. ) J! U# Y2 {7 @  ~
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz; j% j0 {9 q- j
  2. tar -xvf ACE-6.3.3.tar.gz4 V3 \6 D( \* L
  3. vi /etc/profile
    % {+ j6 y2 y5 T; j3 V& n
  4. #在文本尾部添加:
    ; \6 n# N" Q0 I& ]1 U! E
  5. export ACE_ROOT=/root/ACE_wrappers1 U+ J; G  Z+ g% q6 l) O. T
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    5 @( T8 j" [) ?
  7. vi /root/ACE_wrappers/ace/config.h% O: a9 o5 p9 y3 b1 R1 X
  8. #写入如下内容:
    3 K; g. |- ~/ D6 E/ I
  9. <code>#include "ace/config-linux.h"8 Q. Q! P7 I" e7 w0 j' u  Z
  10. </code>( M$ a! ^- l3 _8 b9 P
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU+ C9 G1 p' L" R
  12. 写入如下内容:+ N1 `; A$ ~8 Q5 B
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>
    - b% R% K) _' e. B5 t
  14. <code>INSTALL_PREFIX = /usr/local</code># {5 c+ p+ A7 o- p( f$ p; A

  15. ; q9 U. h' L6 V! N3 W7 l- S1 z
  16. chmod 775 -R /root/ACE_wrappers3 h  i# a+ _! @% f# d8 \; ?
  17. cd /root/ACE_wrappers/
    ; h# _8 H( L! }5 L5 P; h  X+ S7 C
  18. make, V0 Y% V! F+ m/ J
  19. make install
    ; ?5 M5 n4 d7 C& {& }0 a0 O
复制代码
回复

使用道具 举报

 楼主| 发表于 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( d" C; u' x" S: z4 s* z
  2. ###############################################################################6 Y) x  q4 i# l& |
  3. # MaNGOS Build Automation Script                                              #
    $ d) T: ]+ Z3 k1 }" \6 o% i2 r. V
  4. # Written By: Ryan Ashley                                                     #- z; a4 i* C+ ?7 R$ }" U2 T% i
  5. # Updated By: Cedric Servais                                                  #
    # K1 o* E9 B5 m9 v
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #
    5 X  {, \, `& W" O! i. F0 y% ~/ s
  7. #                                                                             #
    % D$ u4 F9 o0 S8 O- U! p$ F
  8. # This program is free software; you can redistribute it and/or modify        #
    4 L# a0 r! S$ `2 \) H! N
  9. # it under the terms of the GNU General Public License as published by        #) T/ T7 o9 j; w5 G8 {# {0 I
  10. # the Free Software Foundation; either version 2 of the License, or           #" [% S) k: w8 p  v/ j) c
  11. # (at your option) any later version.                                         #: c" |  g* q) s7 d
  12. #                                                                             ## H9 @) C! x# Q
  13. # This program is distributed in the hope that it will be useful,             #1 {0 k8 i" S: n* ?/ ]" |1 K: V
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
    " t# C, Y6 X/ G& t& K2 O& ~
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #
    0 p1 M8 @* O( W- X" \! S
  16. # GNU General Public License for more details.                                #
    8 f; J2 s, v: G- h
  17. #                                                                             #
    0 _+ i8 ]) W" Y, a
  18. # You should have received a copy of the GNU General Public License           #
    ; Q1 G5 R5 s3 J. e6 T& X
  19. # along with this program; if not, write to the Free Software                 #
    & E5 `3 c' I* e, H7 {; W
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #8 _- y; l) Z, ^( k! m4 ]
  21. ###############################################################################
    " f+ h- O0 x: ~) j4 O2 M7 m

  22. + G: n1 m" s6 d9 c7 U( N' o
  23. # Global variables8 U) W% s: X. I" D
  24. DLGAPP="whiptail"
    $ }& Y1 w: t7 |4 v0 ~4 Z
  25. VERSION="2"  w; Z! g( ^) h! p2 k$ w2 ]
  26. ROOTPATH="$HOME"
    * N8 q8 k3 `& W+ ], X/ n
  27. SRCPATH="$HOME/mangos/src"
    ' |/ {) N: E; Y  N% h* r* _1 U+ H
  28. INSTPATH="$HOME/mangos": T2 ?% {% O! \' c' I; O" T- V7 B
  29. DB_PREFIX="two"$ D  o: n# H& D; t! X) ^
  30. USER="mangos"
    7 ?: E# `$ h, O1 N7 C
  31. P_SOAP="0"& o1 U1 H# s) K: ?" g5 j( k
  32. P_DEBUG="0"
    . {3 n: a1 r3 M- }9 p6 k2 U
  33. P_STD_MALLOC="1"; j3 D7 c) T, i3 ]. i
  34. P_ACE_EXTERNAL="1"
    * U6 ~: N# I7 q3 I6 y& _+ |
  35. P_PGRESQL="0"  s* G+ J% r1 v$ C* y1 d
  36. P_TOOLS="0"$ l4 e( D+ o- j
  37. P_SD3="1"" x( ^/ I0 T- Z6 J4 b; M4 D6 b
  38. P_ELUNA="1"
      D7 r9 P# h8 c9 e) v
  39. P_BOTS="0"
    ) F2 C* S. U: @: ~
  40. CMAKE_CMD="cmake", h/ M1 L  H$ f) a0 |

  41. ( N& r- ]) u! _; W
  42. " _8 o) a+ c1 Q
  43. function UseCmake3()# N& Q4 j: W9 B  R
  44. {
    4 y- P1 M1 }0 a0 k: V1 c; }. p" K
  45.     # set the command to cmake3 if its there! {+ w# `# i  t
  46.     which cmake33 d: w! r: v1 Q9 Y" L3 w
  47.     if [ $? -eq 0 ]; then
    1 k9 L4 ?) C) }/ x3 D( ?: d9 h1 N. h
  48.         CMAKE_CMD="cmake3"- r( A4 W0 o4 F
  49.     fi0 N, P: l( v% \
  50. }. ^7 U. _1 Q5 j- H' Z* U, Z2 P

  51. ) U; t# G" W; k: N
  52. # Function to test for dialog0 Y& I+ a' n* _7 t' x
  53. function UseDialog()  E: {& `  i! D% g/ P
  54. {
    ) g, n6 B/ H1 E6 A# ]! u, F) [3 O6 r
  55.   # Search for dialog2 `- w5 f  ]; @( R# q
  56.   which dialog- B$ ^; {* o6 A2 C
  57. 5 R# ?4 M1 T0 ?
  58.   # See if dialog was found
    " R4 Y$ q( r7 h* {
  59.   if [ $? -eq 0 ]; then
    / j/ O& w, f1 u  [: y
  60.     DLGAPP="dialog"
    : D& u1 r/ w: Y' }
  61.   fi
    0 M7 r) ~6 o# b6 Y. r
  62. }% i" v0 _2 c+ i+ {! ]( q

  63. " ^5 t  D0 A  b; W& |9 K  O: ]
  64. # Function to test if the user is root or not5 T8 f# C# S- W6 k
  65. function CheckRoot()
    & {7 b4 T. n6 y2 J4 m
  66. {, V3 a  e' @# |4 y% ~7 B4 ]" R
  67.   if [ "$(id -u)" != "0" ]; then
    5 `& [, j9 |% x8 U% l$ X
  68.       Log "This script can only be used as root!" 1$ m; I; K0 K& w3 Q
  69.       exit 1% m! U* f2 j8 E0 @9 s  R
  70.   else
    ( |* j7 t, o$ |  o
  71.       Log "User is root, check passed" 0
    7 k3 a# f1 i' p& \" D; N% f; `
  72.   fi
    # l* c0 {. W" ^# r+ `1 Q
  73. }
    7 Q* Z3 b/ k% i  b* X! k+ B

  74. & @. S5 g  @, ?4 [
  75. # Function to detect the repos
    0 i/ S, g: L; G" A9 z
  76. function DetectLocalRepo()5 G- I5 I) C" K: r, U
  77. {
      h( s# x  K; z2 a/ x: S0 M
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    * A) a3 |  T! t+ E
  79. # _8 x' m' z$ |3 f/ R$ Z& V
  80.   # First see if the Windows stuff is in place
    ' F/ ?" p5 @: Z3 s5 @( |1 Q6 T4 ~2 q
  81.   if [ ! -d ../win ]; then3 V8 ~' G/ w6 f4 u4 u( P4 M. {' _
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0$ o: `0 \; Q; t' |% q
  83.     return 0
    + W) Q% I' M% p
  84.   fi
    1 n4 ]3 {6 h# G: _# \$ B% `" ~, E

  85. 3 d! M7 N$ \0 K3 [: y
  86.   # See if the sources dircetory exists) V! g$ d( l  S, ^# k& H. w# a* I
  87.   if [ ! -d ../src ]; then. M8 ]9 ?/ ?) B1 `- Q
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 09 S/ h" R( h' L0 f1 e; K! W
  89.     return 0
    6 @$ D3 S1 r) L0 t& Z
  90.   fi, S7 k+ B8 x4 r& W2 f! _% x  A9 d
  91. / ]! P, T9 M0 G) I, G7 c, T
  92.   # Check for the CMake directory
    2 z, V$ p- a+ D  N: b: ?, z$ L
  93.   if [ ! -d ../cmake ]; then
    - L2 T& i9 s1 s* O! N* e2 o5 @
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 0' X4 N) x* D' {" y, @! u. s
  95.     return 0
    , N4 Q+ u$ R9 g. y( w3 `/ V! C
  96.   fi- S+ I4 f) f3 H
  97. # C# g2 W0 z$ I( }- l5 C
  98.   # Set the default paths based on the current location8 t7 t" ]* d" d2 v
  99.   SRCPATH=$( dirname $CUR_DIR )
    6 g7 k: m, I: v
  100.   SRCPATH=$( dirname $SRCPATH )
    $ o* _4 a- E: m2 o: {7 n

  101. # K/ k3 X( E( z4 C* {
  102.   # Log the detected path
    % I0 k/ l* ^# E" c- g) i( f0 o
  103.   Log "Detected cloned repository in $SRCPATH" 0
    1 W4 J9 \. G6 f, y2 D5 [
  104. }
    ! \2 F# S% P6 @4 Y* a4 O9 ]/ S
  105. 4 k9 c) m# Y6 G/ Z. |( ]' {
  106.   \  t/ o: Z6 U/ I) m
  107. $ o& q4 [1 q3 R5 J) ]' U
  108. # Function to log results
    ; E& L% F# B* D+ o& ^
  109. function Log()- S# m+ Z# H1 M# S2 q! d
  110. {& G0 }( V9 C1 x) m
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )# u1 \. f: x3 K+ _. k$ C  b
  112. 5 L( q; q. X" g
  113.   # Check the number of parameters: R3 m0 z; v5 y; s
  114.   if [ $# -ne 2 ]; then
    3 M6 h' F4 g+ D! b( g& b) D6 m) \& A
  115.     echo "Logging usage: Log <message> <echo flag>"0 K3 |5 w; i, c1 z+ X$ u3 N
  116.     return 1
    , W, v6 x# z. V5 `. H$ h3 C
  117.   fi
    3 G9 |* B- F+ j- [0 K2 l* E
  118. 2 B- ?+ M! }1 ^5 P* J/ D: [9 w5 n
  119.   # Echo to the console if requested
    $ B+ H' n+ R. n8 `
  120.   if [ $2 -eq 1 ]; then3 `+ K$ }: z' P% d; z4 j
  121.     echo "$1"
    , J! r' r' ^! E+ a
  122.   fi& V$ S4 J( k7 d9 E: f
  123. * i! F8 I9 h: L+ f$ C# h/ x0 H
  124.   # Append the string to the log
      v3 X! M( \6 x3 P& g
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log6 x8 L* S2 y* s4 Y
  126. }
    8 g& {" G0 i" ]+ ?' g
  127. 8 ?  N( u" F/ X
  128. 1 L" ?4 ^) s3 t0 N
  129. / t5 p3 o7 N/ S- W
  130. # Function to install prerequisite libraries
    5 m9 s2 ~! n# P8 Z( v& C  R* |
  131. function GetPrerequisites()5 a- @! }9 T* o9 c$ |) }
  132. {
    ! d+ A( Z& c7 B3 h9 ]0 {$ I
  133.   # First, we need to check the installer.
    & O* B9 @# l/ N! ~
  134.   installer=06 a- B$ |) J+ d( k" `4 b
  135. 9 ]9 @0 v1 Y3 D+ |6 C0 H7 q
  136.   which apt-get& p9 m7 f7 L; B* b5 X

  137. 3 k) f0 O0 j" {% {/ Y9 |
  138.   if [ $? -ne 0 ]; then# c8 p% F# _$ i* R! T
  139.     Log "apt-get isn't the installer by default" 1. L3 X& ~5 m! K" f% p# W
  140.   else5 j2 S  h' W# L& a4 ^; V" L
  141.     installer=11 P6 T* [! K2 r
  142.   # On a fresh OS boot (EC2) libace was not found without first updating + c# o% q8 L- Q0 @9 w
  143.     apt-get update -y && apt-get -y install git lsb-release curl$ S! K8 b* L3 f/ ?2 n+ m/ j* _6 n" x" J
  144.   fi
    ) s- m8 f& z& k0 R+ ~

  145. 5 a5 w7 w- p/ O: m
  146.   which yum
    : C3 J" J2 }0 @

  147. # e* w6 |! ^( q& Q+ c2 W1 \2 P
  148.   if [ $? -ne 0 ]; then
    / r8 D. V7 e& R5 M
  149.     Log "yum isn't the installer by default" 1
    ' Y( k3 A# N/ r
  150.   else# k& b! ]3 h$ ?" m5 y/ Z1 l
  151.     installer=1
    . K( ?; \; L! K% r* U5 }
  152.     yum -y install git redhat-lsb curl# Z; w3 {. n& N$ d6 _
  153.   fi6 a. i- g0 C" A: i$ ?0 b" e
  154. ' P' h6 v, F+ f8 I/ B) ]& Q9 p* T
  155.   which aptitude0 O" Q: u3 U& d0 }) Y
  156.   if [ $? -ne 0 ]; then
    8 x- }( o1 _& q* h
  157.     Log "aptitude isn't the installer by default" 1
    ; M9 J9 o$ V! }$ _( I, d! I
  158.   else) y0 J5 K7 _3 y# f, D  R. o+ Q+ p
  159.     installer=1
    $ a1 T* N! e- b9 I; A1 I
  160.     aptitude -y install git lsb-release curl
    , l- m7 o- N( l+ m
  161.   fi
    5 U& H9 z; U) y$ G8 Q8 m8 `% e
  162. . y# ]7 K/ v; V' ~. \$ ~; A
  163.   # Then, let's check that we have the necessary tools to define the OS version.- o6 }5 n; g2 \3 s) J9 [2 r
  164.   which lsb_release
    - j3 A% q' A- `) j* y5 `- A1 {

  165. % {; a8 M: w* `1 J
  166.   if [ $? -ne 0 ]; then5 z0 t4 J6 |  x! c: [, \
  167.     Log "Cannot define your OS distribution and version." 1
    - a+ D6 [3 z( T% c, m$ J% ?/ @
  168.     return 05 ]1 J9 v) ]4 J
  169.   fi
    6 I) X- U2 W1 u; W% Y
  170. 9 Q( O2 c! A4 y) m+ M9 ?
  171.   local OS=$(lsb_release -si)+ d( I9 ]/ P2 }& q+ H' ~
  172.   local VER=$(lsb_release -sc)
    4 U6 o9 ^9 r- G1 b2 p0 `# k3 V6 _
  173.   local OS_VER=1
    % r3 N  ?! E3 k: ]3 G3 U1 v. q6 F
  174. " @4 I8 I( z1 ~* r1 E1 k" h0 n, S
  175.   # Ask the user to continue
    / ]: S; i  R' r; E2 [
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \# k9 N7 m( Z* K  F- P
  177.     --yesno "Would you like to install the required build and development packages?" 8 60
    1 K/ ]! J: k0 A0 ]6 @

  178. - D: C7 x3 \; C1 h2 b, d0 U( U
  179.   # Check the user's response5 D- M7 h- j. `; z8 r1 r
  180.   if [ $? -ne 0 ]; then
    2 U1 }/ E* j! v. x
  181.     Log "User declined to install required tools and development libraries." 1
    5 \( z3 b# c. j0 E: y
  182.     return 0& E7 x: t' S& [; c1 F1 z& d
  183.   fi; z9 f! D$ V" M/ p& g9 M
  184. 6 _0 m+ l7 H; U& N. U
  185.   # Inform the user of the need for root access" K( r7 x3 K% D& T8 Q
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    8 h) L9 o! T& y0 r4 i' A. u  y' i. r
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    5 Q9 L; V8 Y& N4 d
  188. * V8 q% V( D$ y/ Q
  189.   # Check the user's response
    - ]0 e0 l+ u" k( W5 \
  190.   if [ $? -ne 0 ]; then
    ' P* c$ _5 H' `7 N  E
  191.     Log "User declined to proved root access for package installation." 1( A9 Z$ i$ n% u5 [5 R
  192.     return 0$ }% M$ n+ W  Q$ r4 E8 Q  s
  193.   fi
    % h4 Z3 U3 o+ l3 `0 K
  194. ( m( F0 i( a3 s: K+ \; l3 w
  195.   # Handle OS
    3 b% I% T4 M7 N( i. V
  196.   case ${OS} in5 {7 R! B8 c0 ?" {
  197.     "LinuxMint")
    ( @! l/ t0 r2 @0 b1 w
  198.       case ${VER} in
    : {2 {. f. Z1 c1 U1 V
  199.         "sarah")
    2 U9 z4 U1 F) E
  200.           # Linux Mint 18 - Ubuntu Xenial based2 J' z6 F* G, O7 Y" A: P
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    - Q% O; j; h6 x, c9 s2 Q" u4 x* E
  202.           ;;
    # G* w7 W: P2 N# D% t+ _4 {
  203.         "rosa")
    & R6 q4 X+ E1 G; Z3 z& n
  204.           # Linux Mint 17.3 - Ubuntu Trusty based
    2 V3 [& }4 b/ a2 M) O! p
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root0 ]% C* \1 [% d8 B9 [
  206.           ;;
    5 Y: ^- D5 O% c. f
  207.         "rafaela")
    & t+ N3 I2 c0 X# T
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    ' u: b4 R* {$ R9 l6 ^
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    * I6 u; J. P' E# e. ?: H  e
  210.           ;;
    4 j7 ?9 h* w, ~) z% g
  211.         "rebecca")
    # h9 p: Q* r6 Z3 x# e9 E/ v
  212.           # Linux Mint 17.1 - Ubuntu Trusty based
    9 b. B8 K0 ?8 u
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root1 n) d" W3 V3 A* m: O) `
  214.           ;;- |7 |$ T4 H( k" n! T0 \
  215.         "qiana")
    9 N2 ]& }+ i$ ^2 r
  216.           # Linux Mint 17 - Ubuntu Trusty based
    3 z8 o0 u' G$ _
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root* N; h1 d0 u# `) y$ W
  218.           ;;/ t9 l# `" x. H
  219.         "maya")  ]; i6 @* }7 d1 ?6 d
  220.           # Linux Mint 13 - Ubuntu Precise based
    # e1 C4 J6 I3 T' D7 q2 S1 E3 ]
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    : K9 @) N( t( p4 d3 k% k8 X
  222.           ;;
    * L9 l7 k  x+ |, m7 x8 N
  223.         "betsy")
    0 ]: n( @2 M9 d/ A$ y  Q) z. Y
  224.           # LMDE 2 - Debian Jessie based! y0 s7 H4 Y( w2 P
  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
    $ ]3 r: q$ Y8 J+ j
  226.           ;;, C: A) I) ]" u$ _7 I6 r
  227.         *)) u) M; m& v$ b1 Z
  228.           OS_VER=00 \$ O4 A, R3 M4 F8 s
  229.           ;;0 w7 ~2 B6 t% e5 n" S3 c1 `
  230.       esac/ v& ~  m5 P% E- F/ v$ O
  231.       ;;3 k: e6 L' Y9 u, V2 `. V
  232.     "Ubuntu")/ n* ?/ y. X5 {' T7 d6 [3 O
  233.       case ${VER} in
    9 ~' n+ F& K# X  w- O( x; I+ W! d. p% Q
  234.         "precise")
    1 t( j/ g  \: h- j4 J, ~
  235.           # Ubuntu 12.04 LTS( p: I/ B& @8 A7 w* M$ r5 S
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root2 c1 K, [7 B5 C6 ]0 C
  237.           ;;
    5 J5 l% j9 }4 P$ Z8 f
  238.         "trusty")6 W# @6 p/ \! v' N1 h
  239.           # Ubuntu 14.04 LTS' D( o0 g' P$ V6 Z! O1 Q% T9 E* O
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root4 r* _% x. z0 m3 V2 B
  241.           ;;
    5 z4 D/ C! ?3 F2 z& I- T$ l0 C4 G
  242.         "xenial"): [/ n; O& m( T7 x
  243.           # Ubuntu 16.04 LTS! C: }' f) h( J
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root; q0 L3 B% T7 d4 x' ^8 b+ x6 ^
  245.           ;;, V; F# F. |7 S4 Q# @7 W# x" |
  246.         "yakkety")
    % U4 V! g4 J0 M
  247.           # Ubuntu 16.10
    - o; d, R  C5 ~1 P
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    # p2 N  J. c7 c; \- K8 v
  249.           ;;8 C, H; p) W# ~% l
  250.     "zesty")% K" d* `9 x: F4 L8 z" k  D5 r  v* u* J
  251.       # Ubuntu 17.04' M/ ]4 C3 i" }. n* ]
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    . x+ Y$ w, S- c% w* B6 {2 m5 g
  253.       ;;2 c! C+ k- o1 H# Y4 j
  254.     "artful")
    1 G& {6 V- h4 p0 K# w  J* S5 N0 i  d
  255.       # Ubuntu 17.10) l3 K- L, S8 F) [/ _
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root1 y) n5 c& N  n2 s* O6 `/ B
  257.       ;;: ?  F7 C. }- {0 Q) _7 t" ]
  258.     "bionic")
    + H5 i3 c$ ~+ J2 m/ G
  259.       # Ubuntu 18.04 LTS
      L7 T' |. v' k! S3 N- U8 \) H
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    , \6 [9 H, a# c3 }& T
  261.       ;;1 }: ], w, u0 V
  262.     "disco")1 S6 O+ X) h& v0 Y8 z7 K" J
  263.       # Ubuntu 19.04
    8 q4 J) y& F% U* X% v: l
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root/ G" Z% [+ n; h' e- U
  265.       ;;2 |9 N9 |! n6 z$ a/ N
  266.     "focal")
    " g( L0 B7 M  e  H4 w
  267.       # Ubuntu 20.04
    & u( t( n! M# }5 F2 X! w2 P
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root+ [; j8 e9 K5 w; Y) S' c
  269.       ;;( s- i/ X/ O5 p9 {
  270.         *)
    , a" {+ `: X) a$ h) J
  271.           OS_VER=01 V$ U: D+ d% r! K2 t) M% V9 S
  272.           ;;5 g/ M  q1 U$ y& p
  273.       esac8 f, w, C9 K5 l6 J7 H
  274.       ;;
    + U( q$ }! |1 s5 Q2 H; N0 R
  275.     "Debian")  E$ R7 c8 ~5 h0 q# w
  276.       case ${VER} in
    ; J3 N$ Y3 T; k  }
  277.         "jessie")1 q7 T& ]+ m% B% E$ j  Q4 _, W: J
  278.           # Debian 8.0 "current"# P& W! r; S) m3 L6 Z: u
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    ; M8 e+ T2 K0 G7 d
  280.           ;;
    ) a  ]2 F$ S# @
  281.         "stretch")4 J6 a+ ?0 e/ f& I0 _+ ?
  282.           # Debian Next
      |+ J, o+ @  }0 G
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
      x4 D  q7 Q# D7 K' _( f. ]
  284.           ;;+ W- S5 o4 `: p% W! L+ }
  285.         *)+ w2 v; A6 X/ u& B
  286.           OS_VER=0+ w0 `, z, z5 y3 \3 F, H; y
  287.           ;;
    4 [7 T5 S0 v1 D5 J" Z
  288.       esac: K& a+ s: b! T& H9 @. c% N. c
  289.       ;;5 Q* O/ d. e) x* W1 Q
  290.     "RedHatEntrepriseServer")/ F4 G6 h& G1 Y6 ~) L
  291.       case ${VER} in0 r) \3 @. r4 W3 l' R1 @1 u
  292.         "santiago")
    5 q4 y; G2 I2 ^( P! @
  293.           # Red Hat 6.x
    ; A$ [3 ?8 ]' ^7 J0 L4 {
  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: a. \) Y& m! |& I( E$ v* j
  295.           ;;
      N7 H4 r, @8 |" d( z
  296.         "maipo")9 i, |8 {$ u# B  S" l
  297.           # Red Hat 7.x
    9 j; U2 X5 u' y- K/ Q3 Q9 V
  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" root4 {$ p% F: k/ O! Y. Q% O* c  d5 m! a& ?
  299.           ;;
    9 d: n# v5 V! w: H) ^, D/ r0 \9 Q. a
  300.         *)# L$ Y$ l8 O/ j$ u
  301.           OS_VER=0
    # @5 o+ \/ m) r! Z8 y; M9 y
  302.           ;;! A/ f/ S: n; s. h1 ~0 X8 ^
  303.       esac- g6 D3 p7 Z5 R2 Q4 j# Y  c  o0 `
  304.       ;;) ^9 |* i- _5 e# G8 w  I
  305.     "CentOS")
    # J8 i" e& T! f# I
  306.       case ${VER} in
    5 Q) N& [, ]- a% W. E1 k: R  ]' r
  307.         "Core")
    6 ]3 N$ x  F1 |% n" `; J
  308.           # Default CentOS - Adding necessary RPM third-party.
    . M/ Z! L2 {  G
  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; v1 ?2 Y0 q4 l5 K6 w
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm4 W- t/ R  x; U, m
  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
      c% q# s; y7 h  o$ M: o9 B
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm4 L- C3 I4 [, u, ]2 k) C6 M
  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
    % D9 J. z& u/ H( L' h
  314.           su -c "yum -y install epel-release"
    % a$ L4 T. z3 @
  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
    3 b8 d; g! a, V% [9 X* W
  316.           ;;0 D7 u! i" S+ I9 M2 [) N
  317.         *)
    . e1 p# x9 c0 l4 s+ [1 a
  318.           OS_VER=0
    : \- Z! ~- ~3 m; @) H6 ]) P0 r5 C3 f
  319.           ;;( I' z7 P8 A# V' ]
  320.       esac
    " L3 J: B+ V0 q+ H' d
  321.       ;;
    & m2 n, ^5 \5 }1 ~8 M- N0 ~( c
  322.     "Fedora")
    7 M7 y+ `5 C/ O& h1 i/ d1 n
  323.       case ${VER} in1 @( ^# N% l: Q# }- X* O
  324.         "TwentyFive")
    . R" r9 b, S% z: R
  325.           # Fedora 25 - Adding necessary RPM third-party.
    0 }2 S, O: y  V% v, D
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root
    2 G0 h7 m4 l, D! M* q9 R4 a
  327.           # Getting and building ACE. Not provided in RPM for Fedora...
    + i7 @/ p2 Y1 ~2 U+ Y0 a
  328.           rm -rf ACE-6.3.3.tar.bz2* k: r5 S& L3 w: w; X7 J; \
  329.           rm -rf ACE_wrappers
    4 E3 e- y/ a9 G) W3 A: @
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2$ V7 b% c; Q9 o+ P
  331.           tar xjvf ACE-6.3.3.tar.bz2
    7 p  t. Q- |1 c, j' V: G+ e; J
  332.           export ACE_ROOT=/root/ACE_wrappers: Q* z* Z8 g, t
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h: M) ]+ e6 z! z+ G
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU  M9 i5 Z" K# k1 O9 f% }6 F7 _
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU2 u( B- ]9 U- G. k" [5 O9 Z7 u
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    3 u5 L* }, x- v9 I& F  T& E2 l
  337.           CD $ACE_ROOT6 M/ a7 n8 S% `1 O2 }% t! T
  338.           make
    5 F* K0 d5 k/ w5 d' Y
  339.           make install* _+ x" _( o+ P# [" S
  340.           cd ~
    ; H) J0 Y- e1 F: x8 X% y
  341.           # Installing remaining dependencies..
    , `/ ]( p+ y; F! @3 p
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    " [- U6 K1 \! l* k; F9 i
  343.           ;;% A% m5 ]% s% _. M
  344.         *)
    & n& p5 C( D5 I$ R; h2 S: y0 G! d
  345.           OS_VER=09 @: C3 [/ ~3 w, b0 y) f$ M
  346.           ;;
    . M1 ]% l6 T! M/ Z8 l4 r% N( R
  347.       esac/ [1 o+ o+ G" ~* J' S
  348.       ;;5 P! B9 q* t% J% D
  349.     *)
    ' F) t( `* F& q
  350.       OS_VER=0* `- O1 L2 y1 b7 D  X
  351.       ;;- C) E% \: y2 Z" _! M
  352.   esac4 U! a/ O0 V  f. y4 p1 A

  353. 5 `1 m% s0 c& O6 i. y
  354.   # See if a supported OS was detected8 b% [2 R( E+ c! @6 g
  355.   if [ ${OS_VER} -ne 0 ]; then2 r9 _& O4 F7 i$ |% v4 z* [: e. b* v
  356.     # Log success! M; u( ~# V, Q, B& ?2 \+ ~
  357.     Log "The development tools and libraries have been installed!" 1
    . n  l5 }$ h7 _+ m" o( o) T0 j
  358.   else
    ' l9 u/ s# F# I* ?2 N& C
  359.     # Note the error
    2 l; \* x8 }, c! y- w5 H- h
  360.     Log "Could not identify the current OS. Nothing was installed." 1
    1 n6 k" x1 t* D5 U
  361.   fi
    : I' Q! O- k4 s5 W, R1 d6 t
  362. }/ @; o, {: s! w: o4 J

  363. ' q" \* u1 w* q$ U. G

  364. . u4 z+ k3 J6 Y7 `1 G- ]  p
  365. . p' T1 h3 a: M7 k" z
  366. # Function to get the WoW version
    ' R. ?/ h+ H# d2 T4 e5 o' T1 y4 H
  367. function GetRelease()9 T0 h, D- p$ j0 J6 n
  368. {; \$ a0 e; g: H" F3 h
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \( K7 k! c2 H( D
  370.     --menu "Select a version of WoW" 0 0 5 \
    5 B9 b& I5 T! _: X1 v5 ]
  371.     0 "Original Release (Vanilla)" \* j% c2 y7 S5 v0 f+ C
  372.     1 "The Burning Crusade" \+ Z- V- p, u. B7 F  N
  373.     2 "Wrath of The Lich King" \9 B0 H; r, T6 L0 A' D
  374.     3 "Cataclysm" \
    . ~/ O( i' M- x9 n( e( @4 w
  375.     4 "Mists of Pandaria" \
    ! @* _* M2 H. j( F
  376.     5 "Warlords of Draenor" \5 q6 s* P" H9 M, r
  377.     3>&2 2>&1 1>&3)4 [! @4 w8 z- X% C& z
  378. 0 c; ?0 x: F! ^! ?" f- ^' t
  379.   # Exit if cancelled2 d% Q; N+ Q4 S" o
  380.   if [ $? -ne 0 ]; then6 R# T: S8 H3 @2 g
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1. T# D( Z' ]+ G4 Y7 ]% P
  382.     exit 0  w; z1 v3 M/ }  Z7 H8 @
  383.   fi
    , ~! a& [, r5 ?4 M4 w

  384. ( R: d2 K8 F' U  o
  385.   # Set some defaults based on the release
    6 i8 H$ P# n' v4 [: y
  386.   case "$VERSION" in
    6 ?8 j! O. ?2 N# Z
  387.     0)
    9 S& Y$ K; U# n7 `% o
  388.       SRCPATH="$ROOTPATH/zero/src"6 ]$ c0 W* E. C; y( }% J$ M) R7 o  m
  389.       INSTPATH="$ROOTPATH/zero"
    + t% _1 L+ c! N& Z" }8 U
  390.       DB_PREFIX="zero"
    ! n) w: {" o9 f0 \) e2 s  _8 I! l) Z
  391.       ;;
    1 J0 i9 s: B6 K
  392. 0 D" P' ^6 n. C# |
  393.     1); |. U! F5 s/ [+ g* `
  394.       SRCPATH="$ROOTPATH/one/src"
    8 `- m! e' l) D4 q3 P  Y
  395.       INSTPATH="$ROOTPATH/one"
    ; d& L& k9 u- t& O& K0 f
  396.       DB_PREFIX="one"0 K" R+ x, |  I. I7 }6 n
  397.       ;;- U& X* w1 [+ z5 s

  398. + k5 {$ L+ g! E# [( z0 D
  399.     2)$ }/ A3 V* a) R
  400.       SRCPATH="$ROOTPATH/two/src"; R. z4 k4 L. k' _/ C( @6 Q
  401.       INSTPATH="$ROOTPATH/two"% \$ P2 y4 {! N# P
  402.       DB_PREFIX="two"! z. Z3 w7 `  p/ q
  403.       ;;
    5 k# y9 w  F  J; ^5 _$ Y
  404. ! j. j' k- p, z7 O
  405.     3)1 u5 s+ M6 w: O# \. m, ?: e) C7 r
  406.       SRCPATH="$ROOTPATH/three/src"
    : Z5 `( ^5 _& A5 ^7 @6 i1 b
  407.       INSTPATH="$ROOTPATH/three"
    ! E; c& L- M3 Z  x
  408.       DB_PREFIX="three"5 z7 w3 Q7 d+ |6 O4 U, p4 Z# `/ K
  409.       ;;
      i# t& @" a( j5 a# w: d$ A6 d

  410. 4 V3 n. L/ ?4 z  q
  411.     4)0 k1 ~, B3 |# O2 i
  412.       SRCPATH="$ROOTPATH/four/src"
    " G5 a. d( B6 @
  413.       INSTPATH="$ROOTPATH/four"4 K5 f: h3 {5 u# x; [
  414.       DB_PREFIX="four"
    9 I1 [" f- n8 O. F7 h. j
  415.       ;;
    4 R- L! _6 y! ?) X' Q
  416.     5)0 C. v% K1 q1 I
  417.       SRCPATH="$ROOTPATH/five/src"
    , P4 h* m8 B8 z2 q
  418.       INSTPATH="$ROOTPATH/five"
    " K% P8 _. `9 U& A7 u4 L9 y  @
  419.       DB_PREFIX="five"& M8 v) Q: l7 T2 r1 e" N: p
  420.       ;;
    & j  }7 r8 u  b9 ~( |" Q( v  i
  421.     *)& O* ^- e! b" W+ T. `; n- O
  422.       Log "Error: Unknown version selected!" 1
    / B/ z- `2 }7 I* F+ A$ L9 H* \
  423.       exit 1
    0 E# f" ?8 v, Y# Q8 ^, g% z7 L1 R
  424.       ;;
    3 {, \" R0 s! y+ J3 N) T0 T* b* |. H
  425.   esac
    # t; n5 `  ?# M- F8 V: h; o

  426. # |. ?( V* \  q8 R# V. @( a6 D
  427.   # Now set the correct source path if the repo has been cloned already3 q" [/ t1 G" k$ P9 N. k
  428.   DetectLocalRepo- Q: W3 }: |# i) h
  429. }8 f' q0 K/ s/ ]. N, o" x3 x
  430. 9 k" c( Q" ~8 T0 N/ Q; T
  431. # Function to setup the technical user
    3 P+ \# e8 m1 V. h$ C
  432. function GetUser()* j3 P1 k, D  q0 j
  433. {. |8 R# V$ I% W. g* R
  434.   local TMPUSER="$USER"2 ^6 U+ `* Z  D6 S# ^9 i, }

  435. ; x7 f7 T! N. Q. e, F$ B/ a
  436.   # Set the user
    / s1 K" {8 |0 z; F
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \
    6 o& s3 v& B' |! I6 W/ S4 i- M
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)$ K3 E" }7 D7 ]$ c
  439. ! i+ Z" b. ?3 Y; W, ?% I  a
  440.   # Exit if cancelled7 p! r) R: P4 Y! e6 {
  441.   if [ $? -ne 0 ]; then
    , M- Z9 I& r  E! u
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    4 }( z+ I$ }  ^8 m
  443.     exit 0
    ' s- n6 R% R3 H4 R, Y  P9 S: m
  444.   fi
    ( w$ [* S: ?2 {  j
  445. ' N& g/ z3 Z9 v$ r1 _: b- n. z
  446.   # Change the user only if it was modified: ~2 x8 C4 s0 T6 x- V
  447.   if [ ! -z "$TMPUSER" ]; then
    " U+ v7 [  O  q, K6 W! z
  448.     USER="$TMPUSER"
    # b7 v1 e- j0 ]1 _  T' ^
  449.   fi
    9 Z$ w' r9 z$ a/ A" M- G
  450. $ N# q% H6 m, Y+ ~0 i# A
  451.   # Validate user7 i$ ?8 A, A( R4 L- T% ]
  452.   id $USER > /dev/null 2>&1/ `! _* u& V; [
  453.   if [ $? -ne 0 ]; then
    * ~7 R! p9 x5 ?2 U/ c1 g( x. H- {
  454.     Log "Creating user: $USER" 1
    & J/ w! D' W, z8 O& f8 e  Z
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    4 W4 X/ U$ T  M

  456. / N; }8 ^# Y2 n. T
  457.     if [ $? -ne 0 ]; then
    ' z4 f7 t% ^' h* J
  458.       Log "Error: Failed to create the specified user!" 1
    & [6 p% X! s5 F) h  A. g7 F
  459.       exit 1+ B5 s' \5 R& n% Z
  460.     fi) h% L: j5 k9 |1 r
  461. 1 r+ w# }8 e! K+ N# h5 c
  462.         usermod -L $USER > /dev/null 2>&15 j# t9 [$ T/ k% C" O  ~# b
  463.   else, }- v1 @9 h9 L  w- R
  464.     # User already exist, asking to keep the user2 A( U6 f: Y6 b0 `) i7 f* d8 a4 A
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \- o4 ?! w' i: g4 }6 F) A2 P7 r
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60
      |4 i+ \) ]" s. o

  467. & b7 t& V9 j* A" ^. O
  468.     if [ $? -ne 0 ]; then, k* y6 o( S6 {
  469.       Log "Removing user: $USER" 1( O& A4 d+ i  d4 B: B0 J  u
  470.       userdel -r $USER > /dev/null 2>&1
    + e5 I' y! i2 j4 N7 {9 |4 Z

  471. : f2 h" Z* i! R+ r
  472.       Log "Creating user: $USER" 15 v3 Z- O! E" L1 y$ ^
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1
    $ p* }; D4 C% _! ~& P: K. ~2 c

  474. 8 P6 q% r/ r+ S$ `
  475.       if [ $? -ne 0 ]; then7 O. R5 G2 f/ u7 l' O- B
  476.         Log "Error: Failed to create the specified user!" 1
    + `: A, S/ ^/ C) k
  477.         exit 1: E8 ^$ n4 R$ ~6 _
  478.       fi
    " A. P- R, ?/ S4 ^2 L8 a9 a' T0 \
  479. 4 Z9 f, P6 U3 x' r. A  b( F
  480.           usermod -L $USER > /dev/null 2>&1
    7 |' \4 j0 T+ X8 ^& w# Q
  481.     fi
    + ]4 ]& u/ N  B; @2 F- b% q. L
  482.   fi
    * o8 M! {" J# s; V

  483. " p& `$ r2 y) h8 r9 q
  484.   ROOTPATH="/home/"$USER1 c& E; `/ ^+ S  L0 X. |
  485.   Log "User: $USER" 0; \3 Y7 \# f; A
  486. }, `% _) n% a3 s
  487.   J. R8 x1 t/ C$ W# T
  488. # Function to get the source and installation paths: V2 [1 s* q) L+ j
  489. function GetPaths()
      G4 M# o9 ^2 _# u. N" W* K8 [
  490. {
    9 j  c, l2 M3 o( V
  491.   local TMPPATH="$HOME"
    0 Z2 U. x( X; m2 O5 h

  492. ' l  X% ~& t1 N& Y
  493.   # Set the source path4 q) y6 V) g" L  [7 G
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \  z* u) Y" q# {* v2 Q/ E8 [
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)
    ' L/ s: _5 X: k# x$ R6 X& F

  496. 6 B+ S. D6 G7 O2 r: E; D; m
  497.   # Exit if cancelled* i5 A/ F% y7 x7 k
  498.   if [ $? -ne 0 ]; then- i) H. ?6 @7 F' w0 }) d# o
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 11 S$ P6 V+ A& M/ e" R( U* ?
  500.     exit 06 P0 F/ W9 t; Z2 R0 m8 ^4 V8 S8 M
  501.   fi0 u3 I5 i$ r/ u! E, r6 v% ^

  502.   Z/ T0 F; n+ B' w# l) Y* Q
  503.   # Change the path only if it was modified
    ) W2 {7 j4 z* I% Z& T" o! C
  504.   if [ ! -z "$TMPPATH" ]; then, U. a1 V( f% B+ }! Z
  505.     SRCPATH="$TMPPATH"
    6 X! W6 s9 l% }6 Z2 U
  506.   fi( x6 ^2 {0 f1 M

  507. 7 l% d3 Y  I" A
  508.   # Validate source path
    * p1 y" b& q* _2 ~
  509.   if [ ! -d "$SRCPATH" ]; then
    ( u% X, e; ~5 }
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    - E; Y/ y  V" V! F- ^
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60
    1 E! m' L; @. \

  512. 7 j# F, `9 L7 }; ^( _
  513.     if [ $? -eq 0 ]; then  F/ ?' z' r0 h: e2 T2 a; J% H- K
  514.       Log "Creating source path: $SRCPATH" 18 _1 U* e! y+ p; y
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    & k) D& k, S; v1 v$ t
  516. ) p/ E% U- N/ K3 O
  517.       # Check to see if the directory was created
    4 w$ ]4 o  f& o
  518.       if [ $? -ne 0 ]; then+ K* i; q7 |2 K1 g/ w( Z4 l& v
  519.         Log "Error: Failed to create the specified source-code directory!" 1
    1 r: |$ a8 j: K5 p
  520.         exit 19 u( a2 U* j7 m3 I
  521.       fi
    2 [' T/ l  Q# l+ K. @
  522.     else
    1 X7 t  a& W5 @
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1
    & H/ b0 k; V$ b' {+ j
  524.       exit 01 U6 D& B6 a* B" E" `: l1 c0 J
  525.     fi
    : b3 ^: ^- y7 |! R2 x
  526.   else/ R; I) V0 B" l* u9 b# h+ x
  527.     # Check for old sources: w& P+ [9 Z4 N% Q" }8 Z
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then; x& C) p. r+ ?* J
  529.       # Ask to remove the old sources& P/ m" K+ S0 c  l' a6 I: J
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    7 X8 B% ^( t2 `  b. \
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60
    . z# A% W3 J2 `) U4 j$ h

  532. , s; p' G- B$ s8 D/ x6 L
  533.       # Remove the old sources if requested) x2 g! K' |! W$ g9 ?$ s
  534.       if [ $? -eq 0 ]; then. X' I$ o# l+ e) ?& G9 L3 \# ?# h
  535.         Log "Removing old sources from: $SRCPATH/*" 1; T& @5 B* O( {. `# d
  536.         rm -rf $SRCPATH/*$ a. E: S; g$ q" v  j
  537. 5 ?9 a) p9 x& o2 I) s; P
  538.         # Check for removal failure- R. j& Y: }+ k( J8 o5 ^0 V* h
  539.         if [ $? -ne 0 ]; then
    ' W* P. R* I, ^& b
  540.           Log "Error: Failed to remove old sources!" 1
    * v& R' A) {: k  k' H2 E9 G0 d1 Y
  541.           exit 1
    + D- R% H5 e3 C# F
  542.         fi7 V, l0 E- W: R: u  q& U
  543.       fi: \. F8 O# p7 R
  544.     fi
    . E% V5 I, s% h- X6 A' Y
  545.   fi
    ' v4 `( \' `5 O8 W% U
  546. - ?7 {5 T& K3 a5 m* l- |2 f
  547.   # Set the installation path
    & V6 K+ _4 y  E/ P0 S
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \
    * o" C% b! Q4 u' ?; b- E
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    . J# X5 O# u; b( A

  550. 5 A6 U9 O$ Y% F7 h8 K
  551.   # Exit if cancelled
    $ K- }! q, o- w
  552.   if [ $? -ne 0 ]; then# r$ i0 L, d3 ^" ^& \# p" v
  553.     Log "Install path selection cancelled. Only the source path has been created." 13 Q% J+ ?5 B* L
  554.     exit 0
    ! G, Y/ V3 P. |
  555.   fi
    * I: k' @# Z: V& _, ]/ k/ p. d

  556. 3 {6 U9 b  r% Y" z# Q. _" [
  557.   # Change the path only if it was modified6 Y, l$ I* C' O
  558.   if [ ! -z "$TMPPATH" ]; then7 w0 K5 D2 }9 V, S+ ]$ i2 _: c
  559.     INSTPATH="$TMPPATH"4 R+ {7 S/ a: c' q& U" F
  560.   fi
    6 [! `; [9 u" Y9 i/ _1 a/ K

  561. 5 r# b. a5 h9 Y7 K
  562.   # Validate install path- n1 K8 w, W+ W6 `
  563.   if [ ! -d "$INSTPATH" ]; then) L' j' k3 O7 k5 q
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \9 j. K' ^9 F7 Y, W/ s
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    / X3 ?. o8 s# [0 t3 J
  566. % h* s. [) x, M# ^& k4 d/ M
  567.     if [ $? -eq 0 ];then  x6 }4 \. U: w1 i  h: J/ U& L
  568.       Log "Creating install path: $INSTPATH" 13 U2 F. ~: X, [3 h% ?' w
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
      R& @3 e4 F5 Y4 k8 {& B, ]3 P# W

  570. % \  t5 q% @; A/ A$ A2 b3 o4 I- V
  571.       # Check to see if the directory was created$ G' n$ Y4 k0 G, W5 c
  572.       if [ $? -ne 0 ]; then6 z" g& V6 n( r9 j4 N4 ]
  573.         Log "Error: Failed to create the specified installation directory!" 1
    % z9 X% j/ S# O
  574.         exit 1* n/ k* ^3 s* K
  575.       fi
    6 y: J; C' [1 [+ o$ X# k
  576.     else% z9 a0 i, m1 P4 O# u( {
  577.       Log "Install path creation cancelled. Only the source path has been created."
    ) q6 L. \5 \+ T. c0 y
  578.       exit 03 [! S2 ~! D5 O, r5 b  c
  579.     fi: @; Y7 l# Z. d( }7 I
  580.   else
    / |& M7 D0 i" E6 J, J$ Q3 S
  581.     # Check for an old installation! D/ {# B+ Z9 f9 U
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then! w5 h( ^2 b: T6 ?* h, p! h

  583. % s& }* \3 A8 H9 W2 N5 c
  584.       # Ask to remove the old installation
    . v0 J: T  ]# m, c; ~% j9 e6 M' n7 h, O
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    ( s$ h+ t! |5 R5 P# O! X$ Q
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 00 r# v! ^9 f1 X$ g/ D. R5 y1 p
  587. 8 A8 g3 b& w6 W$ J
  588.       # Check the user's response9 n' `* m2 {/ {6 ^/ [
  589.       if [ $? -eq 0 ]; then
    1 E. K: ?* F# x. |  c, F
  590.         Log "Removing old MaNGOS installation..." 1: y3 A) M+ H) p" e% R
  591. , J$ _: G" x! H6 G
  592.         # Clean up the binaries
    5 X- Y2 `9 L* {
  593.         if [ -d "$INSTPATH/bin" ]; then
    0 c- b8 \: h: f) C
  594.           rm -rf $INSTPATH/bin
    0 i  i0 j/ Z7 z8 l" ]
  595.         fi
    0 }6 Y. H. m" Z# r" s/ h
  596. 8 x/ Q; b; Q. F' A1 R. V2 D0 q
  597.         # Clean up the old includes) v9 U6 v9 R6 S
  598.         if [ -d "$INSTPATH/include" ]; then: G. F8 T& m# J+ @+ l( `
  599.           rm -rf $INSTPATH/include1 K9 y& s# F- J% i. @% u  L4 {2 {7 z
  600.         fi. G, g6 z# M/ I. _4 Z" T5 O* o6 n/ h
  601. * x9 P- \9 b+ K4 _' i
  602.         # Clean up the library files
    2 ^$ J. y: {" ^5 ?
  603.         if [ -d "$INSTPATH/lib" ]; then
    # H# k0 \* }: j) z3 a! D+ M
  604.           rm -rf $INSTPATH/lib" Q3 M' y1 e1 U* ?& h0 L
  605.         fi# ~4 ^* Z4 ~7 x; W! y

  606. $ A# t6 Y+ e1 P; ]; `
  607.         # Clean up the old logs
    , i0 a6 c+ f4 t" Z8 ~. N" S
  608.         if [ -d "$INSTPATH/logs" ]; then; @$ _; W9 X0 k0 z! i, S7 `
  609.           rm -rf $INSTPATH/logs/*
    ' Y2 v9 X+ w/ D0 k
  610.         fi" N$ \$ ]$ w1 ?2 A* [1 Z; o
  611.       fi
    5 J5 Q3 N. b. l% M9 v' j
  612.     fi
    ) ?. o4 E1 N5 U. T9 D1 ?$ v
  613.   fi
    9 W4 V* D$ L" w, G
  614. ' c9 ~5 x# q; U) p" x/ S/ `
  615.   # Log the settings/ b* \" u# _/ h2 u
  616.   Log "Install path: $INSTPATH" 0
    0 s/ _* `1 ~, W$ _" G; [# k5 c
  617.   Log "Source path: $SRCPATH" 0
    0 H: W: g9 X$ x
  618. }
    ; @5 l, g0 W; p- l- M
  619. 1 }' f( h+ M1 X' C8 |9 i7 m; n

  620. / X7 }# t9 F9 m1 U" }

  621. 1 ]6 O% Z7 \0 X2 E, b
  622. # Function to clone or update sources! b; y7 E& x+ b( U4 ~. n
  623. function GetMangos()
    ! z4 z5 f% F7 @
  624. {+ z, s! E1 m, H5 n
  625.   local CLONE="0"$ B, ]) l) I# I
  626.   local BRANCH=""
    , O0 G1 Z, w' b3 k3 F/ p) ?  D
  627. 1 k- B7 s. I8 t# W3 J  U4 c, K
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \) Y  C3 `+ b4 \9 a) C
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \! z$ B* C. h' B7 c5 r+ ^3 v. V
  630.     0 "Clone a fresh copy of MaNGOS" \
    2 q- n$ ~0 z; t1 K9 f" K1 Q: V, Q
  631.     1 "Update your existing copy of MaNGOS" \
    : `" Y  }3 B/ r, i; H5 E! G8 c# q" x1 n
  632.     2 "Use existing copy" \+ v' w- `3 Q. `% u2 M" w  j# d; h, G
  633.     3>&2 2>&1 1>&3)
    ; |3 U  E( V0 P7 I* _% [
  634. . L1 s5 l9 S0 `
  635.   # Exit if cancelled
    : f* F. l0 x: }% r  t  @+ F5 L$ a
  636.   if [ $? -ne 0 ]; then
    ( @7 g. l" I) C; u
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1# X% g- ?# W# W, ^1 H7 U. [3 Z
  638.     exit 00 t* R, p0 x. q$ N( t, }
  639.   fi( j* j* Q3 i. C) \
  640. ( N8 R. G' `: u  i0 e0 p
  641.   # Clone from scratch if selected
    ) ]) W( ?3 Z1 M7 L
  642.   if [[ $CLONE = *0* ]]; then- A0 V9 _* J9 n  [! |
  643.     # Pull a different branch?0 q4 p* z3 z6 Y5 O
  644.     case "$VERSION" in7 p' n6 m' Z# `5 ]
  645.       0)
    7 s% }) z& p9 q3 I" D
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    6 v; N# m4 V, k+ @9 z8 F
  647.         ;;
    ( u2 p- o, \% y- s! P# Z
  648.       1)
    : `4 @' t: e* N: s  q; J7 Q6 p+ u' K+ T
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    9 f+ K9 u3 {( |9 q/ ^/ t
  650.         ;;6 \& m6 f0 \* C6 m
  651.       2)* D6 }. c7 S3 ]  h
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    " {8 D% P; _9 o  w' Q- \
  653.         ;;
    8 @: @( R4 T: l3 r; l
  654.       3)
    / k! A2 O- u& w- V) ?. t1 E: M# W" Z
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')3 n2 Z' z' O3 x
  656.         ;;7 G# R9 Q" G; _$ P& n% @2 q
  657.       4)
    * m  M  q" j/ |/ u
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')' n; [0 F8 M" m# @7 A
  659.         ;;
    8 D& F( T0 ?  o. S  g9 u
  660.       *)" k1 Q- t* Y$ g, l( m
  661.         Log "Error: Unknown version to select branch" 1
      C) `( B5 G) J4 P$ _& Q8 Z
  662.         ;;; `# [( {( l% ?% R
  663.     esac" z% U& v- _7 ^0 J7 V+ V. ~
  664. 4 x$ a' l1 h, r! l& y2 p3 W
  665.     COUNTER=1
    3 _& q  ]6 q4 b
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog
    ' s4 l. B- G$ H- w8 |
  667.     for i in $releases; do( Y3 }: V7 Z5 j" \+ K2 [+ g- Q& Q
  668.       if [ $COUNTER -eq 1 ]; then, ]) o" d" o, L
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "9 D. L& l5 W3 h8 H2 L
  670.         BRANCH=$i9 n% A- J  o, b2 m# k, ^- U
  671.       else
    : z$ T/ q+ i9 G
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "
    ) w4 V5 n) d8 C: h. }
  673.       fi
    : h0 o: w9 a' F2 f  y5 `
  674.       let COUNTER=COUNTER+1
    , p# W2 U, o- Z# N
  675.     done
      Z9 @, {  L  W1 Q

  676. * j3 K& h- h/ P
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \
    1 i6 c  {- K# B; |9 ~+ Z
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    ; x3 Q2 E3 n! e! s4 f1 \
  679.       $RADIOLIST \' V) }' K+ B4 x" A4 R% q' U6 K
  680.       3>&2 2>&1 1>&3)
    + a* Y' ^6 c1 l- @1 H$ W

  681. : Y7 }1 a7 w7 D: o  H  N0 v+ U/ n
  682.     # Exit if cancelled
    & U6 i" A/ Z3 ~" R. Q/ I
  683.     if [ $? -ne 0 ]; then+ Z, X" r' }+ c; D
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1
    : u. G" d7 ^  w5 }# R  T- T
  685.       exit 0
    * K5 P; B! p; X- ]* L
  686.     fi
    : I# ?  w& D. x: I4 _

  687. & I6 y8 @# z- b! x! {
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')/ [8 l- v- L7 w3 b- A
  689. ) G, y: Y2 W9 k& r3 R: {8 G4 E
  690.     # Set the branch; v" Y$ k' E/ X0 W) t% i5 _. b
  691.     if [ -z "$BRANCH" ]; then
    - m6 ]: s# I0 a3 x& o7 @
  692.       BRANCH="$releases | awk '{print $1}'"
    & ~4 n! B- J- [( K5 ^' Z4 @
  693.     fi6 h2 g7 m3 @  V" D
  694. 3 I/ m! w/ [$ r% u0 c; n4 ~0 `
  695.     # Clone the selected version! ~3 l- w2 b7 b
  696.     case "$VERSION" in
    4 s4 m9 [# H; f- U- t
  697.       0)4 n- v2 P- E. n( {" i
  698.         Log "Cloning Zero branch: $BRANCH" 1- U- z) j4 j, `$ t: T9 ?. U8 t
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive+ Y7 b" H9 v4 Z7 D& ~$ \  I7 n
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive
    2 A. H# D% C/ F2 [# F! W
  701.         ;;
    5 S3 C  G* o1 R8 L7 e( |
  702. / m9 N% ^; k& ~. k+ S7 \
  703.       1)- u. c. ^' t0 B  H% R7 _
  704.         Log "Cloning One branch: $BRANCH" 1$ u. e' ?. c9 w9 m4 c5 M0 b
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive
    2 W& F- l9 M$ g: I5 x
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive, }% F! m6 @8 t, o" H4 M0 ~" B/ X
  707.         ;;
    & K" Q4 X  X. `) S. n/ y8 I% w
  708. 3 o% s# a+ ]" p- B0 U6 {+ Z
  709.       2)
    / @3 Q9 m. R( ^$ O) _& T9 Y1 u
  710.         Log "Cloning Two branch: $BRANCH" 1
    # M( _: ~7 n1 c1 t8 `) _2 T4 n
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive8 X7 B$ ~9 R6 c  c: v6 j0 Z  y
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive
    ! f9 l9 x) V' D; Y# ]1 p
  713.         ;;
    ) ]6 I, {& e: W

  714. - I) u, U+ j6 B1 W4 ]- B4 N
  715.       3)+ m6 X/ p8 @% V7 _) `$ l
  716.         Log "Cloning Three branch: $BRANCH" 1
    ! `, O- L% h% d
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    , s' k& w& B, U% b+ q; T
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
    3 N1 g/ U* [6 k/ y) g8 |
  719.         ;;
    & z1 v$ j4 Y* i# @

  720. ( f; |- h! i& A6 s
  721.       4)4 l; l$ C0 t3 }* E4 E' N# A
  722.         Log "Cloning Four branch: $BRANCH" 1
    , `, k3 t: i  a7 k* H' p& @9 c1 P( L
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive) q8 N& {# b3 N2 \8 O
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive
    9 X) h; i7 w+ x7 `' S- t
  725.         ;;
    # T: [/ p  N& t% t

  726. & p3 Q, F9 D) f( [4 F
  727.       *)
    + d8 p, @' p% Y8 _0 V7 x
  728.         Log "Error: Unknown release selected for cloning!" 1
    $ W9 i- g" Y. c! z4 k3 p& Q- q
  729.         exit 1% ^* d& R/ N- b, {* }+ r3 H2 y: o
  730.         ;;
    / P/ r( {! E/ }" X8 a
  731.     esac
    * O0 q7 }9 A# ]4 I  J- v
  732. % B; c9 g7 q0 p! ?, }  o) Y) a
  733.     # Log success2 p5 g8 R7 i6 }3 f5 d* h7 @, m7 I
  734.     Log "Cloned the selected repository!" 1
    ; \5 f( e; f$ V
  735.   fi
    4 c0 V$ `5 a. I" N

  736. 1 v  w4 Q+ ~5 ^* o# \* J5 T) Y
  737.   # Update the local repositories if selected  W$ Q& r) b# @6 i) n
  738.   if [[ $CLONE = *1* ]]; then$ ^/ ^% p4 O+ g% k
  739.     Log "Updating your local repository..." 1
    & f( ~( F  L% g

  740. " P0 Y! o" Z% N% B
  741.     # Update the core sources
    ( a6 {. D1 X6 ?/ T+ \; Q$ G$ R
  742.     cd "$SRCPATH/server"6 v2 ^8 |; T- w3 r* a
  743.     git pull
    ( b: J7 M" y* n) a4 w2 y# H
  744. % z+ t' }! |% s* q: j
  745.     # Now update the database sources
      X9 q/ \" |! V
  746.     cd "$SRCPATH/database"
    . u' y; W0 h) e( O: V
  747.     git pull$ t: y% i0 a+ x( s
  748. 8 _) Y2 k4 d1 \# _' w
  749.     # Log success
    9 c8 P4 j1 B% q7 U4 N) q
  750.     Log "Updated the local respository!" 1
    " k) u" ^1 |( S1 }5 P5 r
  751.   fi' @  C2 D0 t8 `  I3 u0 @) x
  752. 5 \' z1 h- a( d8 ~' R" X
  753.   # use existing repository
    4 I% |/ l/ z/ F: m
  754.   if [[ $CLONE = *2* ]]; then
    : H" j( ?  m2 z1 r, G$ Y; p  g
  755.     Log "Using existing local repository" 1
    * l0 C0 M( E+ ^5 H* G3 H
  756.   fi
    2 p9 ]* s: L3 N0 s
  757. }
    9 N% P( V9 S% i* D3 D

  758. & S& T0 V6 J( V$ W. K$ w4 n

  759. 4 q- O1 K: R1 N1 i/ P

  760. 6 c- M' e. i* \) n- E6 N) H- Q
  761. # Function to set the build options
    , j; X$ Q: N& m# u9 h
  762. function GetBuildOptions()
    0 g9 v9 Z6 G: X: v  F' J
  763. {, |# r; \+ i9 C7 }
  764.   # Select build options2 z( X9 f2 i! s4 |! W  B6 t- v0 W
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \3 F% K0 X- C2 f: R
  766.     --title "Build Options" \5 U7 j, B1 K; m. l* m. P0 k
  767.     --checklist "Please select your build options" 0 56 7 \+ i0 h8 y" J- i" K( t5 [
  768.     1 "Enable Debug" Off \. K. ]4 k* a  c
  769.     2 "Use Standard Malloc" On \/ v9 I! G3 Z  O
  770.     3 "Use External ACE Libraries" On \
    * U2 g* e8 s* p0 d5 n
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \, G- f0 _) J8 v- B  `: f
  772.     5 "Build Client Tools" On \
    " \( I" p$ C* C0 E
  773.     6 "Use SD3" On \
    6 `! e: H6 {' v, y* ^
  774.     7 "Use Eluna" On \# B) l  H3 `# N
  775.     8 "Use SOAP" Off \& ?$ ^! A% I9 ?$ s# \! }
  776.     9 "Use Player Bots AI" Off \4 p6 K" k3 o8 b" o$ \$ c
  777.     3>&2 2>&1 1>&3); V4 M4 W2 o/ }7 P4 A

  778. 3 M# ^4 Y6 D! f9 O
  779.   if [ $? -ne 0 ]; then
    / |: u3 l1 e- K
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1: L9 ?$ Q7 ^; ~" R5 @# G
  781.     return 07 N4 J& _3 [, L4 d
  782.   fi- P$ y2 |0 f1 a) G3 p6 Q
  783. 7 t9 q0 k6 Y7 j( |! P. J- ?
  784.   # See if debug was selected7 P. }/ X& k; s! Q) H
  785.   if [[ $OPTIONS == *1* ]]; then! `# Z4 n1 x% |- t3 ]# j9 z
  786.     P_DEBUG="1"
    , [/ K6 h( i- a+ h
  787.   else
    2 a5 @0 }6 `7 d  K
  788.     P_DEBUG="0"  ^1 j6 o+ A% v; |: d# L
  789.   fi
    & R# p$ y* Q) P; y8 r: I: c! B

  790. / C* y: o$ y' P' }% I( R
  791.   # See if standard malloc was selected5 I* N$ ?) n9 L- X
  792.   if [[ $OPTIONS == *2* ]]; then7 S, G7 C9 ]2 M7 L
  793.     P_STD_MALLOC="1"5 F7 x6 q* A7 Y
  794.   else
    / y: n! F7 K9 b, V2 M% q# s
  795.     P_STD_MALLOC="0"+ W+ D+ n6 O0 I/ S
  796.   fi5 }) j' O6 }  x& X. i

  797.   y4 K8 [8 G; }% H
  798.   # See if external ACE was selected5 x) R8 C+ W* C# e3 P
  799.   if [[ $OPTIONS == *3* ]]; then2 ~) m5 V! d' C9 h8 F/ g- }' ?) w
  800.     P_ACE_EXTERNAL="1"5 a( f# `* l3 T$ H
  801.   else
    4 w, P6 R- `7 ]* ]$ q, d
  802.     P_ACE_EXTERNAL="0"! c7 x$ k* B# Z$ f" e
  803.   fi
    # [. v* u3 h! Q4 R
  804. % g! K  W/ ?2 f0 o
  805.   # See if PostgreSQL was selected3 h1 W8 b) x5 @6 e9 Y" b4 }+ B' f! V+ j
  806.   if [[ $OPTIONS == *4* ]]; then% w0 Q& J, H" F% r, X. [5 W8 M
  807.     P_PGRESQL="1"" D* q# P1 M2 Z. t0 B
  808.   else- Y$ V4 G8 U3 X9 W' X
  809.     P_PGRESQL="0"
    ; z* ~9 y. Z* X
  810.   fi
    % O& D5 f% w. f

  811. ; t1 K( @6 T5 Y0 i6 z# u
  812.   # See if the client tools were selected
    6 P3 a6 P- U4 x4 T# k9 b& p
  813.   if [[ $OPTIONS == *5* ]]; then, f( x! r/ d! g7 p( Z3 E; p
  814.     P_TOOLS="1", q) ]0 e) o) v# q7 C& k8 g# f5 ]
  815.   else6 w2 M) E# S4 S, f6 P6 c1 C7 {# ^% ~
  816.     P_TOOLS="0"3 K0 p- g8 ]+ P) ?* o5 V
  817.   fi
    7 S8 l+ }3 m  n1 i& R

  818. ( z% d/ |7 X' Q+ `% {1 `$ t8 h* ]- P, C
  819.   # See if SD3 will be used
    ; o2 v3 g0 v9 f9 o) V0 L3 w
  820.   if [[ $OPTIONS == *6* ]]; then' m  x9 B8 \/ a: R% r3 n: w1 V
  821.     P_SD3="1"
    # _, {  {0 k4 U& f
  822.   else9 Q+ K; B; `" a- G4 ^
  823.     P_SD3="0"
    , E, [+ m- W* Q* [' v: a& N
  824.   fi
    1 T3 T( |5 t5 j/ g2 |, W

  825. ! X# U. \. u: \3 f
  826.   # See if Eluna will be used9 N' u/ Z, m/ E8 W# K: h) }- }6 N
  827.   if [[ $OPTIONS == *7* ]]; then
    " i4 P% E; n  }5 e! T
  828.     P_ELUNA="1"
    . z& I3 ~. P- j2 z) w, X  {! _
  829.   else1 Z( V, k; x' _% V/ w9 d3 @$ r
  830.     P_ELUNA="0"
    * Y: `$ i: ]  H6 `% c7 v
  831.   fi8 A4 N+ {3 ^* K) u
  832. 2 H% u* J) M8 }- E+ C; G5 I( j5 U
  833.   # See if SOAP will be used
    0 x8 V% [* {) D/ q; }& _; A( j3 m
  834.   if [[ $OPTIONS == *8* ]]; then
    . X* `/ a/ r6 ^0 E$ D' t! k
  835.     P_SOAP="1"
    , m6 l4 X3 x, R# v  r" ?+ l
  836.   else1 L$ ?0 ?. o9 W
  837.     P_SOAP="0"3 y5 F' I; g% u: h% v
  838.   fi
    % }, t( ]2 ?+ ?% v' X5 [: m4 m; m

  839. ) [, T1 ?) C  d( e
  840.   if [[ $OPTIONS == *9* ]]; then9 s% P( S7 r# g; Y0 r' R1 H
  841.     P_BOTS="1"
    6 e  i9 x7 a% j! ]% o6 B5 x0 t4 A
  842.   else
    * S. L) y/ J+ l7 f9 e$ Z- {' P
  843.     P_BOTS="0"
    ! {" }& L6 T) _" s; i
  844.   fi. W# x9 y+ G4 n9 E8 N
  845. 2 y& k5 g  z2 U
  846.   # Verify that at least one scripting library is enabled
    # R9 K; r7 Z/ ~' d& s! ^
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then# X' A, w& @1 z, z% e& w
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1' Z5 {) a0 m5 P: y3 w
  849.     exit 10 P3 y4 O* L. q$ }* F* N: b$ L
  850.   fi3 V! q# Z* ~  f( j
  851. }
    9 s/ O& Q* v8 w- x, q
  852. 6 z4 w' b) R- v2 w( K3 b2 t

  853. 4 \$ h/ T- P: T/ z
  854. 3 g' s) W( V% m+ Y  N% ]4 a
  855. # Function to build MaNGOS5 @  r  d7 Q8 p2 d5 Y
  856. function BuildMaNGOS()6 W4 ^. _# v- M9 _5 Y8 [' i
  857. {) T, u9 \. \5 l4 b2 a9 c) [) Y
  858.   # Last chance to cancel building- q3 `* F# u3 f4 S! j; t8 L; F
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \8 d* Y- v1 O% o5 c$ ~. C- i
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60
    4 @7 u- w& R& o

  861. 1 V- t+ ~1 L- R8 E  t- d
  862.   # Check the user's answer, x, |+ ?" `0 j2 g5 C
  863.   if [ $? -ne 0 ]; then) k+ w( U& `* {" ^
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    2 `: L3 p: P' h' J7 ]
  865.     exit 0: D' D& Z+ Y' j4 h) f4 E- f
  866.   fi  x* e/ Z. Z* d8 S0 E) s) g

  867. ) U) S- W3 L1 P9 o; Q
  868.   # See if the build directory exists and clean up if possible
    $ r$ h5 t5 M4 a& V  t6 l! @5 l! H
  869.   if [ -d "$SRCPATH/server/linux" ]; then
    5 Q8 X7 T/ n3 e, w* L8 F
  870.     # See if a makefile exists and clean up
    - B% i, w. P9 H
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then
    ' p5 \, Z' b4 b7 M
  872.       Log "Cleaning the old build..." 1
    ; `. v% I  L9 B6 a! y* M
  873.       cd "$SRCPATH/server/linux"8 v* F7 S0 z5 c) A% k' n+ G
  874.       make clean  `. w/ j1 B/ g( l6 n3 l$ t
  875.     fi
    . r5 x. D1 G' U- ]. s8 f( Z3 S( v
  876.   fi
    7 r, m1 @$ d* m
  877. 2 w/ y" `$ B9 D7 v, a/ W
  878.   # Attempt to create the build directory if it doesn't exist
    - b; ^% ?! K- K5 G' t* L
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then7 w$ P( a. S( J  M: Y2 I
  880.     mkdir "$SRCPATH/server/linux"6 j4 S+ H) J) d+ P" O; a8 y
  881. : u$ j! D6 a- D  o( P6 {4 g
  882.     # See if creation was successful' C* V& ^: x* u' J& q% b6 v6 U; Q
  883.     if [ $? -ne 0 ]; then
    * j) w; j% N) C
  884.       Log "Error: Failed to create the build directory!" 1
    7 |% E! v1 w6 x. u/ K6 E$ d2 h
  885.       exit 12 H" i- o5 U0 ?9 p& {4 m
  886.     fi$ p  e( L. o1 n8 y4 ~, |+ y& ?
  887.   fi
    0 k5 A6 k$ G) l0 P: H$ b$ x
  888. . p  T6 s4 k. q5 i4 E/ @* K3 C
  889.   # Attempt to configure and build MaNGOS
    $ U% V/ W0 K! ?# e! E
  890.   Log "Building MaNGOS..." 06 {! ?; V& B2 n! G: \2 t# U0 Q
  891.   cd "$SRCPATH/server/linux"% f, I( Y9 {6 X0 s5 s9 |* g
  892.   # make sure we are using the cmake31 X, ^! P* k: H4 b5 X
  893.   UseCmake3
    * e3 T2 m& N6 s; ~4 O, k* _% x
  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"
    5 W; Z* G% b- N
  895.   make
    1 B8 V+ A: f( L) E' W& `& i
  896. " Y5 d- ^3 E4 \( F& X# N# E
  897.   # Check for an error
    # R9 A' H# k, M# G6 E; m( N7 V5 `& H5 z
  898.   if [ $? -ne 0 ]; then
    ! a  ~* A  y6 g+ a/ D7 K/ ?4 C8 {# T! b
  899.     Log "There was an error building MaNGOS!" 1
    # }: j1 N/ e9 R& z
  900.     exit 1, a/ b& Q3 P7 G: O$ A" T
  901.   fi
      `: D% U' l* X0 k0 E' y

  902. ! k( x8 C8 l" b' `* t
  903.   # Log success% f% z9 m1 |' x* t. @1 D1 y; D
  904.   Log "MaNGOS has been built!" 0
    / t2 b% m5 b7 c
  905. }- O8 @0 _* w$ s! H
  906. , v; N$ O: U  q6 y$ G& `
  907. 7 \) i6 u) W1 }; w: m$ K# k+ V/ l3 Y

  908. 5 |3 S& g5 z0 Z, a: P0 ^  k
  909. # Function to install MaNGOS2 ~( A$ a! v  S% X2 T% a$ I
  910. function InstallMaNGOS()
    6 M+ T% n0 K5 j4 _( R. d
  911. {0 W0 L9 x% Q) c. t: s' q# D1 G
  912.   # Ask to install now3 H* J  N1 d7 C6 W% Z4 M( C) e& g- Z
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    6 x" [1 a2 ~3 M3 Q( s
  914.     --yesno "Do you want to install MaNGOS now?" 8 04 n9 H1 ?, s4 H1 O

  915. ( s( y0 q4 w* w9 A# t) |2 k4 t
  916.   # Return if no! L% i6 y- Q! O) l7 D. x- S
  917.   if [ $? -ne 0 ]; then
    $ I- u# H- N7 b( j+ `3 }. I
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    : R# V7 b& [5 M( V) L
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60
    " i5 |) C5 E" P3 N

  920. : n0 S/ X# {5 i$ ?: r& _2 B# v
  921.     Log "MaNGOS has not been installed after being built." 1
    ! |5 v/ r6 s; y' [. b. H
  922.     exit 05 [0 O# o% i3 Z2 a  b
  923.   fi
    3 g- H) J& n7 O0 k
  924. : U% T0 _8 R/ q( a
  925.   # Install MaNGOS; b2 L7 u+ X% p: t( U. G
  926.   cd "$SRCPATH/server/linux"7 S0 G; I- g5 R; `. o* a
  927.   make install
    ( n) x. x& l5 E% b% y
  928. $ |( i$ C0 k, @- F
  929.   # Make sure the install succeeded
    / g1 n6 k/ J; k# k! X  h. C& c
  930.   if [ $? -ne 0 ]; then: [" E, B1 J: @4 \* m! a$ w
  931.     Log "There was an error installing MaNGOS!" 1
    2 }8 W* m; g% x% S1 ^- w- F
  932.     exit 1( z! M- Z! {; j" x( k+ Q  g5 d
  933.   fi1 R, V% J0 i& Z; B
  934. }
    & t, s$ k/ I, _- ~: G

  935. # H5 c( P  O+ g( Y
  936. # Function to apply database updates/ t- X% p2 @8 n) C4 p
  937. function UpdateDatabases()8 B; r2 n) W8 ?6 k
  938. {% W: f5 f/ q( ^6 d1 `- f
  939.   local DB_HOST="$1"
    8 u5 ?/ v5 c4 Y7 {
  940.   local DB_TYPE="$2", Q; ]$ J# n. X; @- r
  941.   local DB_COMMAND="$3"6 q3 N2 G" E2 }
  942.   local DB_USER="$4"
    " i: ]3 r  @- k; |; F2 M- {0 p5 Z
  943.   local DB_UPW="$5"3 Z$ p: d( J% R  C6 c
  944.   local DB_REALM="$6"  {" D3 N! I. ^: w! @' W
  945.   local DB_WORLD="$7"
    ' k3 b, b0 Z4 l
  946.   local DB_TOONS="$8"
    ! N6 W; ?( i. s' _6 l
  947. # k* {5 e$ f8 h8 _* O* I; r
  948.   # Loop through the character files
    - ^2 [+ @7 ?$ P2 Z  w3 _* ]" U
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do/ f& C! J" C2 m# S; R
  950.     if [ ! -f "$pFile" ]; then, \8 y: k9 D: \8 V8 V/ v9 p, l
  951.       continue
    " z4 `6 A4 c2 D" C/ g' F- m' f
  952.     fi
    $ C, @5 c$ B; a, Q# T; G
  953.     # Attempt to apply the update
    ) R+ h- D" i8 v8 o
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1
    7 }1 J/ [2 v) @7 }
  955.   A# ]" t$ D0 |% b& `' ]& B% P$ l
  956.     # Notify the user of which updates were and were not applied9 @! G1 ?9 _3 S$ C
  957.     if [ $? -ne 0 ]; then6 C1 Z+ `& T$ }6 z) n) B2 b
  958.        Log "Database update "$pFile" was not applied!" 0( X6 N6 D5 `* H# p9 p; O+ B  Z% Z2 G
  959.        Log "Database update "$pFile" was not applied!" 1
    1 m5 ]2 P( e" h. P& s
  960.     else5 f/ N3 m9 T$ I5 K
  961.        Log "Database update "$pFile" was successfully applied!" 0
    ; v/ w) h1 G! d; F6 r! [( S
  962.        Log "Database update "$pFile" was successfully applied!" 1/ a, `2 X" f+ y, H, _' N
  963.     fi5 y1 j' S5 Q3 |( Q) T. b# g
  964.   done
    + W1 u$ f% Z9 ?" K8 O( u3 N
  965. - H! I3 p  I; \* A9 J
  966.   # Loop through the realm files' |& D5 C: x3 ]
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do' u* E1 f5 H! m2 Y
  968.     if [ ! -f "$pFile" ]; then
    9 ]! B' v( y# H: e! |7 t" W9 g' i
  969.       continue
    # Y9 `) E4 {7 X' {
  970.     fi8 F- e8 G4 J8 B8 J
  971.     # Attempt to apply the update2 ?& R; s. L: v, v
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1
    ! ~1 u, ?& h4 x( g3 Q, ~; V

  973. / E/ g+ L; w0 M# e$ i" n
  974.     # Notify the user of which updates were and were not applied& @4 n! m# O: ~
  975.     if [ $? -ne 0 ]; then
    5 M  c6 f# O& x  |8 l
  976.       Log "Database update "$pFile" was not applied!" 0  Y. n0 Y. n# a4 U2 G3 U; i
  977.       Log "Database update "$pFile" was not applied!" 1& R* |: A0 ]4 R# F6 n
  978.     else
    : W  B5 t+ K9 B
  979.       Log "Database update "$pFile" was successfully applied!" 01 R6 j/ x4 V3 n: W+ M7 C
  980.       Log "Database update "$pFile" was successfully applied!" 1* M, c9 Z: g) P* `3 Q! J
  981.     fi
    ( B" O3 D) E# L* c" i
  982.   done- }0 o) f7 a1 E; I# h
  983. - e7 J& M/ @0 _& k; Z% f
  984.   # Loop through the world files& A- T+ G, @! v3 n
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do+ i" W/ i% N9 |; `7 x
  986.     if [ ! -f "$pFile" ]; then( d; j1 ]9 v+ G$ K/ H0 U# l
  987.       continue
    # I% ]; e, q. z. Z2 }' t. W
  988.     fi+ \! P8 Z: w. \( y1 Q4 D4 J
  989.     # Attempt to apply the update, R& `% g% e- ?$ G* F# k( k6 Y
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    % x! U$ g$ `5 h- a6 M- `/ m# w4 y
  991. : t( X. t- X) B9 w, ^, C
  992.     # Notify the user of which updates were and were not applied  l$ O. X! S; Q7 D! A9 e$ B0 R  q
  993.     if [ $? -ne 0 ]; then* U, r' z! m$ h2 C0 }! Y
  994.       Log "Database update "$pFile" was not applied!" 0& q. W6 W' c3 b, l8 t* g8 \1 I
  995.       Log "Database update "$pFile" was not applied!" 1% }% ?  J: g% c7 {' D
  996.     else
    4 T$ b# H8 G  H5 t) Z; X- }9 a5 R
  997.       Log "Database update "$pFile" was successfully applied!" 0
    4 Q* A4 W3 u+ V9 |2 ?
  998.       Log "Database update "$pFile" was successfully applied!" 1
    & G2 x/ J# F7 a& K! W
  999.     fi! I( ?# d  a* R0 H
  1000.   done5 ]7 B% E( ?. X
  1001. }
    & a+ }0 A/ @7 n

  1002. 6 B4 E: m9 h0 j8 \) j0 {
  1003. # Function to install or reinstall the databases6 V! c% o& m$ _, f! y; v
  1004. function InstallDatabases()" r2 B# f( S& {. ?* B% `) L
  1005. {7 S. |$ R) F9 T+ W( l1 T
  1006.   local DB_HOST="$1"" @8 n7 j" \8 H7 I
  1007.   local DB_TYPE="$2"
    ; s( j' S0 ]- p5 H/ P0 P* M! Y
  1008.   local DB_COMMAND="$3"- G1 V. {, g" g9 T8 b$ X1 J/ K
  1009.   local DB_USER="$4"! P$ L( ^, A: ]; j0 R! S3 A+ V2 m7 p
  1010.   local DB_UPW="$5"
    6 }1 }* P3 e9 W1 `/ v4 n
  1011.   local DB_REALM="$6"
    8 p8 z' Q/ d$ l: E1 L
  1012.   local DB_WORLD="$7"
      P# {# A- m! s9 g7 e+ U
  1013.   local DB_TOONS="$8"0 T' I- {4 K8 j, f! H% m

  1014. ) Z' s% ~- s! |9 `, {/ G
  1015.   # First create the realm database structure
    8 T. b/ V, a' a, ~0 a4 o/ r! t
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql( v+ Q: i3 D! @0 D3 ?9 F

  1017. 8 j' t; A) x( G# I: i
  1018.   # Check for success
    + M+ _* `- D/ _3 w
  1019.   if [ $? -ne 0 ]; then6 |" `, o6 a6 F) p8 \* U
  1020.     Log "There was an error creating the realm database!" 1+ w9 A; y6 D7 f  G9 F+ i
  1021.     return 1* p1 i+ O& u2 N4 p$ A# p
  1022.   else
    + W  p9 ]5 v, D4 M" Z1 D' E  L' C
  1023.     Log "The realm database has been created!" 1
    & z" Q* L* q0 i9 L' i# r
  1024.   fi5 X/ g; w6 }* {$ Y5 x9 O

  1025. / d5 l# E) x8 \; g! D
  1026.   # Now create the characters database structure. ~4 w$ E  z7 S1 p) D+ A6 O. p
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql; J: a) ]% t4 F# I5 m

  1028. $ Z4 }7 s$ t' P; O/ l
  1029.   # Check for success
    0 W  i+ C# ^  Y% m# N
  1030.   if [ $? -ne 0 ]; then" r8 w9 `' w% k9 y! s+ O+ u5 n* B$ ]6 v
  1031.     Log "There was an error creating the characters database!" 1
    4 w$ b3 a3 i" {& v. `% j" S7 c  V
  1032.     return 1
    & X7 b6 x' d$ j- `0 C/ e( a8 `# V
  1033.   else
    ( K" }9 Q/ e% u$ Q$ C( j8 i/ u
  1034.     Log "The characters database has been created!" 1
    ; A) J* |, e; O% }- v  i; M
  1035.   fi
    7 B$ p9 b; x4 K& Q

  1036. 8 A- G: g. M/ K* W; n
  1037.   # Next create the world database structure6 d% {  f0 b6 `0 [" r! S( f# ~/ m# S9 C
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql3 c2 b* V: R4 l0 k

  1039. & h" W( h! Y& d/ D
  1040.   # Check for success: ^/ e8 Q0 o& ?  C( w# _
  1041.   if [ $? -ne 0 ]; then
      V' R3 ~4 L: z! p
  1042.     Log "There was an error creating the world database!" 1
    : j% t4 @' p" b8 `9 R
  1043.     return 1
    & w& k4 t7 S7 j5 k' K7 m% b( F
  1044.   else0 i( F) w5 z6 f/ p: l
  1045.     Log "The world database has been created!" 1' S- j4 S0 r( A4 A$ y  j& K9 I
  1046.   fi( h9 [7 L5 W- |7 k7 G
  1047. 4 p9 K/ |, P% K  W
  1048.   # Finally, loop through and build the world database database: D2 }# z5 L5 _+ j, t+ ~
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    ) a. X2 {% U5 v6 X. E  o# Q* B' |
  1050.     # Attempt to execute the SQL file" {8 I) S& W* X' i
  1051.     $DB_COMMAND $DB_WORLD < $fFile! f, w- @/ W8 {: y( D4 K3 H
  1052. & O& E  E0 ^5 U7 R2 F
  1053.     # Check for success: a( y. C' ^% x- q. I
  1054.     if [ $? -ne 0 ]; then9 j6 O- }9 |- Y- Q$ V8 W; U; x
  1055.       Log "There was an error processing "$fFile" during database creation!" 1
    # e6 R& C- w8 j/ I+ E' f; R4 O# d
  1056.       return 1  Y6 I: A- b% k  M. t' j+ P
  1057.     else
    7 G/ t& Z" j8 M4 U5 I/ p! |/ d
  1058.       Log "The file "$fFile" was processed properly" 1
    5 E7 K- Q$ d7 ~7 F
  1059.     fi
    ( Q8 F) l3 C- x) h/ t0 g
  1060.   done: `9 P2 W7 j9 q, n
  1061. , ~+ b; u) `( G1 X& f5 _5 w) {
  1062.   # Now apply any updates3 v' }2 s4 k5 ~0 o, A; h3 [
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    1 d$ L2 w& R, A# j5 i
  1064. }
    : f& j1 b0 |& X7 J1 S4 M
  1065. : n& ^# s+ ~" V& t3 w/ o
  1066. # Function to install or update the MySQL/MariaDB databases) w5 W3 D  n, z# @( t9 P
  1067. function HandleDatabases()
    2 w3 A( L: t8 {
  1068. {
    0 u4 P3 U; ^5 f$ E& G" r+ N
  1069.   local DBMODE="0"
    / u# O$ _$ J2 b, O. b) r7 w& m  r7 O% J
  1070.   local DB_TYPE="0"" E5 v; h+ Z; ]% c' S4 w
  1071.   local DB_COMMAND=""
    6 D5 x. |* m1 J# o4 R  Y
  1072.   local DB_TMP="0"
    ! K2 R1 i" Q, l2 D
  1073.   local DB_USER="mangos"
    " m0 F- Y" b# o/ N, I
  1074.   local DB_UPW="mangos"; ]5 U# i  F( ~/ a. c0 V
  1075.   local DB_HOST="localhost"
    - A, m9 u% v- K
  1076.   local DB_PORT="3306"  e7 S- f4 z, Q  x& v
  1077.   local DBSEL="3"$ B4 [) `4 {, a' R
  1078.   local DB_REALM="_realm"' |) w. }: q3 [- L' U; e6 j3 S* V+ Q
  1079.   local DB_WORLD="_world"
    8 u' h7 {( f0 A0 ^( a7 `8 B
  1080.   local DB_TOONS="_characters"( D6 q; z* ]2 {5 y5 |' b* d
  1081. , h1 S) I9 S9 d, J+ D6 @  l
  1082.   # Ask the user what to do here
    8 q# }# Z5 b% S1 p1 q
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \
    ) `) o5 G; z- p& [9 Y% }- m2 c
  1084.     --menu "What would you like to do?" 0 0 3 \' }5 N! y( T2 R3 d  @* _" o! K
  1085.     0 "Install clean databases" \
    + t* M# {# V$ e& f7 k( |( d
  1086.     1 "Update existing databases" \! z" ?0 Q. f# ^7 ]; }( A! ~
  1087.     2 "Skip database work" \$ |' `8 n! D( I( n) ~" D% q- j- F' I
  1088.     3>&2 2>&1 1>&3)3 f$ b4 Q: c) }/ T

  1089. ; t8 [" A' z7 _0 J8 i9 b  A
  1090.   # Exit if cancelled8 L# p. h0 y0 e6 s, k
  1091.   if [ $? -ne 0 ]; then
    - ^2 H# r8 u; w4 `8 H" p0 q+ V
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1" E9 F: y8 e. Q
  1093.     return 04 N% I( B' N( C) L0 H3 L0 p% r6 s  n
  1094.   fi
    . l8 s+ A/ C( X7 ~+ r+ C6 q2 q

  1095. ) W4 K4 t1 j: j( J( N/ L
  1096.   # Exit if skipping
    8 {* h/ B+ I% d; S; j1 m/ W
  1097.   if [ "$DBMODE" = "2" ]; then' u7 j- F9 W  d) ]% [9 c0 E7 K5 ?; q8 J
  1098.     Log "Skipping database work. Nothing has been modified." 1
    1 ^9 }, G( M8 U0 a9 A
  1099.     return 09 _0 S7 r8 @+ v2 l- D1 G
  1100.   fi
    & {; Z1 m& V+ e' ^6 ^

  1101. 1 ~4 K( T" |+ R8 A2 Z
  1102.   # Ask the user the DB type
    * X% m9 v" `. }( K. \& ?% V, K
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \
    + ~) ^1 s  l* E2 \
  1104.     --menu "Which database are you using?" 0 0 3 \9 Z* t- D3 M$ o& A: Q
  1105.     0 "MariaDB" \4 w; L; l5 u. f9 j
  1106.     1 "MySQL" \, m. Q  G( ~% W- J) P) N2 @! x
  1107.     2 "PostgreSQL" \5 o' `2 U+ S- J8 H9 ~3 M
  1108.     3>&2 2>&1 1>&3). U( m5 E6 {( M: @

  1109. ' s8 R9 Y$ Z3 I' O
  1110.   # Exit if cancelled
    ! W4 \0 k, i+ f, C
  1111.   if [ $? -ne 0 ]; then) f  G8 a& d! W& S8 I6 J7 Z
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 1
    # b  ?6 n) _7 ]' O
  1113.     return 0
    & E* r$ l: Q0 B) j
  1114.   fi5 t* L) }' R! ]# S: T
  1115. ) t; N' h6 M  M" P
  1116.   # Get the database hostname or IP address! ]  J4 \0 Z4 C& e9 |
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \
    $ ^  \7 q- _- O
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)5 R0 K* L' x6 J8 w" [' n

  1119. % U/ D( l; o' [8 F" R& m- Z
  1120.   # Exit if cancelled
      ]9 a9 ^/ i% F- J& n7 ]6 G3 ^8 n
  1121.   if [ $? -ne 0 ]; then
    : ^- M; y( T' p
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 1
    ) C. d  I9 [0 t0 Z3 o7 z6 _# i
  1123.     return 0$ i' b  }* m- e% r) ^4 O* Q# ]
  1124.   fi
    7 {2 n; N2 z0 X! Z. d

  1125. 7 \$ ?" M- L% V8 U- N: ^
  1126.   # Set the hostname or IP address if one was specified( M0 j7 I# a# k6 F# }
  1127.   if [ ! -z "$DB_TMP" ]; then
    3 I, S) C3 ^# i4 K/ m
  1128.     DB_HOST="$DB_TMP"1 H" K" Q0 J! m! c4 j# d
  1129.   fi( S( b. T: Z& m+ s
  1130. 2 y4 r8 H: D6 u5 F
  1131.   # Get the database port+ _$ t* s/ S1 g. z; b; m
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \! x8 B5 p% O% d0 [
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)
    ( r: k5 q; J; m9 H
  1134. 0 |% v, ]) Y' X7 q
  1135.   # Exit if cancelled7 a/ g3 s2 J4 V- p+ {
  1136.   if [ $? -ne 0 ]; then
    6 E1 m/ }9 e  p1 C
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 13 _2 ~& V' \6 n
  1138.     return 0/ i: Q  l4 X1 c8 O" ]+ s* d" L/ H1 ~
  1139.   fi7 c5 h: q  e. S

  1140. + N3 }) N, {4 @: {% v$ U, B
  1141.   # Set the port number if one was specified
    ; D+ V) H, o) _5 v- N5 D; ?
  1142.   if [ ! -z "$DB_TMP" ]; then
    2 m4 ?; x8 \+ L5 x2 e
  1143.     DB_PORT="$DB_TMP"1 v* f( r' x9 X$ r" @% ~; j
  1144.   fi
    9 e$ e: `) N5 G

  1145. 9 ?6 y0 C/ T2 r5 F" Y* A+ }
  1146.   # Get the database user username+ T( }8 }# a  X0 d, l
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \' G1 }3 }6 ^: k) r6 J5 {
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)
    $ T' y/ p% |/ c" W6 X
  1149. 8 W  }0 C& f# J  W5 j+ E
  1150.   # Exit if cancelled
      M; U9 R4 g1 K4 J
  1151.   if [ $? -ne 0 ]; then
    ) A% ?  u. o' b* H* r, {7 e4 z0 a
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1
    / v# g5 i$ R  k1 W) v) R
  1153.     return 0; B& |+ J6 B# c8 k7 y. r! v
  1154.   fi0 X7 Q6 T1 L0 p3 ]* Y* ?" D

  1155. 8 d7 x5 b# J0 @; m# O7 j
  1156.   # Set the user username if one was specified, a; F; p9 m4 k/ X! ^$ [
  1157.   if [ ! -z "$DB_TMP" ]; then
    & x2 U: S2 [; e
  1158.     DB_USER="$DB_TMP"6 ^. |. \! M" r0 u2 Z: J! F. n! X! U
  1159.   fi$ b( _& I+ V" h1 ?0 ?1 [  Z- J
  1160. : z: @" K7 ]0 Q6 V9 ^  P( ?
  1161.   # Get the database user password
    9 v1 y1 o. Q' h! r; y
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \
      Z8 o) K$ q7 A! E
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)+ F6 {7 o* |5 o9 U% T/ Q! f

  1164. & g7 Q, s+ a6 F9 P8 d$ t9 Z
  1165.   # Exit if cancelled
    ' `6 X4 e& B. u: b0 c# I/ {
  1166.   if [ $? -ne 0 ]; then8 J/ Z0 B6 r! ^* S
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1/ S2 o! _/ c7 C  U" e) U, N- I
  1168.     return 0
    7 Y% K8 t) V0 g( f; ~. K8 P
  1169.   fi
    $ M* R$ Y# y* V( q% Y) L3 F

  1170. / I0 m: Q2 J4 {+ Y
  1171.   # Set the user password if one was specified
    . D( J7 Y$ v9 ?: N
  1172.   if [ ! -z "$DB_TMP" ]; then
    " Y1 C7 G: u4 `4 i
  1173.     DB_UPW="$DB_TMP"  V. a( a2 O. Y" `3 A. F6 t; l
  1174.   fi
    % C3 O* L6 l9 `7 t$ j  C' S( }
  1175. ! B' z: ^: T  x& j3 `, }
  1176.   case "${DB_TYPE}" in5 Q/ m( a2 X5 N; H$ Y
  1177.     "0")3 M0 A' `2 f6 m" E, r
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "/ b+ P) ?- R5 Y& H
  1179.         ;;3 K$ u4 K) ?6 F# [& V1 t2 c
  1180.     "1")
    2 J& O8 r7 y  b* f% v
  1181.         printf "Confirm your MySQL password\t, "% J' X- g; C8 M- H
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn, u9 n' l/ D% \* z$ Y$ P, r5 `5 |& p
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    2 Z8 h6 i4 W" [! [+ K8 a
  1184.         ;;
    $ S) A4 ^! T# ]
  1185.     "2")
    + M1 ?' U; [& M
  1186.         Log "Currently not supported." 1( s  O+ p# _. g$ a' F
  1187.         return 0# t; m6 z! n8 ?4 Y
  1188.         ;;5 f' o9 Y( I1 h% I; A
  1189.   esac8 q. u' M) E# r6 n/ ]8 t7 Y7 A

  1190. * F# r; w+ M( ]* k& g3 h1 X
  1191.   # Setup database names based on release: g6 m! Z1 o( O5 E, B
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"+ B' ]8 A: d9 S9 e5 H
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    : t* i% I/ w* }+ {1 j
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"; o3 X% x- t9 Y4 K. z! n

  1195. ( ^1 }; b% S: e$ W( H/ G
  1196.   # Install fresh databases if requested
    - a. g, O% x% Z' E
  1197.   if [ "$DBMODE" = "0" ]; then) f( U. D7 x* w8 j# y+ i7 P
  1198.     # Ask which databases to install/reinstall! k; }9 V, U9 }* D) E( p
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \# `6 b, w+ [5 f1 C. Q2 g) P
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \* S5 F" @& q; W7 l; U" G
  1201.       0 "(Re)Install Realm Database" On \
    5 Q7 {0 T' v2 P+ u5 w& H
  1202.       1 "(Re)Install World Database" On \
    6 o( P( G2 K- b# A% U7 B. z) {
  1203.       2 "(Re)Install Characters Database" On \9 @6 l" O6 m! y1 D+ e. q
  1204.       3 "Update the realmlist" On \, X: a: Q% v4 G5 m3 z5 ^
  1205.       3>&2 2>&1 1>&3). V5 a' S. s, U9 d3 E

  1206. & U' k6 ?7 f+ v+ q  ^
  1207.     # Exit if cancelled5 \( P' r$ z/ A' ?
  1208.     if [ $? -ne 0 ]; then
    : j6 A8 g5 r  x) b' [# l
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1- `7 T. |' C! E; a9 {+ @3 E
  1210.       return 0
    " u0 d5 s, P5 o+ ?
  1211.     fi
    8 \2 E/ q) g* ^, e
  1212. . {  G9 _3 f/ [
  1213.     # Remove and create the realm DB if selected
    0 w; Z  U% U! \$ ]* U' ~) d# G
  1214.     if [[ $DBSEL == *0* ]]; then
    3 y9 k1 M# I" J, h* E
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"+ f2 p% |  G0 L
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"* l% O4 r) v7 |, T  @- O
  1217.     fi
    & e5 K8 n% o7 T% `

  1218. 4 f8 _1 H  k8 s5 V4 J& {  R# ?
  1219.     # Remove and create the world DB if selected
    / s: H' }% p1 L
  1220.     if [[ $DBSEL == *1* ]]; then- i" \8 s2 u; R* `+ r6 p' ]
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"5 H  n$ q$ X" [$ B; D
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"  ]9 ]) t8 J& `" l, x0 Q
  1223.     fi0 W1 R" b7 \. j0 s9 [8 v6 P/ E' A" W
  1224. 4 u" H1 J  L( [4 x$ w0 Z% k' E9 q
  1225.     # Remove and create the character DB if selected
    , f& Y. Z; c+ w2 M
  1226.     if [[ $DBSEL == *2* ]]; then5 ^2 C/ B2 @; R* z
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"
    ( d# _! N5 D! e1 r+ \% W  G( F
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"& F, |+ n* B' L( L8 _: ~
  1229.     fi1 T' E. u; s1 c

  1230. 5 x4 B$ \+ x7 `9 ^" m6 X# {* Y! V
  1231.     # Validate success" F7 S; b1 d: b/ v, k3 ]" I# Z- ]
  1232.     if [ $? -ne 0 ]; then! v5 q7 k$ g( A/ h4 j% v4 b) C
  1233.       Log "There was an error creating the databases!" 1+ }0 I5 b; g% I# A0 Q
  1234.       return 12 ~7 {) T$ t! l- g* V) C
  1235.     fi: e8 ?4 j/ ?1 Q- _
  1236. ' g& l, R$ M, o) A/ Z9 _
  1237.     # Finally, populate the databases
      y2 c6 \$ `8 {1 w
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    " v* P" i& @0 x9 ~6 h9 c/ f6 Q
  1239. - B7 v, _/ B* m6 V! z$ ]5 B
  1240.     # Updating the realmlist
    / R3 \+ C2 w' l3 C, e
  1241.     if [[ $DBSEL == *3* ]]; then
    0 _# \+ n2 Z5 r, n
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql
    + Z' p' e/ z8 T
  1243.     fi
    # [2 |' J# W& c7 E5 z. N
  1244.   fi
    ! f2 P- A1 e! t; @4 V" Y% t* q4 n8 s

  1245. . e0 H( O4 c( E$ ^% W1 N7 Q: k
  1246.   # Update the databases if requested
    ( R! M+ g7 y( G3 l
  1247.   if [ "$DBMODE" = "1" ]; then+ S, {$ {7 q% ?/ _6 P% o2 ~
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    % q' ?: K+ E4 l1 ]% j+ p" F
  1249.   fi
    + V! |9 L4 e0 \2 @
  1250. }
    - p0 Q6 X. l+ E
  1251. / s3 V& T  D3 d
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
      w, h& v6 J+ \. ?, v
  1253. function ExtractResources
    / D! K" y; x1 b$ i4 I1 k! K
  1254. {
    ) d, G7 J+ {* Y+ @% v, x
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))0 q' a1 {; J  H% N' u
  1256. 5 C8 g) A9 G: u5 ^& M" l9 `
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \
    9 l/ F3 R( C6 g$ R0 \8 h" _5 |
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)5 h# `) [5 e* A" c& i

  1259. ( D1 e5 A: o4 I1 M! c
  1260.   if [ -z "$GAMEPATH" ]; then
    . E! P- ?7 E1 j9 k4 Y: K2 F
  1261.     GAMEPATH="$INSTGAMEPATH"2 u# T! O: k1 J
  1262.   fi
    $ s+ Y1 l4 r; Q
  1263. : G/ F% q  \" e  @+ l
  1264.   if [ ! -d "$GAMEPATH" ]; then
    + h/ X# ~, S9 d" I$ t. W
  1265.     Log "There is no game at this location" 1
    9 X1 T* f& s$ H5 @' r# r
  1266.     exit 1
    2 p2 g# [# }4 \6 r' w
  1267.   fi9 i9 q$ T/ Y( w) y1 t2 {$ N

  1268. & r6 G: F& F6 t2 Q7 K
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \# H/ N& l( j1 k, h5 G& V$ B4 ^
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \1 a  _: u- d2 r3 t
  1271.     1 "DBC and Maps" On \3 F& Q- J$ I2 o. L
  1272.     2 "Vmaps" On \
    : B; ^2 l0 Z: t4 a, B+ W
  1273.     3 "Mmaps" On \3 o0 ]5 M- s9 k" w+ X. @' e* p, r
  1274.     3>&2 2>&1 1>&3)
    * K7 b& i4 z2 s+ p* ~

  1275. : v3 j  U% A3 p& n
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    4 P! U' p! |: v& B
  1277.     Log "The client tools have not been built, cannot extract data" 1
    ; W! v7 a/ j' S3 C5 o0 K0 |
  1278.     exit 15 P0 O8 W7 I" {
  1279.   fi
      Q! h# b& o. V# z" F

  1280. 9 i% }' h# R8 z) x+ g
  1281. #TODO What if DBC are not yet generated ??
    1 ?7 ^" S3 y# x, \3 Q- w
  1282.   if [[ $ACTIONS == *1* ]]; then
    6 F- m' ~- C, @" Y9 k; I
  1283.     if [ -d "$GAMEPATH/dbc" ]; then
    , y" t8 o0 |) {
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \# w- A  u3 B8 p6 c: c* h
  1285.         --yesno "Do you want to generate them again?" 8 60
    0 H5 g6 h+ M0 i7 n, X

  1286. ) t0 P3 ^- E+ A3 `! L0 c# o
  1287.       # Check the user's answer
    8 Y5 P/ @+ K* u3 z' H9 b: ~
  1288.       if [ $? -eq 0 ]; then
    + f% [7 ]( W1 J, O$ L1 p! t. l
  1289.         Log "Deleting DBC and Maps previously generated." 1
    ! f: m- c8 p% M  e4 [) l! q1 i8 M
  1290.         rm -rf "$GAMEPATH/dbc"3 K, I5 H- z' ?# G" T
  1291.         rm -rf "$GAMEPATH/maps"3 B; {3 U7 f) t+ d

  1292. - {. S1 H% f7 W. H: \7 w* B! B
  1293.         Log "Copying DBC and Maps extractor" 0
      s% C) ~) j7 }) c
  1294.         rm -f "$GAMEPATH/map-extractor"
    0 G- B0 l* Y. b3 {" \! f; \- h
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    7 n4 ^6 G; R& J% p& l9 r
  1296. 0 p$ W3 g, ]- q! r3 E
  1297.         Log "Extracting DBC and Maps" 0+ d( C: \8 Y4 h) h8 z
  1298.         cd "$GAMEPATH"' J! r3 j' q4 w/ \5 v* ~+ t/ t
  1299.         ./map-extractor# @) e, H; Y$ |: ?- Z" A; s
  1300. 0 w4 Z$ j7 z7 B
  1301.         if [ $? -eq 0 ]; then9 g2 t. C6 P7 ]
  1302.           Log "DBC and Maps are extracted" 0
    : Q% S, m9 u7 Y% @
  1303.           Log "Copying DBC and Maps files to installation directory" 0
    / ^" Z  ]) o  [: I8 z( k7 u8 F
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    , Q; }6 \# \: G+ z' W2 q$ b
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"; e3 l0 |; P) ~, @4 n" q- N; P, b" C3 {
  1306.           rm -rf "$GAMEPATH/map-extractor"
    2 U. n3 ]* I5 g! n: O$ R  ^
  1307.           Log "Changing ownership of the extracted directories"
    " J/ I; b7 \- t* l8 s
  1308.           chown -R $USER:$USER "$INSTPATH"( B3 {- \6 X, ~8 a
  1309.         else
    ' l  ^, T9 p0 X% S
  1310.           Log "There was an issue while extracting DBC and Maps!" 18 B! u3 O) W; s* G% C2 K) A
  1311.           rm -rf "$GAMEPATH/map-extractor"1 w6 [9 P: e! O: c2 |
  1312.           rm -rf "$GAMEPATH/dbc"5 H  j) W( A9 H  Y1 B
  1313.           rm -rf "$GAMEPATH/maps"* h/ }2 e3 n$ |$ b4 d
  1314.           exit 1/ W7 _! y; n# J) g$ Z3 o- y
  1315.         fi
    9 I' O4 K( y4 C$ r$ k0 q
  1316.       else
    1 ^: C5 q1 G! e& ]! \: D( l
  1317.         Log "Copying DBC and Maps files to installation directory" 02 T2 Q0 `9 A2 K0 z
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin": N8 s" i% R" v+ ?# c& d
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"% C9 p7 H6 F+ v+ W/ G
  1320.       fi& i# X2 X& R  t5 q& z3 V8 v
  1321.     else
    4 x0 k3 U: g3 F' d: y; S
  1322.     rm -rf "$GAMEPATH/map-extractor"! i( f4 ~" e7 M
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"6 p# A/ B$ _- D% t

  1324. " V$ f6 D: k. z# E
  1325.     Log "Extracting DBC and Maps" 0; R2 P' x  E& [9 P* P2 j! n3 r+ v
  1326.     cd "$GAMEPATH"
    ! I. n& R4 g- R) c! F  Q1 z* q& J
  1327.     ./map-extractor2 s$ N; l: ?. v7 G: F' X. _/ {

  1328.   I, i9 g% ^. ~! w
  1329.     if [ $? -eq 0 ]; then
    ( o" k" F$ y3 O! D( ?7 d* r+ P
  1330.       Log "DBC and Maps are extracted" 0
    4 B7 {( k# s$ g: u8 c3 R0 }9 ^$ C0 [5 q
  1331.       Log "Copying DBC and Maps files to installation directory" 0
    7 _) A- b# `: r: p  ?
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"+ z; o4 K, |& i5 R: u3 F7 e
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    * P* e, L& w- V8 e2 |; Q9 Z1 x
  1334.           rm -rf "$GAMEPATH/map-extractor"% x9 P% r/ b5 l' p5 t; e, r5 q
  1335.           Log "Changing ownership of the extracted directories"3 V  J4 c" g7 I0 h5 X4 Y
  1336.           chown -R $USER:$USER "$INSTPATH"( J4 v9 h$ o- h/ I( e4 A* U
  1337.         else6 G- ~' N, j/ I1 n& x
  1338.           Log "There was an issue while extracting DBC and Maps!" 1* @/ K8 k7 [% Q3 w. C% Y
  1339.           rm -rf "$GAMEPATH/map-extractor"! z+ p4 d, S- G. l, p* l% R1 l' j
  1340.           rm -rf "$GAMEPATH/dbc"
    ; w% _8 K# r0 b4 O/ M
  1341.           rm -rf "$GAMEPATH/maps"5 S6 i9 v. {2 I# |: R# A
  1342.           exit 1& k4 J, O! \+ \' {+ D* l
  1343.         fi: V) z8 z2 ^7 @4 a
  1344.     fi
    ( n8 A- p* q+ o" G3 }
  1345.   fi
    % n. ?! T+ b, w0 V, X8 N/ C+ x

  1346. ) s6 u- J9 x6 E7 l  M& A. z2 j
  1347.   if [[ $ACTIONS == *2* ]]; then5 G  u% I* ]0 }: U" r
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then
    & y9 p0 Y9 o5 n& L# U
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    + w: Z4 E4 H# {- t7 y8 N
  1350.         --yesno "Do you want to generate them again?" 8 60. J+ s' Q# v8 i, c5 X% ?* k

  1351. ; Y  o8 Q! u7 X& B9 W: n" S
  1352.       # Check the user's answer
    & J, S! }' O- f& r* x2 U7 g2 P
  1353.       if [ $? -eq 0 ]; then2 V) L' m# G" E
  1354.         Log "Deleting VMaps previously generated." 1% C- P5 O5 T  ]4 g3 U8 v5 L. _
  1355.         rm -rf $GAMEPATH/vmaps6 v+ S5 e( A* q! a3 L
  1356.         Log "Copying VMaps extractor" 0
    & k' R0 I/ U; {8 ?' r! w
  1357.         rm -f "$GAMEPATH/vmap-extractor"0 n! o' k) w, b
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    8 b- T2 k) U$ {7 f3 r+ [
  1359. / F: s( G! E9 a' Y; x8 K
  1360.         Log "Extracting VMaps" 0$ c  e8 `# D5 o0 B' O+ `
  1361.         cd $GAMEPATH
    & m7 g5 X  M/ n) C9 U# m+ R" W' z
  1362.         # Make sure there is no previous vmaps generation that cause issue.
    : v- Q" H& J- N" Q
  1363.         rm -rf Buildings, y/ o; Q) g2 H7 g& A
  1364.         ./vmap-extractor
    5 s/ G. n8 T% ?( `

  1365. " I4 V( Q7 C. o9 D, ?) {1 R! |! j4 c
  1366.         if [ $? -eq 0 ]; then3 ^' X( A/ j0 i
  1367.           Log "VMaps are extracted" 0" i" O$ J$ I% f' G
  1368.           Log "Copying VMaps files to installation directory" 02 f5 |; z+ N+ Q* C" w! @
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    0 ^6 Y* g: v3 @9 T% f2 f$ {
  1370.           rm -rf "$GAMEPATH/vmap-extractor"
    # X& G4 d* [& z7 r4 \: o3 D: j( H& I
  1371.           Log "Changing ownership of the extracted directories"$ A% y% P, J/ w* P8 ?  ]
  1372.           chown -R $USER:$USER "$INSTPATH"1 `5 _: `( P( l! l1 H3 i! t
  1373.         else
    6 T6 [+ g! K0 W* s
  1374.           Log "There was an issue while extracting VMaps!" 1
    / N1 G. a0 a; v: W& k
  1375.           rm -rf "$GAMEPATH/vmap-extractor"
    ' S% W. Z6 e; W1 g, F
  1376.           rm -rf "$GAMEPATH/vmaps"
    - Z# x" @) P6 ?' |' n% }* a
  1377.           exit 1
    ; I3 O0 R: j' {" u5 Z0 o; [0 z
  1378.         fi
    ( D2 q' n7 p2 F$ [3 }( k
  1379.       else* W& ]+ t; t4 G1 W4 s( X
  1380.         Log "Copying VMaps files to installation directory" 0
    2 e& N; X0 F2 D4 k3 a
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    & [( m" O  s3 l2 d4 f3 a
  1382.       fi- s4 B* T8 j5 {
  1383.     else
    " s1 ^$ \: L& W
  1384.      Log "Copying VMaps extractor" 0( Q# k: Z9 f5 I4 e# _! i
  1385.      rm -f "$GAMEPATH/vmap-extractor"
    ( K" ^) U$ b  j; H5 z; f; r
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"6 D! s- }( W7 s& a, [' _) {, D
  1387. 9 N( G9 S( H, Y" Z& z$ G, h! c
  1388.      Log "Extracting VMaps" 0
    ) n; N" y# E  F
  1389.      cd $GAMEPATH
    , N; D0 n" `2 G; ?
  1390.      # Make sure there is no previous vmaps generation that cause issue.0 H& d8 y: n: x% R2 T+ h5 L. ~
  1391.      rm -rf Buildings$ Y5 z& s5 I, `. s
  1392.      ./vmap-extractor& h3 n+ `' t2 ~

  1393. 6 A% m- V7 J/ ?: y# N4 \4 q" G
  1394.      if [ $? -eq 0 ]; then" N  p" Z2 L3 u2 L; c9 T8 c4 n
  1395.        Log "VMaps are extracted" 01 X& P' a/ _: w/ E
  1396.        Log "Copying VMaps files to installation directory" 0
      ]# K9 j0 [7 I( d
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    % ~( g7 t9 R: z' T7 G' W
  1398.        rm -rf "$GAMEPATH/vmap-extractor"
    " l$ G% H- g4 m( D  V, w' ]/ w
  1399.        Log "Changing ownership of the extracted directories"
    4 n8 Y& _+ Y7 d2 |2 g: G& ~
  1400.        chown -R $USER:$USER "$INSTPATH"* {, s* ~, o- T9 _5 a4 u! ^
  1401.      else' x" K8 z. Z+ W: ]9 E7 R
  1402.        Log "There was an issue while extracting VMaps!" 1" N( i9 `2 {  R  K. c
  1403.        rm -rf "$GAMEPATH/vmap-extractor"1 G0 {+ h& h  ]# Z$ p3 u1 x
  1404.        rm -rf "$GAMEPATH/vmaps"* K* `2 i* r& N" S4 E
  1405.        exit 1
    1 \% J( E* u9 |. M6 H0 L  `
  1406.      fi
    8 {4 i0 R0 R8 I+ k3 q
  1407.     fi
    4 L0 g% U( o; |- H# T% `7 X
  1408.   fi
    4 N' K; _; }, M" V; E
  1409. ! Y8 x' f3 X! z. V5 m
  1410.   if [[ $ACTIONS == *3* ]]; then
    2 Q7 R' S4 i" G" F, u  m5 {
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then7 x7 L9 V9 A$ [) [0 |- M
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 16 L. o8 K- ~2 K( p- j% N
  1413.       exit 1/ L( x1 y8 c, z8 i
  1414.     fi* ]% A# z+ A* C/ F* E6 k4 n; }$ S3 K
  1415. 8 A$ K( b) z! G- Y; m2 M
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then' ~) ~/ u8 D% O2 d
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    8 B: K. J2 l. E! J' [4 ^
  1418.         --yesno "Do you want to generate them again?" 8 60; `( e! c4 c+ l% i

  1419. # ~' q( D; u+ `* l, u
  1420.       # Check the user's answer
    $ |* x9 G) H; A: C
  1421.       if [ $? -eq 0 ]; then
    7 q* u; r% |* j/ s9 b: x. m
  1422.         Log "Deleting MMaps previously generated." 1* {( m# a7 K1 W7 S" U5 F  z9 c
  1423.         rm -rf $GAMEPATH/mmaps9 J8 q2 _0 J6 D0 t& F
  1424.   H8 f' l$ _! h
  1425.         Log "Copying MMaps extractor" 0/ G5 w8 i$ q+ U/ n4 k3 r/ u( O3 z" F
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"( g- E! k3 R5 J, M$ h. f  E3 E
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    ) g# E, s' s( {( \7 q
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"
    ! _& B/ D) g* x+ A2 Z) P$ f- p
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    $ t0 r' U- a2 n7 {9 s
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    / H2 m3 M  V1 C& ~' P5 V5 N: {
  1431. + f! G0 ]" P' e0 i$ b- K5 i
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \+ O' [+ f$ z& J: v6 M# p
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    7 U* z* w7 r! [  X( O
  1434. : u* e0 i: g- i% S! i! t' \- s
  1435.         # User cancelled his choice, set default to 1.
    % e: x0 y) d1 ?5 U3 x4 \; E! R( d
  1436.         if [ $? -ne 0 ]; then3 p. Q1 o5 u" k8 |/ S' C
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1( L$ C2 D9 f' w* m
  1438.           CPU=1. S6 ~6 P( S4 P) [* ~$ l
  1439.         fi
    / ?( n# i5 _8 E9 o6 Y. l
  1440. : B. }$ _. q: _0 M; k0 a
  1441.         if [ -z "$CPU" ]; then
    0 f6 Z( o3 H) w
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1
    ! V0 J) G, t% |( A8 o; B/ h" P& P
  1443.           CPU=13 u+ c1 b; `2 `6 i
  1444.         fi
    + k1 ~  t, `- o. J7 k9 G- V) D

  1445. ! y% q2 [* ?+ ]
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then$ K  w9 H) {4 S- S% w7 |1 E
  1447.           Log "User entered invalid value. Max CPU set to 1." 1) d, k) S! x( ~% s1 m
  1448.           CPU=17 p; |- u, K" c* e% Z$ K
  1449.         fi3 Y4 H* p; ?5 O+ p7 H
  1450. 7 B4 k# u5 c' \2 X. c" v0 X% w$ z
  1451.         Log "Extracting MMaps" 0
    " r% R  \  ~/ q( K
  1452.         cd $GAMEPATH
    8 R  ^' ]6 T7 y9 p
  1453.         # Making sure we can execute the script
    7 `. P5 A  G* X* s  [
  1454.         chmod 700 MoveMapGen.sh* w& U" h& M) S; F
  1455.         ./MoveMapGen.sh $CPU
    4 `- U  j3 J/ K/ j1 o7 i8 x  L

  1456. 0 j# f: x% s+ K# Q3 N1 ]6 k
  1457.         if [ $? -eq 0 ]; then6 m  y& Y$ q! A3 Z2 s# v( l
  1458.           Log "MMaps are extracted" 0
    7 b) S  M- B- Z$ Q( v
  1459.           Log "Copying MMaps files to installation directory" 0
    9 k  S  E7 K7 z
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"  a7 w; b2 g# }1 }/ m! X
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"8 p- i" g, \$ z+ n
  1462.           rm -rf "$GAMEPATH/offmesh.txt"8 [1 f. E) E) z" l" Z" {
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"' G+ e4 ?1 S4 _5 }+ z3 w
  1464.           rm -rf "$GAMEPATH/mmap-extractor"* h0 i: W7 w1 L9 {; Z
  1465.           Log "Changing ownership of the extracted directories"" p. E4 N. W1 ^, E  r
  1466.           chown -R $USER:$USER "$INSTPATH"
    : F: T! Q/ z9 [8 b, l- W9 ~
  1467.         else+ D3 J" e* d: ?- @! {  [/ g% [
  1468.           Log "There was an issue while extracting MMaps!" 1
    0 x7 Y% s% h3 S; I  `- g) z! c4 o: U, t) N
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    & S9 c) K( Y/ Q6 N& d8 @$ L
  1470.           rm -rf "$GAMEPATH/mmaps"- C' }; r$ y' }* @4 d
  1471.           rm -rf "$GAMEPATH/offmesh.txt"
    ! [4 h& l2 @& S: e9 s6 W
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ' Q& p4 x1 ]; t) D6 N2 L
  1473.           rm -rf "$GAMEPATH/mmap-extractor"/ J' p- Q& g( h+ w
  1474.           exit 1
    6 f; w% g, t# [0 M* ~& P3 z
  1475.         fi
    * J& k0 w8 e3 w# X$ a4 p
  1476.       else- D4 O: e2 J" A0 a1 y1 I% `
  1477.         Log "Copying MMaps files to installation directory" 0
    , q# Z# }+ l, C3 b* `7 f% m
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"6 W: }; O$ g; R7 _* b8 F6 x
  1479.       fi% C- o, \% H7 `. f0 \
  1480.     else/ J. q) i5 i1 u$ X
  1481.     Log "Copying MMaps extractor" 0
    0 E% x  N) W4 T2 F; M& i, F
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"
    8 J: U/ j- X# c* L. ~. M
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    + {* u2 ~$ u5 |4 y* L  g% d
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"0 y3 S2 ^0 `4 g* k& w
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    1 \) g- @: b1 V# q3 r
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"; X: Y, u/ y: W( O0 c4 [
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    ! J7 [1 N8 J% \- M5 ~
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)2 l/ |/ P. W* v6 w! }  L3 o
  1489. 7 U6 L* n9 w) ?& A/ d
  1490.         # User cancelled his choice, set default to 1.
      C2 W; @% C5 O. ~/ Q" U
  1491.         if [ $? -ne 0 ]; then
    . c: i7 N3 v) J& e4 {8 i* V
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1
    $ o4 F8 b7 F8 V2 H# `* r
  1493.           CPU=1
    " ~9 y  }; u' O& c- {( o. Q$ \
  1494.         fi0 o; W1 N2 e, ~7 u+ s2 S
  1495. ' {- I9 I' Z' u
  1496.         if [ -z "$CPU" ]; then
    ) ^1 b1 N' N+ Z6 x3 e
  1497.           Log "User didn't gave any value. Max CPU set to 1." 1, q* U) W0 r$ x
  1498.           CPU=1
    ) X2 T$ ^9 w- w9 V* k
  1499.         fi; g1 y/ P$ |- l& C- U( c/ b8 l% u: t
  1500. 9 F3 U0 ]% X& q% y# L0 S
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    5 ~0 X1 {. ~& E9 ~: N! X- u+ B) E
  1502.           Log "User entered invalid value. Max CPU set to 1." 16 \) ^$ J2 [% E" A4 |, P( l# R! R0 t
  1503.           CPU=1
    ; i- S, h; P5 Y6 A2 E2 d
  1504.         fi
    ; i3 W' D" K# u/ K# ?8 J, \4 A
  1505. * o) s1 v9 W! O2 p! f; L
  1506.         Log "Extracting MMaps" 0( k) Q% O; r) I* v# e" G
  1507.         cd $GAMEPATH
    ' U9 \! [, Q; i
  1508.         # Making sure we can execute the script7 i* t- i& C/ r8 F( L% {+ X. V2 `, I
  1509.         chmod 700 MoveMapGen.sh
    ) w& C; Z% f- r% f( m7 {
  1510.         ./MoveMapGen.sh $CPU
    . J* J6 \. K' S0 Q
  1511. 7 o# q7 x  N, U
  1512.         if [ $? -eq 0 ]; then3 n: K) c8 m% s- m! e
  1513.           Log "MMaps are extracted" 0
    ( T5 G$ D1 s3 D) u, T2 d) l2 \
  1514.           Log "Copying MMaps files to installation directory" 0
    3 x! W2 z. D( f! K7 R; B% h
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"* f! V% a+ W7 J; j5 [
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"+ T& B) Y, O- s/ u% e
  1517.           rm -rf "$GAMEPATH/offmesh.txt"
    3 l/ {7 |) V3 t5 _" {, [/ V; _
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ) {+ W7 n, c  h# b( q  j
  1519.           rm -rf "$GAMEPATH/mmap-extractor"/ B2 z( w4 k! c1 g' I3 t) U
  1520.           Log "Changing ownership of the extracted directories"
    3 m; F( Q! C# h/ Y8 E
  1521.           chown -R $USER:$USER "$INSTPATH"/ m. C) \' L7 r( d5 ^& m
  1522.         else0 D+ C$ d, O& z# M8 g) K
  1523.       Log "There was an issue while extracting MMaps!" 1
    ; R- X! T. H* \
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ) t6 `# a( c; s
  1525.           rm -rf "$GAMEPATH/mmaps"4 r0 b3 S5 G% [' L
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    * k" }7 {5 q. v  P' G8 m( u9 d
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    + U6 |, b3 w2 x- \
  1528.           rm -rf "$GAMEPATH/mmap-extractor"8 ^6 n* `7 A* Z" e5 @/ @6 Z1 ]6 I. N
  1529.           exit 1% b2 W5 V) L$ F- i7 k
  1530.         fi4 W7 Z' \+ n( R9 \, j/ u& }) o- Y) u
  1531.     fi% L$ v3 S3 t4 h: t( m
  1532.   fi' \! [% \* S) r- x! e
  1533. }3 I. }% ~! t- f3 l0 G

  1534. 1 F; P0 C" D8 b0 V# V% b( E
  1535. # Function to create a Code::Blocks project% H) \3 C% Z! j- Z8 ~
  1536. function CreateCBProject+ q8 R1 r6 E4 ^1 |% u; b
  1537. {
    1 {$ D* j$ f6 D
  1538.   # Create the dircetory if it does not exist* {) ~- f. Q5 v0 l4 `$ n# I7 [
  1539.   if [ ! -d $SRCPATH/server/linux ]; then* _- Q7 h3 ~  e! w: m# Z
  1540.     mkdir $SRCPATH/server/linux
    ' n' ^) f$ W% `7 @" b5 ^" L$ L+ y
  1541.   fi
    ; x! t& b: ^, ]7 M
  1542. 1 d; c3 b- }* e, x# Z
  1543.   # Now create the C::B project
    7 m; \, N) Q. y% M% F' _
  1544.   cd $SRCPATH/server/linux
    $ `4 W; G2 c/ X+ E: d! u* {5 A( ^
  1545.   # make sure we are using the cmake3
    $ _/ d# e$ W) [6 v$ g& V$ @  X8 C! a
  1546.   UseCmake3
    7 W8 I7 e4 d' e8 J
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    / e2 _$ c3 J. _. I  D% k. m
  1548. }+ I/ L* f& I1 k- u$ Y+ v) r4 O
  1549. # o" ?+ s: w* K% }  s" s
  1550. 4 K& ]2 W, S: w& H
  1551. 9 w% b2 `% D, [5 H' X
  1552. # Prepare the log
    , F, ?. p$ U% e3 D8 _
  1553. Log "+------------------------------------------------------------------------------+" 0. v, x8 K  k7 u- n
  1554. Log "| MaNGOS Configuration Script                                                  |" 0
    - Z# W+ Y. ^6 o; }  Q
  1555. Log "| Written By: Ryan Ashley                                                      |" 0) F% ?/ [: C* ~- I$ U; B
  1556. Log "| Updated By: Cedric Servais                                                   |" 0
    + m" V8 @# \9 H
  1557. Log "+------------------------------------------------------------------------------+" 0
    3 d) b" x9 T3 F' J

  1558. ' {5 u2 F+ i/ N' w- [* J6 O
  1559. # Check if user who is running this is root3 [0 N$ F5 w: N( c0 o
  1560. CheckRoot$ c0 n' E- r- V  Z$ ?) Z% ^9 A( y

  1561. ; c$ o& m4 a9 ^4 F
  1562. # Select which dialog to use
    $ A2 N7 y3 D- M9 c6 L- r
  1563. UseDialog: ^3 ~/ |! j* @7 v

  1564. " s, U8 k3 r+ z' _8 G/ [, O1 G, @
  1565. # Select which activities to do( m( B* |/ P5 U( q, H
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \4 G  X) v& m1 `1 C" m
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \
    # D0 t! |$ j3 u1 L/ m: s$ X! M& Z
  1568.   1 "Install Prerequisites" On \- s; U' v* ]9 s8 m, c4 [0 X
  1569.   2 "Set Download And Install Paths" On \
      \0 `/ y7 @1 ?- y7 h9 g
  1570.   3 "Clone Source Repositories" On \9 d4 P7 p7 T& H( H, U" @
  1571.   4 "Build MaNGOS" On \2 h" Q4 B' }+ S/ M8 `6 G3 }$ ]
  1572.   5 "Install MaNGOS" On \
    ; M6 H( q# |" P3 s$ X# c" c
  1573.   6 "Install Databases" On \
    2 p, Q2 O6 b8 o$ V! \! [
  1574.   7 "Extract Resources" On \  M/ w2 W* q6 F) w3 p
  1575.   8 "Create Code::Blocks Project File" Off \9 P( I9 x2 q4 m4 ?  c) z& H5 k
  1576.   3>&2 2>&1 1>&3)
    ) Y# R- @+ s6 g& U. O1 v
  1577. : [9 J! O5 l; Q, F* h% ~4 r
  1578. # Verify that the options were selected. _: H, d- `' G' ]9 S
  1579. if [ $? -ne 0 ]; then
    3 |$ d) w1 @, x5 c3 L) i& U. Z
  1580.   Log "All operations cancelled. Exiting." 1
    5 T0 ?( M. o( {7 O+ X; }
  1581.   exit 04 n: ^5 H! {( u- I
  1582. fi. E0 J) o) A5 i1 @3 L; X

  1583. / |& A  x- c1 \: g5 u
  1584. # Install prerequisites?7 t8 m6 ]/ Z' C% [" O7 m3 c
  1585. if [[ $TASKS == *1* ]]; then! N6 D8 D9 \8 j% Y
  1586.   GetPrerequisites* P5 |3 G" {. A  Q& z: Y9 |
  1587. fi! G  |, q2 [/ i; r, _

  1588. 2 q8 V5 b' Y" X
  1589. # Select release and set paths?2 C  L( e; B* E8 k
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then% }/ o5 p0 g# x: q" m% j
  1591.   GetUser7 B) g8 K2 {' s3 ]
  1592.   GetRelease
    " Z1 a1 o$ E6 ?3 B6 L
  1593. fi3 B: p7 O/ d. M* D7 b

  1594. 4 T# X% a, z; A
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then/ Y, T% P9 [! t1 v, w9 q0 M
  1596.   GetPaths
    . ]! z! q1 l- l$ J2 a
  1597. fi, Q. r0 Q2 j8 ~8 C/ E6 S/ z, T( o

  1598. ! c6 y) q8 F: O$ Z% ]
  1599. # Clone repos?
    " D! a% x) U3 \/ ~+ T0 E1 @
  1600. if [[ $TASKS == *3* ]]; then
    4 H/ R5 f$ b) l" {
  1601.   GetMangos: L' z7 h1 M$ ~$ D. p( s0 e
  1602. fi/ J9 S7 q  n! L! \8 i1 T. }6 [0 e
  1603. + d/ Z; N' N) H
  1604. # Build MaNGOS?0 N8 U( {! d9 b# f; m
  1605. if [[ $TASKS == *4* ]]; then
    ) v3 z+ L5 x9 V3 Z# n
  1606.   GetBuildOptions
    2 Q" K. Y; ~* n( a, o+ l1 Z
  1607.   BuildMaNGOS0 M2 X( @5 e% U
  1608. fi& M, G6 t5 A/ J8 S1 I$ y0 |% r; b

  1609. " Q7 j7 p! D% p6 H/ t2 v8 C
  1610. # Install MaNGOS?
    6 p; E$ E2 ^2 s6 r
  1611. if [[ $TASKS == *5* ]]; then8 _7 f  x* v% R
  1612.   InstallMaNGOS# i- @. B( q! \
  1613. fi7 a) R) ]3 Y* Q# a/ F; M  [% p

  1614. ' u5 v7 \5 |% F2 b7 M6 |
  1615. # Install databases?
    2 [/ q$ ?/ ]' O" ]( a
  1616. if [[ $TASKS == *6* ]]; then
    $ m& w! S0 Q) _/ S$ k3 B# _
  1617.   HandleDatabases
    / ~0 z* R) o) \* v* K2 v
  1618. fi
    ( U9 L; b" h% s0 O6 u) H/ S

  1619. % B* B: p/ e' u4 u, [. X
  1620. # Extract resources from the game?0 u8 v. q/ P/ J, Z! i  j7 s
  1621. if [[ $TASKS == *7* ]]; then. p8 l7 R2 U/ Y+ L) \% ^; b. T
  1622.   ExtractResources' G7 H  }  @/ d# D
  1623. fi
    8 ], ?7 D& y4 A1 O" r
  1624. + |  B( d* C9 S& C  e( X* {
  1625. # Create C::B project?
    ! b) v6 X# W1 e& D( x
  1626. if [[ $TASKS == *8* ]]; then
    - S# j$ R' N3 c4 c  f
  1627.   CreateCBProject
    0 Q. D% e$ i6 N% [& W- E( V
  1628. fi- k/ F# g7 k. e1 C$ a' Y9 l3 f$ r1 u

  1629. 8 m9 ]* }$ [/ m5 n3 ?
  1630. # If one of these actions has been performed, then we know the user.
    % _5 ~" Y: |+ ]2 K; x/ C
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    5 r+ Q8 S: L4 T% p
  1632.   Log "Changing ownership of the extracted directories" 11 R, m" p# f6 ]$ T' T
  1633.   chown -R $USER:$USER "$INSTPATH"
    $ s. ~( O  k9 h: R2 M
  1634. fi
    . u  |/ E: Y  Z# F
  1635. 9 S' r9 n6 M( o& b2 u/ A( P
  1636. # Display the end message8 \4 z% s6 v3 h6 S, F$ c' ~
  1637. echo
    7 D9 k8 X0 Z2 |& {6 q/ D7 c. `
  1638. echo "================================================================================"3 h) ?( s) T% }" z% E  `
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"
    . S" X# O0 T% {3 P7 Y# T: k
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"1 L, a. p: x4 Z4 Z' C1 j$ s
  1641. echo "server. If you have not configured your databases yet, please do so before"
    4 V! P( X9 M2 s' P) E4 }
  1642. echo "starting your server for the first time."; Q* [% [  e0 ~1 A+ Q
  1643. echo "================================================================================"9 G7 I# K) R% }3 m4 v" c+ `
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh
    * b, Y- p, C& e) K
  2. ##############################################################################/ K# @6 h/ K* V  a+ t) `" D
  3. # This utility assist you in setting up your mangos database.                #) O7 T; O# Z  Y/ v
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #" O8 u# z5 g' `7 F$ G6 ~: t
  5. #                                                                            #0 g7 ?4 |! Y# ?0 o
  6. ##############################################################################
    * z, e- R, y4 g3 K. ~* _+ T

  7. 8 G$ Q+ k1 }8 ~  ?  U! o! J7 i
  8. OLDRELEASE="Rel21"* {( `) v# n3 @! L4 q  ]( L& t6 H
  9. RELEASE="Rel22"
    9 ?3 b  ~# t* j% Z* x) u
  10. DUMP="NO": m( t: v" Y6 z2 V$ l* W5 C
  11. $ X  H" @2 F$ P: Y+ {
  12. dbname=""
    $ i, X8 \2 P9 u
  13. dbcommand=""
    8 F% q! s; E3 b% Y0 P
  14. 5 A' T, K- I9 x
  15. createcharDB="YES"3 `. w& u# ^9 X2 J# {
  16. createworldDB="YES"& n/ k* ^9 s' o
  17. createrealmDB="YES"6 \4 c3 E7 V1 p. x

  18. ( P  ?' ]5 l1 t2 l4 ]3 F
  19. loadcharDB="YES"
    3 J7 t1 C$ |9 r/ ], G* n) f
  20. loadworldDB="YES"
    0 b2 m+ |: Z$ l1 h
  21. loadrealmDB="YES"1 H8 v0 U. c8 [+ J9 E
  22. dbType="POPULATED"* X) t& T4 z7 d
  23. 0 l8 l& \- T* Q5 v
  24. updatecharDB="YES"# F# a+ E# i' J: u
  25. updateworldDB="YES"
      ^# Q& l$ O! M
  26. updaterealmDB="YES"
    9 D. w, C8 s0 K% ?) }* v) \) w4 H( R% `
  27. 8 A* J  H/ \/ J: v# u# [
  28. addRealmList="YES"$ Z3 u( G0 H! d. o4 u

  29. 7 p9 |9 p0 D* B) P/ ]  ~7 }
  30. svr_def="localhost"7 M3 w3 i8 N9 P9 ~' \
  31. user_def="mangos"* f1 i* J/ J) Q5 q' n- z5 a3 e% }
  32. pass_def="mangos"
    $ S0 U' H# K9 P
  33. port_def="3306"7 g: E6 K% {' x8 f( J; n0 l
  34. wdb_def="mangos2"
    * @' i# C, _6 G  w! Q6 `* N
  35. cdb_def="character2"8 H, k; i- z# c" A( ~/ j, M! m
  36. rdb_def="realmd") g* l  i1 H% r
  37. 5 d4 U, t: k" y, i" J7 f
  38. printHelp(): Y3 R4 n- N5 J% I: ?$ H% X
  39. {
    % c; J# Y2 z3 G0 K
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"
    " T: ?% z, j/ P' L
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"; {7 a3 o5 P. ~: |
  42.         printf "\t-u: Run only the updates of the database\n"6 R/ |% p9 s& i7 |2 m
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"
    1 J9 X: n# W, @9 {# }' W5 k
  44.         printf "\t-h: Display this help\n"! i* Z: n! P2 q, Q1 U  L
  45. }. h4 B) \2 R. O
  46. 4 q8 E" j2 @, ?3 }" z
  47. printBanner()
    % y% _: h1 a! j4 g
  48. {
    ) k. X1 V0 t( J+ A
  49.         clear
    . a7 j; w! [* L) [: l" x1 Q) h9 Z
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"! [4 d+ B$ V# P# l9 h! n% M9 `! k1 J
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"& m5 R+ ~1 f: C, K3 _. T: N
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"
    4 a% p8 |, N1 g5 k) O! L
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n": z/ N2 T* Y3 n& w% G
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"
    0 {5 N: ~, ]" V& C( X
  55.         printf "\n"$ ^' p' U9 D+ i8 l- o1 D! k
  56.         printf " Database Setup and World Loader v0.03         \n"
    8 }* j6 J* J" W
  57.         printf " ---------------------------------------------- \n"
    6 E! m8 P- d; ~& ?9 N! U9 h, ?
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"
    0 @- h& ~4 ^- K2 e8 D
  59.         printf " ---------------------------------------------- \n"
    " t. B3 y* ~; S) E$ V  Q
  60.         printf "\n"
    . h: w! M, \) G& ^' ?: ?4 ^
  61.         printf "\n"
    9 N& h+ t$ T9 R& d' }) i  @( F
  62. }# A, [% A& n" W

  63. ) q3 k" K8 T9 ~* L
  64. printActivities()+ h; o2 k% J) J% a5 d4 k5 r3 j
  65. {
    1 r! V; ^/ M# {: o5 R
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"! O# D( q. }6 w+ P1 L1 G* l/ C. ~+ Z# \
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n"
    ! B6 b) P5 H0 S
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"$ c! g2 y1 m; {4 E7 G% k
  69.         printf "\n") p0 ~7 z- D6 [: ^
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"% u2 B* P% X5 v! L5 i4 O$ E& ?: V$ P
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"       
    ; g8 R' ~3 c8 j9 e; o: |  K. Z
  72.         if [ "${loadworldDB}" = "YES" ]; then4 z' `0 ^$ z# L  H  p  ?6 a
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"
    - y" |% `+ y( F" M" D, t
  74.         fi( F3 }- J# d5 q+ \
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"
    6 G7 s* e! q+ m  O3 i$ d
  76.         printf "\n"
    $ W3 Y- G, l) Q# P4 {" e8 Q7 c
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"
    % r: N6 {* g/ {$ S( k8 a
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"7 k) [' J1 Q+ j
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"
    # O; P, F! }" [" B
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"        ( H% {& @4 _) o5 ~; z. _- T: B% u
  81.         printf "\n"
    & ?, o& V2 N+ `7 G$ e
  82.         printf "\t\t\t\tN - Next Step\n"
    4 F$ @( C  F4 F' I* a+ r
  83.         printf "\t\t\t\tX - Exit\n"
    3 U% U6 N* r7 s
  84. }/ H1 G# n. j- U! y* p- v& _7 c
  85. 5 i! m$ n2 W, J7 h, [
  86. determineDBName()! P% @5 i" r( F& F0 g# z, m
  87. {
    4 K# Y% k  P" G# a! e& {$ u
  88.         if [ $(which mariadb) ]; then
    " p1 ~- Y  Y0 ^- [9 C
  89.                 printf "MariaDB found.\n"
    : k0 o6 O8 z9 O; U" p
  90.                 dbname="MariaDB"
    2 K6 D2 Z% P2 h/ K* S
  91.         elif [ $(which mysql) ]; then
    9 y, x5 Y/ G4 e! O9 k
  92.                 printf "MySQL found.\n") J, m1 U' o( n. y: ~7 \# F
  93.                 dbname="MySQL"( ^% D" e& Z5 ~$ u1 i( u% x
  94.         else
    ' `, J* P5 m; J7 z/ d
  95.                 printf "Did not find mariadb or mysql.\n"" H5 C- f! U1 T( n6 R, e+ Y, k+ R
  96.         fi
    6 i! X7 p- x( U
  97. }
    % b& f7 I: O% G* N( _8 X1 d& p
  98. . j: k7 _# O* t  @& m# j- g: F
  99. mysqlconfigeditor()6 g* ]6 v( J9 b
  100. {
    ( }: w: d& y0 R" ^8 v
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"1 A8 B& P, f& c& {4 i7 @6 D
  102. }
    , q6 U4 @9 Y  j: ?
  103. 7 Z5 A* j! k5 k1 x' ^" w
  104. determineDBCommand()
    , D. x# k9 w3 `* t
  105. {- X8 `0 H/ a% Q. C; P0 J0 }2 K
  106.         if [ $dbname = "MariaDB" ]; then' I4 A; \$ p# q, q; d% e
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"
    , K+ p& R  c# T' ?0 M. E
  108.         elif [ $dbname = "MySQL" ]; then, o8 z; j- g9 p6 Q4 H3 l
  109.                 dbcommand="mysql --login-path=local -q -s"
    6 x9 ^8 d8 h# i. h
  110.         else2 `) @, n9 f' m
  111.                 printf "Did not find mariadb or mysql.\n"
    ; t3 }$ D9 ^8 e4 E+ t9 p# X
  112.         fi
    3 q( }1 ~( |  y" Q2 K
  113. }
    - D! F  T0 w% y* ]3 R
  114. 7 L- R4 A4 X. d- O0 |6 l
  115. createCharDB()0 |5 J9 F# t/ n* v6 u2 K! p
  116. {
    - t+ }+ ]- C. k! @
  117.         printf "Creating Character database ${cdb}\n") Z  P; ~- L+ U+ ?; s& H. U
  118.         $(${dbcommand} -e "Create database ${cdb}")
    ) F8 b- j0 M2 F/ |+ @
  119. / B; m$ C& M8 @' S0 I5 V
  120.         if [ "${loadcharDB}" = "YES" ]; then
    1 R1 D* _3 g5 v
  121.                 loadCharDB
    * I7 D6 [' O. D5 N& j3 `1 r
  122.         fi: Z) `: J: l- [( U- X0 ^5 Q
  123. }# X/ K: ^# G* m7 k8 q4 m

  124. 5 n3 v/ j6 S6 n4 g7 J/ d
  125. loadCharDB()
    # f3 O1 D! |, }9 i
  126. {
    + h3 T7 T0 y; W! `  c& |
  127.         printf "Loading data into character database ${cdb}\n"1 I% w$ k, [3 v7 P3 b
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)# @: q5 t9 O& K- m2 }! \

  129.   o( r0 t  e7 p0 t+ T7 {- g0 l2 ^
  130.         if [ "${updatecharDB}" = "YES" ]; then9 t" ]* n/ v. P# F
  131.                 updateCharDB
    ! ]2 O+ e- D, m+ d" c
  132.         fi* C6 w* ^- H9 k
  133. }+ Q) ^+ C% T' |  i' b
  134. 3 f+ E0 K/ }, R$ f
  135. updateCharDB()
    3 I7 e( }. \" m2 X' S- s
  136. {
      v( c% \8 A* l
  137.         printf "Updating data into the character database ${cdb}\n"- X: [* `$ e* H6 L" `$ I
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    2 G0 J# L7 ~! c! S/ X2 A2 r2 P: |2 j6 X
  139.         do
    % s1 J( A, V7 O! _, ?9 ?
  140.                 file=$(echo ${file} | tr '|' ' '), f7 e  m* `: U9 @9 x9 T
  141.                 printf "Applying update ${file}\n"+ Q, ?, h7 B6 g; b: N4 Y, ]
  142.                 ${dbcommand} "${cdb}" < "${file}"& B$ A+ q* u2 V" ~. K- F$ i3 V
  143.                 printf "File ${file} imported\n"2 f: X( a6 U6 [
  144.         done2 }8 S5 d4 M+ c9 K+ b( q; M: h
  145. # H' J8 M: |) Q+ X& P- V
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')$ {+ }) e; S  B- p8 C$ D% E! H
  147.         do- C4 y/ F) N* Q' |& q2 Z
  148.                 file=$(echo ${file} | tr '|' ' ')) C( j1 R) Z& n6 v6 C  q
  149.                 printf "Applying update ${file}\n"0 S" P( `  K" x* H
  150.                 ${dbcommand} "${cdb}" < "${file}"
    + w. A2 k& |+ h$ j( m# _
  151.                 printf "File ${file} imported\n"/ |7 Z9 T" J7 s+ x( F  F: [. |
  152.         done& \8 S0 d) ]; E$ o7 I8 O  ]8 R2 j/ c8 A
  153. }
    ! @- c: S& F+ Z2 A  M

  154. 8 p* t# C% t) g( m" s
  155. createWorldDB()
    1 Y$ f# Z  x0 L
  156. {
    0 {4 |$ S3 C+ _6 x& z- _
  157.         printf "Creating World database ${wdb}\n"
    3 U7 W% ?! `& h8 f8 E
  158.         $(${dbcommand} -e "Create database ${wdb}")
    " h( E3 u) V8 M/ U& y
  159. ' }- N+ L6 Z2 D9 m3 T( e6 d
  160.         if [ "${loadworldDB}" = "YES" ]; then  s8 @( m2 P, K9 H7 V0 J
  161.                 loadWorldDB
    " A/ H, r  P" ]8 d9 o
  162.         fi: J$ S( U/ B8 p8 p
  163. }
    - E, W$ V! a  ?

  164. ' I. o+ [+ Y; j  {6 U% M1 h
  165. loadWorldDB()
    : i! v2 [" A2 `) B" t% [
  166. {0 B+ F* U1 p: j, v, s) y2 i/ [
  167.         printf "Loading data into world database ${wdb}\n"6 v0 \( U) C# J: k- m
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)
    ' O2 z3 i9 M  ?# U. y/ x

  169. " S/ t5 d9 s  L; N" `! g
  170.         if [ "${dbType}" = "POPULATED" ]; then+ l& y. a2 w: }9 L
  171.                 populateWorldDB
    * x8 e1 S  x" z) x% ^! `& V+ K
  172.         fi6 z. m0 k& O/ ]& ^/ @3 ]
  173. }
    7 P2 D( B* L2 T( c
  174. 9 O! J9 x1 f; a
  175. populateWorldDB()$ \: N3 A$ R2 ]' i" }
  176. {
    5 m& u# U6 Y, [( [) N- e' ^8 h
  177.         printf "Importing World database ${wdb}\n", J3 T2 A/ T( T* L, h
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ') . Z# f1 ?8 h7 @1 W) k% P/ \/ F: ]
  179.         do9 i" g" x' D% O# P
  180.                 file=$(echo ${file} | tr '|' ' ')6 J  C2 f" i! m& [5 ]. l
  181.                 printf "Importing file ${file}\n"' h# s# G( O% F, Y  k7 \7 ^
  182.                 $(${dbcommand} ${wdb} < ${file})3 f7 p" Y; b; }
  183.                 printf "File ${file} imported\n"7 _1 G1 g# S  Y0 e+ Z
  184.         done+ ~8 y1 C- }% l. s3 Q8 x8 ^  G

  185. $ A7 n5 S( z6 ~$ e  g) `* B- }* _8 L, T
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ') ( j" _+ ^4 m  v
  187.         do
    9 k4 p# f( J+ Z$ i8 d* ]
  188.                 file=$(echo ${file} | tr '|' ' ')
    : }3 [6 @4 D- @7 Y3 I; u' t
  189.                 printf "Importing file ${file}\n"
    7 Q; X5 [$ J+ p6 W/ X+ o
  190.                 $(${dbcommand} ${wdb} < ${file})4 x" x" R: m3 z8 }; r- }0 m
  191.                 printf "File ${file} imported\n"
    ! \. U' Q# A0 B# i
  192.         done
    ! ~$ l+ G9 B& w
  193. }% b$ v6 j3 \, Z$ \

  194. + o, `8 a' \$ b1 b6 s& j
  195. updateWorldDB()
    7 D  z' e1 g& W
  196. {' k+ o- H3 c8 j( I; e
  197.     printf "Updating data into the World database ${wdb}\n"
    6 q# A+ @& z. Z" H' i
  198.     for file in World/Updates/${OLDRELEASE}/*.sql" n( w2 @/ r% E: f
  199.     do
    8 A2 H+ s3 V8 `  e
  200.         printf "Applying update ${file}\n"5 K/ k6 R% A6 ?) q+ y4 i
  201.         ${dbcommand} "${wdb}" < "${file}"
    / m- y2 o+ Z' e
  202.         printf "File ${file} imported\n"
    : \  b2 E5 H; k( l* o7 |
  203.     done
    4 l% q- A$ c& W0 q' T' |1 @4 D7 M
  204. / [# h5 F& V" ?7 ]+ T
  205.     for file in World/Updates/${RELEASE}/*.sql9 Q' S( T. n) V* [. B8 p1 m* j
  206.     do$ V* S* r( S/ p) D+ m8 h
  207.         printf "Applying update ${file}\n". `! n9 d4 a/ K- B" x; ~8 w4 R3 W
  208.         ${dbcommand} "${wdb}" < "${file}"
    , G0 W. N& R  I5 g6 I! k! E
  209.         printf "File ${file} imported\n"; T9 r- {6 E+ t# ~
  210.     done
    ) p& ]6 F& E. ?7 v( ^2 {
  211. }: ]; A1 k1 V7 ?; H

  212. - e+ @9 y; t4 y/ o4 z: z6 E/ H% C
  213. createRealmDB()1 h8 V, r5 J4 P8 l
  214. {
    + ~) i: _" R5 T, }5 T  `' \
  215.         printf "Creating realm database ${rdb}\n"
    5 Z1 x8 h. H' W4 X! \6 s2 I, i
  216.         $(${dbcommand} -e "Create database ${rdb}")
    ; z, }5 I  P0 L- ^7 o9 \$ L

  217. * ^3 y  ?+ M. Q, x' H
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    % g0 d$ k7 {# ^0 j: n
  219.                 loadRealmDB
    8 R7 \5 M7 }3 G" S
  220.         fi
    5 j& t) D9 n, k! A& o6 u
  221. }' s; o% P% ?8 k# ]1 f! U+ s* l8 q; ^

  222. 8 B, a" |. Z7 z) f( W$ o
  223. loadRealmDB()
    ' S0 r" ~5 q2 D) j' r' x
  224. {5 z1 y( r9 S: X, L1 t4 u
  225.         printf "Loading data into realm database ${rdb}\n"        ) H) G/ i/ d/ H$ K
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)9 I0 D' j" i2 v- h$ ?, M# [
  227. }1 Z# e4 D) O2 e5 L8 Q5 z1 [  R" p( p

  228. 9 U& c! _  O+ X0 F
  229. updateRealmDB()# r" x# e/ p! C) H) Y8 o9 F
  230. {
    3 H" Q0 c" G2 |! d1 _
  231.         printf "Updating data into the Realm database ${rdb}\n"
    # Z: N. Z7 Z5 ]0 ~/ Y% O
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')$ e/ N# G+ x; z4 ^" F
  233.         do/ ^8 l& Y2 k6 u" }) F" R3 E  C
  234.                 file=$(echo ${file} | tr '|' ' ')( K& y8 A" ~1 r* @
  235.                 printf "Applying update ${file}\n"1 k; L4 g% e8 L, e' K
  236.                 $(${dbcommand} ${rdb} < ${file})5 W7 M% ]7 l) d5 _) j
  237.                 printf "File ${file} imported\n". u1 S! G! i8 |; \4 K
  238.         done1 h: b8 q. z" ^3 |! i* |' @% a4 Q1 u
  239. 5 b7 M6 k* Q: a# v3 j
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')2 o9 q: i- p/ `( ^3 i% n- p
  241.         do
    4 A* ^' I( k: T3 a$ c: O0 w% Y
  242.                 file=$(echo ${file} | tr '|' ' ')- h+ D3 J: n9 n  v0 V
  243.                 printf "Applying update ${file}\n"+ u4 h  s. U5 B% b0 ~* t4 ~# e
  244.                 $(${dbcommand} ${rdb} < ${file})
    6 v/ Y# y1 J: }
  245.                 printf "File ${file} imported\n"
    6 e, P1 F* B5 V. k" C2 n) x
  246.         done
    8 m$ N; v4 l: Y' R2 x) `% Z
  247. }' V% [- P) u8 Y

  248. 2 a7 b, k; F0 b3 L6 q0 C
  249. addRealmList()
    : D7 _1 O3 [; p6 }, ~" a  T( Q9 H
  250. {
    ) }4 `. {4 ]8 y& A& B% W
  251.         printf "Adding realm list entries\n"/ n. J" C3 [4 p9 J  j( O+ E) |+ w
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)- X$ [0 }0 v  s/ `  s8 W
  253. }4 N! A+ G: y) t, N( {. N% Z# v' b

  254. 2 W/ x0 k# A% r' n3 s1 C; d' L+ J
  255. activity=""
    0 L9 L% ~7 K! K: j

  256. ( R8 A: t, f8 a5 @7 u: g
  257. while getopts "suh" o; do
    7 X4 R. a- }0 T3 {
  258.         case "${o}" in
    6 j6 q& i" I+ h. u
  259.                 s)
    ) n) M% V% y, o2 W0 c
  260.                         activity="N"
    1 N; X: m0 c2 k. K0 A6 j2 F
  261.                         printf "You selected silent mode\n"
    & A+ I: }7 r, g  y; ^" @, U
  262.                         ;;
    4 u1 R4 _' A# O
  263.                 u)
    4 K7 h% k; j+ c9 v4 G7 K+ T
  264.                         createcharDB="NO"
    9 [. u# I4 }2 A, y. G1 l
  265.                         createworldDB="NO"5 ?; M  N% f$ c- H/ K: K7 I
  266.                         createrealmDB="NO"' z7 D  k* x8 F) D( t! I( A' |7 s

  267. " H5 T6 E+ d. x5 t. x6 `
  268.                         loadcharDB="NO"
    . Y2 A3 B: e. M/ H' P
  269.                         loadworldDB="NO"
    ) D1 D8 {5 L2 v4 R7 |
  270.                         loadrealmDB="NO"2 A) D3 G" Y& s4 Z" O4 \) I. `* ~+ S
  271.                         dbType="EMPTY"1 k% z$ w5 J6 N9 k6 P% l, M; A. g& T
  272.                         printf "You selected update only\n"5 p9 o; {! S7 T7 j' ?
  273.                         ;;+ e* A3 Z' D3 t" V6 j7 r
  274.                 d)) X6 D  D6 K9 ]# a8 ]  X
  275.                         DUMP="YES"( ^2 H7 f$ U; l" F7 v- O, N
  276.                         ;;
    ) Z% I: E0 L; |  Q  W
  277.                 h)
    $ }; U: B1 f$ E- J* i
  278.                         printHelp
    % R) u7 D. z9 x) n
  279.                         exit 0+ G  _6 R' E$ h+ ]
  280.                         ;;, v8 S6 P4 I+ H: e# }4 }
  281.         esac
    2 A' |; p) \: ?2 ]) o
  282. done
    ; ~5 s9 v6 s9 C, K

  283. # K, O, v( Z2 A% Y! M. y
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]+ [, `! C. K  O: t5 F) W
  285. do
    , Z9 S9 |7 @- a9 O% X
  286.         printBanner; O& t, l" L0 ^) }9 D7 i* Z1 c, L
  287.         printActivities* A3 q7 E, o+ Y( }" G
  288.         printf "Please select an activity : "
    + p, {3 h9 _" P
  289.         read activity
    ' C3 C- }7 a% U
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )+ @+ V, f) ~2 l# K7 r1 n3 ?! i4 M
  291.         case ${activity} in+ e: r8 G& J1 K: g+ n  K6 M7 l, n3 w: O
  292.                 "V")
    5 ~8 }" T: _' z
  293.                         if [ "${createcharDB}" = "YES" ]; then3 q3 M1 k: ?) i/ \
  294.                                 createcharDB="NO"
      p1 X' n( U! |6 H( y2 E
  295.                         else
      \$ L9 t% g, j8 a
  296.                                 createcharDB="YES"
      T4 q% D- H. `0 W' E$ R/ j
  297.                         fi) b# S9 u4 H7 I, m; p* K4 V* x  e6 o
  298.                         ;;
    4 c9 d/ W, Q7 [3 N5 O. ?9 y0 h
  299.                 "C")
    3 s2 `% s: t0 ?- K2 O: ?
  300.                         if [ "${loadcharDB}" = "YES" ]; then
    1 e3 C3 q( C& v
  301.                                 loadcharDB="NO"
    2 d8 _6 A; C8 K# L# z. h
  302.                         else
    7 ?  |+ H( E) Y' A6 M4 u/ b- q6 A1 n
  303.                                 loadcharDB="YES"5 @, j% {$ b0 b5 z/ `0 l
  304.                         fi$ d3 D' K& a, k& r- ]6 R% y
  305.                         ;;; c# q8 P. _( r+ {! p
  306.                 "B")
    - I' P2 S7 D: L
  307.                         if [ "${updatecharDB}" = "YES" ]; then
    + E  }5 b3 Y  c- a0 m
  308.                                 updatecharDB="NO"" u: j0 U2 S9 O  q; C+ S! T' Q# k! x
  309.                         else
    2 _9 n# W/ \4 ?. H. d2 S
  310.                                 updatecharDB="YES"
    % @+ s: z3 [0 v5 z: ]
  311.                         fi* w/ p4 m( W$ E
  312.                         ;;
    6 c1 f7 x# ~* U- J4 w0 b& c! D: h
  313.                 "E")
    7 V3 U- V6 ~/ ~& K( ~
  314.                         if [ "${createworldDB}" = "YES" ]; then7 c& ^& u, v& x1 d' P7 g3 V. V* B
  315.                                 createworldDB="NO"0 ^* `# T9 y4 L$ \" H4 h6 \
  316.                         else " y* e  y3 ^, N! B
  317.                                 createworldDB="YES", C6 `* D0 T6 h' p1 H* B  S! j
  318.                         fi        $ V, u0 v) o: h
  319.                         ;;* X+ L' O, C0 d; n! F
  320.                 "W")
    ( J. j1 d( [3 o& U# e+ Q" B
  321.                         if [ "${loadworldDB}" = "YES" ]; then; {) ^; P, r( Z8 a3 t. o- [5 V/ M
  322.                                 loadworldDB="NO"
    % W* ^* l# J1 [0 ?% d3 y
  323.                         else
      p' R# I$ q- M
  324.                                 loadworldDB="YES"
    / t0 B8 C9 N% K
  325.                         fi       
    ; u! E% V# R' C% j# i5 E% i6 [
  326.                         ;;
    , H/ D: R5 U5 b5 s) f0 I3 M
  327.                 "D")+ J( a& Q+ `9 u+ G6 P. |; [
  328.                         if [ "${dbType}" = "POPULATED" ]; then, }6 Y- v9 t% h* w8 ~! D4 p. v; [" B
  329.                                 dbType="EMPTY"
    7 ^. d1 c: N% s3 y
  330.                         else + Z1 }( ~% c# O) k1 h( v
  331.                                 dbType="POPULATED". m3 E- G. c" z8 E+ p9 ~1 U: k
  332.                         fi                                
    4 r$ K' X7 w! n2 f8 q( [
  333.                         ;;
    & Q1 R& T8 M* f, J3 o
  334.                 "U"); l7 e* b$ d4 i9 m
  335.                         if [ "${updateworldDB}" = "YES" ]; then
    ) T: j1 j- l! j# \0 a6 c% {/ ^
  336.                                 updateworldDB="NO"" W, R* B! z- G1 c) ^9 R
  337.                         else
      z& p0 B9 d2 w8 X" T
  338.                                 updateworldDB="YES"
    & u; j3 r3 ]% y- M9 r* U9 |/ s/ g
  339.                         fi
    " w, o: G! \( u- h- N9 X$ k
  340.                         ;;
    , q) V4 p& b- [! {; e9 L
  341.                 "T")
    7 n3 e5 `9 h) j( f- J6 M# [2 q) u
  342.                         if [ "${createrealmDB}" = "YES" ]; then
    & p+ ]) _2 x" X! I- p
  343.                                 createrealmDB="NO"
    8 H+ {$ i2 k2 Z; D" D' r! P& E
  344.                         else
    ) x8 i+ ]" S! P- J4 S
  345.                                 createrealmDB="YES"+ u- n& S" G- S! M: ?+ w
  346.                         fi                                 . U1 j. t! U, F9 |1 U9 v
  347.                         ;;
    2 I2 h9 |/ q+ P) f: c4 l
  348.                 "R")
    - _9 C) T; d( `/ Q
  349.                         if [ "${loadrealmDB}" = "YES" ]; then
    ( N! W8 L& m1 @5 X; h
  350.                                 loadrealmDB="NO"                        2 |- o2 C7 z5 K$ ]
  351.                         else 4 b7 t; F6 h. x7 R, y3 ~
  352.                                 loadrealmDB="YES") X8 q: ~2 ?9 `
  353.                         fi
    # f. t/ ^- [1 I; S
  354.                         ;;
    9 Y' c2 k; ^) y2 {
  355.                 "Y")0 h, n4 v% A7 q# |
  356.                         if [ "${updaterealmDB}" = "YES" ]; then5 o: ^# [; l0 {: t0 a  y
  357.                                 updaterealmDB="NO"' K( B# r5 t6 O
  358.                         else ! C  n5 C( L9 v- N8 Z
  359.                                 updaterealmDB="YES"
    / j; R! ^" b6 W3 u1 `( d2 B
  360.                         fi
    . ?8 e; J9 j( ^2 \: r2 A
  361.                         ;;
    2 O( ]6 N+ T) d4 K4 o# v1 k' Y
  362.                 "L")
    5 c6 j3 v% D8 i6 k( K
  363.                         if [ "${addRealmList}" = "YES" ]; then* P- b# k* I- ?
  364.                                 addRealmList="NO") m1 a9 L: h" J0 K: Z( u
  365.                         else ! P& h+ Y( k# r* g# o
  366.                                 addRealmList="YES"
    6 ^- R& w/ Q# W9 P& z+ a
  367.                         fi3 l. K5 B9 C! G
  368.                         ;;( [; N* r" c8 e/ r. e& p) U
  369.                 "X")' t% z  b; Q, V7 T  J, q# V$ g8 d
  370.                         exit 0;;5 ~4 S! }" C+ \+ y
  371.                 *)1 [! F6 N; Q0 u$ L+ t2 C, t+ M9 |
  372.                         printf "Invalid selection";;
    % {: U# t# m4 u- E; w: U4 V9 f
  373.         esac! B) k+ R- j+ x- o' _0 a
  374. done( \$ t7 M6 H! o* k7 q

  375. , z% [  I7 r/ h/ D
  376. printBanner
    7 w8 v& S4 c6 }- `3 Z- \
  377. determineDBName: V6 Y) g$ I5 L" z* i* O
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "
    0 X  g* v( _* \8 v  h6 a$ j
  379. read svr
    " `9 t1 `5 x6 _8 b7 ?# u" _
  380. svr=${svr:-${svr_def}}
    5 v$ g3 K- y/ p' r% O+ {
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "! H) W# C+ T" n& e8 J" E' _
  382. read user) k3 j% a2 ]- _8 V- h
  383. user=${user:-${user_def}}
    8 C& P  R! `: |, b$ o+ w
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    + E7 n1 b" u% o8 U7 W4 c  C0 ]' ?) S
  385. read port/ _% C1 |3 c  K* @8 Q
  386. port=${port:-${port_def}}$ m% }  a! i9 S
  387. if [ $dbname = "MariaDB" ]; then7 G/ Y9 p$ ]; }" c% s1 }
  388.         printf "What is your ${dbname} password ?\t []: "
    1 L2 b# ~6 B7 T
  389.         read pass
    5 v9 z4 {) o7 t' R4 P
  390.         pass=${pass:-${pass_def}}/ b# R) R+ c$ R1 G
  391. elif [ $dbname = "MySQL" ]; then" B3 v) x, x$ A/ z7 U
  392.         mysqlconfigeditor, z7 J' V4 d- S- k
  393.         $dbconfig
      H8 o! ^; [+ p6 c
  394. fi
    + L, w. F4 w& Z0 j$ \: A$ B
  395. determineDBCommand
    5 G9 d/ {: i" h8 b& r5 z

  396. 9 j2 n: p. ]1 B4 y. S
  397. if [ "${DUMP}" = "YES" ]; then) i5 P& G# \/ y, g  k3 F
  398.         printf "Enter it again \t[]: "
    $ [- O) G: i( O7 G2 u6 U% |
  399.         read pass' V4 ?) f0 \; c" J: Q+ d! F9 {2 l
  400. fi
    7 X* r3 _& i" O( a* }+ F% Q% i

  401. & u3 E% t: m/ l% d0 _$ `% o) l
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then
    - S4 G6 k9 z; M1 X  B  p
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "
    / k0 B7 L) ^9 R2 y! i; u" ?' P
  404.         read cdb* \, ~; w" N: a
  405.         cdb=${cdb:-${cdb_def}}3 m8 Z4 j9 v% Q
  406. fi
    1 _) ^+ c) m" |9 I  ?! q7 a' U

  407. 6 X+ `- Y# r, g( w( ^0 L% n
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then
    * Z9 C& L/ w& P3 v4 k
  409.         printf "What is your World database name ?\t[${wdb_def}]: "5 o9 t" s. y: [6 l$ |2 h2 B2 r* c: q4 U
  410.         read wdb
    2 Z9 ^4 L. K9 q4 A8 F
  411.         wdb=${wdb:-${wdb_def}}& }- k. [$ j0 M) h! U" y7 ]! O( x2 F
  412. fi
    / I: @/ W2 h2 u5 B* M
  413. % M7 H8 Y( r8 X& e# l
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then* m9 ?1 X$ J0 {; \' ?" r7 U2 L& w
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "3 R' T8 D1 X! b$ t& Y
  416.         read rdb% L4 k3 m2 ?" _# ^. ^8 H
  417.         rdb=${rdb:-${rdb_def}}
    & t' V% n2 r# `. m, [
  418. fi
    # |& O5 j% M8 D/ m3 s
  419. 0 a5 S# E7 J2 b3 M( V( Z" H
  420. if [ "${createcharDB}" = "YES" ]; then) ?' x# r9 F, M0 R  j3 u
  421.         createCharDB
    5 E* `( |/ \" A. F$ k
  422. fi
    - u# `; P/ E8 m& n0 J9 {

  423. 8 N1 }3 c8 J' f6 U( k! H4 _
  424. if [ "${createworldDB}" = "YES" ]; then
    6 n' U* z: t  W" Y. v
  425.         createWorldDB' P7 S. ?: m& z( @& M! A% Q
  426. fi
    # N8 G9 J# w* r# H. w
  427. & I& W9 h. @5 _, @
  428. if [ "${createrealmDB}" = "YES" ]; then
    ! c4 w& r% n5 a
  429.         createRealmDB. e  X, s& y; r0 D. s# d
  430. fi, Q# g  [6 l" ]5 o7 r

  431. " M8 d! d( q& g1 X
  432. if [ "${updateworldDB}" = "YES" ]; then
    + n& c! ~3 {' T( D
  433.         updateWorldDB# n2 T$ t3 f! Y+ |! g" j/ J! s
  434. fi+ L: z  o4 B6 o* n* T% c8 o/ v

  435. ( `+ |% s' I6 a; M  L) h$ @
  436. if [ "${updaterealmDB}" = "YES" ]; then0 t6 f9 Z" @1 P+ ^
  437.         updateRealmDB
      X& b: s- ?$ _5 d
  438. fi
    6 _; v9 `/ _/ |  X
  439. : K: `& y2 M# x& G" D
  440. if [ "${addRealmList}" = "YES" ]; then
    : h0 R- {0 k* ]6 F0 J2 t. M
  441.         addRealmList
    $ y0 e" @: z0 R3 S
  442. fi' l0 H$ d9 W5 e. q/ \# g0 o7 x

  443.   h" M5 y& |) I9 U$ V3 t1 j
  444. if [ "${DUMP}" = "YES" ]; then4 H& k) W3 J9 q4 h5 c/ W
  445.         printf "Dumping database information...\n"- w, D- o4 o( n2 h1 o- m4 a/ X
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf1 @$ U* B, H4 J0 s
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf2 g: s5 ?5 D& q! }3 w8 T
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf
    * I8 k+ h1 R5 a  {
  449. fi
    & }5 ?% j9 g0 E; _
  450. 5 f+ n+ _& p5 S& w
  451. printBanner
    ) U# C  E# j, ^( f. {* F! A
  452. printf "Database creation and load complete :-)\n"
    $ r# s- ?& E5 E4 f2 p. s# S
  453. printf "\n"
复制代码

' \# F! z/ G$ E. i2 ~8 K9 l, ^; a
回复

使用道具 举报

 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令) ~1 i4 g0 i: W! `/ Q& B% J: {: S/ C
5 z4 h- l) @2 A7 y
使用 Playerbot 密钥的指南:1 {/ \6 b- m  {4 Z- o/ H
7 _% ^* `; |4 }" n: ?
标识符说明3 T' N& M1 d8 K8 I( K/ U
机器人名称    机器人的名称" I5 R4 x" h4 l0 W# v( s
朋友    命名机器人或玩家角色. g3 J! b; L9 y8 v, _+ K  H
目标    选择目标玩家、尸体或NPC(非玩家角色)
- r* {( \+ Z5 {' @* a7 K|    逻辑或' t, Z- Q9 O6 ^( c' |' W
&    逻辑与
% L1 o; ^1 g3 F..    多个实例% j6 k' S7 V* [& w2 x) o
/命令    MARCO 命令: O  x7 {1 {" G) H5 Z- s
/s    聊天:说- |% ^+ Y' o" W2 \
/p    聊天派对
7 x0 V4 N/ J8 z0 G! [/t 机器人名称    聊天:TELL BOTNAME
& S% x+ h9 D8 x3 X  q' J/w 机器人名称    聊天:告诉 BOTNAME
2 t1 c. Q: V" ^9 A. N: S! L' T/ V7 v* k<名称链接>    名字=) w- d7 u" K6 k. D! m
(捷径)    为命令或子命令分配快捷方式9 L; K# M( y: Q; g& Q( s3 q
! s& `+ o" c4 h) b# F$ Y& o/ K/ S+ b
可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明
8 [- ]& `( L2 `7 ^) Y/ M.bot 添加 BOTBNAME    为世界添加角色
' ^, w: J! c3 V& I.bot 删除 BOTNAME    从世界中删除角色
# ^* }5 M; |; w+ [3 D1 O! _& g6 r9 w
当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)
. @7 q/ K" r$ E3 R& E1 h! Q$ F7 R.bot < co | 战斗命令 > BOTNAME    分配机器人角色- D/ v# j, j; S) i$ S9 s
8 T2 I2 \' `8 J! }" M
宏命令:+ Z% ?$ l' [8 v2 \" O
句法    描述
' g6 G6 C4 W. E% \3 s/ x- K3 X4 V/邀请机器人名称    机器人将自动接受聚会邀请
* w" o& i+ _! A6 a3 ]/uninvite BOTNAME    机器人将自动接受派对不邀请
& e/ ^" U% s  P7 h$ L# M) Y0 X& S! `8 d2 r8 e) G) J
TELL/PARTY 命令:(某些命令可能不适用于某些内核)
8 D! ]. X% ?( ~7 b. _句法    描述, B5 R7 L! i, T" ]+ Y- A' V
协助目标    机器人协助列出的角色,在他们攻击时进行攻击。9 z$ y2 L4 Z2 d
攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式+ v$ U5 s- l  V4 \
拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..' Y5 _1 d6 m0 Y
拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..! F: @6 d5 ^4 G/ k7 a: v7 S
拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..- Z1 R: a. U! ]5 B2 m
银行    命令机器人寻找附近的银行家并列出机器人的银行余额
4 I) P1 o1 Q( s9 Q! v银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
2 P5 s1 _2 `/ p. r* p银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..
8 d- n% ?. M) U7 `/ [3 Y0 A(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..
9 v& o% i: x& T8 h  w7 O©ast SPELL    拼写 = >
7 ~0 t% ^( u" l% y" E搜集    显示收集对象选项和当前收集状态* t) L3 m$ ]% Z
收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>( @+ c0 G; T2 o, `, B
工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
0 Y; ^1 w! U# _9 V1 @工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例
2 @! [3 G; W" L9 h4 `# ~工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习: }8 V& N) B7 Q# L
工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习3 O; j9 s% r6 H
工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习
4 @; P: H7 o4 w1 E5 q7 T1 f工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习1 S; j7 U& r/ H( a+ L) H- |
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习- \; n4 N. Z  |; e* ]& l. r
工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
; H6 J" s3 W2 p: F7 _/ H) a- U工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习! _) a/ j' a! w7 ~( M% e
手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习
! `4 y$ u* s. c8 K7 ?- A工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习
! q( Q: q8 `& Y- H+ P1 z工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习
# L. ?2 a. F6 E5 r5 W工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习9 L3 p2 H, }2 P; A& ]
掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..
0 M% n3 ]1 p* ~5 n全部放弃    当机器人库存变满时,丢弃所有低级物品。" O$ d( l1 ]" G; `' S/ ]
附魔    列出机器人学习的所有结界 1< Spell LINK >
+ D/ @: f0 R/ w3 p$ F附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中- c: _, O) b/ ?5 X4 ], V5 G( C
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品
! v  F/ c+ ?5 o  z$ B& r(e)quip auto on    打开自动装备,也立即检查
8 _/ ]. c: B+ y$ D(e) 装备自动关闭    关闭自动装备。
0 R; B5 F6 i; N2 P8 r4 w- Z% `0 [(e)quip auto 一次    运行一次自动装备,然后将其关闭。0 F$ U& M/ @1 H$ |+ E
(e)quip 信息    显示装备自动切换状态(开/关)。
; O* b: |) d2 V(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用/ G% V! b# R' h( D: F2 m
跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人
, K& A5 d' ~. r  `/ F# j$ r跟随汽车    切换自动跟随距离(开/关)( m. ]3 p4 u* _3 c( J8 \
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)
9 h6 ?/ h  _; ]跟着远    机器人跟随,远离主人。9 u8 [% ?$ Q- ]4 Y
跟随附近    机器人跟随,更接近主人
: H0 ]2 ^% i$ N. d/ R( o跟随重置    机器人跟随距离重置为原始默认值. i5 n% _- g6 m6 Q) [% [+ k6 I  X
(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家, e& k( k* U% k5 p
订单    显示机器人的战斗命令
! o" r; C$ S2 m订单延迟<0-10>    在机器人开始战斗之前激活延迟。
; h& J+ |6 @  g; O3 x+ I- w# j命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
( t3 c( h3 e2 g: N8 |6 T命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。
6 h9 Z- n9 }9 R0 N+ W2 q7 [命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
, {5 ]' i. r6 d0 `* L( ?" E9 N命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。
  f4 b6 b) [4 L# \# V命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。* S$ g0 `  g! K$ P9 o' v6 F  z
订单恢复    将战斗命令恢复到注销前的状态。' u$ V* M( c8 M6 _
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。' |% t8 g' m; q: o1 b1 Y
mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..
- y- B+ _+ |. u3 }0 P2 U: H! r邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..
: W+ t" x7 j7 m# k邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
' s. B0 C8 P- t% B+ F& v, k. F宠物遗弃    放弃活跃的猎人宠物。8 z$ O! U* F3 y5 L- `- x
宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术
  ]6 G) x  V: C7 s( A6 N宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色
- k( h- [9 ?+ C3 q# [. s宠物施放法术    拼写 = >
3 z* Z" F9 F6 F5 H) P& h  _宠物切换法术    SPELL = >为给定的法术切换自动施法
0 k$ v1 a% l/ C) T5 s宠物状态    显示机器人宠物的当前反应模式1 l* k+ ~4 T' G; S
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>6 C8 y2 F, z) ?) I; Q' ]5 o
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
8 K. O. r5 N  Z  l" {+ B) j: ]- h处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素7 _8 S* {& G3 x9 r( i
过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
, s" e, D4 H; ^" s拉目标    以协调的队伍/袭击方式拉动目标。( A6 q' c" z3 P+ p+ }+ ~7 }
拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。1 n; A7 D6 M3 `. H4 u( ~: \3 A1 o
准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。
  C; e/ V# }7 ?# v6 n  j- P( \2 c寻求    列出机器人当前的任务( v; O. z" ]/ S3 v
quest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..2 a: V- f2 r* T0 B# H
quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >: e& ^. U5 a! U. z; H
追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务
* t$ W9 G# A  Q0 Y5 T4 h9 P3 F% J寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象# u8 U" O; Q9 O3 {6 R9 z
任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
/ x# f3 A- Z- W9 s( O& iquest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到
& k, @' N3 O0 J( s6 y修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
7 R: z$ M1 c% q) C, E全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品5 @  ]( q1 m  ]9 `
重置    重置状态、命令和战利品清单
" v/ Q3 I! n0 u4 \2 f0 \% m+ p(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..
# f) z7 U; L$ ?(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。3 P! }. w8 }( B# r8 E6 |2 k
技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能* R0 l6 S6 V1 f. X" F- i
技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..1 S, X" i) ?5 g& D* ?8 {2 a
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..& g, V2 t9 `4 }8 k% x9 K7 W; n1 y
技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术+ N' g; G. i. S) O- z+ d
咒语    显示机器人已知的所有法术! `* k0 s- m+ l1 I' B4 V
统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本
# _# a6 X- ^% M( L/ I停留    命令机器人站立而不跟随玩家/ T4 m. G9 z9 I8 A/ b3 N
召唤    玩家附近的传送机器人
4 S5 I) x  c! q0 [! z民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..: Q& v  Q& s" v  w$ B, }
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)
  v+ U( T: L1 N+ m- S+ ]! M使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)
6 r$ j9 y. m1 e1 f! f- s句法    描述% X4 G( l$ A9 r6 G
天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用
9 B3 C1 U/ O* T人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋5 c( C# \0 K- M3 d9 o, d
天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2# ?& e7 K2 a2 z1 `. D3 v  y
人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
7 ]( B2 w6 Z% ]1 {6 N天赋规格#    机器人将遵循此天赋规范。% M9 }9 T! Q! Q7 i0 F5 N! o  x% n1 a
+ k3 _! _7 j, u
1 要选择 , 。4 h* i5 ]) R; |7 t, N
2 每个机器人的税收增加,每次重置天赋。! N3 W% J& H# T

. \& o8 r; Z  n; K2 K. W, D2 [, U! _& t6 p& Y0 s/ c& v
回复

使用道具 举报

 楼主| 发表于 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)+ u- v; ]* f1 W0 c9 C
" N3 v% b& f, }, T2 A6 n
1. Make a folder for ACE in your preferred location ( I use /opt)7 n& _7 u; T- _. B+ h/ r
/ P; r  C  w: y
mkdir /opt/ace && cd /opt/ace
  O' F! D" b( @% [% o# q7 [" \& z; C' V" C1 d- m) h
2. Download and unpack ACE% n* H' z6 g/ X

7 U2 Y) G8 M/ D0 `# D- Iwget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz/ B1 |/ G/ o( L1 t" C
tar -xvf ACE-6.4.7.tar.gz( I5 M& a) B5 k

" R/ ?+ _9 J# V" [4 M8 t3. Add needed environment variables, k" \, p( r* Q
* B3 I! y" m0 Y; l
cat >> /etc/profile <<EOF
4 {7 g+ q, p! B6 J& d/ I5 \$ ^5 gexport ACE_ROOT=/opt/ace/ACE_wrappers
; j5 {. X1 F; t9 U' G2 IEOF
8 l7 x! m3 }8 o6 h7 V& ^source /etc/profile
5 y1 H4 f! ?5 e6 E
7 o, D6 I  r: _) x% `4 i/ r7 T
4. Add the desired headers
& K& G+ Q& s; A  b! L  o/ P5 s
. Y+ i2 z0 Z) y( N7 `cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF
$ E* b. L0 X1 j$ _: i2 i#include "ace/config-linux.h"! t- v! @0 t( F7 F' z/ {" D
EOF' W8 ]  |' d% ?8 Y' S* ?
cat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF
; {9 S, K; e3 b+ uINSTALL_PREFIX = /usr/local) f+ S- G# K' g" o
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
8 R9 K- K4 ?0 S5 z5 Q" r4 o3 ^EOF
  z* h% |& j- z; h

* c8 V8 A- m; z8 v9 p5. Build ACE% {7 ^  p! B, M* P
. }* W1 [$ G& }+ o7 ^9 u
cd /opt/ace/ACE_wrappers. A( Y3 v& _( m6 j, i( b+ A4 Z
make
- ^0 m4 W) |) y; bmake install

: h( \) i# ^4 z& R# v
9 R7 u; i$ ?. q. \% N6. Add the library to the public path8 ^9 z9 K9 C& [& ]2 Y, |, O) j
  H1 @* E! j$ \
cat > /etc/ld.so.conf.d/ace.conf <<EOF7 o5 ?) a5 s7 m, L# J
/opt/ace/ACE_wrappers/lib
6 A9 a5 T' [, x" Q# B" t! ZEOF) s( t$ m: n$ x
ldconfig -v

* z# x& x4 r0 D, T- F
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client
  ]) w8 D" Z3 z- A! [" R9 F) CTorrent Download& h2 }; Y9 U$ _/ c5 _. t' B
5 ~% R0 \- ]/ ]9 `6 ]/ V: m
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
; \5 p  A9 f6 Q/ x- q% l0 G; p' I9 N4 [5 `/ `3 x4 A$ J. k2 I
    Torrent – Client from Dalaran WoW (Recommended)! s* \0 ?; h% J$ ^0 A4 ]
    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)
: }( [. G8 P# u! U2 Y. y' Q    Magnet – Client from TrueWoW
+ J7 H! V4 [6 z' B/ [) z  K
1 W0 [: Y) y! [# WDirect Download# P) E6 h  x0 N/ y  K% h" F4 P

/ o( ]( w& L' J8 @. c) DBelow, 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.: q0 u/ v! n$ m" @2 F* I
  z+ h5 n; Y9 I# w' f
    Direct – English Windows client
$ z8 ]; X7 b9 N7 O; D: c/ r  G7 H$ p" ~
3 \- e. {* d$ _( h/ L3.3.5 Wotlk MacOS Client
( n: m  r, N9 A
7 \' ~8 L: [& JThe 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.; N, N/ }6 M8 y6 L

- H4 |3 h3 J- f& ^* x. I0 N" T  ?    Direct 3.3.5 MacOS Download – Client from Sunwell/ p, t  g0 }+ A+ B" c( i
    Direct – Client from Paragon-Servers (French)(Mac)( ]/ n4 ^6 P- r( v
$ n/ Y: ]; {! _1 }
Modified Clients, LegionRemaster:
* v* |: }7 C; ]3 h$ h1 d. _! p) }- I* _( f9 q+ Q. O
    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis
, t6 F* l: r% L+ K# ^/ c- o* F; C2 {    LegionRemaster Patch (modified)$ U  J3 _/ ~1 k" C* {+ h
    LegionRemaster ReadMe (Custom) 9 P+ P: i" p4 D  p' F; _; C
https://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos4 _. C: T! R) [1 a! B: s( A1 i
+ l* F1 q5 `/ l5 z" o1 \
在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
% H  S* w+ ^9 D& \( ^5 A* z, |* D
$ `; }0 J6 J5 p5 J9 p本文 章 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。9 g7 w6 c8 h: z2 L- ?
. ]* {' S' k. w& U( i
正文如下:
% Y# r  w# _7 ]( }* G2 Q) a" a# E  z9 ?  h" Z+ g& T
开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。
" d  R0 {: O0 a- `" S, k
$ p; x* z7 q9 [) i* S9 q# C/ p( E# k暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。( d2 U- `# n- h: W6 S, F
) _3 l1 E5 y3 X# m& o8 x
而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。- ?2 U: M' M! p" ?! ~4 s
) N$ H& V* v  ?6 L* }/ ]( |2 g0 O( h
  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。
% p! J/ l. k4 G2 `5 T
/ k5 q" Y1 c, N' n* N$ g5 Y/ O# J开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。8 r3 M" j8 w# G
. Q, I# E1 F6 u: [
mangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。' b8 E& ~' s# ^! \. t! I& e' c
  E/ b; ^0 w# j" O

* b. o0 i+ S, I! J/ T) K为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。
) F$ N9 p: G, g* h- E+ y) U9 ^  s
一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:& p0 Z3 i7 k5 B2 f+ z: x% y
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:
    + \/ `) V" ]8 K9 q0 Q0 X
    Brien
  • 开源数据库软件MySql
    8 C; ^) G3 }4 |7 @) ^% z官网:MySQL
    1 o( U+ U- {( x( `% }- U( t4 D
    或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库
    ! J4 d( {2 e7 l8 z* s3 d官网:

    ! h! g: t2 @2 e我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。7 ]+ l2 T& |1 Z) ~& M! u
    文件名:CompleteSDB156-Mangos3462.rar
    6 K. u" N, [- s8 |7 A: U8 D下载地址:0 S  O4 f, }+ A9 h& R- Q
    . Y# _6 ~9 R3 A+ ]* b/ O8 ]
二、安装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"6 V) D* p1 P4 |2 a) m4 q( ^

    1 L7 ^: ~; j1 W- o1 B2 J  m; c- J
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径  n6 L  a6 k# h
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。& C8 w' C7 Q4 g$ r
四、解压安装地图文件
' t: Q: p) H2 L) z) |* V- S0 U
  • 把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子目录了。
    * i- ?- ]7 u; n3 u$ {
五、解压安装提取的*.dbc文件* Y7 O6 z: z: j# p0 N' u
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:
    / _; ~% @, G( a3 ympqe /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")了。2 U5 N) e: A4 @7 N2 _
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.( U% E! {. n' V6 T9 o
  • 将下载的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”,导入数据库文件。: u* X, }: M3 h7 h
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。% r4 `+ A# E/ a6 y( {& q' w  }
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到0 N( k+ E$ n  f6 |/ ^+ ^1 W" y# d" a. i% H2 ?
    "LoginDatabaseInfo ="
    - H4 M0 B$ E! D. p改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"/ L9 n! g  a6 O% J# P# R" ?" F
    这里的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"
      5 k7 T: B2 B5 F# e7 R9 o- [( |
    " z+ Q0 l9 k( k
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。
, Y% r  f2 e7 {; L; q

, L# K! k# I  ^* {& E/ j
8 F! E/ U/ b! Q5.安装数据库5 ?) c! e2 J& L4 V
使用mysql建立 mangos 数据库
$ s. I& d5 b. i2 C1 d$ O. o5 [$ j* d9 K: v) P
a1)使用官方最小数据库,mysql用户名及数据权限等请自行设置* O1 ?0 O" F9 m" J0 w
mysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据& `* Y3 ^* m: M+ F
4 d$ U$ m* c# K
a2)使用sdb数据库,mysql用户名及数据权限等请自行设置( E' N+ }* M7 [$ F
假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
# w0 k  {" \6 W- dmysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据$ O- \; N6 N& O" k7 B: B
6 H' Z5 h: P" J$ e) f
b)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1
3 N; A# ~8 r4 T% [5 F9 I- h( S4 I
7 D( c; ^1 ^2 R. j& ]9 ?6.编辑配置文件
; m" h0 {9 @0 c1 Y编辑 /usr/local/mangos/etc/mangosd.conf6 p% B0 @9 `, M8 ^
1 p0 o& H0 f, |# Y+ t
a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"7 p7 K" }+ F$ }7 ^+ x8 E
为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"
4 U5 ]3 T5 A7 n1 J# J+ C' F/ u3 H/ B8 j# R! L3 ~0 t
b)找到 Host = localhost: M: {4 s, L/ T
为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1
2 W- N+ Q" l- G1 c! g6 l6 J" Q  A( q
回复

使用道具 举报

 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。5 r4 N+ \/ O4 k  u" @4 k

1 [7 E  v4 e9 X% X7 ~" l本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。
9 ?* U/ u) X% Q, H' K: m0 j  [
" v" T" H1 G0 g我们走吧..* r) h  h2 Y( l9 G$ w2 }# L

$ Z4 z2 C$ H' @: A: c2 e! w设置数据库:- c' K8 U. c1 Z" p- V7 u7 w
- A; V, j  t; ?! t7 n( m
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。) t. h4 b4 q# |! b( T0 j
- t* a8 H2 i% r& J2 T3 q
启动一个终端,如果还没有,您需要成为“root”用户:2 p! R* V2 i& L8 }
! M( v$ f4 W8 c0 e
须藤苏 - 根
- `" `1 [; [1 B- p2 }( ^然后,安装 MariaDB:
$ m8 c' f7 L( i0 m. F! T
3 e  |6 F% L2 B9 }9 Pyum -y 安装 mariadb-server
8 B: c$ \- Q/ t/ A+ h4 Q: J& `     安装 MariaDB 后,启动它:
1 n+ n: \/ A, }: w
' I8 Z2 T- H. m. `4 n" csystemctl 启动 mariadb  p# G; M# A* P0 _- Z+ h' h
我建议您在启动时添加 mariadb 服务以自动执行它:
5 ^0 w0 X. L- T
2 u6 A* m1 [9 U4 ]: f! q+ j$ Jsystemctl 启用 mariadb6 x2 y7 c8 s* Q' W) }" B( `9 ~
让我们保护您的 mariadb 安装,执行以下命令:
% A" m' G+ u+ O* o
2 R1 i; h" g& |; k, l- x" P) Vmysql_secure_installation
. n% w4 G8 h" [8 S1 }5 L7 g) S我建议您设置以下参数:
& S0 T+ D! l* F; v# j2 q  e! f* f3 \2 O1 @8 V& |- S, Y3 Q5 [
设置 Root 密码! p6 s6 ]% o) \9 i4 w$ w  I" U9 p
删除匿名访问
7 U2 c) C# r) S. d. b! R- E% b禁用 root 用户的远程访问* [4 U% _0 K2 E9 a! o1 c1 _
删除测试数据库4 ~5 i; S+ @8 P; X5 h
重新加载权限
! n( d+ D9 W, s- Y$ i验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:
7 D+ X, Q' i  h
4 }& Z$ Y4 l2 l5 F1 }8 a. vmysqladmin -u root -p 版本
; a5 Q$ c* X4 t$ @4 W6 Y* ^6 c% {如果一切正常,您应该有如下输出:
3 o0 T" L5 G3 G0 o# s' w  f! J% Y4 x. p6 I
服务器版本 5.5.52-MariaDB0 S& }, O! D* _% T$ s4 I
协议版本 10" B: ]/ U; \- `6 u
通过 UNIX 套接字连接本地主机
- X' V" U) x0 I" E( x) Z3 l) W3 f! tUNIX 套接字 /var/lib/mysql/mysql.sock
; w" D# Y: Q6 C0 H正常运行时间 x 秒, [, W2 R6 r3 y
6 K$ O1 L* S" P- t
/ C6 n5 g: Z" [6 m; y) t# [+ {7 B3 m
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:
7 H* n. x- p4 M- l$ [' u6 n% `
mysql -u 根目录 -p
" r: c9 p! @0 i9 O3 Y, D创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):) G/ u- c8 z" W
9 i! U7 L& O  d: F/ c2 ~
创建用户“芒果” @ “本地主机”由“密码”识别;4 z+ L; c0 S* X! h1 y* H
然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):  X( ?) f# T' F1 l3 a6 g/ b
; v7 V1 Q5 D! d% Q% d: z
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
& n* I1 l  M, k! f退出终端:
# [2 G# b$ r9 F; F( |
: D0 b/ j- \1 r0 u+ V退出
% G' j  j, ?; q) S恭喜,您已经在 CentOS 上设置了数据库的先决条件!
: d9 A- K; H# K5 o& T
$ U8 S: h7 F8 z  z , @: ?0 T* w, w7 `1 O9 J

7 t& V$ l+ P: h! \安装芒果:, @2 i  g# q% i! y8 U
6 t$ _' _( ^3 o! F% d/ ?& S& o' R, L
我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:
! R" P2 L1 T6 p. S" o3 {# t+ s, l  w/ p! K9 R
光盘~
& P: X4 g5 _" a' }* t" Z, m让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:4 _0 J7 ~6 i. o: _
5 n# ~& e& K  y# u# G
yum -y 安装 wget( c2 ?/ S4 y& M5 S. @$ |$ G
现在,我们可以下载我们的安装程序:4 K7 }" j' J; f8 z
, p: r+ B' T# l* N: R
wget https://raw.githubusercontent.co ... /linux/getmangos.sh1 k$ Y- L+ Q/ t
设置允许执行它的权限:
: o% Y3 k/ i! I7 Q
, o/ ?# \6 D3 L- G- V; P9 q' d( wchmod 700 getmangos.sh
. E  K) w0 D4 d2 W8 P* u) ?并执行它:7 K6 y$ N1 N0 z+ a. |& T* y
8 Z/ u6 m' [. `- c& u! \
./getmangos.sh7 V2 D: L  y, `' R) P
在我们进一步讨论之前,对可用活动进行一些解释:
/ D8 t7 S3 j" B  S; u2 O0 x5 r- y- J% k5 }3 G) I" \- ]% U9 `5 v' C' h
安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。" Z4 d5 h) B& @
设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。
1 {6 O3 M2 W4 `克隆源存储库将帮助您克隆Mangos源。默认切换。
4 k! z+ ]) u5 m6 z6 y/ ZBuild MaNGOS将协助您完成MaNGOS的构建过程。默认切换。
. f$ u, C& _- o2 o8 Y& J- K( M安装MaNGOS将帮助您安装MaNGOS。默认切换。
# o  c! s; v+ u0 c9 J; r* c安装数据库将帮助您创建数据库模式。默认切换。
1 q" p% D. `+ K提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。% U7 D7 J: O1 E0 ?' f
创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。
# _! c6 D% b' s3 V现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。
7 f$ Q% A* t% V7 X
7 ~0 u3 ]! [4 }% }3 H1 B6 o用户选择:
4 n: f* E4 R9 ]( M' w& x2 o7 \% t  c3 B  `$ Q
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。& \) ~9 u2 c  M/ Z' n$ N

  r$ ]  }# j( E) _如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。
7 `8 j! e; ]6 B2 Q% I0 J( ]$ ?/ \6 Z
选择魔兽版本:$ U3 v+ l: U# j8 ]/ G
: z$ |* V# C" t8 y6 ^1 d8 \* |
下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。
8 N+ I5 h+ Q, L0 O3 j( D8 i8 q3 c2 S2 a  p# T
源代码路径:9 P; \3 _: P% x1 z: k6 i

$ f! E$ c# O7 h7 |下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
0 h' t# q  ~5 c$ k8 s
! U/ y! I9 `- A" \9 b! f/home/芒果/zero/src
3 a* x7 G1 y6 [2 C8 w8 H如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。
( ]! G2 W9 f% q" F3 f; X' ]% c( \
+ A0 g; m- O+ E0 C, V* _- }: z安装路径:8 D4 B" ]! H' n

/ L1 C/ N5 u1 w下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:" ^" g6 P1 n! g& @* e" X  ?+ r% \
; v1 j! ^3 U" j6 x5 _) p4 e3 s
/home/芒果/零5 V. Z8 t2 N. N! ^( ^+ {& R
如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。( V# X! A- y) P: j3 |+ ~2 L

" [; B. u9 m- @, x克隆或更新MaNGOS:  b8 M- p4 Q+ j0 X" ], u

- q% k/ _( P5 U) w' j脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。! x# h1 n' l. g; Z( L
: A& E7 Y: |" n9 I1 D
安装程序现在正在克隆服务器和数据库存储库。
) L3 Q) R1 g. B+ ^, U* @& [  i& O/ h
. x# O$ c; g& W4 e; p构建选项:# j" B% b; g- H6 G# o

3 a/ @3 a3 B0 M8 y* }8 D: E您现在处于构建步骤。此屏幕上的一些解释:
9 q! v7 d: V) B; V9 X
( W3 w# u( Q0 }* x+ f4 F  YEnable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。
+ a+ c" Q  w# q; M7 S$ |使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。  |2 q6 ~, c# k- `' o2 {
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。3 w- Q" V9 Q# t6 J# S2 l
使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-11-3 12:48 AM , Processed in 0.124665 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2026 Discuz! Team.

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