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

MangOs搭建魔兽世界私服

[复制链接]

991

主题

92

回帖

5万

积分

管理员

积分
55422
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!
0 H' ]/ K/ U0 p7 K  [( k考虑再三,我选择了CentOs来做游戏的服务端操作系统。
8 @' o1 j& ?: S& r通过Git获得Mangos的源码之后自行编译搭建服务器。
& ]9 Y% W2 z' J8 q这么做处于几方面的考虑。
5 L7 L- G4 i  W. F5 w& Y
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。
    6 z1 i5 i! m, z7 |( U
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
2 N$ a3 f$ I) n6 Y! W, d1 D把该打的补丁都给打了(yum update)
: k4 L3 i! n/ Y1 |+ G2 V0 j完了之后,咱们安装一些基础的组件和环境。
0 o/ m8 b' |! Y% B6 HYum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel* N. A; z/ \4 w3 p9 q  S
如果有些组件提示没找到,无所谓。继续往下。
' _, t7 K) ]  f1 b& I5 m, F我编译安装的第一个版本是cmangos。
+ P) o$ d9 [6 [5 u6 I这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。
, t% K/ u$ _# G; ~) [1 D  pcmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
5 D6 q5 H# a4 n编译参数中:& z& i3 ]6 ~1 f9 Y1 K
DCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。+ c2 z1 F5 B' h: C/ K: _) @0 w
DBUILD_EXTRACTORS是指是否安装地图提取工具
0 q. B# p! h7 E" i- z7 t) \DBUILD_PLAYERBOT是指是否打开机器人% g7 h, G3 @$ G3 c( W3 _* s0 p
这里我做科普2:" x, [( Z3 y1 l% F  _" V
首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。; f; W9 {" C4 F
既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。
1 X/ r3 p4 m) M. c, L7 S6 N至于那个机器人吗?那是个笑话,请自行忽略。
* p# [! u' C  u4 p, k$ V! E我们继续,我把整理好的搭建步骤列一个明细:
" k+ h2 ^, o  T$ O0 p7 N# @
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。; O$ ]+ ]) s' u4 p. Y
这中间,我把一些别人不会告诉你的关键步骤做科普3:+ H# Z2 T! j( t% ^) j; x
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)8 f) P6 I; u  n% t1 H5 s8 ?
放几个链接仅做Mark:
) v. |" |- B4 q7 E. MCmake3 安装6 I5 a# S, I& s3 D; a& \1 U( T9 [
https://blog.csdn.net/weixin_38883338/article/details/86408749
  M0 z, b7 {0 z' ]: {Gcc 6. t  ?- u" z: I7 h( z
https://blog.csdn.net/Al_xin/article/details/92438055
, B* K  r/ z$ y% q$ SACE6.3.3
/ T, a% Y8 T& I- |0 f0 lhttps://blog.csdn.net/u010587274/article/details/50965369# `( e: b5 |0 l+ Y5 U- e8 O) |- z
Git源码和数据库编译安装服务器
8 }; K1 Q" Z7 m5 h8 ogit clone git://github.com/cmangos/mangos-classic.git mangos
& ^" L/ G, ?) b3 c3 [0 Ogit clone git://github.com/cmangos/classic-db.git0 P4 r$ u: @. M
ACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
4 P$ B' ?+ n2 U" r- ^+ O1 O: j1 q我们来说一下服务器的配置。0 y  ?& B8 k) d7 Z& |( ]& h: h1 G
在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
9 v( n4 {& H3 `0 W7 `, r
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)( Z: P9 P- `7 P
有几个关键点,我整理如下:
1 l' R* L* {+ |: q+ C5 |& k" H
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。
    7 k7 {4 g% I. c& z7 U  w8 E
参数名称:
+ a+ O& F, D1 ]. x5 ^7 h/ L地图目录. k- `1 ~0 C0 S$ x; r/ d
DataDir = “../data”
% @- G% m6 p( c2 @日志目录8 Y7 d2 ~3 m0 y+ ^
LogsDir = “../logs”+ m  w- Z; Z/ z7 U* G: G. U
游戏欢迎语7 f% p  ]$ x1 Y- w
Motd= “游戏欢迎语”
) m' M9 T0 a7 }8 y" J3 y出生等级/ y2 j' ~0 s6 J5 @3 x8 ^
StartPlayerLevel = 1* i  j/ s" q, B. }( L; U! j
出生携带金钱1000G# \; }2 h" d0 {- n$ S; _6 [
StartPlayerMoney = 10000000
9 O: [: z+ G; |4 I& m杀怪经验5倍  [( [4 n6 x% S$ v: W+ x& C. P2 \
Rate.XP.Kill    = 5: k' l  O0 |; V" R8 Q2 n8 d
任务经验15倍# Q1 F7 @. K) Y. `2 ^- t7 Z
Rate.XP.Quest   = 15
5 c* w1 O( v' c探索地图10倍8 H: e& n# a4 g. p
Rate.XP.Explore = 106 M( D6 i9 X+ x/ F% i3 n+ p% h
数据库连接(应该有3-4条之多,按下面格式修改即可)! x( m' f; k5 p3 r
LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”5 p: P/ D- Y4 S" v# n8 O( M5 M. K
配置结束,就是启动。
( u' r$ ?& F7 l6 }; m% C因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。' ?0 e* R  ]8 w5 I5 B
我们需要开启如下端口:
2 ~; C3 N3 {6 ~) p  d$ r' T4 s  L8085,9600,3724% u3 y9 A8 b/ ]' }* e& K* x
把他们添加到你防火墙的白名单即可。% n# q6 `& C4 B6 |
(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)
8 h* Y9 B' B( }  r一些收尾工作:
% j9 g% W6 d/ Q; e3 h7 m+ ?
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。+ n% n! I# t$ M! s2 g

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

server.zip

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

database.zip

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

ACE-6.4.7.tar.gz

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

ACE-6.3.3.tar.gz

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

cmake-3.0.0.tar.gz

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

rarlinux-x64-5.0.0.tar.gz

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

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
# U, D5 B5 E  j1 U5 l2 x; o. ngit clone https://github.com/mangostwo/server.git
" r# ^9 Z6 X5 F1 D. wgit clone https://github.com/mangostwo/database.git+ {* ]: G/ m( w- s6 \+ I4 Q

; F% O, Y' e5 Z/ ^
  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' X4 n- S0 ~* ~' o8 j4 T
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils' }3 [. D0 a: }2 p5 i* J
  3. scl enable devtoolset-7 bash
    ! v" d1 x* E" p* Y4 o
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile; M2 U0 g& i- ~% m
  5. # 查看安装的包( h* B, d1 f/ W0 E
  6. scl -l # a* X) x1 F9 d2 B6 W$ e! X
  7. yum -y install rh-python35
    6 ]6 o9 ^$ [6 Y2 n  z
  8. scl enable rh-python35 bash6 w' A) s0 L2 o- S5 k0 ?
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    7 ^0 i( }* V* V0 }2 [/ n* g% |
  10. ; N" U; _7 a( b$ _! ^- Q) p" o
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz
    6 x! d4 H1 @  X  c
  2. tar -xvf ACE-6.3.3.tar.gz
    0 u( ?* P7 O7 N, n0 ?3 I
  3. vi /etc/profile0 P" C3 |, O4 u. b2 B
  4. #在文本尾部添加:
    0 W+ j) D+ O5 v  T
  5. export ACE_ROOT=/root/ACE_wrappers
    0 s5 q1 N: B5 b0 I
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH4 D0 s2 J9 |8 A$ V4 C
  7. vi /root/ACE_wrappers/ace/config.h" f4 i( ?. I; z+ a: X. f0 N8 `$ m
  8. #写入如下内容:/ e3 f' W) C( n+ q; x
  9. <code>#include "ace/config-linux.h"8 [* v  L- s& \3 S
  10. </code>; `  G& I4 g9 T& u3 ~
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU
    0 S+ _, |; a. [1 U
  12. 写入如下内容:
      L' @2 B$ |  ^- C/ z4 y
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>
    + A; c' k8 M1 ]1 i! l! l
  14. <code>INSTALL_PREFIX = /usr/local</code>( ?* [" p2 e6 z- y# B4 ^

  15. $ @& [9 I# M* {7 q* ?# F: Q
  16. chmod 775 -R /root/ACE_wrappers
    . ]) j- t/ T0 K3 i1 V; \, c. e% S
  17. cd /root/ACE_wrappers/
    2 k& b$ ~6 J( f% r0 i: K
  18. make/ K& f( d& U$ g
  19. make install
    ! h% e" a5 x& m) ]) N8 z: k. j5 U
复制代码
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 17:20:43 | 显示全部楼层
  1. wget -c https://raw.githubusercontent.com/mangostwo/server/master/linux/getmangos.sh && bash getmangos.sh
复制代码
  1. #!/bin/bash1 ~) m. b1 w' L  w) @
  2. ###############################################################################
    ! `3 e+ p2 k8 Z3 a! C& ~% ]- i/ b
  3. # MaNGOS Build Automation Script                                              #
    ' u1 e  p- |( o5 @3 O  z6 W
  4. # Written By: Ryan Ashley                                                     #( v5 \8 n5 c* f% O# ~6 H& S
  5. # Updated By: Cedric Servais                                                  #
    5 `  v5 U" _0 h4 h  H8 M1 o& H
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #; g0 |2 D- O1 f. E7 w/ d  y
  7. #                                                                             #3 y- v2 O/ ~8 ?" s+ M
  8. # This program is free software; you can redistribute it and/or modify        #& Y( o$ X  R( n; |- w) g
  9. # it under the terms of the GNU General Public License as published by        #2 d$ @4 y: w0 [& _7 ?
  10. # the Free Software Foundation; either version 2 of the License, or           #
    9 g3 r# t) K5 ]( c3 S; L9 i
  11. # (at your option) any later version.                                         #5 x: z4 Q9 \8 I) u" |
  12. #                                                                             #
    9 m) N* _, T; B, q5 s
  13. # This program is distributed in the hope that it will be useful,             #. L* S  u2 U( i- e3 F- Z2 r1 ^
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #& A8 |9 j: _0 l5 a: [
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #
    1 y& _, j  a0 l8 x- Z' T
  16. # GNU General Public License for more details.                                #
    ; B- k- C; f+ i( B3 H( O. C0 T
  17. #                                                                             #1 A2 r# R% T9 h( u2 J# |
  18. # You should have received a copy of the GNU General Public License           #$ p% z8 G6 Y/ f6 p4 H, c5 g" \
  19. # along with this program; if not, write to the Free Software                 ## [: r$ I5 ]4 x7 A9 T4 v, a: r
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #; f. ]% y" s/ ~+ D* }7 T) X
  21. ###############################################################################! H9 N, ]* U$ s" F( |* _- I
  22. 0 L6 {# l* C+ n% P; v( |1 z2 {( z
  23. # Global variables
    ; s8 `5 b2 l. O" e5 ^8 u
  24. DLGAPP="whiptail"
    ( c+ k% g: c* `+ z* d: N% O* T- c
  25. VERSION="2"" c" T# _9 ^  Y$ A9 T7 T
  26. ROOTPATH="$HOME"
    # ~( c$ g2 B1 P
  27. SRCPATH="$HOME/mangos/src"9 Y9 p' [- u* \+ ?  V1 y% X# I
  28. INSTPATH="$HOME/mangos"8 A( [5 a2 X" I
  29. DB_PREFIX="two"
    + e0 Z9 V( g3 D( X! {
  30. USER="mangos"
    6 h( V9 Z& R% {1 E! c
  31. P_SOAP="0"
    - }3 e) R- ^- j2 E
  32. P_DEBUG="0"# w- X3 L: ^; ?0 X
  33. P_STD_MALLOC="1"2 C5 W% b% s5 I, F  P. W
  34. P_ACE_EXTERNAL="1"9 P9 h- w- d' m  r4 }
  35. P_PGRESQL="0"
    % S) F: z3 V: F7 U" H  s
  36. P_TOOLS="0"
    8 [# M) h: ]% \3 U1 K' k
  37. P_SD3="1": G4 S6 L% O* J: Z% c
  38. P_ELUNA="1"1 w$ |% ?; l5 _' U  P( j
  39. P_BOTS="0"
    5 Q6 \; B& d$ R% U* {
  40. CMAKE_CMD="cmake"
    8 e  G, _0 {. A: d1 d1 X/ e
  41. 6 C: {1 R0 F) S' q- b1 V; |( d3 M
  42. / y0 L. ]5 m6 Q* A% \8 j, ]( @
  43. function UseCmake3()
    7 e0 x' R. B% W* p- C6 u2 ^- b
  44. {5 q# m: r$ x' _2 g" x
  45.     # set the command to cmake3 if its there
    1 Q# P' W4 M# v
  46.     which cmake31 V9 s# d- L6 c5 H
  47.     if [ $? -eq 0 ]; then
    / W% @9 y$ A$ B( Z7 M
  48.         CMAKE_CMD="cmake3"' F. @! e3 R- y1 ^4 _: [
  49.     fi, U: M& b$ b9 y
  50. }: X) T5 {; I0 D1 X
  51. 4 p5 s, w& b) Q5 \- C, V1 k
  52. # Function to test for dialog
    ( N8 m# I8 \5 \$ c1 G# K0 |* X$ C
  53. function UseDialog()
    4 @' a" `* N' O" p
  54. {
    * }5 i( C- q& F% K( i# A
  55.   # Search for dialog
    : b: B$ f: w# L, `) ^2 V
  56.   which dialog
    3 @( z1 a) u5 O# s9 U' ~
  57. # X% j& r" a8 G' s4 x
  58.   # See if dialog was found! T0 n! V. N* L, }0 `
  59.   if [ $? -eq 0 ]; then" u' v; J8 K; z% T$ P  x
  60.     DLGAPP="dialog"
    : l* |* }+ a: K
  61.   fi4 z5 w2 r, X* k
  62. }
    ! |7 x$ h) A3 L- h" k2 S; O) m

  63. " R/ k/ \! W1 g7 [: ~, C6 T
  64. # Function to test if the user is root or not
    ! N: m5 s0 i. @7 w. r% V' T$ t! E
  65. function CheckRoot()
    1 y, G# H/ w2 ^6 s$ t+ }- ^
  66. {; T7 v. }  h* Y: m9 J
  67.   if [ "$(id -u)" != "0" ]; then
    * h8 d5 {, m5 d& A8 D4 N
  68.       Log "This script can only be used as root!" 1
    5 G3 U, ?9 @* Q6 v
  69.       exit 1
    , x9 t6 U7 |; f8 F: P6 @2 l$ l  b1 x
  70.   else8 q- G5 Z$ x: P$ Y
  71.       Log "User is root, check passed" 0
    ' N, n! U; a& ?2 ]" ~4 W
  72.   fi0 @; h9 S" {3 z! ?4 D% g& `# b
  73. }+ P* k/ i* I2 K0 u& Z/ H
  74. * i1 P, f0 r1 g, n) ?) B1 p
  75. # Function to detect the repos
    , P* p0 z% `# D: z& H9 v. i
  76. function DetectLocalRepo()
      b( V" f: F; _  l% b, D' ~
  77. {
    3 c5 |. P6 g. ^5 D2 G0 _
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"7 }/ ], m* ]! i0 k& C/ K6 ]
  79. 6 {3 X9 n, C5 O, N* h  t; D3 |3 t
  80.   # First see if the Windows stuff is in place7 [: Y* [' _, V( f
  81.   if [ ! -d ../win ]; then
    4 M% C( `/ Z8 P* \1 H
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0
    ; ]+ t2 ^. v* s+ R+ b
  83.     return 0
    ' ]( q% j" h  X4 H& l  W
  84.   fi
    1 I5 I. S3 R2 ?# M2 r0 y
  85.   V+ I8 q. p" @$ F9 [
  86.   # See if the sources dircetory exists
    * ?' n/ H9 k" F! X& R
  87.   if [ ! -d ../src ]; then
    , n4 k) f- K% s+ c3 j7 x5 T# F$ l
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 0+ }  i) R6 N; c. ]/ Z
  89.     return 0
    1 @0 A, D! }% `9 H% m8 T3 T
  90.   fi, Q# v" z8 z3 e# |- S% C1 w- r
  91. ; k; ?! m3 e, J# {9 A( u* O0 _( y
  92.   # Check for the CMake directory
    ; R% B4 D) S9 q5 K+ _( u2 X
  93.   if [ ! -d ../cmake ]; then
    ' h( m$ w5 w6 M4 }' g
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 0- D# m9 ]( \! |; {8 V3 N0 c
  95.     return 0
    3 E3 U: V8 Z/ N# Y- w
  96.   fi9 s" F# P9 _, W& {0 N! y& N
  97. 5 B6 ]" Z" j) ~  D1 c) P7 o
  98.   # Set the default paths based on the current location' Y* a+ M' J& z+ f; a) X
  99.   SRCPATH=$( dirname $CUR_DIR )
    ( L; W4 p6 u) |$ R* C1 T0 \5 J1 D
  100.   SRCPATH=$( dirname $SRCPATH )) v3 B. C' D9 ^) S( D

  101. 6 ~# Q0 \7 S; u6 Q( c
  102.   # Log the detected path
    0 V& Z4 D" H9 V+ S6 o' E
  103.   Log "Detected cloned repository in $SRCPATH" 0% i  O8 V2 [; v( I( }/ `
  104. }8 u" N" I. G* g- l: a

  105. 7 q9 W* \6 U/ m+ i5 d4 e3 m8 f) p# i

  106. ) ~7 e2 n1 z/ s) r

  107. - W: d. w' q. z
  108. # Function to log results
    2 x9 J1 |4 |& F- G; O+ e
  109. function Log()$ E) Y; g* I0 P  b6 |
  110. {
    ( _  `$ @4 X9 L, V! B
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )6 E2 I" b) k+ O0 H7 J. z: c2 ]
  112. 1 D4 E9 `* D' C
  113.   # Check the number of parameters0 ]: f  d9 r# l5 ]7 t2 |. s. ], `. |
  114.   if [ $# -ne 2 ]; then
    , {; H5 g# L8 y" S
  115.     echo "Logging usage: Log <message> <echo flag>"7 e1 `, U1 z$ ^
  116.     return 1
    # m/ D  S) h$ t+ a* L
  117.   fi
    $ j1 Y) N) ?' p( F3 n) r

  118. ) h+ F% q! T. @3 Q2 V' u* Q
  119.   # Echo to the console if requested5 O/ L) D! `( I+ @. o
  120.   if [ $2 -eq 1 ]; then4 s4 }  s) @/ _2 r* K
  121.     echo "$1"' O$ s; k7 z/ ]
  122.   fi& k9 j7 n1 p! k6 V! Z1 ~+ B
  123. ( u' T6 X2 N9 i' G) R% j9 k
  124.   # Append the string to the log% D4 i" h" V$ Z: i. f, H$ z5 F
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log+ q9 f7 M0 N0 G" B4 D
  126. }' W2 B# ?$ n: h' s* }5 [
  127. 1 M0 |+ X9 L" S& k3 M% I' W2 s! C
  128. 3 d6 Z4 x7 u$ ~  |/ [4 R+ _, ]
  129.   r$ j- h' g/ G2 [. C
  130. # Function to install prerequisite libraries
    7 i$ J' V/ i+ t- b' b
  131. function GetPrerequisites(). A" I$ ?: _* f/ o# f. N6 M4 Z
  132. {9 H. g6 c; i4 g- j
  133.   # First, we need to check the installer.
      a  E6 m* B+ g& ]. T9 U1 L5 o
  134.   installer=0/ W) _& w" O1 B$ Y7 v+ J: z

  135. ( C! I  E# i1 I6 H
  136.   which apt-get, i0 b  M+ x# r8 y  ~# Z
  137. , e" J6 e0 w$ T6 D3 _
  138.   if [ $? -ne 0 ]; then
    " N! \# W+ P0 n# p% D4 N$ b
  139.     Log "apt-get isn't the installer by default" 1
    & [9 [6 O6 b. Q# D& E$ t  y& v' A
  140.   else+ Q8 I; n. s+ h% i; L$ c" ?
  141.     installer=1
    * K1 ~% R; N8 u5 ~% o2 t7 O3 k& a
  142.   # On a fresh OS boot (EC2) libace was not found without first updating
    & _. |3 y, e/ P; B
  143.     apt-get update -y && apt-get -y install git lsb-release curl
    . L; M* S5 h( n' p+ b# q0 `
  144.   fi3 M  Z" w/ {3 \$ W3 |5 _

  145. 3 t6 }; f) ]$ A0 g8 A3 Y, T
  146.   which yum% l& U% L; Y6 Q; c- b" W

  147. " m# z( `. t5 b. T7 G
  148.   if [ $? -ne 0 ]; then" A% H) _* `, S2 D, L! L
  149.     Log "yum isn't the installer by default" 1
    4 u" l* N7 k  _6 ~1 L0 W
  150.   else
    8 Q6 p" V& I8 ^5 Q. A
  151.     installer=1
    , L% h+ q4 y/ w' m2 R9 _3 G
  152.     yum -y install git redhat-lsb curl
    ( g6 ^' j' u. ^( ]1 C0 M: P
  153.   fi3 |1 S* D( O( ]' ?4 A" `
  154. ! T" @1 @$ N; c) u
  155.   which aptitude
    # a. y6 O; W+ x, I& m, Z' B
  156.   if [ $? -ne 0 ]; then
    ' ?% w! P4 m; @% T: V1 c9 D$ |
  157.     Log "aptitude isn't the installer by default" 1
      }$ v5 x5 N* \2 Z
  158.   else  P! t% q- |6 a; [" H
  159.     installer=1* i$ V" C5 C0 R: |5 j- p
  160.     aptitude -y install git lsb-release curl; W. S6 O& m$ a3 ~/ {
  161.   fi! U/ N( u( p% D) E! s4 d! e. k
  162. , V. @7 l) u$ N6 t; j$ T% ~1 N
  163.   # Then, let's check that we have the necessary tools to define the OS version.
    & F8 M/ x" m1 t7 F
  164.   which lsb_release3 F  [; m: e& H# F) F
  165. - o6 t* z& C3 h& }. r4 }  J
  166.   if [ $? -ne 0 ]; then* }# Z' I5 [/ X7 e3 q9 n) [
  167.     Log "Cannot define your OS distribution and version." 1" ~2 n9 w2 C( C* B* Q5 k* P
  168.     return 0- C" ?% [0 v/ i/ Y2 h
  169.   fi, M  z, a/ M, l/ k

  170. 6 e- X) s' y2 p$ h% ~7 k5 v3 z6 Q
  171.   local OS=$(lsb_release -si)1 L0 }7 L7 {8 q* O& k0 P
  172.   local VER=$(lsb_release -sc)7 D9 B7 d4 F5 I! t% Y
  173.   local OS_VER=1
    " Y$ {* k5 ]+ Q; ^$ U# C
  174. ! Z+ ], R0 x4 v, _8 T
  175.   # Ask the user to continue
    : X! G9 o5 U  z' E7 o; j
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    - Z2 l, S; T6 _* V# D
  177.     --yesno "Would you like to install the required build and development packages?" 8 60
    2 u  M9 B/ C! I& W! u; l, b+ ]
  178. " v+ r2 a; G. Q& a& ]$ L3 c6 G- t
  179.   # Check the user's response
      j) i& F/ c6 R; l7 P2 Z4 s* v
  180.   if [ $? -ne 0 ]; then( i) i5 r. K3 v; R0 K% i5 n
  181.     Log "User declined to install required tools and development libraries." 1+ H; l3 L6 k* m' m" K7 L
  182.     return 05 a4 m+ m) p, ~4 ^: N! y
  183.   fi, n- U( j7 x- W5 J8 Q

  184. ' p( G: L  s; Z$ m/ O: m. b4 G/ A
  185.   # Inform the user of the need for root access
    $ l- ^; H0 E, n" K) S8 D
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    ! a" O3 V9 r6 ~+ i. y5 O
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    6 ~& s/ |5 P: o9 t

  188. 6 Q- E0 r7 Q4 Q; S3 x
  189.   # Check the user's response
    ; k, t8 @' @+ P9 h
  190.   if [ $? -ne 0 ]; then
      r# Z+ F4 Z6 [+ l) C
  191.     Log "User declined to proved root access for package installation." 1
    5 {# a( m: [. p8 Z  p
  192.     return 02 d+ [, `& V0 i7 ~. k
  193.   fi: T  `( f, S( x5 O0 |

  194. 5 W2 Z( A' @) W" o& v
  195.   # Handle OS* |& R" d2 \1 g1 I0 n8 u- X* \
  196.   case ${OS} in$ ~- I0 {: K' o7 v1 @# P
  197.     "LinuxMint")
    " U4 ?+ \, A  o( v
  198.       case ${VER} in
    $ R- S: O. M. d4 i
  199.         "sarah")
    9 ~1 x2 t8 i1 c' v
  200.           # Linux Mint 18 - Ubuntu Xenial based
    ' J. ]! q* u5 X$ _1 N
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    . ~6 _  W) U8 l/ W) @3 d
  202.           ;;; l$ Q# m" P$ p( K  f: ~
  203.         "rosa")3 z3 c7 z; J1 A
  204.           # Linux Mint 17.3 - Ubuntu Trusty based
    : F6 O+ _! y$ g, K$ |
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root0 c9 w* }  a+ _+ F9 Q- y
  206.           ;;
    $ Q  [2 x; p4 @$ U5 M1 D# m
  207.         "rafaela"). w! h1 y! N$ u! H7 T& Q! t& @
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    ( v6 F6 }5 E" F+ g
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    - e( O* A" L" x$ c6 m
  210.           ;;
    ; Q, q3 U3 s  [, \) _: `
  211.         "rebecca")
    . S% R, F& q- P/ W. v( J
  212.           # Linux Mint 17.1 - Ubuntu Trusty based* r% G' m  Z; N) v" d2 g) T
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root* O" D" w- E- X) Z" g
  214.           ;;
    4 D" |+ x6 H! C# U$ I
  215.         "qiana")
      ]" x# d( h* y/ A* ]" T
  216.           # Linux Mint 17 - Ubuntu Trusty based% r9 [" |0 i! M$ ^2 h
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    2 l1 `" H8 `2 h: A' H- H
  218.           ;;
    ' T" ^# ^7 o' X- o/ }1 x( j
  219.         "maya")3 I# Q. `; d3 |4 V8 u1 ~
  220.           # Linux Mint 13 - Ubuntu Precise based) ]; F+ D/ v9 C/ e9 c, W8 @! l: c
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    7 r9 w: c. d" v3 I/ C% h  p# t
  222.           ;;
    ' K- [* n# K) w& v  A5 y, C: K, ]
  223.         "betsy")
    : L5 D, [* H. F" n1 `# W
  224.           # LMDE 2 - Debian Jessie based
    " G, n+ H: R& x/ \4 [8 X' h
  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: k! A7 j  g  T. y8 `' A) f1 A* P
  226.           ;;
    1 ^. b% e8 Q9 q  K# {+ G% g) F
  227.         *)0 d; f- P& @4 G* I5 Z' `: ]* c
  228.           OS_VER=0
    ! j" d& i' x: H( b+ ~: ~
  229.           ;;  }8 a0 F: ~! Q0 b6 ?4 O3 d+ ~
  230.       esac
    ' Q5 \5 y, T( U# [6 c
  231.       ;;
    ! F1 b' X9 Q: n
  232.     "Ubuntu")# H1 \) }1 y: [% z+ a6 Y$ h# ~
  233.       case ${VER} in& O3 s8 `2 [: m  u1 v5 j
  234.         "precise")( f  w1 R  u( ?" t1 \
  235.           # Ubuntu 12.04 LTS
    9 c0 m6 M! F* g& K1 ?+ e7 c
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root$ ~6 }, i4 M& w4 n! T
  237.           ;;. z7 R& @1 z7 `& J5 W; ]
  238.         "trusty")
    0 B# g0 H# f9 |. n% u  e: ^
  239.           # Ubuntu 14.04 LTS
    : ?2 o* Y3 _; |
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root+ Z' t' ^' j' x3 x
  241.           ;;! H  J8 s, o+ W, G/ \
  242.         "xenial")" a0 R' s/ a2 n- p' X5 _( `$ H
  243.           # Ubuntu 16.04 LTS( v4 x7 w2 k$ H" @2 C) A% T
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ! m+ J! A" P( ~
  245.           ;;5 S& b5 w+ D3 e
  246.         "yakkety")
    , Y: Y/ G6 Y) v3 X1 |
  247.           # Ubuntu 16.10
    & A, n! p0 l5 S) o  l
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    2 s4 B$ s4 B& Y
  249.           ;;
    * o# o- X9 t! G/ M* l
  250.     "zesty")* z4 J; @3 K7 D/ t7 v1 t
  251.       # Ubuntu 17.047 Y8 o: y; g. R
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root; Z1 [  q4 I6 X9 s1 m! x3 r5 q
  253.       ;;
    ! T* |9 F0 ~! ?. u3 \/ p
  254.     "artful")
    * o) b8 e7 r5 l! l6 i$ e0 H& I
  255.       # Ubuntu 17.10
    " z& f4 G3 [9 Q5 k9 q+ r% k
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root6 j* m! Y! r" H
  257.       ;;7 K3 _& w- f' u  R, v5 X
  258.     "bionic")
    & _, T/ I+ a1 c$ q" u* b
  259.       # Ubuntu 18.04 LTS
    8 [# g8 A' T, l* b3 I; V' O
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    , _+ }" n, c6 W$ E. |& v9 o
  261.       ;;7 l3 A( u1 g" m/ O" u0 }
  262.     "disco")
    6 R3 V, q  I. N+ {
  263.       # Ubuntu 19.04
    3 _& R5 E* f' u
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
      [- l" Q5 w; A8 z1 }+ ~2 r
  265.       ;;
    " k. O/ A3 Y2 c# u
  266.     "focal")
    3 ^. r" O5 y6 a# M, j- F
  267.       # Ubuntu 20.048 R! E0 J' @  L% J  D0 Q# c
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    1 q) j2 P3 k! N. l5 n- b" U! P
  269.       ;;
    7 f5 f* l, _) b
  270.         *)
    - a  R' v2 w- A8 _: N+ Y" B) F
  271.           OS_VER=0+ g# n/ g% R8 S& ?; O
  272.           ;;
    & K1 f! _7 C# e5 l1 Q
  273.       esac
    0 W1 K  h/ Z! X+ c
  274.       ;;
    ' E) t- H& ?8 f
  275.     "Debian")  O3 _9 ~& Z7 A
  276.       case ${VER} in
    5 g6 i9 {! Q) d4 E* P$ d' S
  277.         "jessie")/ ^& \( Q) O/ P8 v, H/ b
  278.           # Debian 8.0 "current"
    1 g0 X. }) G  y, X8 k/ H8 z, N# X
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    " S: g* Z& i  a+ J1 J
  280.           ;;
    - k) E  `) [/ Q% I9 _' z
  281.         "stretch")
    8 @  a! r' `& B, m2 [
  282.           # Debian Next
    3 ^4 h5 z3 X( o3 W1 V& |
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    , o5 G6 J6 f. A# Z' q: b& J
  284.           ;;; _0 _9 `* x- F8 X3 L+ h6 W
  285.         *)
    2 c; X* Y2 m3 N9 v, U  Z
  286.           OS_VER=0
    ) s( s1 P. B6 i5 E0 Y
  287.           ;;
    : b8 k" k- s3 W
  288.       esac4 m9 `9 v: d/ ^- d8 K3 m" o. q7 |
  289.       ;;
    5 D! a7 M% [4 `8 V/ J6 B
  290.     "RedHatEntrepriseServer")3 {9 L9 ]: D/ i9 ~3 j1 h: S
  291.       case ${VER} in
    9 d8 O* B; t, O/ f
  292.         "santiago")
    / A; S) O0 l: f6 O4 k5 k: ]  R
  293.           # Red Hat 6.x
    . Q. x1 x/ Q/ O* t6 g
  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
    5 Z. Z/ }5 o/ d* ^
  295.           ;;: n! q5 v% [9 W/ Y
  296.         "maipo")
    9 a1 R& r* a' {# J* x
  297.           # Red Hat 7.x
    # o1 t8 p5 c3 L& f7 b6 W7 Q
  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 C) P1 x; t9 [9 M
  299.           ;;: l. r8 b8 I4 x
  300.         *)
    # w3 o* v/ [. e% {$ N4 o: u
  301.           OS_VER=0& p2 f  I, [$ x5 y" e4 h1 G
  302.           ;;8 o7 x$ @) n! i  j5 m
  303.       esac
    + p7 [- a" K* J+ s
  304.       ;;
    2 U# V- m5 |# H- y* o7 n1 T5 [; b2 E
  305.     "CentOS")
    ( T' h. h( i! o! J! v7 s5 }
  306.       case ${VER} in, y2 C( }9 E* q; F6 a
  307.         "Core")
    1 U7 \( t- N0 n
  308.           # Default CentOS - Adding necessary RPM third-party., n7 u1 j+ ~; B" {- x, b
  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
    9 z/ p+ \: C$ f, A7 f& r
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm
    . A& R4 M, b: H, e  q) N! v
  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" O6 w; m& s- k* n4 z+ L, }
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm
    ) u9 g4 ^& I# B# d( g; S
  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
    " h# y" N7 ]0 h3 }
  314.           su -c "yum -y install epel-release"
    ( A# s1 c8 }1 d9 K
  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" root3 e$ y: c4 I  u" e' v7 G% i; G
  316.           ;;2 b; Y, I8 v* J8 m: ^5 p' g( E, @
  317.         *)
      g, o+ v/ o5 y& W7 H7 i
  318.           OS_VER=0, ~0 D+ W, Q6 a
  319.           ;;# t$ T0 l" e' O! }3 U
  320.       esac, i  d- \; Q% L$ D& o
  321.       ;;. z, T/ I, C- V& {
  322.     "Fedora"). V- m: j4 S: I9 r( W' o  q! y) D
  323.       case ${VER} in4 Y) u* i; l) i2 a6 c
  324.         "TwentyFive")
    2 X, j9 J/ E) Z+ s
  325.           # Fedora 25 - Adding necessary RPM third-party.
    8 Y8 P) b$ _' [) u3 c7 P6 N: L
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root: J3 q1 |, T3 m: M1 O
  327.           # Getting and building ACE. Not provided in RPM for Fedora...
    + k0 |! N$ g/ E. L+ w! j% c
  328.           rm -rf ACE-6.3.3.tar.bz2
    + A+ g$ v4 l8 _' ^
  329.           rm -rf ACE_wrappers
    + h( O+ j5 j; ?( f; `
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2
    * r" O! h3 }' q6 p: e9 U5 J! T
  331.           tar xjvf ACE-6.3.3.tar.bz2
    6 o2 C$ g2 v$ z. M$ G3 Q; N
  332.           export ACE_ROOT=/root/ACE_wrappers
    , E6 q* e+ B! f+ C7 F6 z
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h
    2 D6 m+ L. t2 p' l/ |  b) Y" ?
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU( X+ D) B2 F: n( m* t& m
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU' K/ M/ B; H+ b. r0 M: q! m/ ]
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    ) ~' A/ @/ O/ E: a+ v+ H# Y
  337.           CD $ACE_ROOT
    # {+ u9 Z- c0 D* o
  338.           make
    ) W7 y) I2 d" N4 W* _
  339.           make install
    ; g: }4 E0 C. }* S, P5 d
  340.           cd ~
    : F% y# h  q1 @% a- t9 r
  341.           # Installing remaining dependencies..* E5 \8 ^4 L; H5 D# |7 H3 o# x
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root2 U2 m' P! o1 k8 w- B) {$ h' _
  343.           ;;9 \$ Y8 t2 O* U2 R1 ^
  344.         *)
    ; n6 x/ O& h8 g" W/ g
  345.           OS_VER=0# C# u$ `$ T. b& G4 U
  346.           ;;/ X) }8 G* v3 J+ a! Q
  347.       esac
    ( ^+ m0 g; o: }: P
  348.       ;;
    ; P9 y; B3 k4 n* q5 E, _. P: H
  349.     *)& B, w& P$ X/ q4 E) S% K
  350.       OS_VER=0$ M: H2 f0 u; k! j
  351.       ;;
    9 L. G. u, x0 q$ V: ~7 I, a
  352.   esac
    * M5 A! P( P' d, n- }
  353. ; _8 G1 j' V- j; v0 D" I
  354.   # See if a supported OS was detected
    / L. H9 M3 `. T4 [
  355.   if [ ${OS_VER} -ne 0 ]; then
    . s$ Y) }& E; p3 q, ?2 y  c
  356.     # Log success7 `5 I/ I/ J0 C$ C+ q9 W* B
  357.     Log "The development tools and libraries have been installed!" 1  w/ Z7 n3 |% ^( F3 n
  358.   else
    * J: e- d( G, G& \4 ~3 k; _, H1 o
  359.     # Note the error7 {+ ?' u9 m9 e; m, g
  360.     Log "Could not identify the current OS. Nothing was installed." 1
    . b, \, \4 M$ Q" p# ]
  361.   fi/ |) D/ `5 \2 x: _
  362. }
      D, {5 u. f% @& Q$ L& u7 g
  363. 8 x% i; z2 g9 Q1 ~, \- a) T/ V
  364. 8 D! |: G2 k& G, Q

  365. 9 O" u3 q/ a1 x2 s
  366. # Function to get the WoW version
    ; f2 x  W+ C: e( Y5 Z  K' k
  367. function GetRelease()6 _* K) ]; ^/ S5 ~0 L- |3 }
  368. {# y4 [) f! ^- `. S  p  E
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    ! @( n% F/ [7 r2 V8 |! {& e
  370.     --menu "Select a version of WoW" 0 0 5 \
      e' C# o" r; J7 t
  371.     0 "Original Release (Vanilla)" \+ [' Z0 b8 f+ [
  372.     1 "The Burning Crusade" \
    ) w7 q" {. f/ V" F7 b
  373.     2 "Wrath of The Lich King" \
    1 t; }8 W. X2 ?2 U
  374.     3 "Cataclysm" \" Y; L2 o% r0 p6 a* H5 ^+ e
  375.     4 "Mists of Pandaria" \
    ' ~4 U3 P; B  u" r
  376.     5 "Warlords of Draenor" \, h4 _  q# K) \+ t! Q, y7 i3 \# J
  377.     3>&2 2>&1 1>&3)3 o: e- ?5 V7 F5 J9 Z

  378. 3 S3 X" u! S1 ~# Z# x! |# [
  379.   # Exit if cancelled
    " \5 L$ j) m8 Z0 S6 Q9 n- z/ ^
  380.   if [ $? -ne 0 ]; then
    4 X5 H+ A0 h6 E" m' B- D& j
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1
      _+ C2 i# F& P8 C2 M9 S
  382.     exit 0
    4 r1 K8 D2 ]# S8 M9 ?& s, N0 ^! B
  383.   fi8 u$ E7 g: R$ e
  384. ! {5 W4 Z' C8 m+ Z, L6 b
  385.   # Set some defaults based on the release
    , K$ d% R( L0 K: O- X2 S( o4 r8 H6 q
  386.   case "$VERSION" in; \; ]. L: t, J! e- x* u* y1 I  t- z
  387.     0)
    5 f1 Q! G: A0 h% Y% {! g0 u
  388.       SRCPATH="$ROOTPATH/zero/src"" e' z7 w1 b# s' ~" o( P  p& s
  389.       INSTPATH="$ROOTPATH/zero"# k. j% P4 k7 O
  390.       DB_PREFIX="zero"
    * c$ q1 K% F1 h
  391.       ;;2 Y: E, {1 }' Q$ _5 N4 U% Y

  392. 2 n2 u/ u4 a7 ~7 \, N
  393.     1)
    / R2 @1 s- {$ x& f: w8 x5 p
  394.       SRCPATH="$ROOTPATH/one/src"9 |9 h$ {& B* d3 Z# ?  C$ @
  395.       INSTPATH="$ROOTPATH/one"- U) ]0 L* S- {: O/ N# z, T" x; S
  396.       DB_PREFIX="one"
      {5 x# m4 {/ J6 V
  397.       ;;& r+ T$ m3 P: Q* s# [4 G

  398. 2 _- [( R7 r7 x, H# J/ O8 f+ H. i
  399.     2), b4 h5 t0 }  e# o) b
  400.       SRCPATH="$ROOTPATH/two/src"
    . X  d1 P. o. l9 ^6 q
  401.       INSTPATH="$ROOTPATH/two"
    0 f* B$ t! g9 {5 e5 t
  402.       DB_PREFIX="two"
    & c. n8 X9 H  D
  403.       ;;% \1 |& @9 h3 k# Q1 J

  404. * a- u- v: p* }! o( F6 E' G
  405.     3)
    ' Y, Z/ k9 Z1 |" @- a; `
  406.       SRCPATH="$ROOTPATH/three/src"
    5 c* X- t4 _: z' q6 L4 L* L9 X
  407.       INSTPATH="$ROOTPATH/three"6 J. `4 j+ n+ S4 h
  408.       DB_PREFIX="three"
    ' K8 ~% k( `% U" V1 d4 z
  409.       ;;
    9 ]. C3 o) z& V  D$ s

  410. . C0 s: T: T/ V0 K; B2 J3 ?) ~, w
  411.     4)
    ! r/ H* v* x/ V
  412.       SRCPATH="$ROOTPATH/four/src"" w! \8 g: X$ e$ h
  413.       INSTPATH="$ROOTPATH/four"! d; U$ V& `0 o% u
  414.       DB_PREFIX="four"8 j  G7 |, J/ g$ [) Y
  415.       ;;4 s* e4 A# G2 x' v" Q
  416.     5)0 G  e  _9 Y: y
  417.       SRCPATH="$ROOTPATH/five/src"
    , K+ P' b6 M9 K8 s) u& }3 U9 L
  418.       INSTPATH="$ROOTPATH/five"
    & q9 b8 t+ P% G
  419.       DB_PREFIX="five"2 z# n5 {( V4 ?" k$ }! Y% O
  420.       ;;( o8 q% m( }9 l  M7 |- q
  421.     *)5 S+ L# o- r5 S/ R& \( Y
  422.       Log "Error: Unknown version selected!" 1- z0 i* |1 W+ i, O
  423.       exit 12 `. z& ~) z! t  F# K) b1 ]" }
  424.       ;;
    ! j8 t9 C, ]$ d4 U6 @( |: M
  425.   esac- ]) {' L0 r6 a* Y

  426. 0 E  k, h. Q% O' F- x; A) @
  427.   # Now set the correct source path if the repo has been cloned already
    * Z. ~3 d( Z* R( @) \1 `
  428.   DetectLocalRepo
      F4 \/ C0 i9 E, B5 K( q: |
  429. }  ^- g; x- @1 l# |' E9 ^

  430. : V. v& i" T. g. B0 M2 ^4 [! |
  431. # Function to setup the technical user4 R1 i) Y4 I" g) |" y
  432. function GetUser()5 p  }) U# ^0 z/ c. Z" c
  433. {' Z' {3 I7 a. T; c* I
  434.   local TMPUSER="$USER": t* y& ]1 j. C# ~
  435.   Y& H. G- ?! x% t) C- C
  436.   # Set the user; D  l5 ~5 w0 y
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \# R2 z3 t+ |  O  k: q$ a! F+ s
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3): s7 y% n! m$ _4 K( v% I- W

  439. 1 f' a7 Y7 I: K# l7 N# m8 Z8 q! g* X
  440.   # Exit if cancelled
    # J8 Y8 ^* ^* T+ ?
  441.   if [ $? -ne 0 ]; then
    1 F" s7 q6 l9 Z% n; l
  442.     Log "User selection was cancelled. No changes have been made to your system." 1$ E* Q' x7 z% l: e- x  A9 ?
  443.     exit 0' z& q, ~) u: m3 o* b! e
  444.   fi
    ( `8 W: G8 K6 O$ v
  445. ( {4 Z( S3 b7 f& y4 y
  446.   # Change the user only if it was modified" r% [1 A! T" p. `/ K
  447.   if [ ! -z "$TMPUSER" ]; then
    ! H& t8 }  m% D
  448.     USER="$TMPUSER"
    * o: o8 ~1 B" k0 m+ {! d+ s
  449.   fi# L2 |* N2 S2 t6 A3 ~' H  q

  450. . }* C+ R+ @  A
  451.   # Validate user" Y# j6 h. v" ^1 ?7 f9 w) ^
  452.   id $USER > /dev/null 2>&1
    ; G& l" S( G! `2 s, [' S" r
  453.   if [ $? -ne 0 ]; then
    ! N' _3 a# D$ e- i. m( o2 Q
  454.     Log "Creating user: $USER" 1
    + _1 Y+ y; n1 _' J" _$ M+ e6 X
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    8 v) [9 h6 ]1 t  [8 V$ e
  456. 6 U9 F1 X7 T6 q8 h. v$ t' Q! e
  457.     if [ $? -ne 0 ]; then
    ! J0 \( ^, _7 }% `. w
  458.       Log "Error: Failed to create the specified user!" 1+ c* D) m% b1 q; Q" M6 |
  459.       exit 1
    8 {  t) I+ y  A; h6 g8 p
  460.     fi( r% \1 Z: ]' x- J; ^) F5 ]
  461. 4 T8 M, T1 R( m& r! Z- c6 F2 p/ b
  462.         usermod -L $USER > /dev/null 2>&1' f9 }: h3 q7 j, M) ~3 ~) W
  463.   else6 M7 O  _( w- ]* u2 F5 E% k0 V
  464.     # User already exist, asking to keep the user( C0 |$ u- t0 y9 o/ J9 {
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \4 [  I8 u1 Z4 f4 e. m
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60
    8 W  l- Z. D; X: G3 N# ~! j, K, k
  467. & C6 {) \. @1 m+ J. T( q
  468.     if [ $? -ne 0 ]; then
    4 j$ J& ~0 h/ H; j: w5 S, q
  469.       Log "Removing user: $USER" 1
    * X# W% K" D; \
  470.       userdel -r $USER > /dev/null 2>&1
    3 l" Q) m. E5 z: l$ A4 d+ Y! }
  471. ) k( B" T4 J2 {: |5 F# x6 C# }
  472.       Log "Creating user: $USER" 18 Q1 e$ @8 t7 K5 i2 t4 n
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1
    : ]) _" \; y" M4 S

  474. . Z) |  h+ u# x, s. Q  p
  475.       if [ $? -ne 0 ]; then9 n# [9 k$ ~+ N% }9 S! P' a
  476.         Log "Error: Failed to create the specified user!" 1
    " Y: U* s" J' [1 K+ b! m/ j
  477.         exit 1
    - @, P, v4 ]5 a( v
  478.       fi/ k2 n8 d8 |5 p; o" Q  K$ o
  479. ) P% B) T9 A4 W7 ]1 |. t' ~
  480.           usermod -L $USER > /dev/null 2>&1, O! r7 s  S* ~2 Z" ?5 p1 P9 n9 N
  481.     fi
    + \5 L6 u% f+ }
  482.   fi
    , N! }1 i/ V  B

  483. % G9 r: D. P6 ^2 K; _! J0 P
  484.   ROOTPATH="/home/"$USER
    6 `3 b$ Z4 A* g% S0 T* z; s* y2 ^
  485.   Log "User: $USER" 0
    % L+ W: V6 ^9 t0 ^7 f( P
  486. }9 B- M  p& W) t- c* \  T
  487. , `8 }9 ]$ Z. s5 X, v$ C
  488. # Function to get the source and installation paths
    5 V" N% L& @5 }' o0 r. k, a& [! w
  489. function GetPaths()5 n9 h) m( _; R" ?# W3 \
  490. {
    + c1 Q. m0 S- G: ?; x
  491.   local TMPPATH="$HOME"6 B% u4 u, N8 v$ u
  492. - G7 s9 U& Q3 k* F& G3 ^/ g
  493.   # Set the source path: {/ B# M% l" y1 H" b
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \& l2 P1 @$ a5 J) H/ |# |8 j4 X, _; o
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)
    / L7 e1 ~2 W  O4 r# C5 {" P; J9 B

  496. % Q0 _% g- _+ ^9 i9 W
  497.   # Exit if cancelled
    9 Q8 C4 X' x2 g# H7 x9 ?
  498.   if [ $? -ne 0 ]; then1 b# _2 o1 a$ t( j4 {1 i! W3 C
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1
    / Y( k# t) v0 ~, ^) o
  500.     exit 0
    / d' \. {$ x" p# C# K% E) J" [& T
  501.   fi! n/ i" D* o. I1 J; t% ^
  502. 2 s+ c3 I+ H" H$ v- O* g! ^/ v
  503.   # Change the path only if it was modified, U4 R9 b3 h3 g4 [
  504.   if [ ! -z "$TMPPATH" ]; then8 Y5 c( y, l; Z! r' v1 x4 s; ~
  505.     SRCPATH="$TMPPATH": a* K/ M. V! v- w( w
  506.   fi9 R( m, y7 A  s; j
  507. + ~7 \/ w* `. `* Y( M& [# `9 i
  508.   # Validate source path
    ; Q6 t0 U2 t( E* l; o9 e2 y
  509.   if [ ! -d "$SRCPATH" ]; then3 j1 b) t# s4 V# c* u: M) b
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    - Y- p$ R9 w% z2 s7 h1 ~' {
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60
    ; y' e4 \$ q# u) ~" j
  512. , ], V8 B4 Q9 e) C
  513.     if [ $? -eq 0 ]; then
    ) Y: B4 Z0 Y: r* p  M) n/ Q/ ~. `
  514.       Log "Creating source path: $SRCPATH" 1
    1 P- S: Z* R9 p) n
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    ; ^9 |. I6 U  v7 h: G# J3 v

  516. 1 ]) R( G+ q6 P4 o
  517.       # Check to see if the directory was created
    * c5 y& D: n. _/ u6 Q1 r
  518.       if [ $? -ne 0 ]; then3 s% }" f1 [2 }5 r
  519.         Log "Error: Failed to create the specified source-code directory!" 1
    6 Z1 U& r! R! a: Q1 v0 ~
  520.         exit 1
    / ]% d# H7 z& W- k8 B
  521.       fi" `. O. m7 ?; P5 ]
  522.     else
    % M" o3 |0 c/ K3 G, R
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1
    & w$ v2 G7 m( B2 T6 y
  524.       exit 0/ ~. q4 m  N$ }7 n8 L$ ^! C
  525.     fi3 Y, O* v, O; s) \
  526.   else
    : q+ Y: k9 H2 P  Y, P
  527.     # Check for old sources# Y: s1 L9 v; _" |! c5 x& a; o
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then. c5 _" Q' G* Y3 i
  529.       # Ask to remove the old sources
    * k7 ]& s& N9 w2 |/ c
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \2 \' d- Y  t5 g8 M: F
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60  Q% \- d! C$ ^' U3 l3 O6 M: M1 ^& V
  532. $ S. E( S5 f2 U. A0 w
  533.       # Remove the old sources if requested; i8 v7 r. u- J( y6 m& I
  534.       if [ $? -eq 0 ]; then
    1 d, ?! k( C  [3 s
  535.         Log "Removing old sources from: $SRCPATH/*" 1
    7 p( ]! D+ K1 Z) T
  536.         rm -rf $SRCPATH/*
    ; E$ K# ^" o% K7 l
  537.   ^& s- {# W9 g" [
  538.         # Check for removal failure
    , o; m; b  T( e9 R1 y: f+ S. y
  539.         if [ $? -ne 0 ]; then  y  G, i6 z* \7 @
  540.           Log "Error: Failed to remove old sources!" 1  u& e  @) D1 b9 h9 S) A2 g
  541.           exit 1
    ( u, z3 s. d% R* |: M% s+ _
  542.         fi
    1 K: Q( `5 j, ]" v
  543.       fi
    5 k# U, l: F& O/ b7 R
  544.     fi
    - O9 M5 }: ^4 i$ }2 F
  545.   fi' f; Y' _. s8 y% E& Q& R1 O
  546. 6 f2 E9 B+ T: u9 {- K9 i! K# R
  547.   # Set the installation path
    1 [' y; E* }2 z
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \3 p2 A3 |. t: o. [
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    : s& c4 z4 B3 B& k7 {- \- b1 m$ l
  550. 5 k9 ?) d2 R! f8 q- |) O' W
  551.   # Exit if cancelled0 F/ A; r  F" C7 c' E
  552.   if [ $? -ne 0 ]; then
    - D2 L  j2 ?7 j% J7 \: Q
  553.     Log "Install path selection cancelled. Only the source path has been created." 1
    5 }8 Y3 P; C4 d7 ~5 [' Q" Y. _
  554.     exit 0, j; ~6 P2 ?( a+ h
  555.   fi7 Z& \/ A1 `9 E9 Z" {

  556. ; `( P4 o3 ^1 r9 I2 N1 i
  557.   # Change the path only if it was modified
    : L+ v' F! ?$ L7 e9 P
  558.   if [ ! -z "$TMPPATH" ]; then
    ! C, m# c: {. ^' q; [, [
  559.     INSTPATH="$TMPPATH"
    ' s0 w% ~" n) D- I  e3 O
  560.   fi
    1 N2 o- M5 q$ o) K

  561. ! U' y! M( z# M* b' Q8 @: M; a
  562.   # Validate install path
    " C, ^1 A4 ~% l7 o- Z2 H4 y" E+ s. [
  563.   if [ ! -d "$INSTPATH" ]; then
    5 w: F( t+ l% |0 U3 n
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    1 I8 V) R+ U' L) U6 u3 B2 U2 w' ~! F
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    ; K+ G$ @% `4 F

  566. + h8 [3 j1 Q) X5 P; M6 N5 D1 l
  567.     if [ $? -eq 0 ];then( }! }: H/ d3 B' j" t6 c
  568.       Log "Creating install path: $INSTPATH" 1
    & u# @7 @& w# t0 q, I
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
    ; w# z# ^$ J3 w% z
  570.   }, ?4 r& v8 {& w
  571.       # Check to see if the directory was created
    8 [7 g5 t* l2 I5 D/ ^5 K
  572.       if [ $? -ne 0 ]; then, H$ p8 O* t2 O
  573.         Log "Error: Failed to create the specified installation directory!" 16 A6 b0 B% w" `1 E& Q; N5 x. H
  574.         exit 1# W9 a5 w1 b7 f& C; _
  575.       fi
    9 k6 R  l1 i! }' j' ?+ n
  576.     else
    7 b0 P2 x3 K3 [& L2 E4 X2 x
  577.       Log "Install path creation cancelled. Only the source path has been created."
    * z( M& H6 M; [: ~- L  H
  578.       exit 0
    ; J" K" l% b& c& g4 I, s4 X, ?
  579.     fi' T$ o6 Q# p! g0 N7 {
  580.   else
    5 X# ?2 h! o$ ~2 `/ x. ^; Q# a- c$ S
  581.     # Check for an old installation4 i  I% B5 i* b3 y  i0 }3 Z
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then& v$ v  e- `3 u9 N* }

  583. ; h$ L: @$ V5 O& Z! I* z
  584.       # Ask to remove the old installation) c7 K; ?, D% I0 w& O
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    % o7 {! _7 `9 b2 E3 V+ n) F
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 0
    * H6 y+ `1 ^% k3 M- k; B
  587. . h: W6 @9 B7 p- u; U( ?
  588.       # Check the user's response
    ) X' D8 ]1 c0 R2 j# k* l
  589.       if [ $? -eq 0 ]; then8 c! ]0 T( v  V& A
  590.         Log "Removing old MaNGOS installation..." 13 c, a# c8 E, ~8 j' u1 e
  591. % p: g% O9 [* a# y7 p4 `, |! @4 G
  592.         # Clean up the binaries
    7 v% E) x) x  z$ K7 U  o
  593.         if [ -d "$INSTPATH/bin" ]; then* q( q/ v! ~/ p- c4 H- @) [- C
  594.           rm -rf $INSTPATH/bin; t6 P% a' f# r2 M$ i
  595.         fi1 U& h. v* T3 W$ l

  596. $ @+ [$ @5 s. e6 O5 a4 O
  597.         # Clean up the old includes9 c$ O3 h, V1 q1 E- E
  598.         if [ -d "$INSTPATH/include" ]; then9 F- C6 N7 }2 f1 F8 N2 v0 g+ s& [7 _
  599.           rm -rf $INSTPATH/include/ f# b3 ~& {7 G2 k
  600.         fi  R) t8 f) |: D5 _% y( w' Y) o

  601. - a0 X# w' F& a! B! A. |8 d; |
  602.         # Clean up the library files
    * Z- F; m9 l( }9 ]: q2 N
  603.         if [ -d "$INSTPATH/lib" ]; then1 E2 @. A0 |0 F, _0 a+ T$ V
  604.           rm -rf $INSTPATH/lib6 G$ V' c7 E2 X- [% W- }; L
  605.         fi
    + U2 k9 ^. j' A

  606. / z. {* o3 B4 ^9 D- L$ S
  607.         # Clean up the old logs
    1 n( ^# T' t) m) S  f
  608.         if [ -d "$INSTPATH/logs" ]; then
    ( L6 i  t7 E! v) v0 O+ j
  609.           rm -rf $INSTPATH/logs/*+ X4 {4 }. A# R0 C, ?
  610.         fi
    " [' W6 m: K7 T. U
  611.       fi/ K2 \; I; ?& T' z2 V
  612.     fi  H1 \/ U+ I5 P! |4 y1 u# Z
  613.   fi
    - k# I& D5 e; F. \/ k  C

  614. * M% d% c, X% `* S5 E
  615.   # Log the settings
    4 V9 ]% _" x# q. g  Y, [
  616.   Log "Install path: $INSTPATH" 0
    6 g/ _+ t; ~! ]5 {) N
  617.   Log "Source path: $SRCPATH" 08 u4 z* C+ V7 r& q& l- M
  618. }
    , d$ T, Q2 o/ b  d9 A
  619. 0 l# p( z; J& a

  620. ; {- h$ i6 I8 ~+ @7 Q2 t  W5 [4 w

  621. 6 Q& K& B2 X  `- n
  622. # Function to clone or update sources
    9 \+ C( P. _4 \8 P" Q2 w
  623. function GetMangos()! Y' [& l% @& z) X# Y8 u, m* M
  624. {
    + R. S+ f" ]2 S3 ?
  625.   local CLONE="0"
    ) N, f3 b% V$ Q! ?9 Z2 H. ?9 u
  626.   local BRANCH=""* G5 T' l( s( ~0 K, @0 U8 z- }+ \$ R
  627.   W: v3 R2 L; T- A+ G( T0 D
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \- x% E  e/ Q5 o4 Y1 z
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \
    0 I3 M+ ?. U9 Y, ?( Q7 b
  630.     0 "Clone a fresh copy of MaNGOS" \! ]/ H# y( j; \9 `
  631.     1 "Update your existing copy of MaNGOS" \4 y9 m9 f! X' y$ H  p1 ]$ J, l
  632.     2 "Use existing copy" \
    2 V) A; k' u2 y# D7 v" o, Y
  633.     3>&2 2>&1 1>&3)
    / {% T$ I6 H& O9 I3 W- e8 I4 P
  634. 4 p8 r! t* ]7 T' j4 V
  635.   # Exit if cancelled
    " f! E  f6 j! S
  636.   if [ $? -ne 0 ]; then
    + h  {  V7 c) v) ^% U: J+ `! W
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 19 U, Z( `' @2 k3 p( B
  638.     exit 0. j( F& B9 z2 |4 ~
  639.   fi
    $ z1 r7 L0 t4 [
  640. 3 ]/ O/ P& b+ Z8 \4 {
  641.   # Clone from scratch if selected
      P* z) C+ g: {+ c) Y9 A
  642.   if [[ $CLONE = *0* ]]; then0 S) g0 T! v, K" _$ n
  643.     # Pull a different branch?/ v1 D/ F0 j! ]' Z
  644.     case "$VERSION" in. z$ Q, a7 E8 ^# ^' H1 E
  645.       0)  r4 h; {9 @: ?6 D( V0 v
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')7 ]9 z) \% O% o  d
  647.         ;;! t: O1 V4 a3 }, H5 Q
  648.       1)
    : t2 C6 k& U% ~8 @- q
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')! Q/ |" G$ c( P5 O1 a* u
  650.         ;;
    + Z3 g$ W# Q, q2 [, e
  651.       2): r) j# d) H7 }: }
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')$ e7 k4 {6 a( T" N! \' G" W& X5 k( N
  653.         ;;( K, q/ r' M$ T
  654.       3)
    ' g% |4 T: d& C' y4 n! `
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    9 L: ~$ I4 L7 v8 m! \" ?
  656.         ;;* d- J! @! f" b1 m  r
  657.       4)
    5 h$ V& H8 u* U6 M! x9 F0 `- @
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')8 a& Z" ?$ R5 l$ I
  659.         ;;  G" o8 G: m  @2 p
  660.       *)
    ! M3 `& Z: f& c$ ]9 e0 y
  661.         Log "Error: Unknown version to select branch" 1
    ( C2 |1 Q, u9 a4 P
  662.         ;;0 l4 s+ M) ^" V6 h% r
  663.     esac+ z; m9 o" B# ~& b+ m

  664. * W3 m7 q+ Z, n: |7 l
  665.     COUNTER=18 y) Q% L4 c/ P+ \
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog
    ! S* C: B; P1 Y/ a( H, l
  667.     for i in $releases; do
    * {. V1 ~/ Q5 ?# h* i
  668.       if [ $COUNTER -eq 1 ]; then* l' _9 L3 L7 o- q" T
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "
    , E5 ~7 B- k/ `& \3 P5 {
  670.         BRANCH=$i5 L: S4 u) k7 t
  671.       else
    8 [$ m. d+ _: o5 S7 X, R& }  I
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "
    1 u. Y/ o6 A; O
  673.       fi6 b" t% C: i% Y
  674.       let COUNTER=COUNTER+1) n, m; |( ~& T- y9 w
  675.     done
    5 Y8 s3 D7 J3 V) J# K! |; D* r
  676. 5 V0 o. ~2 Y1 v
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \$ Z) q/ ^1 C. L* N+ E( ?
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    / f5 e1 m+ K2 l+ c' U( z: j. G) L0 O
  679.       $RADIOLIST \( S( T* \, H: M  J( \# a& [$ K
  680.       3>&2 2>&1 1>&3)! z% P! ?. l, Z* E6 f
  681. 9 x( Y9 r( c6 a+ X. E5 f
  682.     # Exit if cancelled/ k3 D  j' V" ]9 i! A" F
  683.     if [ $? -ne 0 ]; then; E4 b- L# H6 e' j
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1
    8 h/ R1 X) e0 e( W% W# c5 P2 N8 ^
  685.       exit 0" ?, c& B  [2 K: s  e6 G& f& s
  686.     fi8 M, d  v) z+ V: c
  687. $ p5 H6 A$ ^' K; L7 ?( l  J8 _4 n4 w
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')/ @* T- h: X& C: E) n
  689. - _) m, y" E, k" M  o
  690.     # Set the branch6 L- V& {  f# {% U
  691.     if [ -z "$BRANCH" ]; then2 E  [& \# g* Y0 L6 C: a
  692.       BRANCH="$releases | awk '{print $1}'"
    7 v- l  C$ b4 ^) j, c7 j
  693.     fi0 J6 h5 P1 ]$ [
  694. 1 }; r: d9 m3 f7 o2 g) e
  695.     # Clone the selected version
    - h' [) i: x8 M* t" F
  696.     case "$VERSION" in$ e" Z2 {4 S* t0 [7 W" K0 I
  697.       0)' T3 u# {8 x+ h/ O  e
  698.         Log "Cloning Zero branch: $BRANCH" 1* b' k) z9 H/ k0 E! a
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive
    9 q3 @, j1 w3 Z
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive/ Y5 M& a) r. X- k/ F
  701.         ;;
    3 Z) x# E; r4 J7 G0 {% b

  702.   c! U: W+ o! m- y. _  O$ ~; x5 H
  703.       1)1 X* B6 C8 @+ |% t* f1 V* z4 d2 G
  704.         Log "Cloning One branch: $BRANCH" 1# c  ^0 ]2 F+ U. o6 a% [, G1 h
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive
    9 p& ~; r; {) r3 u, F! a! Y
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive+ G# m/ F$ }5 Q& p8 Y3 c: y, n# G
  707.         ;;
    / {; M4 A: `, n0 Z( u# b0 D

  708. $ I) @  ?+ M# N7 G
  709.       2)
    6 |8 L( J0 g8 w- Q. D
  710.         Log "Cloning Two branch: $BRANCH" 1
    : G9 Y8 b; }! [& O0 C5 K! d
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive
    / T& v/ }) `& e( g/ o/ t! R
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive+ y, T. i$ ?7 J: l
  713.         ;;9 z3 J7 s+ S4 Z' e* N) r: Y

  714. 6 V$ g8 r) T3 B5 K5 D; J8 M: l
  715.       3)5 }# J( u% ?4 G0 u/ L" k
  716.         Log "Cloning Three branch: $BRANCH" 1
    & f! S& Q: h2 H4 }3 }
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    8 L/ A. ~. q4 z+ S7 E! \  I( V
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
    ! P; M, c$ H. y0 X4 ]
  719.         ;;/ m+ w- R9 S7 m& Y, k

  720. # s# p; b* J* k3 p1 \9 {
  721.       4)
    + p6 Q& ?3 x9 Y& ^6 A& T" t  @8 a
  722.         Log "Cloning Four branch: $BRANCH" 1/ C8 z( O; t! s# L! i7 l7 N
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive2 u, R4 p5 Q. A4 m# |" K0 P- {
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive
    - h% Q8 D7 b1 H& ~) w5 O- ?# _
  725.         ;;; I6 p/ ^6 {/ N- B

  726. 3 x  p# u6 m2 G0 J
  727.       *); v8 W6 q: M1 k3 i
  728.         Log "Error: Unknown release selected for cloning!" 1
    ' H' C$ a' z! o/ e+ z
  729.         exit 1
    0 T1 ]- V: l7 o- ~" K# t, z
  730.         ;;
    & }( x5 v. R1 X+ _9 A3 h
  731.     esac& K) Y* x. z' z9 t' j

  732. 3 Q" `( R# C+ O; m7 Y" d3 m! j) G
  733.     # Log success/ ~' a2 p! m8 B9 V8 k5 O
  734.     Log "Cloned the selected repository!" 1
    . [1 \2 T& y& v( P; s9 Y+ L
  735.   fi
    " F- }% x6 ^2 P! p/ M1 X

  736. $ |6 {8 l3 Y( A
  737.   # Update the local repositories if selected
    0 C2 d9 F6 L: M5 A/ ?% J
  738.   if [[ $CLONE = *1* ]]; then' ]5 s! |/ \$ j3 p  v- r% u
  739.     Log "Updating your local repository..." 12 z6 _  P5 U0 \9 m

  740. - P* o/ D; P  B; U- t! n4 R
  741.     # Update the core sources
    9 J5 d1 s' M3 |
  742.     cd "$SRCPATH/server"" S" V1 [- c& n
  743.     git pull3 O" j0 p9 B7 Y( P! C$ A

  744. . [+ @- g; A0 S
  745.     # Now update the database sources$ H( X' u( C1 N# I! e# J
  746.     cd "$SRCPATH/database"
    5 k& n" q6 N: |$ _. s2 E
  747.     git pull8 J- q9 N( l/ N& J, c6 ]  j! i
  748. + P, }/ O2 s9 Y1 k! i8 v6 l
  749.     # Log success, o/ h  G) R8 J9 b5 F6 r# Y
  750.     Log "Updated the local respository!" 17 O7 v/ [$ \+ l/ \. U8 A  S/ P
  751.   fi" {5 y( d3 N) V0 _

  752. , a3 r  Q/ s+ G, `: y
  753.   # use existing repository
    / R  T; x8 p& ?; V% g( [7 w
  754.   if [[ $CLONE = *2* ]]; then
    ; f9 ^; v" c, ~: c. z
  755.     Log "Using existing local repository" 19 K# q7 R) T3 \" H# M4 O
  756.   fi
    % `+ B5 D' a1 I
  757. }
    3 q6 U7 G( b+ g7 G* W$ p/ J. b2 w

  758. 1 v/ D9 p2 h/ E: q5 V
  759. 6 k! n' v! p% ~. i+ q

  760. % A, ^0 Z0 K  M* e
  761. # Function to set the build options
    # Z" k2 B, S5 g( h- N
  762. function GetBuildOptions()8 R, U  {* o- F, E
  763. {6 Y/ p- F9 u7 x+ Z- Z$ }
  764.   # Select build options
    3 Q2 e7 N5 v6 h+ j0 g3 T
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \
    - H$ C. h4 X, N
  766.     --title "Build Options" \
    * e+ B/ I1 ^  _# Z6 S/ _
  767.     --checklist "Please select your build options" 0 56 7 \
    ) \- [; _, \7 T; v2 J  ]
  768.     1 "Enable Debug" Off \" L5 V+ ^+ F* u. Y
  769.     2 "Use Standard Malloc" On \
    $ M5 O! H* w' x3 Y2 z4 C( b
  770.     3 "Use External ACE Libraries" On \0 G+ {. t* V$ w* y, y  n! }
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    $ G0 d5 x* x# I- m
  772.     5 "Build Client Tools" On \
    - v; t8 o! \  u; ]! F
  773.     6 "Use SD3" On \8 K8 W* S1 V0 d8 a
  774.     7 "Use Eluna" On \
    ; V: C- ^4 x' c) k6 v+ e
  775.     8 "Use SOAP" Off \# L: p8 \8 @+ ~1 C# m) S
  776.     9 "Use Player Bots AI" Off \7 d5 e2 C: ^4 q, f
  777.     3>&2 2>&1 1>&3)0 w0 i7 E1 _# n5 r" A( t

  778. 5 Q) k2 {' [: g7 |# k* Q: W
  779.   if [ $? -ne 0 ]; then: m% I7 c, G! C6 Z5 h
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    ! E# B$ r% L2 g
  781.     return 0+ I& P2 G$ j, C' w$ A
  782.   fi# u" {3 p, o7 n# A$ l: j" T

  783. , H% Q; H+ s" r3 H: a
  784.   # See if debug was selected
    - y3 D+ U3 s6 X
  785.   if [[ $OPTIONS == *1* ]]; then
    ! ]+ s" g1 B7 d2 {0 h/ o6 A6 f1 Q4 Y
  786.     P_DEBUG="1"# \* G# L* E. v  l5 l% r
  787.   else
    3 M0 n$ @: D4 E. e  ~9 D" L) b
  788.     P_DEBUG="0"' b' h4 O8 x0 K! C  Q
  789.   fi& S6 _0 {# w# ^4 X, ^
  790. & x/ [! I# Z6 v% a
  791.   # See if standard malloc was selected
    ! l9 b2 Z; \6 G' n! T
  792.   if [[ $OPTIONS == *2* ]]; then3 Z$ h1 f3 {3 R4 q; M" R- Y3 F
  793.     P_STD_MALLOC="1"0 y# ]2 S/ P- k
  794.   else4 p! x6 @( _, S# z3 k
  795.     P_STD_MALLOC="0"7 t# Z& u; e% U% d5 b2 i: n# A  }
  796.   fi
    6 U1 R' @: u9 M1 G: f$ B

  797. / ]9 L5 x: s. L3 m4 }' K
  798.   # See if external ACE was selected# Z2 ]: w1 F+ \3 M! }; c( a+ ?4 w, p
  799.   if [[ $OPTIONS == *3* ]]; then7 R5 }* w* \; q# k- S
  800.     P_ACE_EXTERNAL="1"% h0 [( _9 [* q! x  ^- c) u
  801.   else( w& Q& I1 c$ ^0 e, d# m
  802.     P_ACE_EXTERNAL="0"1 |2 H( l6 ]/ @
  803.   fi
    5 T0 v5 v9 O# _; Q% `
  804. 1 Y% N6 x: [" e" m' M
  805.   # See if PostgreSQL was selected+ u6 G2 _1 j7 M
  806.   if [[ $OPTIONS == *4* ]]; then
    ( Z* I# O* j. C) M  S
  807.     P_PGRESQL="1"1 j* |" y% C: H! v( x  |# i
  808.   else
    2 Y, s# @' A9 K9 S5 m! A
  809.     P_PGRESQL="0"8 p$ Q4 |  j. Q! z$ \( y  |
  810.   fi6 E; t1 R! |2 X- C! ~, m
  811. 6 t( |" g2 J/ O# V
  812.   # See if the client tools were selected
    # x2 ]. Z/ F5 Y3 Y4 B
  813.   if [[ $OPTIONS == *5* ]]; then( N: \4 z! w" r
  814.     P_TOOLS="1"
    - l2 V# ?( o7 o. [+ Q) ]9 W
  815.   else
    - H7 R1 L& z4 x, ]  S
  816.     P_TOOLS="0"# D8 Q% ]" q, B* C
  817.   fi
    6 s% S1 ^8 P: p

  818. 6 v; k8 ^+ \) z) q3 H5 |
  819.   # See if SD3 will be used
    / O1 Z) s, g- W" r/ p
  820.   if [[ $OPTIONS == *6* ]]; then
    + }6 f6 Z+ k; m
  821.     P_SD3="1"+ G% N+ n( E4 [/ k7 ]9 z
  822.   else; r" ?8 k* {4 `5 M- y
  823.     P_SD3="0"1 ]  f6 F( a: g8 k
  824.   fi+ B2 c% }4 l* L& M+ O

  825. " o; w: y8 _- T( H+ F2 C
  826.   # See if Eluna will be used/ D9 a9 C8 ?# D) Q
  827.   if [[ $OPTIONS == *7* ]]; then& ~; [" x6 B, f0 G4 V
  828.     P_ELUNA="1"
    ! L% {. J9 Z! P# e# O
  829.   else
    : J0 {& h$ c$ g  D' t1 n
  830.     P_ELUNA="0"
    ! E8 K  C0 y9 U, f4 }
  831.   fi
    , F) b+ }4 F2 B1 b& l) Y# d/ }- X
  832. ; W5 O8 e) ^/ k  [" z! _3 w
  833.   # See if SOAP will be used
    % L) d& h. C  X8 \& b; W- f# R* l
  834.   if [[ $OPTIONS == *8* ]]; then! \. `( }: G$ C. v/ \
  835.     P_SOAP="1"
    3 b& t. s7 S0 ^: e( k
  836.   else8 @. C4 E9 r  g4 \2 H7 U/ o
  837.     P_SOAP="0"! k; G% X$ ]) J8 t
  838.   fi
    1 b7 y. y* i- i) A

  839. ; q( J' S7 I! J' t; W9 }
  840.   if [[ $OPTIONS == *9* ]]; then5 X' H: ]' D* u! R
  841.     P_BOTS="1"  y8 }9 h& K9 N1 X
  842.   else8 N3 ~$ b) |( J# s
  843.     P_BOTS="0"
    % f  }# T" C' r1 n# p# ^. r, ]
  844.   fi
    7 l) z9 i) ]( j- ~

  845. : v: _( ?2 R3 P  @5 E' x
  846.   # Verify that at least one scripting library is enabled. A' t& I- w) Y0 h+ V/ S
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then
    7 i# r) S/ y- C( g' R) ^0 w- y' X3 Z
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1% L/ H0 j* D& t1 z  F$ P
  849.     exit 1
    , Z+ p: [2 G* }# k# \% c
  850.   fi! w* B4 X7 G1 r) H) _0 ?
  851. }
    ' l4 e4 k6 O4 h/ l6 K

  852. & r- x& }1 `; a3 u, v9 h  r
  853. - [2 n: t& v/ Q  ^" P1 x
  854. + \7 z9 u: `! o5 O
  855. # Function to build MaNGOS- E+ j) C2 _) x8 B9 H0 r5 b
  856. function BuildMaNGOS()+ t. E1 \, t  Z5 Z8 _& [
  857. {' }$ G7 X* u' m
  858.   # Last chance to cancel building
    5 X7 _  Z2 A" X0 n0 {  N
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \
    ; k; r8 \; K0 k% Z" S
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60
    ! h9 F& M+ Q/ R6 U( b  Q$ J( K
  861. 9 \( z9 O  E' p' _# i
  862.   # Check the user's answer
    1 _! F: G- \4 N
  863.   if [ $? -ne 0 ]; then
    # p  U7 G. |. D, J/ R7 ^
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    # A# y  t! x7 i) r; C
  865.     exit 0/ Z  @: x, ^6 M+ R2 K" q/ I
  866.   fi
    . U: P# ~- s+ h' f: D8 t
  867. 0 f  H3 V6 \3 {8 `
  868.   # See if the build directory exists and clean up if possible! r4 s( S& O( Y* e1 d# x5 s
  869.   if [ -d "$SRCPATH/server/linux" ]; then! k* l- j1 B# ~! K7 [3 B  d, u
  870.     # See if a makefile exists and clean up3 E7 }; R/ T& N* |* k: B
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then3 e( [& H" }6 O
  872.       Log "Cleaning the old build..." 1: A7 [' p' p4 O, p, F% w6 g/ V
  873.       cd "$SRCPATH/server/linux"; n. F2 v9 S' F+ ~) [2 x
  874.       make clean
    7 J/ [9 n( {4 Q2 L& F2 l
  875.     fi
    7 m0 G/ K, Q: U2 K
  876.   fi4 o7 g/ [4 q5 B9 e$ @- n& m
  877. 0 b  f; f/ S9 v  t0 }
  878.   # Attempt to create the build directory if it doesn't exist
    : e8 s5 O& D: O. O( F6 {; m$ {$ ], q
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    4 ?; U' ^; N$ W; T' w- O
  880.     mkdir "$SRCPATH/server/linux") x3 l8 R; T6 P4 c, S( F3 }, V* X
  881. 4 q+ V! Y8 C# H0 ^' p# X
  882.     # See if creation was successful
    ' f/ C1 h1 a$ n* h3 L, ?6 T
  883.     if [ $? -ne 0 ]; then
      w  q/ X- O( }! c6 r: F
  884.       Log "Error: Failed to create the build directory!" 1
    ! G. @  P& l5 i- j3 D( f5 d
  885.       exit 1
    & u3 a& b; ~3 u; F% Y
  886.     fi
    " g: k4 |0 y0 ?; D5 b0 Q
  887.   fi
    " I  G  |5 c  Y5 l2 z" K3 _4 T

  888. : e/ Z& S; t  e2 K+ Q
  889.   # Attempt to configure and build MaNGOS
    ! t: x  D% E1 e# b! @# J
  890.   Log "Building MaNGOS..." 0' t4 L) ?  K* P0 \* ?$ M
  891.   cd "$SRCPATH/server/linux"- e: U6 P5 D- b! Q! N6 c
  892.   # make sure we are using the cmake3
    & v0 @9 ?$ t( n3 ~6 ~9 o
  893.   UseCmake3
    / H# F% o2 `* I1 o( K0 m
  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"1 V# N" k+ n. n
  895.   make: o" t- |- R8 h, i# ]

  896. 6 [5 l: Q' C" {3 i5 u% A' V
  897.   # Check for an error! Q: L+ ~* ]+ L0 b% H+ ^2 A! T
  898.   if [ $? -ne 0 ]; then5 m1 [5 ^0 O1 ?! L
  899.     Log "There was an error building MaNGOS!" 1
    " }) W0 C& w, y9 ~' v: M. T7 \
  900.     exit 1
    * m+ g( J6 z) u) [/ c/ `  C
  901.   fi9 Y  w8 \0 ~9 ?9 @& T
  902. ) S  H7 `4 N4 q' y- \3 O8 I2 F8 _4 h
  903.   # Log success- E' d8 Y) G% |  N5 o$ K1 ?( e
  904.   Log "MaNGOS has been built!" 0
    ' a6 W* _8 r5 u) a& j5 a1 P
  905. }
    " L( m2 o% z' a+ c, e7 N% ?% b

  906. / q7 W& A% W4 N. g3 s

  907.   J3 Q+ I: i7 v2 c) b

  908. 6 n& M" Y- d3 y& C; K  Z! [
  909. # Function to install MaNGOS1 a- ~7 O# d. k7 _& r
  910. function InstallMaNGOS(): E. Y  D9 n2 h' [) O
  911. {2 c  \  ?' ^6 k% K8 Y
  912.   # Ask to install now( V% {# ~' ~8 ?% g
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    , _  H" S5 X+ V7 G: ~4 j
  914.     --yesno "Do you want to install MaNGOS now?" 8 00 C4 O: Y) O& j  E6 |6 [

  915. 3 r4 _2 V8 u$ P" [- _' ~, d, @
  916.   # Return if no9 o, @8 S4 n( ^. F; E' P9 b# H
  917.   if [ $? -ne 0 ]; then- T8 O$ ?# n. V* a' `2 S6 `9 G
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \6 [0 ]0 p* }. N
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60/ `$ M7 B/ Q4 \* Q! w2 E

  920. 8 T7 ?9 L, S, S6 D, d
  921.     Log "MaNGOS has not been installed after being built." 1
    + p. J. }9 l7 p8 p8 C$ e* S
  922.     exit 0
    2 A! P3 R6 j! D* M2 V) V# a1 r0 Q
  923.   fi  G* G. ^8 h' }9 z' y: U

  924. ; ^+ J" l" Y/ M) H7 L
  925.   # Install MaNGOS
    - Y& ^  A0 B1 N' A1 a" u" e
  926.   cd "$SRCPATH/server/linux"
    4 F# U4 x+ F6 @* m8 ^* V. s
  927.   make install
    7 z, o9 s. y. [3 s; y' K: u

  928. % e3 k# n4 d: n2 T2 ~* `3 P5 z0 K
  929.   # Make sure the install succeeded0 m, L; _. t& y1 q9 O
  930.   if [ $? -ne 0 ]; then
    % D  l  M) U1 M; A5 X' Q
  931.     Log "There was an error installing MaNGOS!" 1. k; o* g# m2 J
  932.     exit 18 x1 S. e4 P' T: R
  933.   fi
    : |$ G: I- Q) r) @% B0 _
  934. }5 [) ~) [& g* f7 X7 q. [; m, Z$ X

  935. . W/ d/ l: O* |* k$ o; v
  936. # Function to apply database updates. |3 ?3 H# T. M$ ]
  937. function UpdateDatabases()
    5 h2 _* j. S( a) u, J( }
  938. {, c$ M  {( `" \' A1 L) K5 t
  939.   local DB_HOST="$1"1 p3 T2 _( J3 c3 q6 [: e
  940.   local DB_TYPE="$2"
    + g$ G) _' l  w0 }( x% E
  941.   local DB_COMMAND="$3"
    3 D$ P1 S( z+ d; F# i
  942.   local DB_USER="$4"( R' i, F/ x% [4 y7 R- ^, B
  943.   local DB_UPW="$5"' G$ g  }8 N" Y- N' T$ c$ [! K
  944.   local DB_REALM="$6"
    , G% a$ Z* r( z9 V
  945.   local DB_WORLD="$7"& c7 [3 O( j0 K: @$ f. g0 x" B. g
  946.   local DB_TOONS="$8"
      }# J1 ^  i0 [1 f1 X; r
  947. & u) y9 g3 g3 q, k/ {% ]
  948.   # Loop through the character files' Q5 R; ]" m* a" L9 D& `
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do: {( s4 ?8 w( n2 Q1 e! E4 [9 w* W# l
  950.     if [ ! -f "$pFile" ]; then) t* A; W. }5 b% B+ q
  951.       continue
    " p! X4 k6 k  }
  952.     fi5 e+ r0 m1 Y( n, b) Q% w
  953.     # Attempt to apply the update
    ( |- z% q+ k2 B6 R" k
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1( c1 J; Q& z( L) L6 W& g2 E

  955. / F& N9 `4 n4 o6 F( ]9 T8 d
  956.     # Notify the user of which updates were and were not applied3 y1 E3 j8 Y7 R0 Y
  957.     if [ $? -ne 0 ]; then) C/ s8 {) x* w* |1 J3 k% f; M
  958.        Log "Database update "$pFile" was not applied!" 0
    6 w+ @3 }+ {$ I# e) v5 v$ E* E
  959.        Log "Database update "$pFile" was not applied!" 17 n/ |# Z0 B' \$ ]4 ~
  960.     else( R, P" r# Z5 \, x+ g
  961.        Log "Database update "$pFile" was successfully applied!" 0( B9 b  U& V' y! S: _4 Z/ p' t9 ^
  962.        Log "Database update "$pFile" was successfully applied!" 1% B# }9 r2 R& N+ e
  963.     fi- S+ f! X  B$ ^) a3 @9 V" \( c) e
  964.   done
    4 n5 T* ~6 C$ A$ N- o

  965. - p1 B8 `* `- g0 E4 t6 O  @
  966.   # Loop through the realm files
    & u# s; ^" ~2 k+ e+ z
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do4 E2 d6 P" S4 d! ]5 r- m# F: V
  968.     if [ ! -f "$pFile" ]; then
    ( Z2 Y- G" A1 E$ v- X
  969.       continue
    4 x( |, ~$ |" X  w. c
  970.     fi
      G% b' p( M% c7 P+ e" |
  971.     # Attempt to apply the update* _7 H' S; u! M! Y
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1, S/ w" ]1 D- ~* a: K
  973. 8 q$ k, p: e# X& e
  974.     # Notify the user of which updates were and were not applied
    % L5 \  }  z" I5 O
  975.     if [ $? -ne 0 ]; then% N6 z4 G! k4 b9 A
  976.       Log "Database update "$pFile" was not applied!" 0) X0 e* e! {) [, O
  977.       Log "Database update "$pFile" was not applied!" 1
    4 b2 I2 r0 \- U# O* v
  978.     else7 {7 v6 g# C, A3 r: i& N
  979.       Log "Database update "$pFile" was successfully applied!" 0( v- ~" J3 F2 v+ i/ l
  980.       Log "Database update "$pFile" was successfully applied!" 1
    ! r5 \9 V7 D" x7 K
  981.     fi* a* h7 j# \: n
  982.   done* ?# l2 }$ D! [6 n5 ^5 C" P
  983. * r  L0 J' d7 {* f% ?2 E( c' C
  984.   # Loop through the world files
    7 k$ y3 ]2 c( f- L2 }" _
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    , c( D8 V! p% P2 o  S( @; P' V( h5 d
  986.     if [ ! -f "$pFile" ]; then1 I3 a) E7 @; y* T7 }
  987.       continue
    + W1 F  m$ F. J6 a' S' C0 [
  988.     fi! t& b& b& q9 R3 K3 K1 ]
  989.     # Attempt to apply the update( N1 B6 S, G- s" y
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    ; ~& ~; v6 g& m; s5 ~

  991. # }$ Y6 s! A( ?* B: k/ D
  992.     # Notify the user of which updates were and were not applied
    ' s' `+ r' @% O, p: t
  993.     if [ $? -ne 0 ]; then
    6 }, i# z# K6 t
  994.       Log "Database update "$pFile" was not applied!" 0; }/ i2 S  \& U6 ]4 G, Z" |7 f
  995.       Log "Database update "$pFile" was not applied!" 1" {) e0 }- j; W! o5 O! H
  996.     else, n, C$ J8 l0 f9 t# N2 V0 }" ^
  997.       Log "Database update "$pFile" was successfully applied!" 0
    # ^9 {$ n/ ]( W8 \1 W
  998.       Log "Database update "$pFile" was successfully applied!" 1
    0 h+ B- _" E/ F  n" Y* U$ y0 ~
  999.     fi- ^2 [2 }9 s, o" |- d$ u2 s  L
  1000.   done; H! O/ L& d( G/ j/ D  h
  1001. }! B5 O) k+ l& d

  1002. ( a1 O* u& u# k5 w- h
  1003. # Function to install or reinstall the databases
    $ a, ]+ O: T% g" g2 b( a
  1004. function InstallDatabases()
    ( o0 l! g& ]- S; Q
  1005. {
    * S+ |- x5 e4 ~$ l) V
  1006.   local DB_HOST="$1"6 p) W/ x, H2 p  R( ?$ V5 t7 T
  1007.   local DB_TYPE="$2"
    9 h! }7 `+ B1 o& V' G9 w
  1008.   local DB_COMMAND="$3"
    . Q, K1 V, ~! J6 s
  1009.   local DB_USER="$4"$ h, u& ^/ R' j+ V2 ?2 v- Z
  1010.   local DB_UPW="$5"
    7 O8 w" A6 {2 {' l$ l# p$ c& b
  1011.   local DB_REALM="$6"# X- J  e4 @, [0 H
  1012.   local DB_WORLD="$7"! x9 L3 j0 D7 G: u  N( D
  1013.   local DB_TOONS="$8"
    + f! y1 C, A1 A: i- Y" [5 h
  1014. 5 {4 H+ w" h8 ?2 Y
  1015.   # First create the realm database structure
    * b  k" I6 {% V7 i$ J* f7 F3 S
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql
    + L% e% k% z" w' q5 }# G1 f$ y, ~
  1017. 4 l: }8 o0 r" G* d
  1018.   # Check for success, G7 |2 P- k# j5 z5 V% w% a5 s
  1019.   if [ $? -ne 0 ]; then! T1 l5 P9 D* |  }3 v: Z# I. o
  1020.     Log "There was an error creating the realm database!" 1+ v0 `$ G1 b5 s2 {$ r- b
  1021.     return 1
    4 N+ H+ N$ W$ K
  1022.   else: `! @! T/ J, V7 }& q+ @. ?
  1023.     Log "The realm database has been created!" 13 N* p0 u: W. E
  1024.   fi
    + \. {( z: v% ?, Q' P/ p
  1025. 7 S0 {! J; l$ C; c6 n
  1026.   # Now create the characters database structure
    6 C9 N0 C& E/ F; B
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql3 |1 \( H0 o- k9 W1 @, |
  1028. 3 H5 e6 N1 q; S- D6 \
  1029.   # Check for success
    & Q3 c8 S6 `4 p$ N( N5 o
  1030.   if [ $? -ne 0 ]; then
    0 @1 _* e  j6 l# A, c
  1031.     Log "There was an error creating the characters database!" 1  o6 r: u/ P  S+ ]' |2 h' Y
  1032.     return 1
    3 }7 r7 o* k4 E# S, l! B
  1033.   else  s/ C, L3 x5 o/ _
  1034.     Log "The characters database has been created!" 1: b. z. Y% B5 `/ C' k0 q
  1035.   fi) o: C+ t% ?( p& k, O/ V

  1036. 5 ]1 @7 c' y2 B: G5 S7 H
  1037.   # Next create the world database structure. [' _3 Q6 k8 ]- m
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql$ A9 m- J! q5 l* z

  1039. 0 p* n# c3 ]" ^, ~
  1040.   # Check for success  P2 [- w% `! Z0 ^" y: C7 Y
  1041.   if [ $? -ne 0 ]; then
    ! H$ H: I$ X7 T0 X! u
  1042.     Log "There was an error creating the world database!" 1: N. m9 \$ I- C) J( {4 L
  1043.     return 11 n0 ?( Y' y) u6 l
  1044.   else: W( o4 y; Y& I# D9 l7 `3 w
  1045.     Log "The world database has been created!" 1
    0 ^, b. p) H5 N  |6 X, \5 [1 v
  1046.   fi
      g2 |) q+ Z+ A8 }% A' [: p. u) R

  1047. : h& r( K$ ]  |5 `8 T7 g
  1048.   # Finally, loop through and build the world database database$ S% W1 o5 W4 z: h1 V" H
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    1 u" W6 ^! d" f2 Z0 Q7 l
  1050.     # Attempt to execute the SQL file  t3 M3 Q/ W. b' \
  1051.     $DB_COMMAND $DB_WORLD < $fFile
    & ], @5 I; I# N# Z: Z2 X$ n
  1052. 5 R2 n! s. w1 G3 i) r9 X+ _" E& n
  1053.     # Check for success
    5 i. H7 v7 W6 Z- J. v7 @
  1054.     if [ $? -ne 0 ]; then% @! t0 @9 X- {1 f# C1 J& |
  1055.       Log "There was an error processing "$fFile" during database creation!" 1) ]/ V- W5 {  d, @+ ]# I, [
  1056.       return 1
    % s4 X+ p/ E6 v4 I2 z! K
  1057.     else0 P' K$ X5 g# I* w- O
  1058.       Log "The file "$fFile" was processed properly" 1
    " Q+ f3 d# R) f
  1059.     fi
    ( V0 M$ I4 C+ z# j3 o) u+ J
  1060.   done
    & M0 Y' L! A' q6 ?! f0 i# i
  1061. , c( o: k$ Q. i; Z* [
  1062.   # Now apply any updates
    ) p7 I. i3 N) i! v0 c% g& L
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    ( L) \* o! ^9 m- |- U
  1064. }
    9 H- Q7 n2 U7 A. q; {

  1065. $ |6 R7 h& G! j0 d+ q2 K; s. X
  1066. # Function to install or update the MySQL/MariaDB databases
    4 W* u% O6 q- M" x" I3 ]8 g
  1067. function HandleDatabases()
    ; [+ q1 G/ G& Y* P
  1068. {' H2 @) y. h$ |* }8 M
  1069.   local DBMODE="0"9 B0 z1 Y4 {5 Z$ j% Y3 Z6 g$ B9 a
  1070.   local DB_TYPE="0"
    9 m6 s3 v" w/ U5 f7 @4 H9 x" U
  1071.   local DB_COMMAND=""6 p; E9 y" n! }3 S( [& K
  1072.   local DB_TMP="0"8 ?9 s/ [& c$ m9 _
  1073.   local DB_USER="mangos"
    2 \( x9 x! H9 }9 C3 y
  1074.   local DB_UPW="mangos"0 u% E( l: l& O2 M3 l) Y3 A
  1075.   local DB_HOST="localhost"0 b5 G1 V" o" l2 k7 e! s. _
  1076.   local DB_PORT="3306") V- I- X0 u3 f3 y/ W& V; j) U7 i
  1077.   local DBSEL="3"+ V, a$ G) z& I  ?$ X
  1078.   local DB_REALM="_realm"' p+ H9 B& }: }  ^. C* K
  1079.   local DB_WORLD="_world"
    , R/ }2 ~( W2 |; U- f
  1080.   local DB_TOONS="_characters"8 I# U; O$ C- t8 A6 F# P
  1081. / G/ I; K) p1 A7 {  d! x9 C- {+ K
  1082.   # Ask the user what to do here
      D) p7 N) O* U( H
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \0 C+ j( d0 \! U5 Q8 r# U5 ]5 ]
  1084.     --menu "What would you like to do?" 0 0 3 \4 \4 \3 t# L* h7 S: }- q
  1085.     0 "Install clean databases" \3 B7 d- E8 Y, x
  1086.     1 "Update existing databases" \
    0 e/ v, i$ O9 I5 [1 _* ~
  1087.     2 "Skip database work" \! t* _5 B4 |5 H# t& m+ J* N
  1088.     3>&2 2>&1 1>&3)7 F1 |/ M% }% ?# @

  1089. 9 p( e/ T* Z+ k, q6 L! \
  1090.   # Exit if cancelled
    1 q7 X1 a4 j+ Q& y
  1091.   if [ $? -ne 0 ]; then/ w* j0 ^4 S" {, X$ t( h" k
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1' @+ {, L$ Z! g! t# J
  1093.     return 0! @$ Z; v9 W3 f* f( R0 O
  1094.   fi
    2 Z! i& w) g/ i

  1095. : l! }" t, R4 b* l
  1096.   # Exit if skipping
    ( U( f+ L- {. \! z/ m2 @7 G4 D
  1097.   if [ "$DBMODE" = "2" ]; then) c/ w9 M: h1 G7 h: _
  1098.     Log "Skipping database work. Nothing has been modified." 11 r$ j; V$ e8 D+ T
  1099.     return 0* W! B. O# U3 H8 ~9 }- \! H
  1100.   fi
    ) |7 s2 r7 E! f: t. Y

  1101. " X6 x3 S9 t9 q! G1 C
  1102.   # Ask the user the DB type1 n1 A3 B: x% o1 z6 T7 P5 w' f  L+ Z
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \! f- m0 ]: X7 H5 L1 H) z
  1104.     --menu "Which database are you using?" 0 0 3 \
    3 ~: s/ ^6 n8 j
  1105.     0 "MariaDB" \
    , L2 J( S6 l* e& L: H  A4 d
  1106.     1 "MySQL" \( H1 U! Q2 \. l1 z
  1107.     2 "PostgreSQL" \( A" `: e/ [% `8 Y# @0 C
  1108.     3>&2 2>&1 1>&3)
    * K& d+ e( P  L& L0 C: A! S
  1109. 5 T9 C8 |0 t& o8 @( O! s  ?
  1110.   # Exit if cancelled
    - V# \9 ?: C4 _6 y
  1111.   if [ $? -ne 0 ]; then6 |. C6 e1 h6 _: d: n
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 1
    5 K) y# {# h$ f8 o. c" z9 T
  1113.     return 09 W8 H7 T- \8 ]; m
  1114.   fi
    $ D- @& X. g6 z/ G8 ~9 B
  1115. & J# S1 f2 b, ~! v! @/ o" B- U; P) V* }
  1116.   # Get the database hostname or IP address7 p. S$ w- ^% B
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \
    0 D7 r& R5 T* y9 w$ H7 K
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)
    6 r  J7 d5 z' t: r% T

  1119. 9 G  U! g( k4 x) ]0 J  J' U
  1120.   # Exit if cancelled
    ; l( f7 Y) \+ H( W
  1121.   if [ $? -ne 0 ]; then0 r  _8 n) A; B. E9 i' ]
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 1/ f/ j$ K; D& e9 E- V# u5 G; O5 t
  1123.     return 0; D* V+ v% M  j
  1124.   fi
    . q; N$ {+ s; ^! N/ C: N

  1125. : [+ V$ E8 `6 d' E
  1126.   # Set the hostname or IP address if one was specified/ E! s3 E! h0 f! }" q4 Z. p( _/ E  o
  1127.   if [ ! -z "$DB_TMP" ]; then  v' b* L( J* c7 ^; n  m! }
  1128.     DB_HOST="$DB_TMP"6 M" L# O: z) K0 z
  1129.   fi3 ~3 B, s7 j4 K, k5 K! R1 O
  1130. : u* @! n$ y) x" w1 R* Y
  1131.   # Get the database port3 }/ E- w" S  O% S
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \4 U/ Q( S$ S% L& Y+ y
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)
    % w: \+ M/ \- N% @8 L6 S

  1134. 9 A, ]. o3 W6 {% M) L7 x
  1135.   # Exit if cancelled) r) L/ \# q. L, f6 K1 F. d* `
  1136.   if [ $? -ne 0 ]; then
    4 ~' H3 X4 q; l+ F  [
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 13 m% p% ^  Y. L% G2 ]+ f' I+ w
  1138.     return 0
    2 ]& S8 \- g5 |2 R
  1139.   fi) m) T# |4 c& B  x' _

  1140. ! m) f, ?: A' W/ W( f" @
  1141.   # Set the port number if one was specified
    0 r4 b* g/ [0 s
  1142.   if [ ! -z "$DB_TMP" ]; then
    4 B' S7 Y7 R0 X5 F7 [$ N6 U/ Z9 |8 _
  1143.     DB_PORT="$DB_TMP"6 E$ i6 [2 e  ^' S/ Y' s" K
  1144.   fi
    : l* g- S" N. U. m0 L
  1145. " ~3 G1 O) T3 u! f' m7 a
  1146.   # Get the database user username  s: L5 U$ |9 a# e7 J! F
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \
    9 A) @8 D: b, P: }
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)# y2 G  r) ^' `  M
  1149. ' g5 s6 @& o1 ~! j- K9 h
  1150.   # Exit if cancelled
    ' G' V; ]* k) T. e7 m4 l, r! x
  1151.   if [ $? -ne 0 ]; then
    2 g' K, [8 {/ Y5 `" n  f
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1+ V% Z. S! N- T: w
  1153.     return 03 |4 Y3 G6 A8 K1 r
  1154.   fi$ S: ]0 m# D3 D4 \; h& y

  1155. + j! J7 J; c+ u) e* `
  1156.   # Set the user username if one was specified( U, b- h* d0 x* W- p7 i* |
  1157.   if [ ! -z "$DB_TMP" ]; then! o5 s9 ]- M8 J% S) i
  1158.     DB_USER="$DB_TMP"
    , ]7 b; ~" t$ Z" N9 e1 q  K
  1159.   fi
    ; y% [! q' A& f( l, x" x6 _, b* ]
  1160. 3 }. ^2 l  e( K" J% _
  1161.   # Get the database user password
    : v% |0 ]" Z" l5 Z1 G2 B+ d- m* X
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \
    : W& V* C7 _2 {8 h; d
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)
    ! r+ m2 w% H& K. ~1 U+ p; m

  1164. ; e# r4 d& y+ {
  1165.   # Exit if cancelled+ N8 ], C- P* k) t, Q. [1 s
  1166.   if [ $? -ne 0 ]; then
    + R/ g' Z0 v! c2 r+ y4 Q& o
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1
    ! `! V& ?: Q4 w% k
  1168.     return 0
    6 x2 X! P1 ^+ q6 a5 T
  1169.   fi
    : Q7 S$ \! Z: M: s) @% N* q

  1170. ! ~0 z0 d0 C) R/ }7 o8 C
  1171.   # Set the user password if one was specified/ m* F" B& w0 [
  1172.   if [ ! -z "$DB_TMP" ]; then0 }; i4 _, E/ X- p6 r' n
  1173.     DB_UPW="$DB_TMP"- n; \- a% M+ v' ?
  1174.   fi
    6 C; R0 `& r+ u0 X' u) X' R6 B1 B
  1175. & i* G! l8 [" X! ^# {4 C  B9 P7 a
  1176.   case "${DB_TYPE}" in
    2 D4 K+ E" b4 H+ ]# I
  1177.     "0")3 C* V. J8 `( z
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "
    - M* {% k3 k+ ?+ R$ n8 T  N2 Q4 F: U
  1179.         ;;4 s) ]2 D7 J( C/ O& j: R
  1180.     "1")! s7 P, X6 z1 E; M/ M  i& A7 q
  1181.         printf "Confirm your MySQL password\t, "
    6 B( @/ v  s  H8 Z* [6 u  @* y
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn
    " {) i+ b' K. z  O, B, n2 F1 d7 r
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    . M5 ^" l& w( w2 z$ h- {
  1184.         ;;! @2 F  L0 x3 o; b
  1185.     "2")  l9 I) q2 u: c% N5 d6 E# S
  1186.         Log "Currently not supported." 1
    # f3 Q  I) j% k" F% n' e
  1187.         return 02 M( V/ `( V. ]) M
  1188.         ;;
    * h# g4 g4 o9 n
  1189.   esac2 m9 u% [! |. [5 ?8 K
  1190. & ~; Z3 \% _* f) ~
  1191.   # Setup database names based on release" ]5 W+ W; i* r" a  T( ~0 @
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"
    5 B! v' x- ^# T0 ~8 e
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    ( n$ V+ i1 C: V2 q7 C( f- F
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"
    * C' k( i! }0 v! A% A$ N) k

  1195. # }3 G/ m, l  E7 R* p. u  d1 H
  1196.   # Install fresh databases if requested3 Z8 h# r+ m( F" h: y
  1197.   if [ "$DBMODE" = "0" ]; then2 [4 k# h; b, k' ^1 W* ~' l; Y# T
  1198.     # Ask which databases to install/reinstall
    0 l8 e- t& @! x6 k
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \7 ^$ p6 g, n  ]3 a
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \! \1 R4 S% S+ i" }4 O4 ?
  1201.       0 "(Re)Install Realm Database" On \0 S2 A4 ]) p: n6 h' ?
  1202.       1 "(Re)Install World Database" On \. w  y0 G. t$ B3 d7 e' }* b
  1203.       2 "(Re)Install Characters Database" On \$ B1 M5 a# q( P9 v! p
  1204.       3 "Update the realmlist" On \$ k; r5 S/ q& F5 o( z+ o
  1205.       3>&2 2>&1 1>&3)
    4 q1 l  l  N, _5 m
  1206. - U9 }/ b1 o, ?! _( g* y) L/ D9 E
  1207.     # Exit if cancelled# O# c' O# f5 d$ V- Q2 r
  1208.     if [ $? -ne 0 ]; then
    5 s4 ]: S5 n: J. e# `
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1! c! Z* H, l2 E5 L; O
  1210.       return 09 x3 x, [% h- h( e8 x
  1211.     fi3 m( u6 {% M! K6 g9 @0 ~7 K+ F9 b1 d

  1212. % s  p' ?8 `" Z1 |- n# N; \( u
  1213.     # Remove and create the realm DB if selected" W3 r7 D& q, J1 Y2 [
  1214.     if [[ $DBSEL == *0* ]]; then5 ?1 {" n* V" l/ H4 Y, d/ d
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"; i- M2 V' @. q! n% D# D5 s+ A
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"
    5 p0 b7 H% V9 q: F2 R" t
  1217.     fi6 T# D/ A  l6 G& ?& B7 q4 l

  1218. 3 S6 t: p5 Q, Z' R, n1 V
  1219.     # Remove and create the world DB if selected. r& J( {! N- H3 P7 `) n7 K' `
  1220.     if [[ $DBSEL == *1* ]]; then
    & W% D7 v* }2 I& e- p3 d
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"$ H- c$ m) {0 h# j( U2 t6 t
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"
    9 w  @# m! x0 u% n' Z7 }
  1223.     fi, }6 B7 H" w' Y; Q* ^
  1224. ; f8 @  ?4 |, q$ E2 O3 Z1 W
  1225.     # Remove and create the character DB if selected
    : X, ]7 i* y: S) M: X' b
  1226.     if [[ $DBSEL == *2* ]]; then! X  u. C& K9 O; `+ T
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"
    ! M4 D- u8 [& K5 S
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"; C  h1 x+ Z5 T8 P- x9 I' B
  1229.     fi
    3 T! D! b2 V6 d( |' |3 U* p
  1230. # n  O. `4 Y0 A+ Y  C: C7 [
  1231.     # Validate success  C$ Y7 A3 Q" G, T- N
  1232.     if [ $? -ne 0 ]; then! h; r* l  n4 I8 t5 N( k5 P. b
  1233.       Log "There was an error creating the databases!" 1; H9 M/ r( m/ F/ {1 s+ m- P
  1234.       return 1/ |7 v1 \6 p7 k
  1235.     fi
    8 Q* p9 J- |4 L' f# k) |

  1236. 3 O: t0 ]. y4 t
  1237.     # Finally, populate the databases- D8 z/ [+ P2 e% l5 K
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS0 p' `' y& I7 x9 f# P7 L# {( u

  1239. ' m# u, s- p) J$ F) M
  1240.     # Updating the realmlist
    + v, m! i" P$ c! t% @6 N2 J3 {
  1241.     if [[ $DBSEL == *3* ]]; then" r3 ]# L4 I8 C( P& c
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql
    4 a* `+ |2 l5 T8 y% Y4 {
  1243.     fi
    ; B" F4 {: V" @$ U- N9 v
  1244.   fi
    0 t2 M3 J" S9 n

  1245. + ^# F' G% b) A; ~' ~! ~, ~- e" }/ }
  1246.   # Update the databases if requested
    ! @) Y: n+ v: Z8 ]
  1247.   if [ "$DBMODE" = "1" ]; then' J7 y: W: j/ ^
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS5 t7 n) Q+ T( ^7 ^
  1249.   fi( |; ?) Z% @( U0 u, Y- b5 I
  1250. }
    4 P0 \4 G/ _' E2 z9 [
  1251. 6 v0 K/ K1 m' i
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
    5 u: ^* f, O; F' l7 X
  1253. function ExtractResources8 e2 Q5 B( K0 q! e$ h7 O# W' `
  1254. {
    $ O! J, I) L- [: ^0 N6 S/ B
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))$ z$ x0 p9 c1 B9 y
  1256. 6 N+ s+ u7 g. a# [( w, ?
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \( ^8 Q; n6 h2 y- e- h! Q
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)
    5 ~# t# s& s* h: o0 a. }& k
  1259. ; ]7 F. \& r' _; h
  1260.   if [ -z "$GAMEPATH" ]; then) |$ c& f3 g- p/ W% D- z0 W
  1261.     GAMEPATH="$INSTGAMEPATH"1 V* L% u+ y" W$ w7 a" V
  1262.   fi
    # c: r2 t1 g2 r! c% \

  1263. * a$ a4 L; o/ S; o9 g' `8 t
  1264.   if [ ! -d "$GAMEPATH" ]; then
    : A" ~8 x! f( E2 C) z
  1265.     Log "There is no game at this location" 1
    / G; y, W7 j( J9 R1 F2 @
  1266.     exit 1
    5 b3 W& s5 e( Y9 M
  1267.   fi
    5 ^2 ~3 U7 w- u% @. S) q% c
  1268. 4 X  z6 J' {5 L; N: r  V" g
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    / l; P$ K2 Z) w3 H' {
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \' d+ I' K5 ?) o; W$ q" w
  1271.     1 "DBC and Maps" On \, y8 C3 v; H4 y
  1272.     2 "Vmaps" On \
    ) q7 _7 D% p' J! g
  1273.     3 "Mmaps" On \0 ^6 C! m8 K6 {5 r
  1274.     3>&2 2>&1 1>&3)0 B0 n/ L, t) q$ d' f

  1275. 8 U9 ]) a) f8 N! C
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    ) p) N9 n9 i" {# t% a8 Z) D% p/ r
  1277.     Log "The client tools have not been built, cannot extract data" 1
    ; l. w# d; h" g. X' M9 F
  1278.     exit 1- M, L( L! F$ l5 t  `+ L5 V
  1279.   fi
    4 C. w' m' j3 u1 ]
  1280. . H. U* O& o- E6 I% E
  1281. #TODO What if DBC are not yet generated ??
    * D( w' y( e, S# Y0 {
  1282.   if [[ $ACTIONS == *1* ]]; then
    3 z- _' v# h6 }0 I
  1283.     if [ -d "$GAMEPATH/dbc" ]; then# n# i) D/ W! f% t7 }+ Z
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \# j# b: r6 s5 t6 m# z
  1285.         --yesno "Do you want to generate them again?" 8 60/ `- S9 C% ?5 d; E$ e3 x/ z+ J

  1286. 9 P8 s+ f  L/ C5 M* Y, _
  1287.       # Check the user's answer
    " @& h. o+ C; n4 z
  1288.       if [ $? -eq 0 ]; then2 \; U4 r" \  _" T0 n9 K& p
  1289.         Log "Deleting DBC and Maps previously generated." 17 L4 P. W* u2 c7 ^' ^3 @
  1290.         rm -rf "$GAMEPATH/dbc"
    ( H8 `" t; E3 O8 s2 S( Y$ t
  1291.         rm -rf "$GAMEPATH/maps"
    7 i6 P+ S& `9 I8 R3 U
  1292. * b% ^) |4 X4 p, [3 \; e0 A& }% a
  1293.         Log "Copying DBC and Maps extractor" 0& N& l8 w( W  L& N. H3 g
  1294.         rm -f "$GAMEPATH/map-extractor"9 w8 ^7 O! y4 M/ {: b
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    * B9 \" _+ ]  K( h
  1296. + V/ m% x" R0 N
  1297.         Log "Extracting DBC and Maps" 0
    ; b& S( s$ d( T5 ?+ R* I' K
  1298.         cd "$GAMEPATH"5 o/ v2 V3 X2 {. a' L; M  E
  1299.         ./map-extractor) y. ?' _: b& [9 K
  1300. 7 r% C- U: ^) K; @2 l/ h
  1301.         if [ $? -eq 0 ]; then
    * F& j7 w* E2 `# C% X
  1302.           Log "DBC and Maps are extracted" 0
    + f% i6 t5 O  g8 K# g# V
  1303.           Log "Copying DBC and Maps files to installation directory" 0
    0 _! Z& q# O+ g3 h* o2 D
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"( q1 L/ x2 X. R
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"8 A% K, b- f) n. P3 G
  1306.           rm -rf "$GAMEPATH/map-extractor"
    % o4 _# h6 [4 F' {" O% z
  1307.           Log "Changing ownership of the extracted directories"
    $ `- d0 W+ P3 z2 D
  1308.           chown -R $USER:$USER "$INSTPATH"7 d. a2 [, c7 i0 }
  1309.         else8 l5 B3 |1 g' f) d. O
  1310.           Log "There was an issue while extracting DBC and Maps!" 1
    $ ?- A, S6 k* U  q) t, `; L
  1311.           rm -rf "$GAMEPATH/map-extractor"
    9 g% r6 M9 H5 |7 T; L0 G! Q
  1312.           rm -rf "$GAMEPATH/dbc"+ W$ B* t& \. o& H3 }( B
  1313.           rm -rf "$GAMEPATH/maps"
    0 I( A0 W" M1 D1 m
  1314.           exit 10 P% p  ^, @+ h( r! B7 E5 w
  1315.         fi' K: w$ f$ e7 P4 O
  1316.       else
    : g& {( o" k, H/ J7 n
  1317.         Log "Copying DBC and Maps files to installation directory" 00 @! e4 O; P) T- j
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"  i2 J7 [% r: X( v) P
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    & Y0 B, y1 M( Z
  1320.       fi- G. c# z3 A, q- o
  1321.     else5 B; S8 a; Q2 R4 f* Y, D
  1322.     rm -rf "$GAMEPATH/map-extractor"
      V8 z/ S- m8 k! L: [  T  ^
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    ( ~+ W$ g9 C: c& A4 o
  1324. 3 @8 y: Y; W; |+ \0 t0 y6 T, l+ |
  1325.     Log "Extracting DBC and Maps" 01 `; r( b8 k4 ^' `
  1326.     cd "$GAMEPATH"! p! o$ Z: ^/ S( w2 c. D
  1327.     ./map-extractor
    : X. r8 \' j  Q+ a
  1328. ; U4 O% B% `! M( X& P
  1329.     if [ $? -eq 0 ]; then
    8 |7 F1 o' n0 V* G5 n) s0 K( }* l
  1330.       Log "DBC and Maps are extracted" 0
    3 |& n1 |" L1 I; x+ n
  1331.       Log "Copying DBC and Maps files to installation directory" 0
      w: l" P3 G& c% p1 r, q
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    ; {7 p1 |9 M: g
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    , K; y* J/ W7 ~- S# r3 H2 |2 p  Z
  1334.           rm -rf "$GAMEPATH/map-extractor"$ q! v5 K1 k. s' X* D
  1335.           Log "Changing ownership of the extracted directories"; ~' _" i' @- {
  1336.           chown -R $USER:$USER "$INSTPATH"
    5 E3 I9 E2 V3 X$ u5 }
  1337.         else
    ' s) S4 ?. O5 u3 B
  1338.           Log "There was an issue while extracting DBC and Maps!" 1" r% M' w! W( l7 C/ d8 m! H4 z9 h
  1339.           rm -rf "$GAMEPATH/map-extractor"6 D9 h/ e; _; u# \! P9 }
  1340.           rm -rf "$GAMEPATH/dbc"
      A9 \4 ^! t  D2 m
  1341.           rm -rf "$GAMEPATH/maps"
    & T5 Z% g" m) o: Y4 L. L
  1342.           exit 13 |! {5 f+ s' [7 @$ R! c/ d
  1343.         fi
    0 O: X6 B2 X/ p4 V
  1344.     fi
    4 a0 k* ^- T) V- |, `- p
  1345.   fi* W/ K$ U! _# b) [, T

  1346.   F  |( _/ x% N$ D; a7 x4 W. u
  1347.   if [[ $ACTIONS == *2* ]]; then
    # Q8 `' Y) o1 y. i
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then0 _) b$ p: @! _, U7 f% J
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \, k0 }/ [$ p& Y& u' u
  1350.         --yesno "Do you want to generate them again?" 8 60* M1 B2 _5 y# T# m; D, m5 G. k: c

  1351. / j3 W. r: L) |. n3 o
  1352.       # Check the user's answer0 A" t. f$ `& e  {' w  I
  1353.       if [ $? -eq 0 ]; then
    ) C5 }+ Q3 _$ E* F* S
  1354.         Log "Deleting VMaps previously generated." 1* P) @8 G% a* @5 J9 T
  1355.         rm -rf $GAMEPATH/vmaps. N& A1 y% j; ~$ u2 h
  1356.         Log "Copying VMaps extractor" 0+ ~4 F  S) ?1 v9 }( ?$ u
  1357.         rm -f "$GAMEPATH/vmap-extractor"2 f4 U  q0 ^' d
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    + ^. A, z( f  }4 ?
  1359. ( a7 y+ P) q1 m( d1 R3 f1 T' R
  1360.         Log "Extracting VMaps" 0
    ' n! Q/ R4 |  r! J8 |2 O
  1361.         cd $GAMEPATH
    ; P" i. V+ p9 Y
  1362.         # Make sure there is no previous vmaps generation that cause issue.
    + @6 Y* B* p* i
  1363.         rm -rf Buildings' P5 @( ]: b+ E" y' ^
  1364.         ./vmap-extractor
    2 r; U% G, D" S2 }2 Q

  1365. 5 E" _3 c. Z; U, E% C  g- c
  1366.         if [ $? -eq 0 ]; then
    8 r+ d* T) z/ X7 b( ^5 l0 h, J
  1367.           Log "VMaps are extracted" 0- |# u1 B) B* E8 ]
  1368.           Log "Copying VMaps files to installation directory" 0+ W7 G) k/ n+ E# Z
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    ' c6 h) d, j* F7 A
  1370.           rm -rf "$GAMEPATH/vmap-extractor"
    6 C+ b# G  B" ]5 B8 p( \2 i; p! u
  1371.           Log "Changing ownership of the extracted directories"# H5 e' ~2 B9 R- M
  1372.           chown -R $USER:$USER "$INSTPATH"; b* L8 M4 \# f1 z1 x0 A) h) U
  1373.         else& a: c2 s( g" O
  1374.           Log "There was an issue while extracting VMaps!" 18 V' H% T- N% ^0 S+ a8 J7 e
  1375.           rm -rf "$GAMEPATH/vmap-extractor"
      X, {# G& @4 y. ~' S9 C3 s2 L  r
  1376.           rm -rf "$GAMEPATH/vmaps". y  U1 i" p9 f/ q
  1377.           exit 13 ~/ L& j3 l6 o5 X+ v
  1378.         fi" w# N+ q  B" j: C
  1379.       else  m! J/ Y; B- V3 ]# |( {+ a' }
  1380.         Log "Copying VMaps files to installation directory" 0  D3 [4 u; Y& o) H
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"" b8 ^& G) N6 \- q" B
  1382.       fi
    0 w' z3 F$ p3 {& e
  1383.     else6 I  s4 Z# s/ C) e- l
  1384.      Log "Copying VMaps extractor" 09 o2 c. w9 C( G3 z5 ]7 i
  1385.      rm -f "$GAMEPATH/vmap-extractor"8 a( U" v# K- Q3 p. L% _
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    0 f3 m3 _3 k2 K4 k- H4 b& _

  1387. . \) Z; E4 n% t+ e4 A  G  w) Q
  1388.      Log "Extracting VMaps" 0! g! K0 [1 f: D5 e: i$ R0 h7 x
  1389.      cd $GAMEPATH
    / f+ Z- l! z& |3 S- H) S
  1390.      # Make sure there is no previous vmaps generation that cause issue.+ {2 ?7 H) O2 F, S4 W) z* H" q7 a
  1391.      rm -rf Buildings
    + ~* [& |1 ~1 `- o6 @) `! Q
  1392.      ./vmap-extractor) J; j$ _5 P' R9 L# o3 X3 a
  1393. . f$ B0 q& J' j; a. L3 c! e
  1394.      if [ $? -eq 0 ]; then+ W. @1 r1 |( D! P
  1395.        Log "VMaps are extracted" 0
    * j1 f% a6 W- T! k; i
  1396.        Log "Copying VMaps files to installation directory" 0: \+ k. x; _3 x6 C$ L, ]$ a
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    " ^+ T1 O$ i4 Z* }* z
  1398.        rm -rf "$GAMEPATH/vmap-extractor"2 j# B3 B) g3 B' W
  1399.        Log "Changing ownership of the extracted directories"
    + M0 x- s( d8 ^' A/ S8 @
  1400.        chown -R $USER:$USER "$INSTPATH"
    + G; f3 Q9 n& i5 v, D; k7 T+ s
  1401.      else8 R9 p) L/ ^9 ~3 u3 C
  1402.        Log "There was an issue while extracting VMaps!" 16 H7 v/ I# D! Z. s: Y1 J
  1403.        rm -rf "$GAMEPATH/vmap-extractor"# C) N5 _" U* R) l8 M( r& ]( U
  1404.        rm -rf "$GAMEPATH/vmaps"
    3 \* }5 s% ]3 F- w9 M
  1405.        exit 1( i  w+ I0 R4 \/ D" L5 g; R: O
  1406.      fi4 a  ?3 y/ S! e, f+ w( y
  1407.     fi3 m/ d$ Y9 {# x. `. e2 e
  1408.   fi7 g1 S+ T8 c5 k2 H; ]% B
  1409. 6 V. D3 m3 e; l6 N8 |# U
  1410.   if [[ $ACTIONS == *3* ]]; then
    ; U! p1 U* ^* H: Y9 O
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then, r- Y4 f1 K0 z2 |
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1
    % j# Y, d5 P5 T1 Y" b; M) n
  1413.       exit 1/ m$ b0 e. Q- j% \% y2 r
  1414.     fi& T7 m5 C( E  {
  1415. - D" q  U  E+ n4 |
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then
      `" S$ m( y# f7 }' k; i
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \, y1 o* ?; B+ b
  1418.         --yesno "Do you want to generate them again?" 8 609 q3 \2 }2 d$ v) g( C

  1419. 0 ?" h2 O" c, H" j5 G' U
  1420.       # Check the user's answer  W5 h7 X6 ~" ]- |( _- [- d  t
  1421.       if [ $? -eq 0 ]; then
      n! j4 }- M) r3 y% D
  1422.         Log "Deleting MMaps previously generated." 1% x8 v) f4 I: ~  I" O
  1423.         rm -rf $GAMEPATH/mmaps
    , A! Z4 |! {# s- A" @
  1424. - d. B9 i5 P# N  h0 q
  1425.         Log "Copying MMaps extractor" 0
    6 G" W- ?+ x5 q0 C4 [( ~, @  C) o$ s1 |
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    ' t  S$ d! o1 r3 x
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    , C4 ~( N; r* f3 m1 h
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"6 K2 j1 q% z" S" W/ G
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    ! b) @6 [$ C, w( h$ o2 d/ M7 W
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    ; ?8 l2 o1 {( m3 ^5 R
  1431. ( [/ H( O9 A$ @+ r' G+ z. `9 ?
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \* s8 o" L% T' D& ?/ T$ @
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    # _8 \( ~" @  e  ]

  1434. 1 [; }( b5 g7 J; h
  1435.         # User cancelled his choice, set default to 1., k8 M& ]( o9 b( m9 o1 {: L9 S# G
  1436.         if [ $? -ne 0 ]; then: E$ @! |  w2 r0 u9 g$ ]  y; ^
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1, l$ G9 s. \" H& \3 V
  1438.           CPU=1
    ( s# N8 q1 L9 E5 k1 P. a
  1439.         fi' Z2 W3 ^; Q; c9 e

  1440. # k9 R1 c, T# S$ P9 B$ ?6 C- h
  1441.         if [ -z "$CPU" ]; then2 _7 S8 V7 {- T/ y; t& z2 s9 X- o
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1
    . L5 \8 y* Y% z' r7 d: `# m
  1443.           CPU=1( q/ V! ?) {0 T
  1444.         fi
    1 |5 Z! q3 ]1 s8 v3 |

  1445. / D% v) f% N* N0 a4 g
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    7 k+ k+ o# _5 V" K$ G
  1447.           Log "User entered invalid value. Max CPU set to 1." 17 W+ H, V7 n% r! e9 A' X7 i
  1448.           CPU=19 w5 E4 i- ]2 o4 n
  1449.         fi
    + P2 w7 z4 B) o. K; F9 H

  1450.   p- P5 j6 n  L) f. D  l
  1451.         Log "Extracting MMaps" 0( I- p" J% [, p1 u/ b
  1452.         cd $GAMEPATH* a; F! i$ e1 P+ P* g4 c
  1453.         # Making sure we can execute the script
    ; _3 V( _0 w( T, }; `7 h3 S7 b% @
  1454.         chmod 700 MoveMapGen.sh0 y+ E# q- s) T9 S8 m
  1455.         ./MoveMapGen.sh $CPU: [: }: ]& H( t: L5 _+ g! V
  1456. / y8 J  |$ ?, |4 a$ t
  1457.         if [ $? -eq 0 ]; then7 ]* n9 e- v5 l+ Q7 s
  1458.           Log "MMaps are extracted" 0! h4 w2 I2 [5 w
  1459.           Log "Copying MMaps files to installation directory" 0; {5 n2 k) R* O& k; T; r( f, B# {
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"! F2 E) q; H, a' H
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"6 D; `* X' W8 ]7 p
  1462.           rm -rf "$GAMEPATH/offmesh.txt"
    4 D; C% ?% f+ ?3 j7 D0 u
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"9 _+ W- }8 B3 y5 b' d
  1464.           rm -rf "$GAMEPATH/mmap-extractor"" X9 K9 w- [# P! C
  1465.           Log "Changing ownership of the extracted directories"
    - P5 F: V5 e6 a! @$ R1 _
  1466.           chown -R $USER:$USER "$INSTPATH"+ r9 b! }/ h3 x
  1467.         else
    * F5 V) z) k% L1 @$ T' p
  1468.           Log "There was an issue while extracting MMaps!" 15 q4 W1 |: i' G. h# k7 q
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"8 A' o5 a+ b, Q; H
  1470.           rm -rf "$GAMEPATH/mmaps"
    , w8 N3 b3 D) x1 v- G5 c
  1471.           rm -rf "$GAMEPATH/offmesh.txt"
    6 V6 `8 s9 U8 [8 V
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"2 n  ^$ v" x2 q
  1473.           rm -rf "$GAMEPATH/mmap-extractor"
    . [- Y. A# C6 Q( A
  1474.           exit 1, U0 S: w8 M( N% d. {
  1475.         fi; B, Y# W1 d9 M. ^4 @
  1476.       else& P0 [5 N% J- j# Z! Q
  1477.         Log "Copying MMaps files to installation directory" 0% k; K9 [3 i1 V6 H
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    * ~* g+ L) S( G7 E
  1479.       fi) F, P, O% w8 O! ^: O" ~
  1480.     else' A+ t5 v7 c0 T2 E& F- y+ W
  1481.     Log "Copying MMaps extractor" 0
    ( M- E3 e- O1 |  R) P2 ]
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"" J( a0 O' [' \% Z$ H
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    % u$ U" Y! H7 Q  w
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"& x  a9 b# ]1 q$ F7 _
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    4 \5 T; S6 a' t7 T" O1 W* U
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH") f8 ]- d( n" D, a+ {
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    % O; k6 D+ R  o1 ~$ Y# v& E/ D( n
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    ! ~& `7 S; G, V: o8 L2 e: e9 g6 e

  1489. # `1 Q' I0 O# Q* \( V3 ?
  1490.         # User cancelled his choice, set default to 1.: J4 |/ A2 Y, i: {9 Z# n, o6 |
  1491.         if [ $? -ne 0 ]; then
    $ M4 g# k" M* V4 o' @
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1
    * S, N+ P+ z7 A7 J! Q8 A! n% n
  1493.           CPU=1" A, T( S, @& ?+ X- i
  1494.         fi
    4 S: G9 l! g3 k: h$ q/ v1 U# L
  1495. 4 S, @$ e1 c* Q+ V6 N. F0 e
  1496.         if [ -z "$CPU" ]; then
    & W( {, [/ k5 U, }$ \
  1497.           Log "User didn't gave any value. Max CPU set to 1." 1- M( G' f( }9 T; a& |7 ^
  1498.           CPU=10 d0 A  I( K' o6 q0 Y) l0 Q
  1499.         fi
    : ?% I# }% W: X" W
  1500. - x2 t/ G+ ?  d- \) t
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    9 \) e2 k5 m6 T6 X, n2 N4 H" X
  1502.           Log "User entered invalid value. Max CPU set to 1." 14 _7 C# g1 X8 y3 i- b$ v0 E7 s9 P
  1503.           CPU=1# J$ j5 \+ P0 h/ a/ S7 M& f
  1504.         fi
    9 N( T& t; Z3 t4 u% |" q

  1505. + V* j+ k& L8 T3 M4 g3 K1 v1 Y$ q% d
  1506.         Log "Extracting MMaps" 0; H$ W- F* }. E. m! T# |
  1507.         cd $GAMEPATH7 @! \! y, w' [. c5 s" O
  1508.         # Making sure we can execute the script! @7 \. V4 R( ^6 c$ i( k! m
  1509.         chmod 700 MoveMapGen.sh+ W- K0 G' b. [  y4 b
  1510.         ./MoveMapGen.sh $CPU
    * i& i# ~! t; _/ }6 {
  1511. - q7 v- a7 [+ [5 K
  1512.         if [ $? -eq 0 ]; then& ~) n* ^/ b- N8 o
  1513.           Log "MMaps are extracted" 0
    $ _% s3 Z$ o! t- t: y6 I3 o* X
  1514.           Log "Copying MMaps files to installation directory" 00 Q$ [: }; M" }
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    0 K2 n( t/ n  l) B3 b+ p
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"9 c9 r" j, X$ c, A
  1517.           rm -rf "$GAMEPATH/offmesh.txt": ~3 \# Q/ y+ @' F
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ; ~! V4 H% g, ?- Y& e& M
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    - V4 g# M0 l: y* w6 D
  1520.           Log "Changing ownership of the extracted directories"2 K3 d* k7 Z; G
  1521.           chown -R $USER:$USER "$INSTPATH"
    . F$ n' I" c( j* x9 K
  1522.         else% x+ N/ B# p/ B% R1 O
  1523.       Log "There was an issue while extracting MMaps!" 1; _9 |) Q# B' S# S' o6 p9 [: Y! U
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"3 W$ t6 _2 B& L6 B
  1525.           rm -rf "$GAMEPATH/mmaps"
    9 D5 Q" N- o' R1 \) z0 {
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    : V. G4 p) y0 g  x" O
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    6 a' e' l( f0 _$ Y; j
  1528.           rm -rf "$GAMEPATH/mmap-extractor"
    9 h' M. Z, B' g: A: y
  1529.           exit 1
    % K6 v2 X* I- W, h
  1530.         fi
    ' `1 I5 A# w5 g
  1531.     fi
    . W# g- b! Z) _* b9 d5 V( o
  1532.   fi+ J6 c2 K$ n; c7 o! D% }
  1533. }
    4 W( K7 L$ K, a! o
  1534. / C" f" [8 d# r. {* }3 \& Q# L
  1535. # Function to create a Code::Blocks project
    $ L4 e8 B8 c2 X- o; A' b
  1536. function CreateCBProject- a: X' ]' B* F
  1537. {
    # t1 w2 W% B4 D& O4 N
  1538.   # Create the dircetory if it does not exist
    + y+ \: `5 Z: ^' Q. Q2 W
  1539.   if [ ! -d $SRCPATH/server/linux ]; then
    # n7 R: _9 A3 P- O/ Y$ U9 P
  1540.     mkdir $SRCPATH/server/linux
    ( |* ^3 v6 c7 ?2 }8 F
  1541.   fi
    * z' }7 L4 {6 A/ f

  1542. # G' S& ^/ t9 P, p2 U! t
  1543.   # Now create the C::B project4 e$ J7 V# y9 q- M2 P
  1544.   cd $SRCPATH/server/linux
    7 k9 a3 D& X4 f& O. W/ a% R
  1545.   # make sure we are using the cmake3; P! B) S" `( G1 n6 x0 M
  1546.   UseCmake3
    * {( E+ i6 S# W1 U# h, i
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    7 J" a7 ~2 u2 t: B- ]
  1548. }( A8 \% u+ Q9 g& a" X

  1549. 4 q4 z  W+ h0 Z& p+ N1 c

  1550. # U- b* Y6 K2 y2 p$ X+ f
  1551. ; H" r6 N! K% d8 w( d. h' V3 {
  1552. # Prepare the log. z$ |) E$ Y0 O
  1553. Log "+------------------------------------------------------------------------------+" 0
    " X$ w9 h+ `3 a. }) D7 u! c
  1554. Log "| MaNGOS Configuration Script                                                  |" 09 ^1 Y7 {9 w* x0 T
  1555. Log "| Written By: Ryan Ashley                                                      |" 0
    ( k4 H& D' k0 _0 \0 y
  1556. Log "| Updated By: Cedric Servais                                                   |" 0
    ! t# ]: L7 |, R
  1557. Log "+------------------------------------------------------------------------------+" 0
    # j: l! k+ h. y* w/ [3 k2 t/ z( z9 C

  1558. / r- D8 d5 F/ c1 _* C$ {7 L7 ~
  1559. # Check if user who is running this is root8 ]% G/ @/ m5 o4 h. o9 \/ M$ ]
  1560. CheckRoot( n& X! D. {! K+ u2 n% g
  1561. . [; W; m- d/ Q
  1562. # Select which dialog to use
    - N$ f# J1 X+ x. u1 L% e1 G
  1563. UseDialog
    $ R7 m1 P/ z  L' b  [/ J( h9 G

  1564. 0 y9 ~: O- t- A
  1565. # Select which activities to do( M5 }6 ]$ s, p
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    % |5 h. O. }. V) P% {
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \, B! k. \& \6 z* j
  1568.   1 "Install Prerequisites" On \2 [! a! U0 @2 _# E% z0 \) T
  1569.   2 "Set Download And Install Paths" On \: ]( q2 x) B0 F- B
  1570.   3 "Clone Source Repositories" On \9 c2 R1 E! c5 z, Y+ X, m+ ?
  1571.   4 "Build MaNGOS" On \
    0 K* A; j# S5 ~) R
  1572.   5 "Install MaNGOS" On \$ i) J) y: y! {( l
  1573.   6 "Install Databases" On \
    ! s- m, V" c# A- ~# ^0 d5 w4 P
  1574.   7 "Extract Resources" On \
    + Y  P* k( g5 g) D2 d$ q& f
  1575.   8 "Create Code::Blocks Project File" Off \
    & m' W- L: f4 f' }% P
  1576.   3>&2 2>&1 1>&3)
    " y. J0 }$ a0 R! r4 o! g

  1577. ) o$ W: X9 S  N9 U4 T" O- \" e$ D
  1578. # Verify that the options were selected
    $ H( t  a- {( c: X- B  Y* j
  1579. if [ $? -ne 0 ]; then
    5 f3 N" \6 L! M0 i  d' j. a
  1580.   Log "All operations cancelled. Exiting." 13 X6 L, L' R0 J5 }
  1581.   exit 0
    8 A% U" h4 O9 w1 s1 Q
  1582. fi
    : g* u6 Q$ j0 C/ V
  1583. 0 p' R, _5 l9 z: @+ V- v
  1584. # Install prerequisites?
    , P4 ~$ ?' F2 C- u" v1 N2 ~
  1585. if [[ $TASKS == *1* ]]; then0 E3 ?( d! u# d9 _' R( A
  1586.   GetPrerequisites
    9 @- \- O% K% I5 x
  1587. fi
    - q5 h2 D- Y$ b) [9 v) B2 x, a3 N
  1588. % r7 F3 W: T6 U/ ^! v* J
  1589. # Select release and set paths?
    5 r3 e3 n' c/ r4 e. y! q, }% }0 k. V
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    & G' \+ K4 p; {8 [
  1591.   GetUser
    2 j5 j5 [( Y7 d0 Y
  1592.   GetRelease
    7 t8 F, H' w, r& o. I" l0 l
  1593. fi2 c3 S. d2 V3 S" H# f2 P
  1594. 6 t% m# V' }* z' }( h+ Y! p3 A& I
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then
    9 v5 j: o$ q: m8 }& V) T4 A
  1596.   GetPaths# G! y4 p( A7 A4 }4 [9 L
  1597. fi
    % ^" g2 z" ^2 f0 c( U7 j, v, H
  1598. " i  Y3 ?4 n8 m' L7 [
  1599. # Clone repos?
    ' q6 F* }+ t% C! ?* r
  1600. if [[ $TASKS == *3* ]]; then7 l4 O- X$ W1 d6 h+ p) g& N
  1601.   GetMangos
    + g2 m+ C& u2 g' E' Q4 A
  1602. fi2 ?- Q  W; Q, r+ }

  1603. ; J4 l# L( V% S
  1604. # Build MaNGOS?
    $ c" u' e9 X# Z8 m% E  ]1 ~
  1605. if [[ $TASKS == *4* ]]; then
    4 a- B5 e% N+ P! [  U$ @+ b  o
  1606.   GetBuildOptions8 Q2 }- e, g& B) i* Q3 q, f
  1607.   BuildMaNGOS
    ( V! c, j6 r( ^* t) {
  1608. fi0 \- I4 W" w6 ~4 _

  1609. & |6 u6 K6 R+ q2 [
  1610. # Install MaNGOS?
    ; s5 f+ U# u$ P# {; v/ ^0 K
  1611. if [[ $TASKS == *5* ]]; then8 h* B+ H: t+ j: m* e5 ^
  1612.   InstallMaNGOS
    2 ^1 n5 v* N( X, C; Y
  1613. fi, c( K( ^. \% i! X

  1614. $ U4 m6 R8 T4 {! j0 W
  1615. # Install databases?8 a, e. @0 R3 }: P$ x
  1616. if [[ $TASKS == *6* ]]; then5 i4 ]* ?- b' y
  1617.   HandleDatabases" o# a4 e/ w4 }
  1618. fi8 m+ G8 e6 L& \' b2 S$ _( o

  1619. 3 l* |# r7 c& u" Q
  1620. # Extract resources from the game?
    0 E* t' l. b0 M! G& V* i
  1621. if [[ $TASKS == *7* ]]; then
      v- Q4 A& c" S$ z7 E8 _* l( l9 Q
  1622.   ExtractResources
    : P8 l0 I& W+ ^  L( }/ K
  1623. fi
    + Y8 \6 c. `; i! A6 x; ]3 }

  1624. 3 ]2 T0 C% M* b' G- G% ~! O9 `
  1625. # Create C::B project?
    $ W: p/ {/ G* u: T$ v
  1626. if [[ $TASKS == *8* ]]; then
    + y7 H& L7 N2 g( N4 G
  1627.   CreateCBProject
    ' ]. M/ ?4 a3 F. K
  1628. fi
    2 s# @  n, j  X( L: Q, F7 t/ v
  1629. 3 Q/ N' N% Y' a9 v
  1630. # If one of these actions has been performed, then we know the user.
    4 X' W1 J/ D& y
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then9 h$ e& ~2 t& W# Z3 e! {
  1632.   Log "Changing ownership of the extracted directories" 1" X* H" j6 J7 s. @- r
  1633.   chown -R $USER:$USER "$INSTPATH"( z$ @6 S3 T' A' v- I+ C1 d! i
  1634. fi* ]% w# }5 x6 ^- U% A# O9 h
  1635. , P; j4 c; l8 n* g! g8 I0 f+ Q2 ^
  1636. # Display the end message) I8 S: b& `- c% Q% h+ w, O$ q
  1637. echo
    - H; [# N- `: R' ]
  1638. echo "================================================================================"
    7 N8 z4 l( B. n0 k/ W3 b
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"& f! i2 T9 ?" [% U! P
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"
    3 H& j4 _' [6 g5 o% m
  1641. echo "server. If you have not configured your databases yet, please do so before"% ?" `8 r! {1 w) d" C
  1642. echo "starting your server for the first time."
    , Y- c+ f4 m# u& d* l
  1643. echo "================================================================================"& t% n8 r* j) D! Z9 I, J% b+ r
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh
    # d2 i/ f2 y. I; z+ D
  2. ##############################################################################
    2 D) f* b3 I! `& d4 b
  3. # This utility assist you in setting up your mangos database.                #
    9 g9 I, f% S9 i  p, m' l: A7 G
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #
    + s4 f8 W4 N/ m5 F4 ^+ @
  5. #                                                                            #
    1 k3 v7 \; B: R  U$ w% K! ?
  6. ##############################################################################! q1 T+ |- [# \" E

  7. ! I% [* ]/ W. D: n3 Q$ e7 \9 b
  8. OLDRELEASE="Rel21"
    - _' h* y. M# ~
  9. RELEASE="Rel22"
    4 B* P  y) K' y. W* c4 k* P
  10. DUMP="NO"/ h; l& N7 x; a+ W

  11. 7 E% {& L4 a* l2 S
  12. dbname=""
    ) m, b: q6 E) u7 n) K; ?" I
  13. dbcommand=""
    8 X0 V# K3 u# W. J6 h: E# p

  14. 0 ], \: Z$ t5 a$ m' D. c
  15. createcharDB="YES"
    3 f. ?2 [1 L  k, m% K8 v
  16. createworldDB="YES"$ g1 z( k9 ], }! b! u$ k0 {
  17. createrealmDB="YES"
    $ g7 n, K7 n' q1 l: U7 A2 h1 o' G
  18. 7 N( @7 d. L) E0 h
  19. loadcharDB="YES"  p5 U5 O* B! K. l
  20. loadworldDB="YES"
    5 V; a; v5 i- c9 x
  21. loadrealmDB="YES"" {  B* s. Y+ R! M
  22. dbType="POPULATED"$ n+ \3 h& W. v/ V! F
  23. 3 Y; l2 M% U3 s0 T
  24. updatecharDB="YES"
    7 p; H  D1 P* u+ R( Z! B6 c4 _
  25. updateworldDB="YES"% @' R3 L+ W$ f# J' i3 B4 z3 v$ y: d
  26. updaterealmDB="YES"$ z! Q7 L8 f/ ^$ Y
  27. : h) Z) v6 k5 N' Z6 ]/ \: J) T$ v/ p8 G
  28. addRealmList="YES"; }" B! u# @/ n  t8 e, ?
  29. 0 w; l. F% [' s/ T6 e6 D
  30. svr_def="localhost"
    7 B( P5 L. X8 t$ z0 i) |3 i9 J& i
  31. user_def="mangos"
    3 K. K8 P% A1 f7 e7 c
  32. pass_def="mangos"
    ! K1 S/ [. k9 Q
  33. port_def="3306"
    7 i( }) s# ]7 `6 N$ h9 n0 ^
  34. wdb_def="mangos2"
    6 `% K* U0 e( d
  35. cdb_def="character2"
    - e  |) ]+ Y) _1 Z9 C7 \
  36. rdb_def="realmd"
      m+ o2 A( H8 e/ }

  37. 3 n( w, n0 U5 S- ^% b
  38. printHelp()
    ; t9 I' G) `! B$ Z0 Z' }( Y
  39. {
    ! x* X/ k8 p- y9 @! q
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"- H; Q. s6 E  ]- n  A
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"
    : e, }+ c2 t3 U" ?' V
  42.         printf "\t-u: Run only the updates of the database\n"
    " ?& q" t4 l% T
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"
    6 x6 [7 s% O+ g9 o
  44.         printf "\t-h: Display this help\n", C! S3 T/ |# M2 m' x! ?# c% J0 w% J" M
  45. }
    0 i% C6 ^6 r& v$ `% y( T6 m% I
  46. ; \# y2 j' _* r& c/ w; E! M" Z
  47. printBanner()
    ) Z' d# B! l1 W+ K9 ]
  48. {
    / r1 O5 S, ?) N) P  f
  49.         clear8 I7 c7 _; Z: j' [
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"
    0 W) R3 C9 Q5 ^9 o$ G# c
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"1 |4 ?2 J  G! D5 b3 P* `
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n": `; b8 [8 u; P" H
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"+ x0 V; i( u$ `' ?. N
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"' w, C# V2 o9 R1 Z4 c* e
  55.         printf "\n"
    " y: t" y6 a& k1 u, Y: f
  56.         printf " Database Setup and World Loader v0.03         \n"7 {1 P" Q* J5 }9 N# z
  57.         printf " ---------------------------------------------- \n"
    ) |2 O3 i& r6 ~; ]& W
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"
    $ x1 Z" b% c2 @" s, o( o* F
  59.         printf " ---------------------------------------------- \n"
    ! N2 v' z' j6 O& ~
  60.         printf "\n"
    4 |' k' t4 a+ S2 s- z
  61.         printf "\n"  U, i9 l6 T+ D( B; t
  62. }# I: d* s" w3 K, `$ i

  63. / J0 \6 v/ Z3 T- E# c' h
  64. printActivities()
    $ @0 {, _; L9 r
  65. {
    # A' S! N3 l; `: h
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n", z: T2 x* J2 w; t' \1 O' z* l
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n". k+ u. L" L2 w- J; Y; H
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"& d* c8 n+ V/ [- A
  69.         printf "\n"7 J( `. U/ u) F4 t* u# n" R
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"
    2 L0 M; S6 C4 q
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"        4 T+ Z$ L+ s2 ~. @# {
  72.         if [ "${loadworldDB}" = "YES" ]; then
    & A& l; i. j! `* _* c3 w  {
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"
    ) a( F2 e4 ]; [% d3 s
  74.         fi
    # ]" k" O4 V% ~6 i% r
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n") b2 N8 }9 m: }, [- b1 o* o% {8 [
  76.         printf "\n"
    1 |: F' j, l: }" z5 _3 u  \/ k1 L) I
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"- R0 F, W0 K/ i5 r1 R8 |
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"! p# z3 p9 ?3 x3 U3 r, v# k
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"2 `; O$ B" B# R* e5 {6 y
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"       
    ( e/ X+ D/ `& e. M! T
  81.         printf "\n", o+ M+ I5 i% c- R6 p7 N+ b1 Y: B: s
  82.         printf "\t\t\t\tN - Next Step\n": l$ G% P6 w1 a1 H
  83.         printf "\t\t\t\tX - Exit\n"7 E. x4 R* p' _0 B( M" C2 A% J
  84. }! \- u9 X4 F5 U6 {0 V6 f

  85. + K" e) C( k; p: v
  86. determineDBName()! d+ d7 l9 \' {
  87. {
    ) O7 V3 |- O% K: K6 Z
  88.         if [ $(which mariadb) ]; then, L8 {# b) d3 X9 w" _6 h3 f
  89.                 printf "MariaDB found.\n"9 v; K" h9 L5 Q0 t+ [/ f) G
  90.                 dbname="MariaDB"
    $ G" \& U0 d- z' ^; i/ L+ J
  91.         elif [ $(which mysql) ]; then
    9 X$ r/ l. _; @( d2 G( b
  92.                 printf "MySQL found.\n". S# a8 }* P4 C$ o. l
  93.                 dbname="MySQL"
    , [5 ~; W% ?+ _! \; o
  94.         else
    & N. ]6 R6 Q, y; P$ D0 Z# W
  95.                 printf "Did not find mariadb or mysql.\n"
    $ ^  i: k9 n8 S* {% ?  i
  96.         fi
    # d& k6 ]! L5 V8 v+ e8 y, \
  97. }
    ' y; z8 ]/ [% |) b5 Q

  98. 1 r: `* h5 z' q' G& W+ R2 W: F
  99. mysqlconfigeditor()
    ) J$ I. Z5 J5 h! L3 W0 u4 t2 i* _
  100. {' O* `* r0 {) C, q' V" V, Z
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"
    % Y& J* ?  ^: i1 k& C# [. i
  102. }$ |4 U' D. g8 z" ]0 r0 K3 g

  103. 1 f* w0 o/ a4 r
  104. determineDBCommand()) `6 f# W4 I& m* U8 L, F+ k
  105. {7 G8 n% v% I, w
  106.         if [ $dbname = "MariaDB" ]; then
    * S! T& o& V, f4 w1 V
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"
    9 ]* a) j9 J0 X  Z+ s. N# t7 l7 v
  108.         elif [ $dbname = "MySQL" ]; then! X# }; R9 ^$ Z5 u% B* O
  109.                 dbcommand="mysql --login-path=local -q -s"
    & r2 i, s# f2 ]* C, e
  110.         else( U: a+ h+ {8 a- {# L, K
  111.                 printf "Did not find mariadb or mysql.\n"
    # e3 j! U5 r$ o* j, i% r1 G
  112.         fi* M+ Y5 I$ i% ^" m; q" p1 G
  113. }' M: @1 j4 o' E
  114. , Z) ]1 m4 I' O- A- e9 _6 _
  115. createCharDB()' j3 t- G0 o4 ^4 P
  116. {! l+ u  i' F1 r  Y- D% z( }6 l! y
  117.         printf "Creating Character database ${cdb}\n"
    : ^  K( l4 U, f: T
  118.         $(${dbcommand} -e "Create database ${cdb}")& }# g8 q3 o- t1 B6 `& @+ i$ A
  119. - y- N8 _" s- K" L: R
  120.         if [ "${loadcharDB}" = "YES" ]; then" U. k" d" N- i0 t! e
  121.                 loadCharDB: \+ b) X) d; k; ^) ~/ F
  122.         fi* w4 a9 Y. a3 K
  123. }5 n2 I* F  Y  Z3 R, I

  124. 3 _! I! S$ F3 t9 ?
  125. loadCharDB()
    7 M: L/ A( g3 H/ s3 `
  126. {
    % H, x  v1 j5 Y  [1 b
  127.         printf "Loading data into character database ${cdb}\n"
    4 v4 J9 T7 |8 H& r3 m
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql). I! s3 q( F  U! V
  129. 5 W1 E2 p9 E8 O( Q) z
  130.         if [ "${updatecharDB}" = "YES" ]; then
      x% Q* L" {' o6 X; H
  131.                 updateCharDB0 {1 r" d0 }/ w; Q' i
  132.         fi
    9 Q2 y6 [* B" ^
  133. }
    . P; N+ b' T3 i/ Z

  134. ( \7 ~# @! u9 u. w' [
  135. updateCharDB()
    & S7 u: x6 }* Z( |: ^
  136. {9 o/ s+ f& t7 I; W( Y  n
  137.         printf "Updating data into the character database ${cdb}\n"; l6 h+ M0 B/ H8 ?
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')  p3 T  T" q4 u. C
  139.         do
    ' [# I" j: K7 H  ~( y
  140.                 file=$(echo ${file} | tr '|' ' ')) }7 }- h- p: d/ \  q
  141.                 printf "Applying update ${file}\n", ?& {# l' ~1 @
  142.                 ${dbcommand} "${cdb}" < "${file}"! J1 K" x! [3 J* ~+ B' ^- r7 v
  143.                 printf "File ${file} imported\n"
    ) o" e- E, J. ?. [: _% R$ q* X
  144.         done
    # _+ a2 ~) w" W* a/ p5 q

  145. 7 d7 ?& ~6 M2 P5 k- I
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    $ A% u  u4 J: {" R3 T4 W
  147.         do
    8 i/ ~# P% P. |3 |/ B% |8 a0 z
  148.                 file=$(echo ${file} | tr '|' ' ')
    7 G& {0 ~/ [1 L2 ]. h
  149.                 printf "Applying update ${file}\n"4 o9 R# R1 e5 v5 B+ P
  150.                 ${dbcommand} "${cdb}" < "${file}"" _5 q- T% X- @1 T1 _5 T
  151.                 printf "File ${file} imported\n"
    ; ~# f/ I2 }7 d# w2 Z% W. N* F
  152.         done  `' [& T( n2 _% M" l
  153. }
    ( B5 E5 M  }1 h9 J+ e/ j1 L
  154. " M1 ^* P' ]) i" f
  155. createWorldDB()
    ; T9 `5 D* }) u- }, G& S9 Y
  156. {
    * i+ g" Z3 P2 H3 r$ g
  157.         printf "Creating World database ${wdb}\n"
    ' w. B( V# z: T+ ?2 s3 ^
  158.         $(${dbcommand} -e "Create database ${wdb}")
    0 P1 A$ d$ y- o% n4 t- z

  159. : J, [6 x; Q8 v( ?. ]8 }* f! G, Y1 p
  160.         if [ "${loadworldDB}" = "YES" ]; then* H1 \' y! Q# W: M; |
  161.                 loadWorldDB0 K9 J" Q( \4 Z- B
  162.         fi
    ! U7 R- b3 k) b
  163. }  D9 Q# X: B- R2 d, p; Z

  164. " i* k5 s( P8 O5 Q5 l
  165. loadWorldDB()
    2 D. _( a0 r0 t0 e* W" F2 ^
  166. {7 P8 O2 W; ]8 {! V  \4 J4 `: S
  167.         printf "Loading data into world database ${wdb}\n"2 x# m" N# o; y0 l/ m( c
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql). \/ g# P/ c( e2 Z" F/ v
  169. - N/ t3 @( T7 ?/ n
  170.         if [ "${dbType}" = "POPULATED" ]; then
    * s6 N8 \( r, C" @( `
  171.                 populateWorldDB
    8 N4 {' x0 ~" q$ W& B/ R5 b
  172.         fi! k+ J( V" d: }/ R
  173. }
    ) V  v/ Y8 L8 d" f

  174. - J; t# `% n1 L3 s2 F+ [% Z
  175. populateWorldDB()
    $ S7 ~6 j; j6 b: i& w
  176. {
    $ m! ?; Q! u8 _0 [" R$ Z
  177.         printf "Importing World database ${wdb}\n"
    6 ?, Y, L& ~6 N$ W- h
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    ( \, _" |" C" O; r" J, n( B; t
  179.         do3 q  A9 I' O6 ]; a, V" y* q5 C
  180.                 file=$(echo ${file} | tr '|' ' ')6 d8 O8 Z9 F- Z0 L
  181.                 printf "Importing file ${file}\n"
    5 q( u6 ^; s9 Z& m" Z
  182.                 $(${dbcommand} ${wdb} < ${file})3 M) w- T* M+ Q5 g" j
  183.                 printf "File ${file} imported\n"0 M' W  I- ]. R, W" [+ S8 R
  184.         done
    4 a* {- P$ Y2 U/ k# V( z0 x$ V
  185. 4 t- u, z) u2 d0 @. q$ {) m2 q- t
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ')
    2 o2 u& k6 k7 |1 o; h: W
  187.         do
    4 A. _5 J( d7 |: Z
  188.                 file=$(echo ${file} | tr '|' ' ')
    1 z7 J7 u' {$ X$ p$ m7 m5 N. L
  189.                 printf "Importing file ${file}\n"+ h- B' h7 o& N) ~0 M2 f* c0 Y$ ]
  190.                 $(${dbcommand} ${wdb} < ${file})
    5 D" |+ m# v) \0 p( ~3 y
  191.                 printf "File ${file} imported\n"2 Y8 ^& P" _0 I7 v% V- O( N4 `
  192.         done; O4 f5 Y- j2 Q& y' ]2 N& n3 s2 u5 n+ E
  193. }5 O9 b% ?3 i) H. j
  194. 6 @& O- g7 S" b* _# F1 _. D& u4 ]
  195. updateWorldDB()
    ! e5 Z) K" d+ k5 U  F
  196. {9 [4 H! i  J, ?3 M# B4 [4 Q+ o3 N0 \
  197.     printf "Updating data into the World database ${wdb}\n"
    * u$ }" G9 r3 x7 c! ]/ ]. v9 L" r5 m
  198.     for file in World/Updates/${OLDRELEASE}/*.sql# U( u+ z) _$ a+ z; ~$ W; ?
  199.     do+ k6 r: R- |4 F$ Z8 R# E
  200.         printf "Applying update ${file}\n"
    / A, M. f& K9 g2 N# U; X: S, a4 N
  201.         ${dbcommand} "${wdb}" < "${file}"
    # a2 Z- l0 [% |( z
  202.         printf "File ${file} imported\n"7 f. ^( b& `2 h! E& N3 f( c5 i% `
  203.     done& E' M' U1 S- K! y, o5 b6 b
  204. " `) {4 [+ n" {( u$ A; h( g7 V* F
  205.     for file in World/Updates/${RELEASE}/*.sql6 n# E% g$ Y/ P
  206.     do$ g5 N; E! V! A5 q* v8 Z- L( j
  207.         printf "Applying update ${file}\n"
    2 _# ~8 F- A9 ?" W4 r
  208.         ${dbcommand} "${wdb}" < "${file}"' {& u5 J) J6 j% ~9 ^& \
  209.         printf "File ${file} imported\n"
    2 F" Z* m3 }2 Q% h7 m
  210.     done
    6 A; m/ `2 v, w+ f- @3 i
  211. }, m9 X" D2 j+ _# [

  212. 2 y- E* O  b/ z- u, v
  213. createRealmDB()6 D2 u# o3 \* R- V
  214. {
    ) s( z. X2 }# C9 k1 [
  215.         printf "Creating realm database ${rdb}\n"9 G1 E. B& I: x% I  y' J
  216.         $(${dbcommand} -e "Create database ${rdb}")( Z" w. I+ A/ ^3 E7 i( A+ g

  217. 6 A2 m8 E* ]* v  t$ b. j  y, T  W
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    : d" F6 X3 S& g1 {- R4 ^  v6 Z
  219.                 loadRealmDB
    5 y4 O/ b  x; U1 O' l5 f
  220.         fi
    1 f; g4 m# V5 e4 ^, m% y/ D
  221. }+ \8 |  O0 F0 C0 T2 Y

  222. - A, y4 k$ ~$ `7 ^; @
  223. loadRealmDB()
    $ f& ~3 _; L+ n, o9 e6 G4 o+ l
  224. {# ^# n6 O, C( R* l% ]  k- o/ G4 i& }
  225.         printf "Loading data into realm database ${rdb}\n"        / W, q' b! e' }3 Q7 H; t
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)& o) z' E0 k9 x) [  e8 R4 C/ T! p
  227. }
    7 d8 ^) M( d0 W! U' y( i1 p
  228. 9 w$ c# `2 y" R0 K
  229. updateRealmDB()
    ! @2 d' O9 l4 z1 W- N. h: o: y
  230. {
    : D5 ?; R5 F! J: i
  231.         printf "Updating data into the Realm database ${rdb}\n"6 r  ?# A9 ^9 p8 ?* H
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    1 z. L) R2 ~" u; f3 E
  233.         do  i% D. z$ l; |! P$ m& X5 ]# l
  234.                 file=$(echo ${file} | tr '|' ' ')
    ; G+ p8 i7 A" V/ W6 A% _
  235.                 printf "Applying update ${file}\n"
    & k" j- s* n4 F) f! E1 h) Y
  236.                 $(${dbcommand} ${rdb} < ${file})
    3 |: F! E! s; ^  F
  237.                 printf "File ${file} imported\n"
    ' ~) r7 f8 M- K* h. W/ {5 S9 e+ U
  238.         done
    8 x9 V5 }1 |% b4 B6 ?+ y* s

  239. : p5 A# `* Q0 Y: Y4 S* O4 `( L
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    % O6 V7 M. _2 {  u- b: G3 a
  241.         do
      P- a$ c' v8 E4 G! A  M& Q& W
  242.                 file=$(echo ${file} | tr '|' ' ')
    0 z$ Z. y8 `0 F# K" D% {* o" X
  243.                 printf "Applying update ${file}\n"" `% R5 j; h% X% V3 H# o: j
  244.                 $(${dbcommand} ${rdb} < ${file})9 h8 x5 x' j+ Y( P" ~
  245.                 printf "File ${file} imported\n"
    . {* b6 d+ t7 F& Y! Z; h
  246.         done
    ' |0 _5 q; {3 `
  247. }" x* \1 z4 F% i3 ?8 m  _! ?
  248. & K) \% A$ G2 f5 b4 x
  249. addRealmList()
    9 r( L! a9 j) H; J: d, L
  250. {
      w8 x/ A9 W/ e# h! ^0 d5 T1 j
  251.         printf "Adding realm list entries\n") I# w4 Z8 K  P/ u& t/ v
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)2 p# m! o% s6 f
  253. }
    7 {' @: M0 X& x% |
  254. - L  s$ [0 y9 P6 f% h$ @2 j1 x- T' F
  255. activity=""# @8 j* n3 f1 l0 D
  256. 2 U: r( w1 ]5 b, b$ Y+ c% T* C: a# ~
  257. while getopts "suh" o; do5 X" O! [7 \2 a) {; h  L: r! ^2 I5 ?
  258.         case "${o}" in5 L5 l) j: Q+ [0 N; w2 P* e7 a
  259.                 s)& N0 p5 |: b% B) I8 y+ ?
  260.                         activity="N"
    ) u; B& h/ w0 c, |" x
  261.                         printf "You selected silent mode\n"$ H  H1 ?: U7 S- X% t
  262.                         ;;
    2 u- k& h( G4 \5 f+ J. F
  263.                 u): ~% Q; q8 J7 |" V" F! M
  264.                         createcharDB="NO"& Y; ]/ \0 N7 n* {0 w2 d- S
  265.                         createworldDB="NO"
    ; t, h/ x1 q8 p, A( C+ n
  266.                         createrealmDB="NO"
    1 K' V6 {' M" Y* r8 c. f

  267. 8 ~" Y# y4 n- J) _& T5 ], Y/ c
  268.                         loadcharDB="NO"  |* |, F( D* _2 J; |
  269.                         loadworldDB="NO"
    4 H' z) [. P7 a" ^- i
  270.                         loadrealmDB="NO"* _' J$ k/ P0 C6 B" h
  271.                         dbType="EMPTY"
    & }$ D; {+ m5 R
  272.                         printf "You selected update only\n"& M" f/ ]1 y$ K2 q, b+ D3 |
  273.                         ;;
    & @+ o- ]2 C6 `3 @+ {
  274.                 d)
    2 S% C- `4 S; w
  275.                         DUMP="YES"& l, a1 P0 {+ {& N* K4 \9 R
  276.                         ;;+ v8 {9 J) K+ ?, h" T
  277.                 h)1 c& A; g8 f' N6 D) P. w
  278.                         printHelp
    8 {  P2 H9 e- r* B6 ]
  279.                         exit 0
    6 k; m# t9 i# w( i
  280.                         ;;9 `4 d- N- H( \, |5 s  f
  281.         esac" ^& u& C( u9 R8 t; _
  282. done
    " E" S: M# E- {+ j3 Z

  283. % k! W4 R/ L! D! |
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]
    . J, u$ ]' b1 ^$ ?' W# K2 g) Z
  285. do2 Y5 ]3 ?8 M" r2 A# u
  286.         printBanner2 Z* t# G. w) `4 j6 T
  287.         printActivities
    " s0 c# N' z  B: a. ]3 q9 L5 ?
  288.         printf "Please select an activity : "  v/ U' V: A5 E) F5 z% h2 s
  289.         read activity8 i) E2 Q4 J/ w! j
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )1 q& h* q8 y) h7 }% h
  291.         case ${activity} in; F* |" Y4 H$ ~) f0 K, A  G1 Z4 k  K
  292.                 "V")
    + f$ _% l/ f' I9 j& k
  293.                         if [ "${createcharDB}" = "YES" ]; then
    % }9 O. A2 P5 m6 G/ o
  294.                                 createcharDB="NO"* }( `9 `0 \& _1 X: r/ D/ ]
  295.                         else % C9 u" ]4 O$ Y1 r# c# J
  296.                                 createcharDB="YES"
    : y% e% _6 R2 \, D' M' a
  297.                         fi
    1 L7 }$ s) F0 |
  298.                         ;;
    . g+ {% E- A$ c7 B8 {3 c
  299.                 "C")
    : J' r6 u4 P: X+ Z, a
  300.                         if [ "${loadcharDB}" = "YES" ]; then
    ; C8 U4 A- x2 T
  301.                                 loadcharDB="NO"
    % \3 ?6 A2 x9 w8 s
  302.                         else ' M% }' \9 L/ S/ D8 _" K
  303.                                 loadcharDB="YES"; Y3 t" i9 P% Q, t% Y
  304.                         fi7 c) }- g% [. p- ]* ]/ j/ P
  305.                         ;;$ [' H& U7 l7 ~* K
  306.                 "B")
    ( R; C7 W1 q: P
  307.                         if [ "${updatecharDB}" = "YES" ]; then+ k6 `3 f* H7 V( n; b
  308.                                 updatecharDB="NO"
    " y0 o2 A6 f4 T6 _' s. s5 R" S
  309.                         else
    7 e) n, k9 }+ o/ h
  310.                                 updatecharDB="YES"  J/ ~! i# y5 f  R7 V9 L
  311.                         fi
    $ E7 x7 ?6 J; Y6 D7 [
  312.                         ;;
    - q/ y, }  E" e& P/ d: v( I
  313.                 "E")  h6 F2 s: L# Y! Y3 M
  314.                         if [ "${createworldDB}" = "YES" ]; then
    + [4 g" {2 h3 x) {# _2 V( U
  315.                                 createworldDB="NO") w4 m8 Q9 J, g" L* z+ }
  316.                         else
    $ d% C0 @5 [. R5 A' @6 @# D1 }
  317.                                 createworldDB="YES"
    - @9 z( s  W3 V9 x& E
  318.                         fi       
    1 u& t3 A5 S  h; U# R
  319.                         ;;
    * o4 U+ {8 ^) ^0 D
  320.                 "W")$ [. D& v/ \% t
  321.                         if [ "${loadworldDB}" = "YES" ]; then
    # J5 a# ?" S! e9 b! i+ q* G
  322.                                 loadworldDB="NO"
    . _$ @7 r. g7 {
  323.                         else
    - D; [8 i6 J4 ~8 |  ?
  324.                                 loadworldDB="YES"
    4 l1 I6 F! Z. N
  325.                         fi       
    ' ?0 @- A# U, J9 N& f% N) F! p
  326.                         ;;0 m5 E- X# a/ [/ |$ v+ F
  327.                 "D"); l, [: S( r: K+ e7 b& C* G0 \/ V2 a
  328.                         if [ "${dbType}" = "POPULATED" ]; then0 Y  u- A" v; ^/ U6 F$ T( ]- F
  329.                                 dbType="EMPTY"
    : |& _) B2 a8 @: S1 M: ?
  330.                         else
    2 T+ o7 ^% f# R2 [1 o* r  K
  331.                                 dbType="POPULATED"
    - |1 h$ U+ \) _3 l( j2 k8 x; x
  332.                         fi                                
    - E7 {. N' I0 e
  333.                         ;;' d9 Z4 z2 L) i/ x/ v$ X: _8 L
  334.                 "U")* z( }6 F6 |' s. g! S) r6 d
  335.                         if [ "${updateworldDB}" = "YES" ]; then
    1 J+ O; ?' }' u. G2 C% y
  336.                                 updateworldDB="NO"
    4 A( F1 A! j+ H, e, u
  337.                         else
    ! U- m9 W& M7 B% ?: N( K& x
  338.                                 updateworldDB="YES"9 W4 l3 P9 K. Z+ l7 {/ H2 T- Q! G" h
  339.                         fi8 P! a+ j! z% z2 r1 w! H
  340.                         ;;
    9 ^# {8 p/ e8 p. q0 H% O; F
  341.                 "T")
    2 z, x! J- ]8 ]
  342.                         if [ "${createrealmDB}" = "YES" ]; then. E0 S  }3 m# f- k) ^' i4 {6 }9 a6 x
  343.                                 createrealmDB="NO"
    1 I: u; f6 t1 [" B( c
  344.                         else / Q2 C7 N9 _- [0 ?. `
  345.                                 createrealmDB="YES"* h" o; f( ]1 E* x% {
  346.                         fi                                
    0 \$ e4 h% S5 U# P0 M
  347.                         ;;% V2 @0 e& n) H& ^
  348.                 "R")
    6 f$ l8 ^# G9 _7 x3 h  E9 G  V
  349.                         if [ "${loadrealmDB}" = "YES" ]; then
    1 S+ r% `. S5 X) o
  350.                                 loadrealmDB="NO"                        7 D5 S. O. R# P: o
  351.                         else * e+ G/ z. r6 I9 Y+ k
  352.                                 loadrealmDB="YES"% e! a4 W. J# R  b. X
  353.                         fi/ z) s  V& @" X
  354.                         ;;0 r# |. \+ a5 ?- i) r
  355.                 "Y")# b# m8 q; O9 g5 D
  356.                         if [ "${updaterealmDB}" = "YES" ]; then5 C$ b; Z/ ^& H1 a$ j' U  t; A
  357.                                 updaterealmDB="NO"
    ; m. ]' q2 \  x1 D
  358.                         else
    & [+ n+ V" K8 Y- b2 L! m
  359.                                 updaterealmDB="YES"; b( E5 ^3 I# W1 r) }
  360.                         fi5 S. f$ S7 [$ w- s+ j/ M
  361.                         ;;
    7 l: ~( I  O! P$ k$ O
  362.                 "L")
    2 f6 s& L5 T2 }  [* h" u
  363.                         if [ "${addRealmList}" = "YES" ]; then( L! \9 i) |% {) J2 x) n* c
  364.                                 addRealmList="NO"1 g% d9 l( m0 _' p
  365.                         else ' L2 L0 d0 P# Q, q6 u
  366.                                 addRealmList="YES"
    0 s) c, d% y3 _" s9 ?- s
  367.                         fi
    % d) K8 \& G- M5 }$ A! A( N
  368.                         ;;
    : f, j9 y. G# s5 `; w& O5 R
  369.                 "X")7 g' g& F- I+ T7 I( h' Q/ D' u; G
  370.                         exit 0;;3 k1 H% {5 @( H( K& S$ @8 @5 N5 x
  371.                 *)
    . o# _2 w7 E- \0 u% o, E
  372.                         printf "Invalid selection";;
    3 @( n; K! ^3 N' ~3 _
  373.         esac
      ~# J' L6 b& f
  374. done0 D( I/ q; E; D2 V( ]

  375. 8 O9 {7 |8 L* m6 a7 [" t: B/ i
  376. printBanner( _: H% b9 v: [/ D8 }5 g/ K- C
  377. determineDBName& ]8 b# F  |4 `5 V
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: ", T0 `' X8 K- y" V8 A* I
  379. read svr
    ) K0 S" K( e% [* i7 E
  380. svr=${svr:-${svr_def}}$ @( J  n$ @$ E
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "
    4 k. y1 l5 H. o: ?4 i
  382. read user
    4 e2 a6 l* a/ F7 ^
  383. user=${user:-${user_def}}
    2 M7 i  A' Z2 @. l6 H5 H0 y9 g
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "# Q2 s7 c- s+ |- e
  385. read port
    , `0 A: N* G% L2 g8 w- f
  386. port=${port:-${port_def}}
    1 V1 z$ D- j2 j: ?7 s& n( m% ]
  387. if [ $dbname = "MariaDB" ]; then* O9 c) a7 M$ o! p9 g1 E/ u
  388.         printf "What is your ${dbname} password ?\t []: "$ K& a. U$ J0 F4 d- s/ v! p; ~
  389.         read pass
    ( w& F% Z* ?) l, N( A( R+ \
  390.         pass=${pass:-${pass_def}}8 v, c1 G9 L5 x, K6 S( C" x
  391. elif [ $dbname = "MySQL" ]; then
    ; f3 P3 G- v' x- U# I
  392.         mysqlconfigeditor
    2 x6 @  K8 n) m! D: v
  393.         $dbconfig& P! k6 u) Q) P6 e- v% T# J+ h
  394. fi% O9 B& X4 `, i
  395. determineDBCommand
    - [" h; n: j: S' N. }

  396. ' u/ H0 }4 ~- _
  397. if [ "${DUMP}" = "YES" ]; then
    + J0 V( |! X# Q& T6 G7 ~
  398.         printf "Enter it again \t[]: "+ V4 A. ?! n5 ]: U! M
  399.         read pass
    % H" U, m2 s) T, R* o7 \, j
  400. fi% U/ g. H6 `4 D* Q" ~- ^
  401. 9 b3 _. ?: L1 @! h+ T5 f+ d
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then& U" \' j1 l9 P! d( j
  403.         printf "What is your Character database name ?\t[${cdb_def}]: ". g" |7 V& y- k& Z0 ~
  404.         read cdb
    / L2 x  R! N' S& X6 a3 j0 F4 n
  405.         cdb=${cdb:-${cdb_def}}3 o+ A3 I: `+ v! q- V
  406. fi
      |  `0 S/ j3 D) J  d1 y
  407. : [/ _9 d) I$ j! Q: k, u- z
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then
    1 {% p( C6 {5 x2 s7 K
  409.         printf "What is your World database name ?\t[${wdb_def}]: "4 b. I8 l1 }4 [5 k
  410.         read wdb" h! A* x6 e1 r( V+ D, r' c
  411.         wdb=${wdb:-${wdb_def}}9 _. ?# x! A8 q
  412. fi- i  J) O0 b/ v( O

  413. * o7 j8 l: |1 }. n( V5 D
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then
    - K6 R% m( O4 }. e' W
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "
    * O! B, G$ J& p! v" p
  416.         read rdb- L7 s0 x: T8 B0 L: |, m2 v! S; a
  417.         rdb=${rdb:-${rdb_def}}
    + c" r4 q- I0 y0 b9 K* u! P0 {
  418. fi
    - d% P5 t, V0 s# a

  419. % k/ f  m( b4 P; {
  420. if [ "${createcharDB}" = "YES" ]; then
    / `7 I4 p% ]! Y' R5 G( ~
  421.         createCharDB9 V; e7 p- i* g, n" q- }
  422. fi$ y. V0 T. M# `! {- w

  423. / A( S- j  h+ m3 r4 z, |
  424. if [ "${createworldDB}" = "YES" ]; then
    % {8 R: H$ [" r" Z" ~; T& d, @
  425.         createWorldDB7 Z/ y+ ~, ~) m& O
  426. fi
    ; K" K" ]% [5 _  L, p( w" `% S

  427. 6 y& \! D! L% R# X1 Y  z
  428. if [ "${createrealmDB}" = "YES" ]; then
    1 ?, O: J; c$ Y5 u1 c
  429.         createRealmDB$ {, P" q& o1 \& x* i- b( F
  430. fi
    . X' M" }: G. h) y4 T

  431. 7 G1 I8 \# j; B" L6 D
  432. if [ "${updateworldDB}" = "YES" ]; then
    * }9 e2 K# w) L, b
  433.         updateWorldDB
    6 J' x2 L) e" j* d6 A
  434. fi8 j# [, u8 U9 T% v, C% d( B" S0 R
  435. / v0 q. \2 r# p, k
  436. if [ "${updaterealmDB}" = "YES" ]; then
    " q; |. {/ `2 r5 t
  437.         updateRealmDB- ^! u9 t5 O6 s/ x8 d
  438. fi  e2 }: I2 T/ G

  439. 8 N9 w: Y* @+ N/ m9 k- F
  440. if [ "${addRealmList}" = "YES" ]; then
      }+ H( ^% h2 O4 C$ ~9 o
  441.         addRealmList$ v( u( T; Q9 ?9 o; u
  442. fi' D4 ^# v8 b, n" X/ K2 Y
  443. 5 G5 b9 t' F6 ]3 b2 q
  444. if [ "${DUMP}" = "YES" ]; then
    , a+ J2 X8 z, H
  445.         printf "Dumping database information...\n"
    , R& _" ?1 G# i/ |& J0 y# n
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf
    " ]- A' h+ ]; |7 o! G
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf; d! H7 z; o* g
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf
    $ u' g. b" t- t& \9 d
  449. fi0 {  Y8 J; x( s2 ?
  450. + ^: E; P+ L$ L
  451. printBanner6 X' v: S( }6 V- s' T# H+ Z
  452. printf "Database creation and load complete :-)\n"3 f/ i3 X% y# x- v" A
  453. printf "\n"
复制代码
$ R, Z+ V& w  E
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令
/ M4 S! k3 v' o2 q
* i# l) I, ]6 |% i% `& x使用 Playerbot 密钥的指南:# ?8 W/ Q$ k, ?

; Q1 `5 C- L$ K: y) |2 p标识符说明
4 x' b, P! w3 \9 l8 }/ I9 l( Z机器人名称    机器人的名称! Q& K2 C8 p* q7 d( f% N
朋友    命名机器人或玩家角色
7 Y4 T, Z% ~+ Q! n3 k' c3 K/ `目标    选择目标玩家、尸体或NPC(非玩家角色)
' ~1 X5 [, f. ?3 m. w& R8 F|    逻辑或
$ J6 d4 R7 b, T& y; w&    逻辑与. q* c3 Y' ^5 o
..    多个实例
9 e( B: Y8 A, o% o/命令    MARCO 命令# k! t  {# O6 ]/ c1 {
/s    聊天:说* p  o" j# [! E5 n+ ~
/p    聊天派对$ `, G. V8 F7 m( B7 J4 a
/t 机器人名称    聊天:TELL BOTNAME
8 C2 q2 P7 e4 h2 N/w 机器人名称    聊天:告诉 BOTNAME
9 `, Q6 X' h9 i1 `4 k% d<名称链接>    名字=* k1 f+ ?- d0 O
(捷径)    为命令或子命令分配快捷方式* m3 `) z  y) _; i2 X

- z8 k3 {. V6 G; U9 I. N可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明" ]; G6 c8 O9 v) X# v, F
.bot 添加 BOTBNAME    为世界添加角色
: w5 x& g2 o6 \# y; H4 j3 D7 X0 y.bot 删除 BOTNAME    从世界中删除角色
& K4 w* \2 C6 \+ k8 v  \+ N0 }2 T  A6 }7 H0 g" S
当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)
4 z8 T* m# w; s. R, c.bot < co | 战斗命令 > BOTNAME    分配机器人角色
1 ^! |) X, [& y
' }. }0 P0 Q9 z" Z9 V, x宏命令:! s; W, t$ r6 M
句法    描述
# p2 j# q  O0 l3 \/邀请机器人名称    机器人将自动接受聚会邀请
; T# p9 H/ h! ?; \2 ?/uninvite BOTNAME    机器人将自动接受派对不邀请) P9 ^$ b" k9 z' k( n' O$ v4 i& X

) H: \& R% n$ VTELL/PARTY 命令:(某些命令可能不适用于某些内核)
8 H# K1 T; }& |) k1 }句法    描述* |1 |% E1 q9 Q
协助目标    机器人协助列出的角色,在他们攻击时进行攻击。
7 x" H" e' o  R; c- Q' K攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式7 w7 {) G, ]- w2 u8 F" ^' X
拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..
( z; A1 F9 }; c拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..
" f7 `6 Z, L) M. y. w6 |: [, g" Z拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..: |: X' s! z9 [
银行    命令机器人寻找附近的银行家并列出机器人的银行余额
+ D2 z' k. M7 H& {2 U9 l银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
2 R1 l' V# M2 U( K* Z0 M! R( R' `( @银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..
5 h* ?6 n4 z, n; |8 S# ?8 D(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..! i* m  l. v: Y) d
©ast SPELL    拼写 = >
3 {! y( ~9 A- L$ |搜集    显示收集对象选项和当前收集状态
3 O" x8 ^) J0 f( }# }$ L收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
. |5 }5 [5 M" A, s: r2 F工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
: r) K! D4 B4 P" w& g" L& `; A工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例
, W+ |+ `* ^. S9 s5 T工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
; g. @6 Z& j* t- x9 p工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习
$ @- l' e- O+ C) C0 o工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习8 U1 w- V/ x- e9 ~0 n8 \+ l0 \$ p
工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习
: O7 c* d) J( e- v" d" ^  Z: S0 b工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习. k1 m6 a' f2 \# c+ ^. S" Q& a
工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
4 }, n# Z; d1 n2 U. ~4 s# }工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习
/ }/ Y9 o. B. k手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习
7 V5 M4 I. d+ a工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习
9 r- K& t+ f. a+ k/ p* Y工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习" C- d# V/ c& C
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习
9 ]8 w. A0 C4 ~" X- e掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..
* J4 B/ L- |8 b8 S$ G- h% X全部放弃    当机器人库存变满时,丢弃所有低级物品。9 o0 w# @; q2 ?5 L2 Q  q9 f2 _- V
附魔    列出机器人学习的所有结界 1< Spell LINK >
: Z% r* g; R" Q# U4 L6 Q, @附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中
6 M" m" k4 z4 B0 B) e6 I/ w(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品" a/ {3 ~0 \* c" R/ d4 D
(e)quip auto on    打开自动装备,也立即检查
; Y) p, \. {4 o9 L* z8 X% Y(e) 装备自动关闭    关闭自动装备。4 X- r% I% [* j) E( K
(e)quip auto 一次    运行一次自动装备,然后将其关闭。
( J6 v  q# c: v5 r  p. p(e)quip 信息    显示装备自动切换状态(开/关)。
( R/ p' b( V" d; \# ~2 q(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用- i0 \0 e* Y! |0 n7 U
跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人) y4 \1 U5 B5 E7 J3 Y
跟随汽车    切换自动跟随距离(开/关)
4 F: z$ p5 I" v' l关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)
' p3 L9 u7 G+ ~, |) o5 v- L8 N4 y跟着远    机器人跟随,远离主人。
* z) `$ Q3 y/ ~& E跟随附近    机器人跟随,更接近主人
) ^" c+ U0 j* K6 O跟随重置    机器人跟随距离重置为原始默认值
2 Y) E: q& t6 E, Z" _(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家
" p9 X$ `% _; y9 p. B, W$ x订单    显示机器人的战斗命令8 E% t1 [/ L( M& P0 r  i6 A6 r
订单延迟<0-10>    在机器人开始战斗之前激活延迟。# \, Q: Z- T$ G
命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
, P8 N3 m3 J/ H6 j5 t  }! I" ?命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。. f. \, V- H2 L6 B# g9 c
命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。4 t! V; r; R) g. l
命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。
' X" M# H& Y+ Y3 Q5 q! r命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。
& ^1 h: W1 y# b5 l4 e. h- g) i订单恢复    将战斗命令恢复到注销前的状态。; `( J8 @) W5 H4 w$ J* f$ G1 P
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。* W+ E; G7 W; A7 p9 Z  q
mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..
( e* z  c  @, V4 G. Y. F7 M* |9 Y# `邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..  U! O) R* n8 r% i% K% _
邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
2 \9 T- V3 a& ?0 i+ E% d4 d宠物遗弃    放弃活跃的猎人宠物。: Q3 ]$ H7 s4 }/ X
宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术
; P# S' h4 {. M6 i1 R. ^宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色8 {. \/ [+ C: _9 s* d& n2 ]" ^7 M2 R
宠物施放法术    拼写 = >0 ]4 {2 @, \. `6 K5 h
宠物切换法术    SPELL = >为给定的法术切换自动施法
8 ?4 p) F" p7 H2 A3 _6 W% j& U( |宠物状态    显示机器人宠物的当前反应模式( a; i, A- h( v  g$ e" {+ U' P
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>7 B! |# G6 b7 T
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的: I/ T4 N: T9 ~( [5 u8 `# u5 W
处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素6 z& d8 q/ R; h5 g. z5 l2 R
过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石7 b8 H! U7 E* h
拉目标    以协调的队伍/袭击方式拉动目标。
3 L3 u) N# s4 A  G6 \9 [拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。
; i! g. _: p, Y$ I! A! U准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。" p" I7 Y- ~5 O4 @; [
寻求    列出机器人当前的任务
3 K4 R; Z  M3 l( E: F' Pquest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..
0 O; f1 {) I3 c+ A9 _quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >& ^3 Z1 O4 ~  G$ X- y9 |
追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务; W- s! w6 D) {0 u
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象
( c; v% ?# k  e. d任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..6 w2 q0 B% ]" w& d' p( k
quest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到
2 ?! j4 [! j. n9 J1 m' q" d修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
( q5 x9 W+ R, }# i全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品
/ a( r8 j- Q+ ^9 p/ A重置    重置状态、命令和战利品清单6 f: x$ t: l1 F" [
(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..
- R8 i0 n" }$ g& Y(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。
3 @( x( l1 j$ d! l# j) g- ?0 R- o8 l技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能  G2 A* n# H) V/ C8 b  @
技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..! l2 o  j3 n( H3 o5 |0 f# x
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >.., n0 _" ^) b1 u: G, l+ L
技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术
/ |( C- ?# H& s# B咒语    显示机器人已知的所有法术
- `6 C8 b, b# O# c8 G统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本' x9 O2 w: C' S- w, J% w" L
停留    命令机器人站立而不跟随玩家
& F3 B0 W" n5 P% ?8 m. v召唤    玩家附近的传送机器人" O; s2 u/ k# Y" v# \
民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..
2 n5 r0 [2 U! X8 ^6 Z3 m0 `使用 1< 项目链接 >..    使用物品(例如食物、饮料等)6 q$ _% U, l! @: r+ ?& g2 a- h
使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)
3 U0 K$ U3 C3 S- Q句法    描述) F2 j5 O' Q7 e  f( t6 y" s
天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用5 ~% c! d& U2 N2 e* a
人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋( C; Y" P# t/ c+ p
天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2
- y. x4 ~7 Y; |  s% k人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
6 Z' z! s: W8 g- A) r  `天赋规格#    机器人将遵循此天赋规范。: @; U: j' k8 x- Y8 D

, Y" x' `% W2 b- U1 要选择 , 。
: x) E  a0 d/ H$ j! k2 每个机器人的税收增加,每次重置天赋。1 E0 M  p$ X: T) ], q- c# ]( e& N

% v& V2 E& j. c$ @& Q$ \, _
% |; U+ @  h% J5 r7 z  O3 }2 \
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

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

Installing ACE on CentOS 7

Building MaNGOS on Linux requires ACE libraries. I could not find information on installing those here, so I will make a short HOWTO (copied from ACE documentation)% S. s1 ?$ f: [
! i+ S( S$ _; I5 w$ T, I
1. Make a folder for ACE in your preferred location ( I use /opt)
, Z5 z) o7 A; {3 l+ Y# j* I$ F- {# t) t. P( q* ^5 P( y* `$ |
mkdir /opt/ace && cd /opt/ace# f3 ]- Z. B2 T2 Y% K/ }

) K( i; g2 S% n# t3 g3 l! b& s4 h2. Download and unpack ACE
1 L- Z0 P3 Y. q% w/ g0 o! d, g& i: k
wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz- n0 g2 j# @) J
tar -xvf ACE-6.4.7.tar.gz% j6 u& l  K  K8 t, W+ \
" Q7 @" P0 c# V# C
3. Add needed environment variables
! ]4 [! Y) k$ R# l2 q/ l
* `; h" v# s  T$ k' k# b# y" {, \cat >> /etc/profile <<EOF3 v+ M3 y9 ~2 y4 H
export ACE_ROOT=/opt/ace/ACE_wrappers4 {- d% l: o' z6 O# i! @# R! d
EOF
/ a  P' ~; s! P0 a; Psource /etc/profile

' w' j7 I1 _! P( V, A( L1 ]/ c  p, @
" C! f2 S6 S1 d4 k; j4. Add the desired headers
# u- P& {  I+ F, d0 x5 a5 r# f* H8 ~+ g) L8 q3 G* Y; `
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF. C  N9 z4 B: g) K, u8 W0 J* V9 o+ |4 c
#include "ace/config-linux.h"
% N8 \* d. W0 t& j. x9 REOF
5 b6 _( p( Z7 R: F9 Q3 ucat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF
4 X1 w7 a: M8 a* NINSTALL_PREFIX = /usr/local
& A$ r+ h* z0 G, cinclude $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
+ S5 O! r+ p5 |4 J6 u& ?EOF

) _, Z  ^  f' y/ }# M# j& Y3 F( x# D0 d. Y4 p1 F
5. Build ACE
  h7 {# W% r: w! c: n) T2 j5 ?/ q! I2 l: u+ g' Q( f' z2 l1 D2 i2 L
cd /opt/ace/ACE_wrappers
+ T* z. b  `# X5 xmake
, x: l2 T" Y7 O  P$ @make install

" i$ K% r3 S/ o! W/ z' M( \0 s
4 {: @% c+ s8 i% u. o$ }6. Add the library to the public path
" A- B( d4 {% [1 F3 \4 B  e0 R) o
& A2 o% l8 [; y, S! pcat > /etc/ld.so.conf.d/ace.conf <<EOF2 O6 C1 A, Z2 {# f
/opt/ace/ACE_wrappers/lib
* \5 P1 ~: e2 O) ~5 ~EOF( K0 G$ w# W" b/ @  H0 q
ldconfig -v
6 _. ^( n, ?1 s; a+ h  c( h2 B
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client
7 C4 ~" _) O& n. ^Torrent Download2 Q/ x, v- `9 T
  k5 V- R6 ]: r" D3 T$ k
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# \! J5 ^# o7 W
) ?+ T" P  z3 a0 S9 X, ^! B
    Torrent – Client from Dalaran WoW (Recommended)
9 Q# p9 O! R  I) D# ]3 v% C" H    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)1 ]; w5 p0 ?. b3 @$ M
    Magnet – Client from TrueWoW" |0 A/ ~: k1 L: v
; V* v  m4 g$ q8 E
Direct Download; N4 ?5 l' n9 U" G2 ~) }# A( D$ o
* G4 Q# Y% E3 L, S' ?0 W' K
Below, 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.
$ E0 f+ J5 h  K2 x  D6 }% }
( p( u  R8 b! H8 g; C    Direct – English Windows client4 Z; c* o% U8 N  ~) n; y

  a3 h$ k. Z2 P' \3.3.5 Wotlk MacOS Client
2 @3 F( \" e% R6 q$ k2 T# w. N% b, |* E  V8 J% \" c% ^. |
The 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.& [0 F7 x4 f9 z: l; ?+ X7 }/ C6 n

1 b4 n) w2 w  T$ q5 C" T- Z/ f8 C    Direct 3.3.5 MacOS Download – Client from Sunwell8 A% ~! v5 {0 D8 N! x6 u5 v9 J
    Direct – Client from Paragon-Servers (French)(Mac)
, h- z7 W% S! y7 u0 W4 M9 V6 o) a# ]1 S' U9 }# k. Y! |. P1 x* \/ X
Modified Clients, LegionRemaster:0 s( `" O/ Q3 y
  S' l2 c0 q0 D6 @( f5 k
    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis( N6 W6 R& V$ N" Y# Z
    LegionRemaster Patch (modified)" ^/ O6 u2 }* x3 z3 }  R( O
    LegionRemaster ReadMe (Custom)
5 \* R7 [, o% Z; K1 Y; ihttps://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos
) T4 a+ \2 a, V" k) @5 l
/ u7 q/ e% e7 Q! _/ _4 S$ O5 w在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。+ P+ Q' ?0 i, k4 q' K

5 n1 Y0 m9 n3 a& v5 b0 u本文 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。- q; I, l) \9 x! C# |* V

( ~! x4 ~! O3 \4 B+ _正文如下:
8 `& R, b% B" ^( F/ ~5 c- N& Y6 d" H, q$ E
开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。
2 K6 k5 [, [2 D; O) N$ ?; I% R8 T
暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。
1 O! W" v( a) y9 l% Q, i/ N- n9 }) u$ g, w4 A+ U4 a; e/ a
而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。
- I/ b) \6 k7 Q% N7 I# @  J" }7 j. R/ E8 |& n. j
  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。7 B% G) g& \, h0 F% }0 o3 S( ?9 |5 h
  F* q; {) ^# P1 u8 m  K. ^  Z
开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。1 L) L: [4 \/ e, H

& P5 ^8 S8 D" ?( amangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。, b2 j; F: `5 U! c; R

6 v2 J  W* j( M
0 u5 D5 |* f6 k为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。/ q1 A6 S2 S6 a2 m" S
# g9 Z6 T( r# [; B" u
一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:/ y  b) W5 H0 z0 ~# i  O
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:* a9 R# R; {' _3 _
    Brien
  • 开源数据库软件MySql
    / P" G" p, Q. o* i, K1 ~官网:MySQL

    # R5 f9 I" A$ q或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库
    7 p# L7 S7 [% t- p官网:

    6 {1 R) d8 M3 N1 i  P# g我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。
    ) p" e0 U9 W/ ]" q8 T文件名:CompleteSDB156-Mangos3462.rar
    ! S  }9 H+ U9 f& a# H; C) b3 M下载地址:- @/ k9 y6 ?6 i4 ?9 J, U, Q

    - C* s2 q! G" L; z! |( o5 k
二、安装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"
      8 o# v3 z) a+ p7 ?% k  M6 ?* K% V
    8 ?$ j0 }8 d' [. ]) D' d
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径) R! n! r1 I+ I: C' D
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。; J4 g5 u, G, f
四、解压安装地图文件, W+ N8 `4 w! H. n( [! g$ O0 k- Z
  • 把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子目录了。+ Y- R2 D6 k" [" H/ }/ J6 ?
五、解压安装提取的*.dbc文件. }* ]* @/ E9 T
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:
    ) `. _, U- A+ i- \' F) y; u( `mpqe /p dbc.MPQ DBFilesClient\*.dbc
  • mpqe工具将魔兽的游戏信息提取到了\MPQOUT\DBFilesClient目录下,整个结构为:("C:\World of Warcraft\data\MPQOUT\DBFilesClient")
  • 当mpqe运行结束后,可以将所有的*.dbc拷贝到你的mangos的dbc目录下:("C:\MaNGOS\dbc"),你大概有158个*.dbc文件。
  • 你可以安全删除魔兽世界下的dbc文件目录:("C:\World of Warcraft\data\MPQOUT")了。+ A2 ^0 N, ?: F7 I! \
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.
1 I, V8 b2 {1 E7 }6 W* C0 L
  • 将下载的CompleteSDB156-Mangos3462.rar文件解压,里面有几个数据库文件。找到其中“realm-database-full.sql”和“mangos-full-for-rev3462.sql”文件。
  • 使用SQLyog连接到你的数据库。
  • 在左栏找到realmd ,点击右键选择"Restore from SQL Dump",找到“realm-database-full.sql”,导入数据库文件。
  • 同样找到mangos, 点击右键选择"Restore from SQL Dump",找到“mangos-full-for-rev3462.sql”,导入数据库文件。8 a$ l& g% G3 n& A2 R. o
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。
6 r" m& J- M% b% ^/ _
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到5 A, l8 d1 ~" X9 J5 Z
    "LoginDatabaseInfo ="$ S& \0 F: G1 G. E) W
    改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"
      |) Y3 c5 U4 t3 g" h这里的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"
      6 [9 g1 w& x1 P/ D5 T
    : G/ A& P# l+ Y; H: q
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。

8 k0 z+ m* A/ K; f( U$ @5 e3 q
9 |" i8 H* C% a; E- C* n6 k' ~( `  _+ A7 k9 k  \/ Q
5.安装数据库( r3 p; m8 d! O+ S7 `6 C
使用mysql建立 mangos 数据库4 i7 x. J  D, O5 J, N

) p& \+ P3 b9 M( S1 M  D# ^' da1)使用官方最小数据库,mysql用户名及数据权限等请自行设置
3 N! n$ M' h" j$ i# ymysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据
) l# w; {7 H- l7 a1 ?# ^7 o. P
. X- U8 ~- j+ H( A7 d$ |9 j8 ?, Ka2)使用sdb数据库,mysql用户名及数据权限等请自行设置
1 }: b: V3 k1 a2 J' z假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql8 `  O* x) S3 f5 h. y# T
mysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据
! q- i9 B5 T" s* b; q4 A0 z5 v9 J/ n5 q# w' n+ G' o8 J
b)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1) |7 T. l; X/ b& ]1 I4 @# P: M  \% P

0 \) I* [7 c- L5 m2 J6.编辑配置文件% E( }7 K6 O1 g- |! {7 w
编辑 /usr/local/mangos/etc/mangosd.conf
3 C/ v% n' \# `. t9 z- V; X4 {* z2 o$ G
a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"
0 l6 ?) }2 _( ^# S( L为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"
) N! H$ `; f6 I' [/ X# ^- O
& v) W9 A1 g: T3 v/ t- }' cb)找到 Host = localhost
& |7 n; ^8 h% t- i  ?为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1
7 R2 L! V7 [$ K8 v
& |) ~: J# W; Y( |; Y; e
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55422
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。1 ?9 j2 L# T" L  c5 m  G6 W
) ~0 u1 L! r" V$ `5 z7 a
本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。
. H" \- f) [4 P& _1 h- ?' y
; m9 M6 \5 L( e/ r4 }$ }- N+ n我们走吧../ ~+ E! O' q6 W. S2 D5 z. O: n

+ B1 B4 ?$ Z; ]/ t设置数据库:2 P9 J' n- \" X" v; S
6 W' [) q! T( [1 C2 [4 ^
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。3 ~& T% v. J% F4 J
3 v# B0 e* U+ {3 q# _% A( {6 @9 L/ y
启动一个终端,如果还没有,您需要成为“root”用户:; t. K9 t6 \1 h" L6 |2 K

- V8 }5 J: T, x: q, q须藤苏 - 根
' M& R% _$ J! Q然后,安装 MariaDB:' j) q1 n7 X. |2 I, ^- e6 S
. s6 @$ E4 ^8 H. G8 w' x2 j; l
yum -y 安装 mariadb-server- a, T9 U' w  R
     安装 MariaDB 后,启动它:* @& H& S) R/ J2 w

) I4 n  [4 R( n7 G+ isystemctl 启动 mariadb
' A( N" }7 T9 e我建议您在启动时添加 mariadb 服务以自动执行它:9 ]( d$ ?1 g3 N( S& l! B
6 m' _$ L0 r' k( F. l
systemctl 启用 mariadb/ f: v; m8 }# M# {
让我们保护您的 mariadb 安装,执行以下命令:! b( _4 ?8 r1 N9 A7 ?/ V& w9 A6 u
! }  Q  o$ }  c2 Q; l
mysql_secure_installation
+ e( S4 @5 }. X1 u& ~) l# W我建议您设置以下参数:
' D0 Z0 D8 S! N) e' I" B  k3 Y" |- ?* b
设置 Root 密码
3 G* w4 x9 Z) R- s$ L3 V删除匿名访问2 @# [0 P( T: C6 u. Q8 L
禁用 root 用户的远程访问
  K9 n/ |. c* a删除测试数据库
7 }% t$ W  r; i; h- j重新加载权限
  {$ L  L# ~- J; i, U1 Z& o验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:/ S$ d' ?5 B1 z$ A

% `3 T6 h! h; b: r" F# N: bmysqladmin -u root -p 版本
; K  V% ~3 @7 z0 X如果一切正常,您应该有如下输出:
# r) h0 M" ^. U, S( J8 k
/ D3 L/ P9 T& q# Y. f( R2 v服务器版本 5.5.52-MariaDB% g2 P# l1 ^0 a, u0 c+ V
协议版本 10
. Q7 s: s4 P" E. A/ E) s通过 UNIX 套接字连接本地主机
1 X* I# l0 \6 B8 l6 ]UNIX 套接字 /var/lib/mysql/mysql.sock
) }% M9 g9 m+ L, G  I正常运行时间 x 秒# r7 O; ?0 t3 V5 W5 `/ j
' s1 c  @! Q) @& t# g

4 n: S. v; _# O( J* N现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:
* a/ W  x; @. w$ ^: }/ B( q% e- c& F5 Y, b& Y
mysql -u 根目录 -p/ Y* @. C/ O  v0 B8 p
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):
' R1 L1 p: q" h2 {& @
' z+ Q) h. \; d3 |创建用户“芒果” @ “本地主机”由“密码”识别;
- x1 \! X5 R) G; k然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):
3 h4 P" c4 m. [# e9 \2 F' g/ b6 {+ M* A  X+ L+ K" h! B
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
9 o& l$ z/ W, E9 q, M* W退出终端:
5 G9 |; i8 V* `2 I/ I( F: s! z& }7 A# _5 ^
退出, V. k, H& A4 l0 i) ^
恭喜,您已经在 CentOS 上设置了数据库的先决条件!
. P5 m) B  a/ f7 v" O+ a* {% ^6 C1 R' v/ c8 }" d

3 H& D" B1 D4 ^# F* H: H3 Z
9 K. G+ t' E" ~, e7 h+ c4 \3 i安装芒果:
3 U) b5 d# e* K' M' ~* t, E4 w& U5 B) `% _9 r- z0 b+ F
我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:. f# Y+ P9 R7 Q3 p% j+ l& U2 x

1 f2 i+ m' E! v' H3 Q) b4 r! c7 [: J光盘~
4 p4 E: ^( e) @( s; x( y8 @8 R, r3 H让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:
9 B" v4 N( c' G. r1 ]& A8 @5 O+ ^: d/ q" r8 F( T
yum -y 安装 wget
( b& c( B, T8 M& e& d) x现在,我们可以下载我们的安装程序:
) _2 i  H( G4 Z% `
! ?9 O  C, y% |8 T- y2 T# x- `1 p4 ^wget https://raw.githubusercontent.co ... /linux/getmangos.sh
6 F& T# I4 u) D* K6 I) k. H设置允许执行它的权限:3 S! k/ f2 C: k; M) x
( Y6 X1 V& N6 Y6 J) r# k  o: T$ Y
chmod 700 getmangos.sh, o; k  V  G) d
并执行它:/ l/ R* t+ O2 L
! A9 i2 D& G  R4 c, {1 Q
./getmangos.sh
5 G' x1 f% M: W# T在我们进一步讨论之前,对可用活动进行一些解释:
3 F& ^' z+ U% @4 P! ^2 q4 v/ b' n* J5 }. R0 h. V" t" I: a
安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。
, e: A* {- F9 w9 l$ W设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。# K( I3 H1 O7 e7 P3 p  f
克隆源存储库将帮助您克隆Mangos源。默认切换。
* R# H! W2 Q4 X/ pBuild MaNGOS将协助您完成MaNGOS的构建过程。默认切换。  p8 _) }5 V! y2 G$ _0 `
安装MaNGOS将帮助您安装MaNGOS。默认切换。& z0 U  q* z3 S1 x9 X
安装数据库将帮助您创建数据库模式。默认切换。
2 k6 |/ d, t' m3 i提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。9 o0 C* J6 l1 z
创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。2 j# E5 E9 I$ V+ F' a: B) p" {
现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。
4 u( S7 ~4 z8 K5 T
& o$ \8 ~/ Z- ^6 u- A用户选择:" j6 S4 x! C3 y* i5 K
  j, M! M8 n4 i
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。* B9 |6 h2 f; F# `# D0 E9 b% a
0 q/ V: F& i% l. v- J
如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。
' j# e  r+ B. T, z
( _: x5 i6 N2 a( i" Q( C选择魔兽版本:
3 A8 E2 }4 T& D/ C( e( [6 }) X9 U! e
4 \: H! f) h! j. P" k9 [下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。! v% |: K1 v( P" |3 t+ Z6 t* g7 G
% [6 h" r5 R" {; ^9 n
源代码路径:' o' ]3 W7 [  v6 b$ C

* m4 ~& P: {7 K) W# @4 Y下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
6 H" R* o" v' n, f% R) g7 Y$ ?4 D" S, h# T* b0 t. e
/home/芒果/zero/src
: {0 A# Q+ u7 y6 S* }, D2 r如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。  |* j- R) Q) k) I/ p

5 L( W) `2 i2 |( p9 J安装路径:1 N" m  A4 p) T6 G2 C; m" s) {

  w; h% Q( h2 c& e, u5 o" @下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
4 d; m1 z2 S. y% K6 o' E' f" V5 q% ]) q
/home/芒果/零
% H3 V+ A9 E- O7 H/ o" o- F如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。' v0 e, E( O! Q+ O0 ~0 \7 ~, J# R1 V
: b; ~. \0 U- K1 ?6 b2 C
克隆或更新MaNGOS:3 \6 V: r% _, @3 \- g2 h

2 \3 h5 |6 ]6 T5 z! d7 p脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。8 ]/ p( ]' [# O+ r: t/ k! D, {
2 m/ h, E+ y5 g: |& ~
安装程序现在正在克隆服务器和数据库存储库。9 c- ^. D; z" |0 z- S
7 \# A2 z3 g' ]- T' v
构建选项:: ~9 G0 |: o7 o1 ]1 f

& t; x2 n' V, Y+ Q* N) x. O. a您现在处于构建步骤。此屏幕上的一些解释:
2 G/ u5 R7 H- n7 v' K! Z% a3 w$ M$ q! `/ V5 k0 Y6 ^2 b6 p
Enable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。
1 e0 B6 h- `# p; i使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。+ \/ Q. l) E+ U# V8 E# O
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。" G' y) _- w8 x8 ]# @
使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-6-20 05:57 AM , Processed in 0.172347 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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