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

MangOs搭建魔兽世界私服

[复制链接]

985

主题

92

回帖

5万

积分

管理员

积分
53561
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!6 ^. B4 E7 [7 Q
考虑再三,我选择了CentOs来做游戏的服务端操作系统。
7 t  Y) P, D* r+ g通过Git获得Mangos的源码之后自行编译搭建服务器。
1 h% O2 n# J% D4 I. H. C1 q# G这么做处于几方面的考虑。
0 }* i  E) f' ~% Q% O- K
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。8 A* Y2 S0 n' T/ {- n0 P
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
/ i% j! V  o3 {把该打的补丁都给打了(yum update)+ k# {$ n8 P7 e/ H- L
完了之后,咱们安装一些基础的组件和环境。3 {" p" z  l% e1 z8 f0 j. S( |
Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel+ v# u7 `1 E' ?6 b4 _
如果有些组件提示没找到,无所谓。继续往下。- t0 p# v+ w( L9 A, J
我编译安装的第一个版本是cmangos。
& i  A: @/ C- O6 G3 g5 r这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。5 ]( Q6 e7 l* M& \! f
cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
; l% g6 b1 w% \' V* n, u; a编译参数中:3 j! l- K( U! h6 I' o
DCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。
1 Q9 D$ M0 W" J. mDBUILD_EXTRACTORS是指是否安装地图提取工具
& F& {- F. Y4 Y. Q1 u! ^- ADBUILD_PLAYERBOT是指是否打开机器人- b! F" i5 ^& Y7 M* x9 r  S5 S* h! A
这里我做科普2:" i' C  B6 ~, U8 m; _; ]: l$ j% O
首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。
) T+ L; m: l9 G( b既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。( ?. S& ?; l: Z- U! r! H1 {8 ?6 w
至于那个机器人吗?那是个笑话,请自行忽略。
! n2 R% L! a6 K" m; D" B我们继续,我把整理好的搭建步骤列一个明细:7 z! \, B; e" r, R2 C2 p% k
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。* C: U8 u, f1 h" H2 V: t* e
这中间,我把一些别人不会告诉你的关键步骤做科普3:3 |4 i8 U* [9 k+ m8 Z
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)9 D+ E% h6 F5 m" d0 [
放几个链接仅做Mark:: W8 e7 L4 Q) J2 ]
Cmake3 安装
- g/ W( Z3 U' C2 l& D5 Q! U: uhttps://blog.csdn.net/weixin_38883338/article/details/864087494 ]  Y0 V; Q& P" ~7 C
Gcc 64 g$ G* k& l/ H  ~  F
https://blog.csdn.net/Al_xin/article/details/924380554 l. q9 ~3 D9 w# M2 I
ACE6.3.30 P, Y; ^+ m0 U* g4 U# r
https://blog.csdn.net/u010587274/article/details/50965369
2 H- F# h6 Z+ F6 dGit源码和数据库编译安装服务器$ e' k4 S6 d+ b; s
git clone git://github.com/cmangos/mangos-classic.git mangos
; K& S* r6 {" b1 Q& u. Tgit clone git://github.com/cmangos/classic-db.git' ]& ]6 t8 z  s) T; L' I
ACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
. V: F8 x% l6 H我们来说一下服务器的配置。
% i+ I  m) `( m9 ^) f& F! X在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
3 M; w. p" q  R# h
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)
    3 K6 p. J! u4 F* t: X$ `4 D7 X
有几个关键点,我整理如下:% c8 J6 x/ @8 P0 u# m. M- M4 X6 j- b
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。
    0 n% x- |. x9 U2 F$ h
参数名称:
% v! m( u/ X8 }1 m地图目录$ u& B. l& s; f; u
DataDir = “../data”
; C  D8 o. q/ m$ R日志目录
) Z3 `8 M0 p  _- V( VLogsDir = “../logs”' I, \- \; F9 F5 D% p; t+ \
游戏欢迎语
6 d3 v! b( M0 }$ d5 @Motd= “游戏欢迎语”; B0 O- J+ W1 a9 X3 `
出生等级
6 j% b) k. I) Y+ U, J- E% LStartPlayerLevel = 1
& {& {6 Y& T2 D8 a9 C$ W. W4 p出生携带金钱1000G7 H0 B$ A6 d  ~, W( B  S
StartPlayerMoney = 10000000
7 q+ V+ ^3 x% {4 d, ?杀怪经验5倍; z: K' Y% }9 @( e
Rate.XP.Kill    = 57 A- f+ F; X3 p/ y" f) v
任务经验15倍
# l9 C6 }! C% G9 V& \) dRate.XP.Quest   = 15
% }3 K! W9 `* m探索地图10倍# b) Y9 K3 u" C$ Q' P5 ]+ a4 E
Rate.XP.Explore = 107 p( h! j& e5 R. h7 \7 A4 ?3 H* t
数据库连接(应该有3-4条之多,按下面格式修改即可)
8 {# D2 }! U0 KLoginDatabase.Info              = “地址;端口;用户名;密码;数据库”
; R% G' j% \. z4 M5 i; U* a; K配置结束,就是启动。8 s/ t4 G  Y1 \; ?9 U
因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。
2 W- V6 R2 ?& S* w我们需要开启如下端口:9 p- z/ }1 F1 _, J
8085,9600,3724
3 g; z7 x8 n# e把他们添加到你防火墙的白名单即可。* @7 Q8 n) U" \* |! x" ?/ e
(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)7 V3 V) F( Y! D% G) A' ]6 C3 ~
一些收尾工作:2 ^6 g( w4 \* ~: c8 U
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。
    ( {& N" W+ D% Z- O) i/ _1 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

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
- \2 h- |, I7 F; L2 `git clone https://github.com/mangostwo/server.git  A& B# `  k0 z
git clone https://github.com/mangostwo/database.git' n, q' i$ L9 e4 G( {: W

9 u, }4 r+ x3 t, k/ \; {
  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& K9 {% b8 q$ N9 O9 ]6 P
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils
    % @  I6 Z! [! ~, G* E
  3. scl enable devtoolset-7 bash) c& m1 D* j9 |7 S/ c( B/ X! S
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile
    : T# F3 I6 e- P: N0 \3 c+ |
  5. # 查看安装的包
    / k& u; [1 E- V9 T/ r6 l
  6. scl -l 6 g% |7 O. D" t2 F% h4 x
  7. yum -y install rh-python35
    . Z7 K% T6 u2 ^2 N7 ]
  8. scl enable rh-python35 bash
    ( S3 F/ \# W/ s8 I+ g5 \1 X
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    " h- c' w7 _5 f7 {/ W) c  L
  10. ! G, t! r- u6 {9 y; O. s+ x
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz
    : t4 ^& B( K. [/ N# b! R
  2. tar -xvf ACE-6.3.3.tar.gz
    5 P) }3 [+ c/ A/ E0 W+ a* X. h
  3. vi /etc/profile
    " p7 p* M5 u, ]  x0 j" F  R
  4. #在文本尾部添加:
    3 d: r2 b# Q: k, E
  5. export ACE_ROOT=/root/ACE_wrappers! ?: w& }, K6 E) A5 k6 j
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    $ J/ V# o) y' u! h( [
  7. vi /root/ACE_wrappers/ace/config.h
    7 Y0 ]% l4 }  ~7 u. K0 s6 \& o
  8. #写入如下内容:% I0 _: R3 ]9 B3 k
  9. <code>#include "ace/config-linux.h"+ m1 `. u) ^; z" o. K; F
  10. </code>1 I" ~) l+ X# Q# h
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU& `0 }, N& f; p: B% H! D# Z; G& w
  12. 写入如下内容:
      M& L  p& T) {2 U' q- ?
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>
    ( S# [2 |' ?  }; S/ c; ~2 n& |
  14. <code>INSTALL_PREFIX = /usr/local</code>
    / @. t; U$ ^$ d4 k2 T2 I+ }4 V
  15. , |  u+ b$ W& R# ]7 u8 x9 |$ u6 K
  16. chmod 775 -R /root/ACE_wrappers
    ' S6 T- s# H1 l9 h
  17. cd /root/ACE_wrappers/
    $ ~8 {; r7 K8 @& b4 f2 c4 [
  18. make
    " n; R  U3 V" c
  19. make install4 R: _- R3 B% t) C6 ~8 a3 B
复制代码
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-29 17:20:43 | 显示全部楼层
  1. wget -c https://raw.githubusercontent.com/mangostwo/server/master/linux/getmangos.sh && bash getmangos.sh
复制代码
  1. #!/bin/bash
    0 t( [+ P" D! w& R: Y, c
  2. ###############################################################################
    * S7 M/ F1 B+ R* N" y- f/ T7 ]
  3. # MaNGOS Build Automation Script                                              #* N$ Y& u# b) Q. m. O: j4 L8 v
  4. # Written By: Ryan Ashley                                                     #
    4 X0 q0 K5 p# ?
  5. # Updated By: Cedric Servais                                                  #
    1 Y8 d. |0 W4 U! p
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #
    + v- T4 U$ T% u. T
  7. #                                                                             #' ^6 y/ K# d& X: z4 _
  8. # This program is free software; you can redistribute it and/or modify        #2 H- ?  |! l  ~2 L
  9. # it under the terms of the GNU General Public License as published by        #5 q$ ^+ b: V( k& @; v# }. r
  10. # the Free Software Foundation; either version 2 of the License, or           #
    ; b# v; f; p* @- V$ e$ {; t
  11. # (at your option) any later version.                                         #
    : S  Q4 t# i) D8 f% J! K: \0 W" @9 M
  12. #                                                                             ## Q* R% ^) ?3 m# R# w9 B0 J
  13. # This program is distributed in the hope that it will be useful,             #
    ) w' R1 U0 w& Z6 Q2 z9 V: i
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #& o- a: D) j% g3 o
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #
    " g7 g3 X0 Q& V6 w5 v' {% D
  16. # GNU General Public License for more details.                                #+ T  S1 T- S2 F3 {# c
  17. #                                                                             #0 G/ P3 a: m, @2 U% j2 D) ~8 L
  18. # You should have received a copy of the GNU General Public License           #
    # x! S- H( {3 }; V2 j% K
  19. # along with this program; if not, write to the Free Software                 #
      \& C- o2 b! ~
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #
    ) b5 d2 Q. T! d) j, F, m
  21. ###############################################################################
    $ I; H0 e  b' m$ _( d& p$ G* I

  22. 7 ?- E5 E. L  Z; t
  23. # Global variables0 x% N3 Q- o, l3 L' i
  24. DLGAPP="whiptail"
    2 `% K6 D) w4 Y5 F7 a
  25. VERSION="2"8 {; |1 l& |  i  H/ P: Q
  26. ROOTPATH="$HOME"7 _; N8 Q' t9 O2 g
  27. SRCPATH="$HOME/mangos/src"9 B- Y9 a$ m: ~! n
  28. INSTPATH="$HOME/mangos": E7 M1 _1 n+ u, u
  29. DB_PREFIX="two"
    4 s" o+ b6 J( f# B# |+ E* [+ a
  30. USER="mangos"% P, u' Z. c: K5 M2 d4 M% d& N( {
  31. P_SOAP="0"6 k$ f0 Q& j& h% ^3 u
  32. P_DEBUG="0"
    2 L. ^0 X3 H. |! ~. g3 A/ r
  33. P_STD_MALLOC="1"
    5 }( M1 u& V  H! v
  34. P_ACE_EXTERNAL="1"
    ( ^. W9 q8 J# Z2 k$ X
  35. P_PGRESQL="0"
    % z* u2 W3 c; m5 l0 }: p
  36. P_TOOLS="0"
    ! J; e0 J1 {$ z/ E2 g, a" f- [% y
  37. P_SD3="1"
    1 n! }! c2 \( Y6 z  `- l
  38. P_ELUNA="1"
    4 Y6 r% L! a+ ]) d0 d
  39. P_BOTS="0". A! y/ _8 `+ j) q8 n+ w3 j$ g
  40. CMAKE_CMD="cmake"
    0 e  v$ G3 i$ T7 C: f) ~! z

  41. 1 k- [/ x! w% x' P$ g9 V5 M' c" X
  42. ) l* r$ ]' `% o- K& b8 x, C
  43. function UseCmake3()
    . U/ f' c/ [7 _, c
  44. {
    0 b+ G" x) Y8 j- j0 N
  45.     # set the command to cmake3 if its there* U% x9 v2 H# Y1 A% U/ v
  46.     which cmake3
    1 s# l6 E: _, F5 F+ z* Z4 K
  47.     if [ $? -eq 0 ]; then
    & J# k* L- s: a; [2 y7 |
  48.         CMAKE_CMD="cmake3"
    9 [* Q. w+ L4 g& F# a
  49.     fi
    3 J' M+ @* c6 a4 S; v
  50. }
    8 b) _) o- d. k# [: A' v9 U. p, f* w
  51. 0 n+ d7 w+ }+ k% q' v, z3 t
  52. # Function to test for dialog
    + ~; {3 G, T: ]( w8 G, c2 [
  53. function UseDialog()
    $ ]2 l/ q% h0 P& V. s2 s
  54. {
    7 T# V) m8 ]. R0 t7 u4 x
  55.   # Search for dialog
    * B* K& j0 [* Y* `( F( p
  56.   which dialog% C& d  B0 l/ C; u$ K( j1 i

  57. + Q' e5 c, V4 @6 k
  58.   # See if dialog was found% Z' ~3 e" o" t& B& T% }, b) z% A) ~
  59.   if [ $? -eq 0 ]; then. |9 M+ L; O: ~9 X- n- i- \& Z5 O
  60.     DLGAPP="dialog"
    ' u+ {$ G) l( x' s
  61.   fi7 q- ^. z  ~# g& d
  62. }/ c7 j) l- o; n6 c. Y
  63. ! D# {! N$ t/ h/ u% ]
  64. # Function to test if the user is root or not
    6 f& g. J/ B$ s
  65. function CheckRoot()
    : a# Q7 I( k# D; ?; M3 Z
  66. {- v, t5 l( \0 J/ Q* l+ K" A: m3 s; d
  67.   if [ "$(id -u)" != "0" ]; then' h& W, H" \% {- P+ L# }1 M
  68.       Log "This script can only be used as root!" 1
    ( ^- Q  u0 o( @- B* @
  69.       exit 1
    & j8 v1 N% I# u" X% D3 k# E
  70.   else5 ^  U* H5 u3 A  r3 b
  71.       Log "User is root, check passed" 02 w/ V* I5 r* x! O' }) q- M
  72.   fi9 _, N3 M! z& r0 U1 {6 ~8 q. V4 q
  73. }! B( x* B: n: \. Y7 O1 ]2 R, ?
  74. 5 s4 _1 t8 P# t- `
  75. # Function to detect the repos
    9 I. e4 M1 U' P' f6 p1 r+ V* t
  76. function DetectLocalRepo()7 @* J3 T3 n0 \1 M$ I; y
  77. {! }9 W  i* _. J/ s* L" f
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    2 i6 g% R) u$ W
  79. " V6 ^2 q9 M# `; w, V& b) O
  80.   # First see if the Windows stuff is in place
    6 A) T8 a% U/ S+ W2 t/ h* l% x
  81.   if [ ! -d ../win ]; then) f% a- E$ r7 }
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0. E* o; W7 j; d7 N8 N, ^
  83.     return 0
    ' @1 F! P( P+ {# v0 N& h
  84.   fi6 b! G; I% N" F5 H& b' m+ @
  85. - R' V" M6 Y; F1 I" i$ {2 I( i
  86.   # See if the sources dircetory exists
    + e6 N3 I* h' A* o& B
  87.   if [ ! -d ../src ]; then
    - {( O  [) x3 Y+ o+ e. J6 D
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 01 k& X- ?& p4 q
  89.     return 0  ~0 |( q2 e6 b3 g) T
  90.   fi
    : q& R5 L0 _$ T
  91. " @" y5 e: h) l3 d6 N
  92.   # Check for the CMake directory. D8 G8 Z. j. M' q
  93.   if [ ! -d ../cmake ]; then
    ! Y$ c/ Y2 i, p
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 01 W( c: M7 m9 X2 E$ M3 d
  95.     return 0
    & h% v4 T' y  S* W2 P: h3 d  m
  96.   fi
    - q2 {. ^( J: {/ q8 m0 ~

  97. , i5 L, I/ u% O' ^  [
  98.   # Set the default paths based on the current location
    : D1 [/ M/ w( g0 {% n1 q
  99.   SRCPATH=$( dirname $CUR_DIR )0 p/ ]. n9 u8 R6 Z& X2 H# c
  100.   SRCPATH=$( dirname $SRCPATH )- a+ m! x9 h# V3 U
  101. , ~9 c# }6 j& d6 C
  102.   # Log the detected path# p0 g- }% {# y4 `: c) b, Q5 A
  103.   Log "Detected cloned repository in $SRCPATH" 0
    ' s9 E: o1 ]# ~# d
  104. }
    7 J! I9 E, U: X1 `/ L
  105. - V+ R2 \' O* \

  106.   k" e. ^" M  J7 D" R

  107. ; A8 W% S/ ?% d8 K8 G$ A
  108. # Function to log results
    * J7 A- G) Q( \- {! M) E
  109. function Log()- f: \4 i! ?# [) B5 o
  110. {
    & h7 F: X3 h( z- F4 _8 w
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )  \6 V  I) g- z9 D

  112. ' q) l# h9 A- S: P, Y
  113.   # Check the number of parameters9 B1 J  c7 f2 W' w" m4 q' B
  114.   if [ $# -ne 2 ]; then
    3 q3 d6 j# P8 u5 a1 \
  115.     echo "Logging usage: Log <message> <echo flag>"! T: x4 z  t8 U2 I  A9 G
  116.     return 1( N- |& |( }2 B# }3 p6 a& v
  117.   fi
    ( B" M5 o+ ^& W$ t7 ^/ g& e

  118. . o: |+ }5 W! Y" [) ]" Z
  119.   # Echo to the console if requested
    * a7 g# X' b& _7 G, b% M6 V
  120.   if [ $2 -eq 1 ]; then
    9 [. l6 `; r( b$ v% y
  121.     echo "$1"
    1 O' p7 H* h1 d, B( B
  122.   fi# E0 z5 R# ]8 @) t

  123. : v8 T, j6 j) w2 C
  124.   # Append the string to the log) }6 j7 K' O1 J6 t0 x
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log
    + e4 e7 n! S) i% i* U
  126. }
    * l1 \. x+ }; w: e0 N+ D$ j! e
  127. / h; p- B( F  T4 I" _. H
  128. : x+ ~% x% T0 S" A! X4 m' U6 ~

  129.   Q+ t. K8 \1 q, a+ n7 c
  130. # Function to install prerequisite libraries
    3 B& _" g0 ~- k" {3 W
  131. function GetPrerequisites()
    6 A6 |" @' I9 }; |
  132. {
    # d7 J, a. Y. `1 N' c. E. `
  133.   # First, we need to check the installer.
    % j$ W  H9 T6 p+ C2 N. e' q
  134.   installer=0& w3 ]" p1 [* H6 E# h. j
  135. 1 ^6 m6 u1 E+ y8 D
  136.   which apt-get' D) v3 P8 N$ i) v, ~

  137. ) W/ `8 l& j* r* `
  138.   if [ $? -ne 0 ]; then8 @) k. n- t2 r0 _; M* U  v
  139.     Log "apt-get isn't the installer by default" 1  m& ?  E0 Y* B
  140.   else
    # `! e& [8 [" f! c
  141.     installer=1
    * f9 |5 [6 u4 s! W
  142.   # On a fresh OS boot (EC2) libace was not found without first updating 5 W7 @6 y8 k( C2 e8 g2 s
  143.     apt-get update -y && apt-get -y install git lsb-release curl3 k5 i  g) |7 _5 F) a
  144.   fi
    / C% @/ E# v2 y* @
  145. - h4 ?1 `8 f; c/ D4 |# K
  146.   which yum
    # e1 _% k6 G! p/ C' V! W
  147. # \. ]" Z7 ~5 H/ Z8 ]
  148.   if [ $? -ne 0 ]; then9 L- t/ \' k8 \$ {" b) B% y5 m9 |
  149.     Log "yum isn't the installer by default" 15 w2 c& b$ s  O( x8 Y
  150.   else) P$ ^! A8 v- J( @2 E0 Q2 {: [. C
  151.     installer=1
    ; V  I1 n3 f5 }; W
  152.     yum -y install git redhat-lsb curl6 O' @% s- Y+ p, O7 G
  153.   fi
    # R2 e$ l% E: D! W; {

  154. 8 [, g5 [7 T: ~: Q- c
  155.   which aptitude
    * Y1 z! ?1 k$ {& o& f
  156.   if [ $? -ne 0 ]; then
    0 p& M. L8 j! _9 F$ I- f+ e
  157.     Log "aptitude isn't the installer by default" 14 N+ Y1 r" u  d
  158.   else4 S- ]6 M2 r9 W# L7 f( M+ c! A; b
  159.     installer=1; q5 k$ p% c/ f2 E! s+ M- E8 {" w
  160.     aptitude -y install git lsb-release curl
    3 e3 }% c0 x4 Z: T. i& Z+ x: [
  161.   fi
    , R0 n7 n: l7 q7 [8 _7 m" i0 m
  162. $ {$ B- i) T4 Y$ `4 J: n0 a! N
  163.   # Then, let's check that we have the necessary tools to define the OS version.) n5 v& \6 s6 T9 ^# f9 c
  164.   which lsb_release
    ; Y( W4 Z" K; v, G$ r! y/ A8 B

  165. 2 s) K4 p- n6 @% \! {* s3 R
  166.   if [ $? -ne 0 ]; then( w# Y% q5 T, t  b  C4 ~3 D
  167.     Log "Cannot define your OS distribution and version." 1# ~* O# H7 B- o3 p% k
  168.     return 0
    , p6 k' I' v/ B
  169.   fi
    * d# J: m' G) r0 C- P; Y
  170. . f" A, \9 Y  u$ M  @
  171.   local OS=$(lsb_release -si)
    : p0 s$ x* z* z: _0 F
  172.   local VER=$(lsb_release -sc), k( G4 ~  j: H. ]( i4 u, v
  173.   local OS_VER=1
    . C+ f4 s# y/ Q& X; W+ w

  174. ; B2 g7 W4 J% O, \$ z. a) N5 M* l
  175.   # Ask the user to continue9 P7 E- P4 H3 r) Z1 V
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    1 v, `+ r, e+ C7 z, ^+ B2 X
  177.     --yesno "Would you like to install the required build and development packages?" 8 600 R3 w6 n9 ~7 j% y! B/ h1 l3 l2 V
  178. $ R. X: b* P( S1 U0 D
  179.   # Check the user's response
    " U1 {9 E- y- g1 q$ v- e' R* W  `
  180.   if [ $? -ne 0 ]; then& w& k; G/ X' A/ F- w5 j/ g+ b
  181.     Log "User declined to install required tools and development libraries." 1
    + |1 u" G' R- p. F6 J8 f
  182.     return 0% B( |% U0 x3 Q2 Q1 v! L" g0 @
  183.   fi, P/ O; g  P: v2 Z8 ]7 E5 x* B+ S
  184. % m. L/ l5 G3 d" d9 ^1 Q/ N
  185.   # Inform the user of the need for root access6 w5 L/ P+ H& S+ E, W$ y
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \+ f0 C) W  R9 f* d. ^: ]
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    . H! \- t: X% |7 i% ~  y# L

  188. ! w# z# o9 {% B
  189.   # Check the user's response% F( k" d3 R  R9 I1 x4 f
  190.   if [ $? -ne 0 ]; then
    " c6 R, U  }) _) Z
  191.     Log "User declined to proved root access for package installation." 1
    . Y; }3 M/ g7 o; D
  192.     return 0( T6 p- V6 L# i: e# v$ V/ {
  193.   fi
    ( c9 R4 b; ?  l* Z' O0 O& `
  194. 5 O& ]" {, d$ z' z
  195.   # Handle OS
    - b7 Z! ]2 R" Q& Q9 f
  196.   case ${OS} in
    1 ]( d; r( N0 u  B
  197.     "LinuxMint")0 Y- R/ S1 H( b" V/ Y7 Y* C
  198.       case ${VER} in& }1 `: }3 P+ {" m: J8 b
  199.         "sarah")- R; g7 f' m; Y' V' y: \
  200.           # Linux Mint 18 - Ubuntu Xenial based
      a2 D* I) p) C8 e2 S, Q# P5 {
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    : e3 F2 ~9 V+ j5 L" \, y7 ]7 p
  202.           ;;) I: @- i8 q# s  w
  203.         "rosa")
    5 d3 h* c0 _0 a* v1 t6 {
  204.           # Linux Mint 17.3 - Ubuntu Trusty based6 D5 s% u1 z% o% j
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    6 q& G- g: x: c
  206.           ;;7 F$ z4 a8 z: w+ m, ~  d) Z
  207.         "rafaela")
    1 x0 Z6 E  I* `- @
  208.           # Linux Mint 17.2 - Ubuntu Trusty based- ?( x0 q* L: k0 K& t* X
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
      [5 j$ {6 A6 |& K# U& s4 d3 _) S
  210.           ;;2 b& {- E: U% q) q2 R/ H* S* ?
  211.         "rebecca")
    & d1 Y  e9 s# w* F6 e1 ]  F& {: v1 O: h
  212.           # Linux Mint 17.1 - Ubuntu Trusty based
    0 d* Z7 N. A! c4 V6 d) V
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    - D) |2 c! d, v7 g& T
  214.           ;;% a5 R" x) d4 e
  215.         "qiana")
    5 M* W4 S3 w" p4 Y) T* R7 Y
  216.           # Linux Mint 17 - Ubuntu Trusty based
    9 D9 M+ ]5 D  f3 C, O7 F
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root9 [2 s2 g- {2 n0 F
  218.           ;;% n9 d1 k9 P0 {& l% Y, `7 W
  219.         "maya")
    8 h" A: s( E& R; e
  220.           # Linux Mint 13 - Ubuntu Precise based6 C- b  Y0 ]1 V& @" R; A* y
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root# g* i. v3 s$ T8 K
  222.           ;;$ a/ C" M8 s/ m, u! I, T
  223.         "betsy")* ?9 L3 j6 l/ \, F
  224.           # LMDE 2 - Debian Jessie based
    # D$ t# S* U1 k9 Y( W$ k0 B
  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
      l3 n' e! V% d% `9 ^# u2 Y( j% w
  226.           ;;
    5 h/ p1 ]0 o' L- ]0 t4 P' t: d& _
  227.         *)! b+ ]% }' o  }* q. ]! a5 d
  228.           OS_VER=0
    ' i+ |' |, q1 f% h0 m
  229.           ;;" W" Z3 S0 C/ k7 b& m
  230.       esac. {/ I( e/ I" Y3 p  G6 A, `0 n
  231.       ;;
    2 I: X0 U3 V- f3 N0 C8 a. Q. h
  232.     "Ubuntu")
    1 u& m/ z, o- W$ Z8 ]. n" B
  233.       case ${VER} in
    % }$ m- o3 V3 ]  a, V
  234.         "precise")( R' I. m" |- ^+ a
  235.           # Ubuntu 12.04 LTS- ?9 @' q3 v% R; o
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    . Q5 D# P* V% r( h: @
  237.           ;;. H. u+ m9 z" r: j1 P2 s- z
  238.         "trusty")
    # K8 @5 P  Y* v. b5 E) Y* ~
  239.           # Ubuntu 14.04 LTS. K' v4 N! J+ ]
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root9 s2 r' e& O; u
  241.           ;;" y0 N! M; t, ?0 e7 ]# I) ~3 p0 K2 Y
  242.         "xenial")4 C9 n6 X4 r9 w$ v' \( H, [
  243.           # Ubuntu 16.04 LTS& w/ l& i* P- T& ?4 k. }
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ' S9 _0 R( f9 d9 x3 ]9 p$ U/ r
  245.           ;;* i# T3 O. S5 R& [; U8 k
  246.         "yakkety")
    5 }) A$ \! e' e  u
  247.           # Ubuntu 16.10: z; ]. z4 o& M: Z; [
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    $ \9 g/ M, J2 }( t# F
  249.           ;;; y- n4 r3 f6 H- o
  250.     "zesty")
    " h' C7 c- o" T2 v9 u. M
  251.       # Ubuntu 17.04
    . ?& E- b8 z! A/ o# A( D) w
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root6 W. Q' F/ p" |6 ~- A
  253.       ;;
    9 ^! q/ j6 J4 C: t. w( P! m. c
  254.     "artful")- u& }% r, n6 {3 l* p
  255.       # Ubuntu 17.10
    0 ]' e% r: p" V- v! p+ Q5 l- I
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root) ]0 F6 t/ t* B
  257.       ;;# F% N: F6 Y; Y% }  d
  258.     "bionic")
    . @& I- g' O1 v
  259.       # Ubuntu 18.04 LTS
    % _( `5 p5 G7 O- J5 Q
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root7 H& G. m" K3 c! P
  261.       ;;0 G* H0 `; t' K/ K* r, ]8 b
  262.     "disco")( j9 m' Y' m& D; q
  263.       # Ubuntu 19.044 a$ d- ~% Q& ^& B" t7 B7 v. H9 v9 H" b
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root. ~  Y$ R  P( p+ V# I. E3 F
  265.       ;;
    8 b, a' _+ b4 Y; ?+ F
  266.     "focal")
    ; [) Z5 ~7 x3 O  b0 B6 }
  267.       # Ubuntu 20.04
    ! c/ \7 i- r; T# j1 d. w: a+ K
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root% o9 a0 @+ W% ]
  269.       ;;  F0 O4 K0 T9 X8 S1 B9 V7 y
  270.         *)
    6 R+ v3 W7 ^( a; R) X" {+ h' @
  271.           OS_VER=0
    ! N# n2 I+ @/ e) j4 d; Y0 l! ~2 O
  272.           ;;6 Y" M' D6 K1 T4 z) H; I
  273.       esac
    2 x6 [" c4 ~3 L& J
  274.       ;;' }0 M4 {, ^" |& D
  275.     "Debian")9 p2 P" {" A8 T  n5 f3 q* R4 `: ~
  276.       case ${VER} in
    $ i  g! \8 i( @; E7 ^: |
  277.         "jessie")4 C( v( J, l5 B( J$ e* w9 A- N  A
  278.           # Debian 8.0 "current", E) n9 ^" v8 N! @
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root2 n0 b7 P$ }& f9 ~
  280.           ;;0 h6 ?( a  `7 \0 q- q6 l
  281.         "stretch")" ]* X: d0 x! P3 c' g& e" N$ g
  282.           # Debian Next
    $ [  w# n2 d: o! H, p# d/ R
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root) u1 |' k$ [% \8 r5 {6 C
  284.           ;;6 I6 V" z' }2 n& D
  285.         *)2 Q# N3 S, Y, r  y: h* K2 Z
  286.           OS_VER=0
    0 x1 k: N6 Q6 Q. o- t  M1 [
  287.           ;;+ {2 o9 `$ I6 h$ N
  288.       esac. f8 U$ F. Y6 H
  289.       ;;! t8 N' o5 q9 s! g3 R& L0 ]
  290.     "RedHatEntrepriseServer")% [6 M& p$ f* c3 B& B
  291.       case ${VER} in; n2 L- n. K" \
  292.         "santiago"). p7 c( s) Y3 ^2 X
  293.           # Red Hat 6.x5 b. i) J0 w" e) O. C. C" \4 r
  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 i' t3 [; @* E
  295.           ;;- h0 Z  u! }9 d7 v2 v
  296.         "maipo")
    1 M, a/ W0 A6 @3 \) }! r: n( I
  297.           # Red Hat 7.x' J. H9 }" ?$ [% ?
  298.           su -c "yum -y install curl build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev ace-6.3.3 libssl-dev libmysqlclient-dev libtool zliblg-dev" root' {' i* ?: G, J( L7 _
  299.           ;;
    ( P! C: @$ o/ p- r
  300.         *)
    6 b7 K* G6 K3 y5 ~* B
  301.           OS_VER=0
    6 Z; u+ E# `8 T  S7 h
  302.           ;;" `( S; p# ^$ D) _8 w
  303.       esac
    8 ~( _, ?! i0 c
  304.       ;;
    9 T" S; Y9 @& k; L
  305.     "CentOS"), k. s$ @$ U2 m
  306.       case ${VER} in4 T1 y, y# a( Z$ Q' i
  307.         "Core")$ f/ T* V: _5 u
  308.           # Default CentOS - Adding necessary RPM third-party.1 G! [! c( @7 C: b* Q
  309.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro/CentOS_7/x86_64/ace-6.3.3-55.1.x86_64.rpm
    " T, w6 ]; p. V9 b2 U- ]3 G
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm
    * y; V+ T! u9 m6 q  u. U
  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
    % a9 Y8 o0 P; Y( B/ }: {* K
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm4 E  p* H* D2 Y3 r
  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; g* C' t/ W! P: @
  314.           su -c "yum -y install epel-release"
    6 c3 H& i8 ^( j. e! ]0 |* i
  315.           su -c "yum -y install curl autoconf automake cmake3 ace-devel ace-6.3.3 openssl-devel mysql-devel libtool gcc-c++ bzip2-devel" root# M  V! e: e; D1 r% f4 F8 s+ d1 X
  316.           ;;7 B7 c5 o6 b6 P0 P2 g
  317.         *)
    - c! [0 S: r5 F5 w' N4 A
  318.           OS_VER=0' T+ R) g; M1 g6 Q' p
  319.           ;;
    ' s3 {4 s0 L3 ]- L
  320.       esac/ Q( D: l$ z" I% B2 C) V# s9 B
  321.       ;;: x! t$ x1 ~1 H% H9 [# u- I" b4 _
  322.     "Fedora")4 x3 p2 e* u" l! M
  323.       case ${VER} in4 O5 T5 q  g1 P3 e
  324.         "TwentyFive")
    0 E: V  e# I% B1 n6 X7 a7 J
  325.           # Fedora 25 - Adding necessary RPM third-party.* c  q" F7 a8 e' h7 g
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root; V9 c  r3 q- T: ?
  327.           # Getting and building ACE. Not provided in RPM for Fedora...
      j- T! Q& l( w$ Z
  328.           rm -rf ACE-6.3.3.tar.bz2
    ) M# F7 [7 Z; d. c5 [6 \% u( f$ ^2 t
  329.           rm -rf ACE_wrappers
    5 ?9 u1 I0 A' m
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2
    4 T3 ?) f8 [, j& @# X1 G7 J9 f
  331.           tar xjvf ACE-6.3.3.tar.bz2
    $ S/ G  z/ I+ Y3 L4 ?. n
  332.           export ACE_ROOT=/root/ACE_wrappers' F% j7 I/ |3 m
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h& ~! [5 g0 i: s( J4 c1 ]% L
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU- x, V: w4 Y, |
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    & o6 s1 D3 [1 Q6 R- d+ X
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH% O/ w0 ~# C. f! t2 k9 ~$ t
  337.           CD $ACE_ROOT9 y, S# j6 Y( `/ G" }1 Z
  338.           make8 z' }" z6 Z6 c/ w5 ]+ a5 f: p' e! u6 _
  339.           make install
    / @4 X- S3 q. G* v- l4 i  S2 V
  340.           cd ~1 M, d0 G% p& J) i
  341.           # Installing remaining dependencies..
    " o. [2 D5 o* D
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    1 m2 i* z  K8 e3 z+ k9 Q/ ^* n
  343.           ;;
    + s6 F( L5 w5 A# p
  344.         *)
    / r$ `( E# z7 t& u% ]) B
  345.           OS_VER=05 N: P' h, V7 A# V2 o4 d5 l
  346.           ;;9 x. ?  Z8 F) E; }# F
  347.       esac6 E/ e: L) ]2 t* Y1 h* }
  348.       ;;5 e" k& T9 f" Y6 x9 R% E
  349.     *)
    3 ]7 ~1 S& R) p0 `
  350.       OS_VER=0  n) ]7 l3 b+ e: ]4 |
  351.       ;;
      t; K/ A1 {- i
  352.   esac
    " P- x5 k$ ]3 r; u- p
  353. ! R; A9 C, }, A6 @
  354.   # See if a supported OS was detected+ K# T. I* B; m2 G, D' W! U- E
  355.   if [ ${OS_VER} -ne 0 ]; then) `8 t. N: ?8 `3 t2 A
  356.     # Log success# D7 ]# T3 `; V% e2 S, Q8 T
  357.     Log "The development tools and libraries have been installed!" 1
    0 n+ ?+ u' v: F. A9 e# q+ y
  358.   else
    % x* f, K3 G6 g8 P5 w. H8 Z8 Z
  359.     # Note the error3 m; [2 O* t7 c" F" v+ L
  360.     Log "Could not identify the current OS. Nothing was installed." 1
    ( \5 C! X3 G- z% E1 g  x
  361.   fi# S" M8 Y6 z" X/ D3 _7 d9 a
  362. }
    1 \; x. d) Q1 y6 n6 o' Z
  363. 3 k+ p9 t, G, Z$ n, t3 v; k

  364. , T4 ?7 O: P6 I  s# I

  365. ( h0 ?( `, t" `2 ]8 K! ~$ h
  366. # Function to get the WoW version; D  E9 Y' r. E, W. d- l2 y0 k
  367. function GetRelease()
    ! Q' O% z# K% I8 O! T; B2 v
  368. {
    $ I9 y% y) |  n$ Y4 T
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    ! j7 r5 s; J  S
  370.     --menu "Select a version of WoW" 0 0 5 \
    % _2 {2 n5 m. Y+ G
  371.     0 "Original Release (Vanilla)" \' Q6 `9 P! Y  O' B4 i
  372.     1 "The Burning Crusade" \
    4 W1 L6 Q; H& D/ M) ?& {
  373.     2 "Wrath of The Lich King" \
    5 R. v2 t4 j4 J) B! a  _
  374.     3 "Cataclysm" \6 s$ a) O$ C6 ?, v/ M
  375.     4 "Mists of Pandaria" \% T# b" {6 D/ y) Y2 h2 u
  376.     5 "Warlords of Draenor" \/ S, U& o2 }' k) m3 {* O
  377.     3>&2 2>&1 1>&3)
    + }, |+ \6 r: s- \2 Z  T, N4 X

  378. ) A9 M: {. C. T
  379.   # Exit if cancelled8 Y* X; T/ i6 c7 ^# C( c. O; b
  380.   if [ $? -ne 0 ]; then. ?4 k; x; E, q
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1
    # ]; t4 k8 u" ^% h/ E) `5 W* ?- ~
  382.     exit 0. ^( l0 O( J& D; f9 n( V' T
  383.   fi- L9 _6 o* A: P0 F" ]6 N+ u8 R; z3 n
  384. * y- r7 _$ Y# V6 X0 F: C4 C) _5 J1 `
  385.   # Set some defaults based on the release
    ( A" E* C8 q) E1 ]6 k% _8 k) J. I5 `
  386.   case "$VERSION" in
    4 K8 C* N( U& `7 t8 a' ~; H
  387.     0)
    , B1 l1 V* @9 j+ z
  388.       SRCPATH="$ROOTPATH/zero/src"+ v3 M+ A$ m/ r' g) K% u
  389.       INSTPATH="$ROOTPATH/zero"" z$ N  z6 U) T+ I* W" ?+ k
  390.       DB_PREFIX="zero"
    5 l7 s( `* `% T# N5 {9 v% @! d
  391.       ;;7 w& s) N1 A  P4 N8 d2 }$ u$ z

  392. # n5 \4 B8 i# H  ?7 r. M7 U7 ]6 ^
  393.     1)( G  G6 X9 T# n/ B: t; O
  394.       SRCPATH="$ROOTPATH/one/src") m7 Y. F& R; n2 [$ Y+ U% z$ f9 M
  395.       INSTPATH="$ROOTPATH/one"2 H2 N! g4 S' j& j! z& A0 B
  396.       DB_PREFIX="one"7 |$ Z* g! G/ @/ O& X
  397.       ;;
    3 E! h  H9 K" L# w1 c+ n( E1 V

  398. 9 [  G& [" u1 T; T6 s0 h
  399.     2)
    - }6 }) y, @# }! x- m- L  `0 x
  400.       SRCPATH="$ROOTPATH/two/src". l/ T0 p% i  J( P
  401.       INSTPATH="$ROOTPATH/two"
    , J* e% ]( C4 ]1 `& c
  402.       DB_PREFIX="two"
    ! ~; i) f" T5 D$ w
  403.       ;;- |' z; `6 u8 o1 f! g

  404. ' I; k! p) H' _9 D
  405.     3)- G% s6 Z. a3 u+ n1 T
  406.       SRCPATH="$ROOTPATH/three/src"
    " z8 \, u( u! b
  407.       INSTPATH="$ROOTPATH/three"2 R! V  a( r  Y* U; {* n) v
  408.       DB_PREFIX="three": Z- q0 f5 T+ l. W5 y& `/ j
  409.       ;;' d1 B4 E5 I2 w5 ]$ d
  410. 2 F6 ^& h0 M/ I; G* b0 f
  411.     4)" |7 H6 g$ U0 }$ e: R
  412.       SRCPATH="$ROOTPATH/four/src"
    : ^3 ?/ s+ ?  H0 e: U5 ^$ @% N
  413.       INSTPATH="$ROOTPATH/four"+ Q: J6 i9 ^& n$ ?5 \* x, ^
  414.       DB_PREFIX="four"
    " n" {  |% B/ m: i
  415.       ;;
    # Z8 O) x' [% Z( C
  416.     5)8 z. E( I9 w1 c% U
  417.       SRCPATH="$ROOTPATH/five/src"
    # x$ n( \, v% V6 ?7 X9 Q
  418.       INSTPATH="$ROOTPATH/five"
    $ n. X9 R5 Y/ e' @+ h
  419.       DB_PREFIX="five"" T5 p% _6 ?4 z7 U6 I
  420.       ;;
    . v- k& J& D# Q& ^& n# V( c
  421.     *)
    0 U) E+ |" v% g: t" n
  422.       Log "Error: Unknown version selected!" 1, P0 X4 i( V& t' w( i3 B. @
  423.       exit 1
    % ?  s5 S; s% m! h
  424.       ;;. t) p& S. w( a: o: I5 z" B
  425.   esac1 J% l9 ^# O/ _4 E- @
  426. * `" f# q& O5 B! i. b% ~6 y
  427.   # Now set the correct source path if the repo has been cloned already% h3 H4 Z! @5 I; C) T' ]4 d
  428.   DetectLocalRepo+ V8 A) k. K% ]* [- [$ d
  429. }5 ^5 G, W, X% u- D$ a7 ], ?! v& e

  430. & o/ G  w5 l5 @9 Q# i" j2 Q3 c( Q
  431. # Function to setup the technical user
    " a5 N. u8 R( g# M% b. r' S
  432. function GetUser()8 a/ s6 j5 y" X# ]+ D  h, r) I
  433. {
    ' ]# u- Z8 X: m  l% j: ?7 V& ^
  434.   local TMPUSER="$USER"
    1 F1 z. L: C* C' j1 K) r9 v) v* F$ o

  435. " r  r5 M( ^$ u1 x  d! Q! |
  436.   # Set the user! o7 m( g$ y, M% o
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \  I1 P9 F# Y" v1 H9 @+ H
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)5 ~$ e( O! x8 e6 L
  439. ' u4 D5 C) l) L) I2 y7 G
  440.   # Exit if cancelled
    ! i, W& V! F/ M5 {# j
  441.   if [ $? -ne 0 ]; then! `4 d; J2 t: ]+ X$ q% ?0 _: F; L
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    ! z6 Q5 j: ?1 @
  443.     exit 0
    , {' a4 k, P; i5 n, _$ q) Z+ I8 ?. h" B
  444.   fi
    1 Y' R* j. J# T) K9 Z
  445. 2 y% w) Y- Y) M1 U
  446.   # Change the user only if it was modified
    % f8 @% w: r4 O4 x, b+ M* s
  447.   if [ ! -z "$TMPUSER" ]; then
    , F3 y$ o. [: S' C
  448.     USER="$TMPUSER"' J) |5 K  ]) g
  449.   fi. S' @! g& ~" s/ O& L( p

  450. ) }- h" y' q0 I6 p* H5 h% z2 h/ f' L
  451.   # Validate user
    1 J) q# Z6 e6 y* R* Y% z
  452.   id $USER > /dev/null 2>&1
    ( Q; x% |' f% }1 ^, I2 A8 c
  453.   if [ $? -ne 0 ]; then
    / o2 c! S4 M, D8 n  w% a+ {
  454.     Log "Creating user: $USER" 1
    / c$ a1 h0 y8 Z+ i
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1- F6 l  i+ p; C* S* B+ V' n: M

  456. 3 x" R* P7 l/ d: U4 P0 C
  457.     if [ $? -ne 0 ]; then1 Z2 Z8 `: x* W4 n! P: z! y4 }
  458.       Log "Error: Failed to create the specified user!" 1% W) O* u' S6 }' a) u
  459.       exit 1
    % d" v% Y; c) M0 u
  460.     fi( \" ]5 p' u+ u7 _# T% ^
  461. 1 c1 i# N1 K4 E. T* }0 Y5 p
  462.         usermod -L $USER > /dev/null 2>&10 v# f. {0 K- ~; P" }, ]& z8 m
  463.   else
    * e/ E) m7 a) g7 p, K; x
  464.     # User already exist, asking to keep the user; y: x7 y  `$ b: M6 S8 ^
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \
    " C5 L+ R- Z/ T, S6 b$ X
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60
    ' w, P( T" g# a! U

  467. * m" T# O5 M0 N/ `" U; w
  468.     if [ $? -ne 0 ]; then4 L7 T4 B" A% a8 U8 T+ U' F
  469.       Log "Removing user: $USER" 1
    ' S# |4 d( i2 q, v
  470.       userdel -r $USER > /dev/null 2>&1
    . h- [6 T' [. U+ p) ^5 b

  471. / n+ t: O" ]7 X! a* v& s# y
  472.       Log "Creating user: $USER" 1
    4 s+ ~5 z& g3 N) ?+ D
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1
    , ]3 |' S+ g2 j+ o" C
  474. ; E, _. P) [9 Q+ K+ Z' [
  475.       if [ $? -ne 0 ]; then! A6 E) ]1 W, H: o5 N1 T7 T* z
  476.         Log "Error: Failed to create the specified user!" 1
    $ l5 S3 n1 P5 F! D5 ^3 z
  477.         exit 1
    * w' _: k1 N5 O1 Q2 b. Q- a
  478.       fi
    0 F- w" d# a$ f$ v. @: V

  479. - q/ P& m9 i5 t  {
  480.           usermod -L $USER > /dev/null 2>&1, o: `: A+ V5 Q, }
  481.     fi* {, W% [2 k7 t1 E" C
  482.   fi: H  E4 J2 l, M7 F9 {3 _

  483. 4 ^1 s0 E7 e  J0 ]( w; _
  484.   ROOTPATH="/home/"$USER
    2 E. W9 ^: p: Q* U, O# j9 h4 f
  485.   Log "User: $USER" 0
    - B* I1 [  U  n+ v# f* h6 ^3 b: i
  486. }) o, |7 T# ^3 ]$ b
  487. 3 c* u$ _2 Z9 I/ r- g
  488. # Function to get the source and installation paths1 B  n6 J: P# O5 F1 J- W; J
  489. function GetPaths()
    6 B' F$ x! M# f$ r# h# T
  490. {, v" O( r9 c3 n" Z
  491.   local TMPPATH="$HOME"
    ' j: ?: V" p* |1 Z/ @

  492. $ @& H8 ~+ C' C1 [4 ?" y% V
  493.   # Set the source path- I4 `% k. a6 p) z
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \
    / G& J  N) {( n8 F' C9 p
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)4 K, X" r* z' B: {

  496. 6 A( g7 ]5 C7 B% {* s
  497.   # Exit if cancelled
    4 j9 d+ G) L' }: K
  498.   if [ $? -ne 0 ]; then
    9 r8 ?5 x  h! m! ]: Y9 F
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1
    ' c1 q6 J1 P3 P
  500.     exit 0
    - B  d7 Z9 W8 V# C5 t
  501.   fi. Q/ z" q5 ~3 U

  502. # K7 q1 }. W- }+ j
  503.   # Change the path only if it was modified
      J6 a4 q$ R& n( [  B
  504.   if [ ! -z "$TMPPATH" ]; then8 l3 y3 X0 ]3 j" `
  505.     SRCPATH="$TMPPATH"
    9 B' l" P7 A6 N9 ~- m3 H
  506.   fi
    0 J6 \$ v1 X7 }8 a2 L3 C" S

  507. * Y8 J* t  f6 m& e( o
  508.   # Validate source path
    2 ]0 E- W$ i$ \3 R
  509.   if [ ! -d "$SRCPATH" ]; then) H& L9 g" r% ~" h
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    7 i) h  N' X" a, L: S/ H9 w
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60
    ( P+ q: j' @: k# e# I: j

  512. 3 c7 q" N. f. j1 g
  513.     if [ $? -eq 0 ]; then2 i$ F4 M. _, |) f$ D( \$ q
  514.       Log "Creating source path: $SRCPATH" 13 _7 _8 q  u7 J
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    + s2 ]4 M5 r. R2 @% z4 h
  516. / G6 N, ^/ p. i9 l% z
  517.       # Check to see if the directory was created. J* f% M5 |% p) ~1 B; t- U
  518.       if [ $? -ne 0 ]; then
    6 e4 B4 Y, V# r
  519.         Log "Error: Failed to create the specified source-code directory!" 1
    ' J9 B. K9 Y- r. e3 h
  520.         exit 1- G6 e- @+ o' e) Y# \; m$ r
  521.       fi, K$ P& R+ v7 t. Y0 B! A
  522.     else
    5 _; U4 ^6 E& _  a7 F9 \3 \4 a
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 14 s1 `! b" q6 _- }) k$ B1 U5 i
  524.       exit 06 _% n% s! J$ }3 h( F
  525.     fi
    / Y1 A/ }/ F& N8 r
  526.   else; N# X! D  O. B* H4 o/ R' N
  527.     # Check for old sources" m+ [9 S- R& `! k$ B8 F
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then
    3 ~3 ?2 H2 }9 a2 E1 [, R* K- C
  529.       # Ask to remove the old sources) h/ v! s7 g" o- D/ |; S% [' {/ C
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    : C' _- P: l4 E9 S2 r; D4 W
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60  g: ^' Z/ ]% W8 ?* `3 z/ i0 V
  532. 4 |8 M7 l& [8 l# h* g7 P9 H
  533.       # Remove the old sources if requested6 G2 |2 b$ y8 h/ B; Z9 _- X
  534.       if [ $? -eq 0 ]; then
    * l& {' S7 G/ E, y! H- K0 ?
  535.         Log "Removing old sources from: $SRCPATH/*" 1& E# _9 G* j* z
  536.         rm -rf $SRCPATH/*
    : G4 {* [* a5 P8 t( o# I1 f$ w

  537. ! E2 c1 ~. Q# F
  538.         # Check for removal failure
    7 S* n7 m. \  P
  539.         if [ $? -ne 0 ]; then7 s1 _, P2 u0 H6 G( k% A/ A
  540.           Log "Error: Failed to remove old sources!" 1
      l+ K" c# e9 g/ s- F
  541.           exit 1
    , |* ~+ d% t8 C; B
  542.         fi4 y2 r0 t8 w' l8 w$ Q- c
  543.       fi
    - l1 x5 W5 b+ Y2 f
  544.     fi% ], X/ ]5 `6 R7 N
  545.   fi
    % s& J4 I% E5 Z  i% q; |. e3 d3 f

  546. $ x$ u/ V$ f6 I, \
  547.   # Set the installation path7 h. \0 X4 D5 L, q) ~+ u( M
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \1 `( H5 J* _  }! t5 l" V
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)* ]  C' Z3 ]! q  [
  550. ( X& R2 |- l" y/ [
  551.   # Exit if cancelled: D% }5 X# D# X! t7 o! s
  552.   if [ $? -ne 0 ]; then+ m3 n0 f8 ^: z# t' s, U2 o$ h! j
  553.     Log "Install path selection cancelled. Only the source path has been created." 1
    - v$ n5 J2 g5 C& U
  554.     exit 0
    5 o2 }9 ^$ h$ N$ ~2 A+ K0 A
  555.   fi0 i0 J3 f) V% H: V; Q
  556. 9 z- g+ Y- B( G3 }0 \, k9 ~- n* G
  557.   # Change the path only if it was modified' t1 r# D+ c/ g7 x$ o( H8 D
  558.   if [ ! -z "$TMPPATH" ]; then7 P' k* l9 c1 i- R* o. E
  559.     INSTPATH="$TMPPATH"7 r) a& c0 a: n4 T# H+ x$ H
  560.   fi4 M1 J. {9 \3 F1 k/ W# Y+ \8 n

  561. 9 f8 U! @9 P* D# f
  562.   # Validate install path
    : |& M% }9 g8 K  ]2 @; Y0 [7 ^
  563.   if [ ! -d "$INSTPATH" ]; then
    9 e) `4 W2 }# v1 [
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \7 {! K7 H% E0 i6 @) y  h
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    $ J4 M3 U/ t5 U8 D
  566. 9 u  U; E4 [0 ~# c6 S
  567.     if [ $? -eq 0 ];then; w1 c8 j1 j, k/ A' ?5 ]& e
  568.       Log "Creating install path: $INSTPATH" 10 d( J* j' |# S, _2 u4 b/ m- e
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
    # j7 _1 C" u* y" x# ~0 p

  570. - q/ {0 e0 W4 S) |: D/ }
  571.       # Check to see if the directory was created$ U% O! O' h% |- V3 U
  572.       if [ $? -ne 0 ]; then) Q4 V- Z" W& O" R( N9 b9 K) S
  573.         Log "Error: Failed to create the specified installation directory!" 1
    & _3 f7 e' I  M
  574.         exit 1
    2 o* }* h1 l" f! b- u
  575.       fi
    $ V2 Q% o9 P% x
  576.     else; [0 c. Y4 q5 \  D- h
  577.       Log "Install path creation cancelled. Only the source path has been created."
    % w, E4 b+ Y5 D4 O8 {1 ~9 q
  578.       exit 0$ Y4 d& v  A, T$ x% b8 `. W" y
  579.     fi0 {+ n8 C; \1 y( X
  580.   else/ x9 S  t+ ~; c# g3 X7 m
  581.     # Check for an old installation: j, k! C: l3 O- T; E
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then# u  z$ H4 n2 q* v/ Q! S
  583. * j- k6 L  X5 X- ~; d: G
  584.       # Ask to remove the old installation
    7 x0 l( J: V; p2 S$ E
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    $ f: S% W& ^3 W( F
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 0) }, k/ |6 i  Y

  587. 6 C' e$ q- V& v4 I, i9 |
  588.       # Check the user's response
    , S9 o4 T# K( f- T7 J% u* H
  589.       if [ $? -eq 0 ]; then- W, G- o/ C0 k1 v) Q
  590.         Log "Removing old MaNGOS installation..." 1/ u- O3 A& h8 K$ `9 R* n, e

  591. 4 W* F' q3 H( a' I* q' t( m, e3 F( l
  592.         # Clean up the binaries! `: H% n  Z5 N! h+ p
  593.         if [ -d "$INSTPATH/bin" ]; then
    4 F4 q! V  z( r( \2 @# n8 @- Y
  594.           rm -rf $INSTPATH/bin
    & B, Q: Y1 T+ |$ ~  n$ G. T
  595.         fi, a0 `2 z7 G6 {9 h6 V' Q

  596. 7 @7 @, k" A$ }0 P" E
  597.         # Clean up the old includes6 p2 ^) O" F1 c$ }( D/ K
  598.         if [ -d "$INSTPATH/include" ]; then2 y1 X9 @" U  c, |" F6 F- J9 k
  599.           rm -rf $INSTPATH/include
    ' W  o, c( l; R$ }
  600.         fi- s  L) H3 H4 g+ w9 O; Q+ f

  601. * o7 D4 n: Z: u* e
  602.         # Clean up the library files
    " {6 A0 a+ C# N8 {  E3 d
  603.         if [ -d "$INSTPATH/lib" ]; then4 i3 Q1 }+ N+ h: F6 s% N' [4 O  W- q% M
  604.           rm -rf $INSTPATH/lib
    1 X& t% |: k; e3 w1 x
  605.         fi
    % A* g. f% @* @" R0 l" \+ }, ]1 U4 d

  606. ' B" D$ n: o& x- E! r
  607.         # Clean up the old logs
    ; e* W1 s. Y! H7 t% \8 A
  608.         if [ -d "$INSTPATH/logs" ]; then" _& O* Y6 h  ^0 g: w
  609.           rm -rf $INSTPATH/logs/*$ Q# z7 i( r7 ]; W% L, w1 o* J
  610.         fi
    , r9 M& z* e7 n7 w# p$ V3 U
  611.       fi  E# n4 a3 B. s6 X7 \7 ^
  612.     fi
    7 J% a8 ^  J: J7 ?3 O+ E$ v
  613.   fi8 l( _3 \! ]2 G6 O! P. E

  614. : m2 \' Y. s% E) Z& {
  615.   # Log the settings
    ( }1 D1 x6 v. ~( B: D* @
  616.   Log "Install path: $INSTPATH" 0
    3 Q2 C) d3 q5 d$ O" P
  617.   Log "Source path: $SRCPATH" 0
    6 c0 j% ~& U) r8 @5 U3 b
  618. }; v- S) P# ?3 F  p

  619. : L. g5 k/ m3 N+ \

  620. & w; z% i. N) l* c4 d

  621. $ c" d4 O( b! M4 k: I1 o
  622. # Function to clone or update sources
    + ^4 c/ l& u6 O- n8 i& I
  623. function GetMangos()" v6 o0 X1 _$ _- \- K6 R
  624. {7 y3 {2 F- U) A1 u" k
  625.   local CLONE="0"
    . m. B* S, j6 s  \: }
  626.   local BRANCH=""
    * d+ u1 G. p- R& O: @! \+ S* h/ M
  627. / V+ f" ]0 Q' g
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \% A/ B2 S- }  B0 q$ I1 P( V
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \- d6 f4 z. |1 G; S
  630.     0 "Clone a fresh copy of MaNGOS" \1 A, V! b0 }+ O6 X; M3 _! T
  631.     1 "Update your existing copy of MaNGOS" \
      r. o' s" [% @
  632.     2 "Use existing copy" \
    7 J& o) w  m! M: n* |
  633.     3>&2 2>&1 1>&3)) S3 ]* A3 D$ i1 @3 t" D

  634. 2 k- h, a3 D& x6 s7 O- [
  635.   # Exit if cancelled$ L9 V. ?4 j2 {% c; S# W4 \  w0 C4 |
  636.   if [ $? -ne 0 ]; then3 J! K0 i+ Q3 p7 s
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1
    , l: X2 J, c: f7 w/ G
  638.     exit 0
    ) t6 d! I# p' j  ~. ?5 ]0 I
  639.   fi4 v' o3 w7 H1 ?. v
  640. , M, }3 x, {5 j
  641.   # Clone from scratch if selected. M0 `6 h& O" a9 f4 j- G: C
  642.   if [[ $CLONE = *0* ]]; then+ D/ q: k" h, s& g
  643.     # Pull a different branch?
    5 x7 o3 K8 F1 x9 x/ ^2 O
  644.     case "$VERSION" in
    ) w3 m! K. p8 M, q
  645.       0)
    " d8 L2 z; a. N3 d4 ~8 h
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    * Z8 @* S7 Z. o
  647.         ;;
    ; F  n# a, d: Q2 Q8 J4 Q: x
  648.       1)4 h0 h: ], v/ |+ g
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')9 t+ z' |1 {# D3 F
  650.         ;;
    5 P5 H; M9 f: Q% b& X
  651.       2)
    6 z; T! j' a, x
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')' x' s: F/ D0 T% K1 e
  653.         ;;4 h2 O0 z/ f$ U$ M: B
  654.       3)
    ) ~, ~: L" B$ M1 V# v% i; c) r
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' '). X7 K9 ?+ k2 s- ^8 M
  656.         ;;
    % [; P, m% G& R3 D, H+ \0 @' d8 m+ b5 e0 P
  657.       4)0 K/ X0 {& g0 D
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    5 }6 Z6 F% k4 @; `% ~1 @/ Y
  659.         ;;
    " e4 F' ~' t5 e9 Y: ]  b
  660.       *)
    ) K4 K. J/ w+ e+ A2 C
  661.         Log "Error: Unknown version to select branch" 1
    ! f2 a% V0 l3 d6 M, [% a7 J2 G3 _
  662.         ;;- T% J/ ^. j3 b* b* c" N
  663.     esac
    ! ^; L: g% i5 B- W

  664. ) k4 n: a' Q- |8 e2 a3 B
  665.     COUNTER=1
    # J  h9 A. b1 ~+ z
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog4 _0 a2 @+ y, w! p& D8 n1 }1 C2 |3 l
  667.     for i in $releases; do
    / J$ z) _0 D3 f6 h# i
  668.       if [ $COUNTER -eq 1 ]; then% S1 P0 z* Y( g& R2 r" @( B) U" j* T
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "9 P) z7 `# u# S# I) Q
  670.         BRANCH=$i
    + K* |+ R0 u7 G0 Y; ?/ h
  671.       else! f! |# r1 W4 ]
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "
    . e7 K2 g# T* `0 x* N
  673.       fi
    : T- S6 p- F' i% m7 i! `& ]3 a4 L
  674.       let COUNTER=COUNTER+1
    ! W6 h) J" h! j* M" @6 `& u
  675.     done
    + s4 b8 E5 c: V" F" i
  676. . i* w( r% S) w7 T( e9 G6 g4 ?3 G
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \8 _/ r6 \* _6 ~  q! E; g
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \, H/ a7 ?% y) V
  679.       $RADIOLIST \
    7 h3 T! @2 E4 |+ r2 |% Y
  680.       3>&2 2>&1 1>&3)& A9 g/ K7 P, r4 c( R
  681. 6 W! s8 m, S( Q4 ?. D
  682.     # Exit if cancelled# t& \6 P8 @; P5 Y
  683.     if [ $? -ne 0 ]; then
    * A4 m9 S% C5 f& g
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1
    1 q. U# s7 P1 d; S7 d2 H0 G
  685.       exit 0
    $ {+ C2 E/ ^6 Z5 i3 c8 |
  686.     fi3 p0 S& m/ ^) k- \8 o6 d/ Z: J

  687. ( y8 z3 ~* l/ h8 f+ _/ z
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')
    , f$ L  Y) ^6 F- v& E, d& f4 ^
  689. 4 G! d  u1 b  S& ?3 ~
  690.     # Set the branch
    9 f6 W2 j( @; s8 w4 i0 f+ ^
  691.     if [ -z "$BRANCH" ]; then( J8 I* h, v. K
  692.       BRANCH="$releases | awk '{print $1}'"/ K4 I4 B8 W8 K/ z( E. ^" B$ W
  693.     fi
    / s* d# f5 ]* f" S% Q3 r

  694. - ~  t: L; l2 B* k" @- I
  695.     # Clone the selected version9 a/ W- o. o. P* v/ k
  696.     case "$VERSION" in
    7 S5 k, i1 O: N& k" A' ~6 u8 R
  697.       0)" S' _8 h2 L8 N7 v6 t- k( V5 X
  698.         Log "Cloning Zero branch: $BRANCH" 1( f3 k( ]2 t2 j9 q
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive/ D2 p% w2 K# W; m7 N0 w5 l/ O
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive0 [; x) Q- I+ ~( \- u
  701.         ;;5 r) N/ `) ]; d- j

  702. # J( s; a5 y7 Y( R
  703.       1)  c; h1 C- Q* d$ A
  704.         Log "Cloning One branch: $BRANCH" 1
    + H$ d6 A4 u- v$ w5 m+ ^
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive
    $ a9 g$ l( ?/ m& ?4 M! S
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive
    2 @& C% h( p6 {* ]; p0 ]
  707.         ;;! [( i  F7 ]2 i- Y5 l

  708. / j0 ?* G* F! f% `+ S! f5 |1 Z
  709.       2)8 p. ]8 D# C2 K. Y3 @% X
  710.         Log "Cloning Two branch: $BRANCH" 1
    8 x1 C3 k8 \; u
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive
    4 ~) I/ A& Y, {
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive5 X3 _  \( B1 {' a9 d% J* q
  713.         ;;  z5 E+ s+ t' K' \$ O9 Y- ]& u' y

  714. - d8 p6 ^, Z/ Y% U) b( Y
  715.       3)  W8 I1 T" |" y7 M' z( T9 f$ V
  716.         Log "Cloning Three branch: $BRANCH" 12 k- r2 G- @8 X
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    1 |0 O1 k, G7 S- d  }
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
    % o+ s# m9 F" w2 L% i+ h& d
  719.         ;;
    , \' T( {8 z! A$ Y( X
  720. ! K8 s# _( q: k/ j# i4 M9 u
  721.       4)
    0 w" l7 O% B# a6 O% f( v
  722.         Log "Cloning Four branch: $BRANCH" 13 [+ R# k! W6 C) A6 w
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive4 J6 l+ {% N# w9 y! N% v  a/ F) w
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive
    ) v4 |1 I9 u/ I: z. k
  725.         ;;) P& p1 Z) B- v6 w. q

  726.   l6 T! C3 L7 x; W4 V1 c/ R6 l" ?
  727.       *)
    6 j* A9 `+ z. `6 u  a
  728.         Log "Error: Unknown release selected for cloning!" 1
    : K  ^3 u( f* l( x1 O
  729.         exit 1. |! u0 g" Q' q+ ]! }6 ^. v* u# G
  730.         ;;4 l* F* O( q6 @  b3 h
  731.     esac
    & ~& {5 P. k( t8 w9 T7 j" [7 B
  732. " u/ \: X* X' I
  733.     # Log success+ k& v, n  O2 T3 p( ~5 X% p
  734.     Log "Cloned the selected repository!" 1
    7 K+ V$ p+ ]/ W7 T' B
  735.   fi
    ; l, U5 r% m9 y& P; e$ f9 I" Y7 ^
  736. / `" `0 C+ `* p  d/ y
  737.   # Update the local repositories if selected
    ; \8 `$ O, M" U: ]+ J5 L  Z0 p: a
  738.   if [[ $CLONE = *1* ]]; then8 X8 w; F) F! n
  739.     Log "Updating your local repository..." 1- o2 k9 U- q5 K" L0 ]
  740. ( p. M3 e% g  R3 A. V1 V( j& L
  741.     # Update the core sources
    , m$ J6 }3 K! c) o% T. l
  742.     cd "$SRCPATH/server"
    + _* J: d1 H' j- s
  743.     git pull- M( M+ s* e; @" z

  744. . w: {! z; c. `: k0 K
  745.     # Now update the database sources
    . Y2 S# p( s! ]( j' c
  746.     cd "$SRCPATH/database"
    ! B% T3 K! w* ?1 h
  747.     git pull1 L8 F  r  ~/ ~* U
  748. 6 `4 V( Q/ P. }2 D! ?( y
  749.     # Log success/ A1 Z$ `/ K6 P% F0 m5 e
  750.     Log "Updated the local respository!" 1
    5 H5 E0 w" C/ W$ ?* g( l# [
  751.   fi9 X$ H- o; \3 r: C0 r/ g
  752. 0 j. A& l) r. ]2 K
  753.   # use existing repository1 O2 }+ ]% \' o6 |
  754.   if [[ $CLONE = *2* ]]; then
    ; B+ O1 q- {& S. f, v& q
  755.     Log "Using existing local repository" 1
    2 @! l7 {/ o. i' y; X- z$ F5 @
  756.   fi- p) ?( d0 n% h5 T8 Q3 ^
  757. }' V5 H1 k2 w( W* k

  758. , T, I, D6 `, Y5 _

  759. " @! v; s6 L& P/ L0 k, U

  760. 1 k3 @. I' g0 z3 ~$ Z" W4 ?4 G
  761. # Function to set the build options
    : n0 B! Z% ^8 M. @
  762. function GetBuildOptions()
    ) _0 E  U; }, x7 F4 y. v& v: A3 w3 b
  763. {
    ( v; \0 W1 I/ @
  764.   # Select build options% J8 A* c1 X, c# l/ N0 z* n7 u
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \/ p% O- T0 ]6 t2 z( \6 _/ C8 s
  766.     --title "Build Options" \8 ]1 g9 }+ f/ V) K0 e3 _7 F% Z+ y
  767.     --checklist "Please select your build options" 0 56 7 \
    3 J6 o$ q+ s! C- `
  768.     1 "Enable Debug" Off \! i! H" D) C; p. l$ \8 t4 V/ P9 y
  769.     2 "Use Standard Malloc" On \! x& b5 R- M' @5 t$ d
  770.     3 "Use External ACE Libraries" On \
    . F3 L: x) r8 I1 h
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    7 b# |) s+ i8 Y1 {; k
  772.     5 "Build Client Tools" On \
    8 [2 _/ N- W! g* X; z9 E: G* `
  773.     6 "Use SD3" On \$ I8 K9 s7 D) b; Q' }9 |6 P( p  L$ N
  774.     7 "Use Eluna" On \  b3 Q. B, a2 X" n
  775.     8 "Use SOAP" Off \
    4 e5 |( z6 e" W& ?
  776.     9 "Use Player Bots AI" Off \3 D4 L, T$ _# t3 Z* B' H
  777.     3>&2 2>&1 1>&3)
    # M$ }) C! _: P

  778. 3 P. b& P; y7 v" t& ^0 s! ?; L
  779.   if [ $? -ne 0 ]; then
    $ c" b; a( l5 d2 b
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1" Z0 H! i4 u# X3 ^
  781.     return 02 X6 k0 g% |! P8 z! j. {4 ]3 W% k. c; _
  782.   fi
    " ]4 P( g# k  E
  783. . c1 o* h. u5 r  I1 K
  784.   # See if debug was selected
    , {8 k+ A5 I& x2 g; H/ B. C
  785.   if [[ $OPTIONS == *1* ]]; then
    2 M) @5 G" [! y9 ^
  786.     P_DEBUG="1"  @0 n) T; z  v% y
  787.   else
    0 n4 H1 f4 H: x7 l3 s
  788.     P_DEBUG="0"
    ) A) B! d1 C* J: ~" @9 [* X, E
  789.   fi
    * H6 m7 ~2 l! H$ n

  790. 4 Z. g( K# M2 u( F
  791.   # See if standard malloc was selected" N* ]1 g( O; v% s$ K, f
  792.   if [[ $OPTIONS == *2* ]]; then
    7 t4 z4 G/ |8 R
  793.     P_STD_MALLOC="1"+ ^# X0 j8 J9 G: R: Q# z
  794.   else
    - i) ]; r: ~9 g6 c" ~; I
  795.     P_STD_MALLOC="0"# h& ]  [4 {0 Q" R: _! e
  796.   fi
    , K$ q+ p% _( A0 {0 g+ V2 X( D! t
  797. 6 E. K% G  ?9 k2 h% e" m
  798.   # See if external ACE was selected
    ; D9 D) K- q' a$ `
  799.   if [[ $OPTIONS == *3* ]]; then! a) s+ p0 W. F% M- ?
  800.     P_ACE_EXTERNAL="1"
    & N' \" w. |6 w7 @0 Q, R' z
  801.   else
    9 C/ i$ k$ u) i! U0 \
  802.     P_ACE_EXTERNAL="0"
    0 M% {/ [: g. n3 c6 M- P! J
  803.   fi
    * i/ J, g1 X+ S) H
  804. + b7 d, [& s$ a, q3 S( [
  805.   # See if PostgreSQL was selected6 p0 O6 I0 T6 `2 p6 E
  806.   if [[ $OPTIONS == *4* ]]; then
    6 G5 I7 ^6 a$ G8 r
  807.     P_PGRESQL="1"5 `5 W0 K" ^& o! G* }
  808.   else
    & H- C- o1 e+ n4 `/ b- X
  809.     P_PGRESQL="0"& `# `* i  v0 V5 |- q/ d2 g( M
  810.   fi
    # E  x9 Z6 c' t
  811. 5 I3 ^1 f% t+ a9 \/ b; d( M
  812.   # See if the client tools were selected/ ]. p7 V! V! B: E
  813.   if [[ $OPTIONS == *5* ]]; then8 ]6 H* `! Q. Y& [
  814.     P_TOOLS="1"
    1 _0 O9 d, Q+ f2 S( j5 f7 C$ O
  815.   else( ?/ k1 `  Z. [' x+ n2 Y8 T
  816.     P_TOOLS="0"
    3 T; @0 @$ G2 A. _, O
  817.   fi
    + x, k8 L. S8 k
  818. & v1 W2 U: A7 b9 x. E& N6 s4 [
  819.   # See if SD3 will be used$ E- z6 T. Q4 P2 R2 r" ~
  820.   if [[ $OPTIONS == *6* ]]; then( _; w3 F0 `- \3 q( H) O
  821.     P_SD3="1"# ~0 ?+ j  i0 z* f7 i6 P$ y
  822.   else( x* h6 c3 v1 d; @/ U7 B
  823.     P_SD3="0"  Y% {, o+ W* ^! P4 b
  824.   fi) v! a6 I) ]/ Z  p
  825. 5 w' W, a  ?1 @9 }+ ?# \
  826.   # See if Eluna will be used4 y( g+ P- O1 T5 M/ ~3 K
  827.   if [[ $OPTIONS == *7* ]]; then
    6 X$ N$ O4 ]+ Y! V8 w" p( c* H- a
  828.     P_ELUNA="1"
    ! X# @+ y7 J; _/ A3 }7 L4 V8 y
  829.   else6 m9 Y( e* s5 r& M
  830.     P_ELUNA="0"$ C- J2 W+ z- e& Y& K# P9 ]
  831.   fi
    , E2 y2 o# n5 L3 S

  832. ; c$ d6 I" T' F" D" n
  833.   # See if SOAP will be used
    6 Q% [1 P5 T4 [& U
  834.   if [[ $OPTIONS == *8* ]]; then
    , W$ j9 O% h3 t$ W' k! e) _. p$ e
  835.     P_SOAP="1"
    % q. Y6 w) N1 y6 A7 N0 a0 \5 z6 X
  836.   else4 Z( t$ n- c2 P9 ^, X
  837.     P_SOAP="0"
    8 h4 V! S9 Q- @( |
  838.   fi8 N# }: Y$ k. P2 b

  839. 4 v5 u4 E3 M8 s' s$ {/ @) B
  840.   if [[ $OPTIONS == *9* ]]; then
    % i: p1 _9 R, g0 W0 ^7 u
  841.     P_BOTS="1"( O" O/ a$ E, A
  842.   else; {% E0 \+ T8 _; ?$ X
  843.     P_BOTS="0"
    # Y9 H6 y) W" ]4 A7 N( p
  844.   fi2 b% W  H& q) Q. w9 m
  845. , q- F+ J; u& F/ _  q/ k
  846.   # Verify that at least one scripting library is enabled
    ; o7 _$ |/ E: [
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then
      e5 u6 S* @* m* s9 ]; V8 i
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1
    9 U& x! j  Y7 n* J+ ?2 j
  849.     exit 1
    - z5 \, e8 l( f
  850.   fi  e& f) Q) m( ]& U
  851. }
    / }# C2 ~/ v! U% A

  852. 8 n, h: N; h( L$ f2 T4 U$ l7 N+ w
  853. . n  y# A7 Z1 g) }; \* t" h) M
  854. 0 F: E% e3 E, @
  855. # Function to build MaNGOS
    $ z7 [8 T- M% q8 C, [
  856. function BuildMaNGOS()/ |0 o7 T3 W2 |7 `- t% }. q
  857. {" O6 v  Z  f" A) r/ v
  858.   # Last chance to cancel building
    ; U+ L2 n; Z1 X9 }( ~( d/ d
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \1 C- v& @9 Z1 j
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 606 s  i1 [& v4 a5 N" t/ D6 Y' ]& |  _
  861. ; g. I$ B' W9 l1 q+ S7 {" h$ {4 ~/ t7 ~
  862.   # Check the user's answer) M1 w+ D  p$ h) T' J+ a+ U/ k
  863.   if [ $? -ne 0 ]; then
    ' b! _0 |1 G: g* u. M% N9 x- w% t
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    $ S7 r1 Q0 n* }9 [- V
  865.     exit 0
    ( K4 p8 S% |& j, k. Z1 H) A
  866.   fi
    ' B* \( t2 m3 v, j
  867. * G+ P6 p. v) d; D: ]
  868.   # See if the build directory exists and clean up if possible* V, T4 g9 S' \" |
  869.   if [ -d "$SRCPATH/server/linux" ]; then! H. S/ x+ y; f* {
  870.     # See if a makefile exists and clean up
    & k7 ~" _; U) _( v, _
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then
    # |( O% e. `6 S  W* ?
  872.       Log "Cleaning the old build..." 1
    2 w7 a/ N+ H7 J. `
  873.       cd "$SRCPATH/server/linux"% b# C6 e9 H- r2 c* A1 n" U8 H5 d
  874.       make clean
    & F  B. E; W* ?5 B9 R$ s
  875.     fi
    ( T# ?1 L5 p* A2 |& C& ]
  876.   fi! T0 v6 l# s: z0 r

  877. 3 \" ]5 K* K* B2 q
  878.   # Attempt to create the build directory if it doesn't exist
    4 l) C) B6 Y" y+ Q" i5 V6 K
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    / ?( d1 B- J( N; U
  880.     mkdir "$SRCPATH/server/linux"
    1 |/ {* ^; `* u

  881. * u5 ?4 W+ N- j" ]2 F
  882.     # See if creation was successful* B2 z/ D% E' m; Z; I  m' ^. x1 g
  883.     if [ $? -ne 0 ]; then- C' l& ~3 z/ D! j6 p
  884.       Log "Error: Failed to create the build directory!" 15 u4 l* E5 Y0 x& I- G
  885.       exit 1* f# Y, w. T, E/ D8 i: ]# U2 V5 s
  886.     fi4 l0 ]9 Y) d0 C4 @
  887.   fi
    6 U9 b6 ]) m5 r! o, i

  888. 8 V' P% g2 F, _7 l
  889.   # Attempt to configure and build MaNGOS
    ! ^$ p; H) W4 v. s& F5 k* Y
  890.   Log "Building MaNGOS..." 0: t/ b5 n; ~. P% b
  891.   cd "$SRCPATH/server/linux"
    . j3 g$ w% n( ~
  892.   # make sure we are using the cmake33 g. c( V8 V9 b8 ^# t. l4 c
  893.   UseCmake33 H+ c1 s5 h* H) z0 T8 Y
  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"3 E. J% A) c; a5 B% f. {
  895.   make' {) \# @& ^3 Y6 W# Q$ \$ s# k

  896. ' }: c2 K" r1 A" j, [) H
  897.   # Check for an error
    2 _3 H5 e. A$ Y& U" M
  898.   if [ $? -ne 0 ]; then% G9 o; _$ `2 P- a
  899.     Log "There was an error building MaNGOS!" 1
    2 W- K+ x3 b6 l
  900.     exit 1
    * j9 L, x/ F: y6 C7 ]
  901.   fi
    : h. ]. @0 N0 J7 g

  902. " E: L: T( d. E
  903.   # Log success2 ^0 ]4 P2 w0 y% a$ t. h
  904.   Log "MaNGOS has been built!" 0
    ) H7 h- T) s0 J, y
  905. }
    " m3 x. }: ^5 a9 ^* L' L

  906. 4 ~& j/ T& }; b$ M- Y

  907. $ f+ \% D3 d- s  r+ `! }
  908. 4 E& H- v, x6 |! [: s
  909. # Function to install MaNGOS
    9 d, |* y& s* j9 k
  910. function InstallMaNGOS()
    & D0 o( g+ D0 o! |
  911. {
    ; a) L8 J+ W4 m! j
  912.   # Ask to install now) t" g+ j7 y+ {4 h1 ~: N0 K
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    - M8 g& }  b/ C* ?
  914.     --yesno "Do you want to install MaNGOS now?" 8 03 l3 D! ^: y* b; S1 F5 L
  915. " N" u4 X! K8 E! `  D
  916.   # Return if no
    ' O, D% |9 c& f) F- w0 h2 ^
  917.   if [ $? -ne 0 ]; then2 j3 @: q. j6 m3 b/ v, R: }
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    % U9 h$ u; I0 M% z  v- M
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60
    , I2 b0 J6 a) A
  920.   R: l; ~* V8 `5 U& ?
  921.     Log "MaNGOS has not been installed after being built." 1
    ( u  m9 F0 e8 f6 U4 v
  922.     exit 0
    8 D2 b& M9 a0 ^) p  m
  923.   fi" \0 |" U2 e9 M1 D" U# x6 X
  924. & q1 _$ Q8 ^( [6 k9 Q% \$ y
  925.   # Install MaNGOS! J1 V- [, k# ~. ^+ p; o' h. u6 u
  926.   cd "$SRCPATH/server/linux"$ C! B4 D' _  G) ~4 k+ ]
  927.   make install8 w! ?' c- r; q7 }

  928.   [( M* b, x) j
  929.   # Make sure the install succeeded
    ( M" L7 O8 Y3 m/ K4 h; ~6 R6 f
  930.   if [ $? -ne 0 ]; then
    3 _. D: z* K9 [1 R; g5 i
  931.     Log "There was an error installing MaNGOS!" 1
    6 R" ]/ t8 x/ d# t. v
  932.     exit 1
    & }% |6 `5 N* f+ j
  933.   fi3 z4 p9 s; s  {; \$ s" ^
  934. }8 [- i* r0 _% F: J2 U

  935. * H" ^" e) P! l, B, }8 c6 u
  936. # Function to apply database updates* o8 f/ C1 F: F6 r0 y6 t  f) K
  937. function UpdateDatabases()
      t9 p* y# m# J9 J( y: f
  938. {: g3 H6 G& W2 B  p/ g
  939.   local DB_HOST="$1"( P  Q! x+ y* m7 O6 }7 D8 }0 o5 {
  940.   local DB_TYPE="$2"
    * L5 X6 u9 D3 T, V4 ]; h* Z3 b
  941.   local DB_COMMAND="$3"
    ( g- a: r3 d7 R1 Q( k" H. a
  942.   local DB_USER="$4"
    8 C% L4 x# f) W8 Z- g8 g6 G
  943.   local DB_UPW="$5"
    % t  I' X) h+ N! o9 ~9 ?
  944.   local DB_REALM="$6"
    7 K& M" X& }4 y/ s, w3 B  V
  945.   local DB_WORLD="$7"
    , z  k& @" h7 ]$ l% J! B( `( |
  946.   local DB_TOONS="$8"
    & s$ H- O* M. H( r7 ~4 A
  947. 5 q4 }  V/ A: ~: V# m
  948.   # Loop through the character files
    $ U# B( \/ g1 F" n$ h/ |+ L
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do2 o2 ~* v& e$ R/ E6 [- O# @) J
  950.     if [ ! -f "$pFile" ]; then$ t1 ]6 }2 {# b' I4 b
  951.       continue" F1 ~4 ^0 y9 }, R5 R2 `, z6 F# ]- x$ @
  952.     fi
    1 \/ E! w, N- b, i1 p# ~9 J' s, _* f
  953.     # Attempt to apply the update$ D) T; ?; E0 L5 x2 C) L
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1+ A' t" Z* W, a9 j$ I3 b
  955. " s  V+ e, x! ^- L0 y$ \
  956.     # Notify the user of which updates were and were not applied
    ( q6 i: t; o" b1 ~
  957.     if [ $? -ne 0 ]; then
    # e# m, x8 V$ s. J( s5 K
  958.        Log "Database update "$pFile" was not applied!" 0
    # t+ j. x. h1 D+ D2 Y1 u, g  r
  959.        Log "Database update "$pFile" was not applied!" 1$ S: w. \$ f8 Q$ n1 @4 g
  960.     else3 S( Y3 ?  j( q& b. P7 r
  961.        Log "Database update "$pFile" was successfully applied!" 0
      C6 z4 y1 |' f2 I
  962.        Log "Database update "$pFile" was successfully applied!" 1
    # ~, E8 |" y4 a) m9 {
  963.     fi
    9 q# K) C$ }- ~& e/ ^, O
  964.   done/ Z1 _7 K4 s9 I
  965. $ v4 J" j- j1 a
  966.   # Loop through the realm files
    - h5 O3 M% h& n3 H6 i
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do& D" l  Z8 ?) P4 |* a, Y
  968.     if [ ! -f "$pFile" ]; then; h/ m5 R7 C* l  x# J
  969.       continue# n$ G* D+ {% E2 H
  970.     fi( k8 Q* q. c2 j
  971.     # Attempt to apply the update8 h2 k( _' m2 Q, w8 e& U
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1. M+ N0 H! ]1 H. O, _3 A1 n

  973. ( i3 L& y4 D4 V; L7 l% o* l
  974.     # Notify the user of which updates were and were not applied
    " N' W! K; ?6 j
  975.     if [ $? -ne 0 ]; then# z. b: {: I5 D4 L
  976.       Log "Database update "$pFile" was not applied!" 0% G0 M3 d) F/ U( f! ?4 v4 l( V
  977.       Log "Database update "$pFile" was not applied!" 13 ]# Q4 \! G: ]$ \- \8 G4 J7 L
  978.     else
    - Q1 c6 t; J! X+ Y
  979.       Log "Database update "$pFile" was successfully applied!" 04 S9 s# @8 x$ g$ E" D7 Q5 U) l2 {
  980.       Log "Database update "$pFile" was successfully applied!" 1
    / k" {5 N8 L" ]) i
  981.     fi
    1 |$ T- u. @8 S6 B. Q1 G( R
  982.   done
    3 U1 t* V, b9 ^4 E
  983. $ L5 g  E6 Q4 E8 g# _6 }# K" |
  984.   # Loop through the world files# ]( U2 A; c6 {' M9 |
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do# h, H- q$ E' h0 Z; g0 A
  986.     if [ ! -f "$pFile" ]; then5 Y7 l) j, G. f/ N6 j& @. I" P
  987.       continue
    $ }1 w! M4 K2 X2 {3 Q# K
  988.     fi
    " w" l' ]7 j  Y# }5 E
  989.     # Attempt to apply the update! t. _1 Y4 @0 }& `3 t9 g+ r, y( W
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    . t8 p7 ]8 ^3 \; ]3 T8 I6 j

  991. 5 g+ c8 p( z  I$ E
  992.     # Notify the user of which updates were and were not applied( R; A/ W2 _# D5 r2 ~
  993.     if [ $? -ne 0 ]; then/ S- a( D6 y" T- {# `6 |$ I4 i* ?
  994.       Log "Database update "$pFile" was not applied!" 0
    # u1 z* u6 z& _% y7 n2 `# }
  995.       Log "Database update "$pFile" was not applied!" 10 f/ [% I. M$ h% v) ], s6 d4 x
  996.     else& N" k, v' L( K' M
  997.       Log "Database update "$pFile" was successfully applied!" 0! a+ y7 _3 E% M, b# A8 }
  998.       Log "Database update "$pFile" was successfully applied!" 1
    ; e2 ~8 F$ q6 i7 t
  999.     fi
    ; ]) f1 Z, L, ^" }) T( I( F
  1000.   done
    # M2 G2 v4 m+ f! Y. f
  1001. }
    , s" h  v( N+ X- b. m

  1002. $ c. k0 ^6 h# e. R
  1003. # Function to install or reinstall the databases5 K' x% Z$ p$ O
  1004. function InstallDatabases()
    # s. B! k" z/ s' s, R
  1005. {" B- S2 T- K4 v1 D, P; ]
  1006.   local DB_HOST="$1"# c; m9 H; H1 b# d8 o+ n: [, H
  1007.   local DB_TYPE="$2"
    0 F% U: t/ k, r7 w2 }/ I' i7 t
  1008.   local DB_COMMAND="$3"
    ; o  H5 T# D0 w5 _0 k
  1009.   local DB_USER="$4"
    + r6 \) f( J* Y" r* s
  1010.   local DB_UPW="$5"6 {& N5 ?: X/ @# v: K% |
  1011.   local DB_REALM="$6"
    & s9 V2 e7 _2 S7 x5 k* v- p
  1012.   local DB_WORLD="$7"
    / P- O( k- T6 m! A5 d
  1013.   local DB_TOONS="$8"- F# r( S. G7 g
  1014. / Y" C! t: i+ C& H: L1 p" e/ B  W* t
  1015.   # First create the realm database structure8 t  P+ W8 j5 B; W  A5 ]4 M; N+ s
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql
    2 I3 C6 u  F  h$ u( f3 l, t

  1017. % a1 m% l- j- B6 m3 u; |& A
  1018.   # Check for success  J* ^) E0 W' y! M4 Z! i
  1019.   if [ $? -ne 0 ]; then
    " e! @/ k$ Q( k/ K9 x
  1020.     Log "There was an error creating the realm database!" 1* G# j4 q0 O* X, U
  1021.     return 1
    . p% L& L0 R, }0 \5 l
  1022.   else
    , y! K3 X5 c9 s. n3 F) u  z) Q
  1023.     Log "The realm database has been created!" 1
    : x4 \9 @- ^1 V# c. o
  1024.   fi
    ' \1 a3 A3 Z6 D2 C, F) R6 d) f

  1025. ' G5 a/ c; m+ o! @0 O
  1026.   # Now create the characters database structure
    * F0 W0 c1 K# Y# a
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql4 k- X+ k: L9 [( d) B1 e, V
  1028. 7 c0 M; k" B% B) H) u& M8 g. J
  1029.   # Check for success, ~, L1 ~2 x* [& v. m) L$ ?
  1030.   if [ $? -ne 0 ]; then
    ) d5 \5 @# N: G6 n+ K/ u% P
  1031.     Log "There was an error creating the characters database!" 1
    7 t4 B# v4 V# O3 A7 x( Y: F
  1032.     return 1" r5 f0 [) T4 x
  1033.   else
    ( j# P! p0 f# o) \& m% e
  1034.     Log "The characters database has been created!" 1
    ( t2 b; A0 Y7 v( B
  1035.   fi& |  N" u3 \; M2 q& X0 @- E

  1036. / p& B; `  r, |0 M3 u! s) L
  1037.   # Next create the world database structure
    $ a" A6 F, b! D. m4 T* p, Y3 F1 M
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql
      B1 M9 f. }# \/ Y
  1039. . E5 ^3 I) Z" d! d5 p5 a
  1040.   # Check for success
    1 h8 j& l0 S" n/ B
  1041.   if [ $? -ne 0 ]; then( D5 ?' ?4 P3 K" E9 @
  1042.     Log "There was an error creating the world database!" 1
    1 j+ M1 J- B. R
  1043.     return 1( T; }6 l2 n3 h+ d" X
  1044.   else
    1 M+ z# q$ e9 W, c* V4 J$ ~
  1045.     Log "The world database has been created!" 1
    2 w$ _! M% L/ D% J  X
  1046.   fi
    " z7 p6 D$ F! \; z5 q6 e: e& Y
  1047. * [1 |, \* ^3 J# h; L7 M
  1048.   # Finally, loop through and build the world database database
    0 b7 D9 J: ?% h; Z
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    : n- ^9 `4 `- v2 {9 l0 [' i0 V
  1050.     # Attempt to execute the SQL file2 X- }5 \, O6 c, I* U6 c' F
  1051.     $DB_COMMAND $DB_WORLD < $fFile' G4 x( u8 d0 m3 o6 y
  1052. ; b# Z5 V" ?# Z9 {
  1053.     # Check for success  G" N- ~6 N6 z7 K$ X
  1054.     if [ $? -ne 0 ]; then) s, X0 e0 u  N  @# a
  1055.       Log "There was an error processing "$fFile" during database creation!" 1
    8 V! c' g" n1 q' s" i/ _3 a6 a
  1056.       return 12 D9 r6 U7 D. {0 [$ t4 y: e
  1057.     else
    9 n( g$ e- U- O3 [! z
  1058.       Log "The file "$fFile" was processed properly" 1
      O7 B2 Y, G2 ~4 }# _
  1059.     fi  c1 k- r2 l0 o
  1060.   done! K, k- h; S% C0 q# M! l
  1061. 4 K* c3 P) L3 u% e& F/ f6 E' k$ p
  1062.   # Now apply any updates
    & s# U+ g  e2 ?) X2 O/ e4 U" ^
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    ! y( |* N* V5 B! U1 ]8 |2 [
  1064. }
    # I9 D  F2 [8 {

  1065. 7 U* K& l0 W! c, |/ _- r. ?
  1066. # Function to install or update the MySQL/MariaDB databases
    * B' t1 E2 @- T2 r  Z+ m* c
  1067. function HandleDatabases()
    5 R& t/ x( i" Y- s
  1068. {
    . p+ Y6 A$ N+ r9 k* ]. m
  1069.   local DBMODE="0"3 Z: ~( _; U2 c" P( T
  1070.   local DB_TYPE="0"
    4 [2 b1 L. P, w
  1071.   local DB_COMMAND=""! f9 N, m! _; v2 D. x
  1072.   local DB_TMP="0"* @7 Y) i8 t8 h5 x8 g
  1073.   local DB_USER="mangos"  v2 i0 Z6 \5 B2 y, s) N
  1074.   local DB_UPW="mangos"
    9 B5 \0 \, \" f9 j; n
  1075.   local DB_HOST="localhost"- l$ F0 V, b9 t
  1076.   local DB_PORT="3306"
      r2 J9 c& C* G$ u& p' Z
  1077.   local DBSEL="3"
    8 p( d' m& s" h- W5 b* c
  1078.   local DB_REALM="_realm"
    # \- M0 X3 C2 q* A4 I4 B- S
  1079.   local DB_WORLD="_world"
    / r6 n6 v6 c9 g) g! @( |
  1080.   local DB_TOONS="_characters"
    3 b3 R  f4 \* u( g
  1081. 5 J1 X5 q. X2 w/ U
  1082.   # Ask the user what to do here
    5 U  Q' B  O4 [7 Z" f, C
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \, ~; E7 `$ V0 ~/ W# k5 f
  1084.     --menu "What would you like to do?" 0 0 3 \- [3 E  z7 O# u+ l, p
  1085.     0 "Install clean databases" \7 }3 l! l: P: R  u( ]9 V
  1086.     1 "Update existing databases" \
    & d, {6 R, F& a% z
  1087.     2 "Skip database work" \' g- r+ ~; k: n+ U# r% T1 X7 g  K
  1088.     3>&2 2>&1 1>&3)
    3 L8 {& E" ?2 W5 G* o4 U0 e
  1089. ' T6 y9 @; o/ W. z/ y. t
  1090.   # Exit if cancelled
    6 ~( B3 m2 i) r" z4 ~/ ~7 a* w' q
  1091.   if [ $? -ne 0 ]; then
    4 I+ R$ ^9 {1 m& g0 b
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1) A4 ~- ^* e( W. Z
  1093.     return 02 w9 _' R, F/ q8 g, H
  1094.   fi
    * Y. D8 a) x$ w

  1095. 9 y( Z9 z. Z# {- J4 D0 ^
  1096.   # Exit if skipping
    ) c% D7 t( w0 o
  1097.   if [ "$DBMODE" = "2" ]; then9 B1 m, u8 y, _+ c4 A2 x1 a* m
  1098.     Log "Skipping database work. Nothing has been modified." 1" l1 a& n# P1 \# L' [* f
  1099.     return 04 x7 S* S0 w4 j+ G& t
  1100.   fi# r9 c: F* m: U) |. q. P

  1101. 5 N% O/ N- o+ ~2 ?. d/ o
  1102.   # Ask the user the DB type8 u$ p6 |5 i, K8 h: O
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \: n- S6 G4 \! k7 Q  x8 `& H2 [
  1104.     --menu "Which database are you using?" 0 0 3 \
    7 ]5 D7 d, J+ v3 D- b0 _/ V0 P2 k5 ~
  1105.     0 "MariaDB" \# x' i' m7 C& E! r' M
  1106.     1 "MySQL" \0 t+ e8 G/ `( s. T/ l
  1107.     2 "PostgreSQL" \
    1 P. t* s# |, f- v0 y
  1108.     3>&2 2>&1 1>&3)* P8 j; o3 G6 J
  1109. : T2 A3 L" b( s
  1110.   # Exit if cancelled
    3 u- \8 S! k4 G7 f$ h
  1111.   if [ $? -ne 0 ]; then. F% D$ P1 U( G' d" @
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 10 C( Z" o# w' L2 d" s' A
  1113.     return 0
    ' h6 _; y. B0 s
  1114.   fi
    : Z8 S7 T& H  i9 X+ ]
  1115. " T) A0 J% f, W4 k- I  E
  1116.   # Get the database hostname or IP address, O, ~! Q4 ]9 C( E* K* v2 k
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \
    ; ^7 W8 A* f/ K. ^' l" `+ e
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)% K0 Y, B; Z, D6 G& }' Y0 H

  1119.   H) M+ q( r, p- k$ n" y2 e2 x
  1120.   # Exit if cancelled3 ]8 e0 n$ h( ]1 r2 D8 N$ f# Y- X
  1121.   if [ $? -ne 0 ]; then
    " F- c1 w' q0 y2 U. h8 E2 }. G* l
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 16 L/ G6 B+ y+ y8 F7 g! o
  1123.     return 0* \$ n0 v. {# O8 s! W
  1124.   fi
      U# @  ], `  L4 Y2 l

  1125. 2 @- b0 D( k- K% }% {
  1126.   # Set the hostname or IP address if one was specified
    8 p9 o" c2 T6 Z1 b' @* a2 c& V4 s
  1127.   if [ ! -z "$DB_TMP" ]; then# P! @9 I" U; g3 }
  1128.     DB_HOST="$DB_TMP"
    3 G$ d: {/ y/ c2 W8 b$ G8 x6 J" X
  1129.   fi! H, R5 p( V% N4 y; q- d

  1130. 4 L' K3 v, B* i$ d* X1 w
  1131.   # Get the database port3 Q- q2 v3 G( {6 m( V$ {( M, R
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \
    7 C! q: K& F) B6 N
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)0 {4 Q# u0 o, ?- K
  1134. - a1 q7 G/ i9 o$ U8 P9 |6 D
  1135.   # Exit if cancelled
    4 Q, E! F* S7 b& R# T
  1136.   if [ $? -ne 0 ]; then- Q6 R' Y# H1 C3 L- x- B
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1  U: Q. _* h8 ~& m8 K) w: h; T) u# w
  1138.     return 0
    0 r3 d* u; v9 S- _, L" ?
  1139.   fi
    + X; s+ ^7 N3 b" s/ O% r1 o

  1140. 9 c( N1 R) Q, ]. l3 p
  1141.   # Set the port number if one was specified0 Z3 g5 ~8 _; W" y% ]: b: L
  1142.   if [ ! -z "$DB_TMP" ]; then& L* f5 t8 a  K  E6 z3 C7 B9 e3 D
  1143.     DB_PORT="$DB_TMP"$ m+ q$ x5 H0 A3 u
  1144.   fi
    $ q. R2 n+ N4 I! G% j$ y/ i
  1145. 3 x6 |( i  f4 ~* k) E3 C; n
  1146.   # Get the database user username
    1 y7 b0 P4 ]- c3 k
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \
    $ o3 X2 @- V* I( c: R: @
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3): [; B: G: H' T4 C. c8 C+ X1 q
  1149. - P4 R3 _' x  Y/ H- D9 R
  1150.   # Exit if cancelled
      j2 c5 M2 [7 w7 m' N; W: \
  1151.   if [ $? -ne 0 ]; then: D" c( H) m% Z: Q$ U" D/ F
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1
    # T" j2 F; \' X6 B% @8 }1 f$ Y
  1153.     return 0( K' h# i; D1 p6 N# B3 |: A
  1154.   fi
    # i) z4 ?' P6 D
  1155. 0 ~& Y- k6 p: V- c+ Y- Z1 d' ~
  1156.   # Set the user username if one was specified
    3 P% y9 Q8 u/ i) u/ C$ h2 F: n
  1157.   if [ ! -z "$DB_TMP" ]; then4 X8 ?5 m% A/ _. i% [
  1158.     DB_USER="$DB_TMP"9 }+ n  Q2 [: j/ E7 o' R$ f) H
  1159.   fi) r$ D6 x5 {* w, b

  1160. ' ?3 c* q% R6 w/ n( v
  1161.   # Get the database user password
    ) N, G6 V) c+ I& _# [
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \  {% \9 ?% v. K
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)
    , {; H6 l9 i7 O1 `* {3 @* |/ v
  1164. $ M2 l- X2 c, k& y  G; {
  1165.   # Exit if cancelled& Y5 x( V8 d$ B5 H- P/ n
  1166.   if [ $? -ne 0 ]; then+ h% X; P# a7 @$ y
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1
    / t" q# z( B  x6 O& m3 F- t7 u
  1168.     return 0" C& B. b8 M7 p  Y5 f1 [
  1169.   fi
    ) F1 J. w# U! D' x" D0 j" K8 ]
  1170. $ f8 v2 z/ a% y$ f% G
  1171.   # Set the user password if one was specified
    7 h: P1 t; N4 P0 R3 G  J; c# g
  1172.   if [ ! -z "$DB_TMP" ]; then7 a' d0 u, o1 f# y
  1173.     DB_UPW="$DB_TMP"
    . H6 |2 @: d1 E, G. q
  1174.   fi
    / b+ }# y3 ]9 H
  1175. ) U' @. @* s, C7 u
  1176.   case "${DB_TYPE}" in8 y1 u" Y: k5 O3 s0 C; r" o+ H, Q& i
  1177.     "0")
    9 r, b8 i  T! {& Z
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "
    3 h4 }3 [  r* b
  1179.         ;;9 f% e1 E. b1 |: f$ h" o4 |4 x
  1180.     "1")
      G; P" S" n9 e, ^& o# |0 z* f; M/ _
  1181.         printf "Confirm your MySQL password\t, ": O2 [/ ]7 h) b( ?
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn; X/ w: C, S, K0 r( \- z
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    . j- U+ ]' Q! x% h0 r; Y2 l% _$ z
  1184.         ;;8 `: ?; o6 f. D8 K' P2 G
  1185.     "2"). {( V; c0 M/ n$ d
  1186.         Log "Currently not supported." 1
    # \# @  _+ w7 B% o. O* ], L1 p0 J* `
  1187.         return 0
    2 j& i) v5 |5 U
  1188.         ;;
    ; n" Z2 B+ u# f! d5 r" `5 n3 ^/ P1 q
  1189.   esac
    * i" K0 E" l( ~

  1190. " O( ^8 _, H0 }4 H4 S
  1191.   # Setup database names based on release
    8 P+ ~+ |( r1 D
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"$ C6 V: }. y3 ~' ]% r* ]! Y
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    - S- u7 l/ G/ S7 O
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"
    0 h7 A: k* J. h$ p9 A0 h
  1195. 5 L- _. b9 w0 ?! p+ ^
  1196.   # Install fresh databases if requested
    ' Y. h2 i. y4 K* v- y
  1197.   if [ "$DBMODE" = "0" ]; then8 G6 ]9 k2 x+ I+ p* A
  1198.     # Ask which databases to install/reinstall. S$ V9 f; q- w0 [9 V
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \. g+ A- z* [% M! e  u1 y  s' H- f
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \
    3 |$ I8 R3 q7 R0 Y. m8 K. P7 L2 c
  1201.       0 "(Re)Install Realm Database" On \
    9 Q7 _. N% Y9 K6 @! o* Z- Q! E1 P1 @
  1202.       1 "(Re)Install World Database" On \- U' c, G8 l# P" L- Q, b9 A. ^  U, h
  1203.       2 "(Re)Install Characters Database" On \
    1 l5 M% r8 A0 O3 H
  1204.       3 "Update the realmlist" On \8 h  s5 N8 Q/ ~# X
  1205.       3>&2 2>&1 1>&3)
    3 }$ D6 O- L; L/ N! I- w* c5 l! ^; W9 @5 {

  1206. 1 r' v: o7 ^8 _* X
  1207.     # Exit if cancelled
    8 x6 G1 Z( G: O7 V
  1208.     if [ $? -ne 0 ]; then
    3 A, q! @0 F& x
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1$ j/ x1 G) Y0 ]& Y/ g* I3 }6 Q9 E
  1210.       return 0
    7 N# L1 t. O# N) e
  1211.     fi1 w" {9 w, _3 _6 @9 V% R+ g" m

  1212. 8 Q( U+ Z7 I: ?4 j% Q* S/ x
  1213.     # Remove and create the realm DB if selected
    * N+ a. @3 _! B9 g7 i
  1214.     if [[ $DBSEL == *0* ]]; then4 j" C/ u+ }$ S  c+ R3 w# s) `1 e
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"
    ; f( ~* @+ I3 ?+ ^! i$ ~; A+ C
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;", }& w1 s+ K( \6 K- n1 q
  1217.     fi* L7 e" L* a2 ]
  1218. . k4 Z) d, \; U) v
  1219.     # Remove and create the world DB if selected- \% V3 `$ m6 C% ]8 {' I( H' e$ F
  1220.     if [[ $DBSEL == *1* ]]; then
    9 ]- D, B/ o/ `+ c3 }4 s
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"2 O  @8 H1 z' a7 x
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"8 T# K" m: r" g% A$ C1 ~  \
  1223.     fi
    - J1 w6 u# c: o: c

  1224. - D: D% `9 x: L& O" d; R3 x( _" E, {
  1225.     # Remove and create the character DB if selected; c+ w( m% z% X4 }! b' w
  1226.     if [[ $DBSEL == *2* ]]; then
    ' M& q% x/ m2 `% e* r! D! J
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;", J1 Z  x5 `* U! B) B7 E
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"- L9 h- P. [( N# i' P% H" C! H
  1229.     fi; y, s+ R4 i, l3 P' L6 B
  1230. 7 t7 v  W1 c6 I/ F0 f
  1231.     # Validate success" K$ ]$ y7 ^) R+ F/ A- V. \' |, A6 ?
  1232.     if [ $? -ne 0 ]; then, k5 k) ]& |# `  m9 `2 [
  1233.       Log "There was an error creating the databases!" 1
    9 l% H" j3 c9 U2 v  c
  1234.       return 1
    : K1 T$ f9 y, L+ Q7 t
  1235.     fi( r# V& R) {* V2 m  B7 J

  1236. 4 L+ Z6 W% j0 j) v
  1237.     # Finally, populate the databases1 {0 o4 V% {5 o* ]
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS: e2 n( Z8 M' `3 J2 k/ H6 v

  1239. ! h" R$ f7 Q0 F5 y. R1 T. b
  1240.     # Updating the realmlist
    0 P& n# @; r! N; z3 {, _
  1241.     if [[ $DBSEL == *3* ]]; then
    . f$ o; m/ L0 n6 U* p1 t$ c3 u, ^
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql2 k; p' C4 {% T4 D; E
  1243.     fi
    ; P& Z0 g  r/ K& f( j  P
  1244.   fi
    $ z: z) f) T; a! a6 E, t8 T: q5 U$ T

  1245. % n5 I# k1 o! M9 e* z
  1246.   # Update the databases if requested
    - T, i2 k/ ~9 E6 ]8 C! P) s
  1247.   if [ "$DBMODE" = "1" ]; then
    ; i4 |' k0 }) L0 S  P% j
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS6 u" E6 {; X) L) p* w( c
  1249.   fi
    2 O" C8 Q7 N1 c6 f3 P
  1250. }0 B. M0 z& r4 |+ ]2 q9 d
  1251. % \2 o& j! Q; k$ C! h" x% Q- E" Q
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game$ m2 q. O: g; C
  1253. function ExtractResources# p3 b+ R3 u  U
  1254. {* M0 k# P$ p; [* a; X5 M0 d- c
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))+ H7 F# E% V/ }3 ^6 A3 S. G% ^

  1256. ) V! H0 p4 V  ^5 F7 U" a/ a0 X8 c8 M/ _% E
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \
    7 ~8 x0 c3 O+ H2 d2 p, _" q
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)2 T; j  f) @. {  R" \6 k

  1259. 6 i, t5 }$ ^" F8 G7 A+ y4 f: x# W
  1260.   if [ -z "$GAMEPATH" ]; then5 m  s! U: _! \; A$ h% A
  1261.     GAMEPATH="$INSTGAMEPATH"3 C7 s0 u0 S! s, ?, w
  1262.   fi0 h' z* _9 S3 V! z4 n9 V1 k9 I
  1263. 5 K9 f. J( B: E! z' w
  1264.   if [ ! -d "$GAMEPATH" ]; then8 v* f2 D+ v* E* [; N4 f# D
  1265.     Log "There is no game at this location" 1
    0 H: Z' O$ N. {; g
  1266.     exit 14 w3 m5 L% v! _3 ^! ~1 a& J% @
  1267.   fi
    : S7 [% `! n- }9 p

  1268. 4 x6 p% @0 Z/ z5 i5 _5 S; w6 }
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    0 s5 q, S7 R" \. l# D3 J8 d
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \
    ) v7 o0 {! i6 a2 g0 Z2 F- f
  1271.     1 "DBC and Maps" On \6 T& V1 x2 d# f: J, ~' y, n5 A* L
  1272.     2 "Vmaps" On \, o0 D' l+ N% u" g+ u
  1273.     3 "Mmaps" On \
    ! p: J6 h: L0 m( `
  1274.     3>&2 2>&1 1>&3)2 J- N( y1 F' n) V1 v1 W

  1275. 2 D0 U  ^; e" C( ~: @  [
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    ! g1 z' ^2 s3 o# p
  1277.     Log "The client tools have not been built, cannot extract data" 10 C" U) g: z2 T9 z
  1278.     exit 1
    . S: u2 W5 J5 O: l, `& @# g4 y
  1279.   fi  k% N" j" `( g
  1280. ) K3 P* o4 i0 \3 }1 P; Q/ o
  1281. #TODO What if DBC are not yet generated ??
    5 H( M' {1 D4 n1 X. X7 a. z% s
  1282.   if [[ $ACTIONS == *1* ]]; then5 G$ ?! f. ?5 O
  1283.     if [ -d "$GAMEPATH/dbc" ]; then
    % ^! f' o8 N4 f
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \( G% z- V; I2 J
  1285.         --yesno "Do you want to generate them again?" 8 60
    . t7 t" A  Y6 l
  1286. ! O( _% e" U3 P
  1287.       # Check the user's answer
    ) K2 Q/ y0 u* i9 F$ c( V: p" ]% f
  1288.       if [ $? -eq 0 ]; then
    & T2 H! E) \8 Z! M
  1289.         Log "Deleting DBC and Maps previously generated." 1/ U3 A. z5 J7 ^
  1290.         rm -rf "$GAMEPATH/dbc"
    ' @8 B" x2 g" ~% C0 T
  1291.         rm -rf "$GAMEPATH/maps"
    : `% M! \+ P" P5 b9 ~3 A, c

  1292. , M0 M0 t- d! \* M' }
  1293.         Log "Copying DBC and Maps extractor" 0
    ; s( W4 }' O7 P+ x, s) A/ G2 Y
  1294.         rm -f "$GAMEPATH/map-extractor"% v% R* E# I6 W7 K1 m" t6 m% f( C: l, b  A
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"6 v% Y1 O4 Z4 Z" C1 C4 ~3 s6 g% c
  1296. : b7 w/ ~" V% l
  1297.         Log "Extracting DBC and Maps" 0! G1 Q' {/ u. c  [; q$ c# h( K0 T
  1298.         cd "$GAMEPATH"
    9 U7 S7 X% o) j: _$ r$ }  B
  1299.         ./map-extractor
    5 g. u: L- B( ?) X6 X0 x8 H
  1300. + s( v4 a5 P# p0 a% i1 |
  1301.         if [ $? -eq 0 ]; then
    ) Q% A: ?3 |. r! ?$ _
  1302.           Log "DBC and Maps are extracted" 0
    : r2 E( Z5 c4 a: }+ {' z$ z
  1303.           Log "Copying DBC and Maps files to installation directory" 0% \5 B. b1 h: P8 C
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"2 ^+ ~) H3 Z3 Z7 M6 Z" s& ]  p
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"$ z! U9 ]7 \+ X( C! Y$ [+ c% v
  1306.           rm -rf "$GAMEPATH/map-extractor"2 I+ m3 P1 v0 \: E1 {
  1307.           Log "Changing ownership of the extracted directories"
    6 [- o8 o6 M. w" {- F% p; A0 h
  1308.           chown -R $USER:$USER "$INSTPATH"+ B! ]" O; [8 i! W1 V: T. Y8 k  }
  1309.         else
    2 m$ C+ Y. P! C( _) q4 Q
  1310.           Log "There was an issue while extracting DBC and Maps!" 1
    0 ]. M& x) P' c2 y+ a
  1311.           rm -rf "$GAMEPATH/map-extractor"
      j+ ~) _9 Z' F+ U
  1312.           rm -rf "$GAMEPATH/dbc"2 i1 C* G  Q! {0 C2 _7 y
  1313.           rm -rf "$GAMEPATH/maps"
    ( F8 p" K; o# P* g, M
  1314.           exit 1
    ; Z) Y# X% M. K: [& ?: M2 F
  1315.         fi0 k- A/ w# T: H
  1316.       else
    9 ~5 @( f5 R* q& p) e
  1317.         Log "Copying DBC and Maps files to installation directory" 0
    8 w; k0 N! Y1 a! A  h
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    + g, b: Z7 a) H: H7 \1 z4 i8 Q5 \
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"/ q" r6 p0 W. P  l/ o; W
  1320.       fi" Z7 d& l  ]7 L7 Z
  1321.     else
    $ E8 E. p' h+ h, ]/ _& o
  1322.     rm -rf "$GAMEPATH/map-extractor"7 H' J5 _0 Q- Q  t3 b! P. c% S
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    . V7 s4 V5 |) J; a% C5 m% ]$ A

  1324. 9 D9 ?( L$ f, ^" S
  1325.     Log "Extracting DBC and Maps" 0
    ! o6 z' W! n# ]9 d5 Z# F
  1326.     cd "$GAMEPATH"9 u( u0 a3 D' G1 a9 S  B5 u' P9 Y
  1327.     ./map-extractor
    # L9 a- Q3 q% c1 _- H- X
  1328. ; \  \: V* b  w
  1329.     if [ $? -eq 0 ]; then
    ( T9 b; G8 {! k
  1330.       Log "DBC and Maps are extracted" 0: _- C' Q0 J' u2 o" f6 o% b
  1331.       Log "Copying DBC and Maps files to installation directory" 0% A( Q; ^7 [3 J9 y: P) k- O; b( D" R
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"& ]  Q: j( O+ h, i
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin": C0 V2 B6 W! x
  1334.           rm -rf "$GAMEPATH/map-extractor"# g. H4 Y8 I+ y1 d( a- C
  1335.           Log "Changing ownership of the extracted directories"
    1 y# j4 L5 A& @
  1336.           chown -R $USER:$USER "$INSTPATH"# V3 D2 X; b( C9 C& V2 z; j9 t
  1337.         else( U2 P% f6 \0 r, A) E7 L
  1338.           Log "There was an issue while extracting DBC and Maps!" 1
    : N" D/ S* l$ M( R4 F; M) K
  1339.           rm -rf "$GAMEPATH/map-extractor"
    : F, j1 q# t" w" w: I
  1340.           rm -rf "$GAMEPATH/dbc"1 f. S9 R1 g7 r; S3 V% G' \+ O
  1341.           rm -rf "$GAMEPATH/maps"
    4 Z8 x* Z; \" ]3 W
  1342.           exit 14 m4 h- I$ R' D& i9 q: v
  1343.         fi! s- z) g. O9 k7 J+ B8 L* k
  1344.     fi
    # Y# Y# p. ^0 I$ |4 C" ]3 ]
  1345.   fi
    ( Z/ Z8 g2 ]9 v/ |5 x( H9 e2 X
  1346.   H. x6 B6 V/ x/ u
  1347.   if [[ $ACTIONS == *2* ]]; then, g/ E1 C9 a1 F- H$ j; ~
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then
    5 }0 R$ D- i& e* k8 q: W
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    ! i1 F$ q! ?& L+ K( D
  1350.         --yesno "Do you want to generate them again?" 8 60
    ) N7 L, H# O7 s1 }) z: A! I# I
  1351. - h# \. y. d1 O
  1352.       # Check the user's answer) w* ^* x; ~: z8 ^+ U  |
  1353.       if [ $? -eq 0 ]; then
    9 B# U' B$ E, s* _
  1354.         Log "Deleting VMaps previously generated." 15 Z) j9 c& g5 S9 [# I
  1355.         rm -rf $GAMEPATH/vmaps
    1 W& K, _. I  O/ `; C0 ~
  1356.         Log "Copying VMaps extractor" 05 p7 o7 N# A  E' q. e  F
  1357.         rm -f "$GAMEPATH/vmap-extractor"
    7 x3 h$ q6 i; R7 B
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"+ U% f$ Y, h' g+ e5 E4 e& K1 s

  1359. , p3 i( i: P$ \1 G% q2 U
  1360.         Log "Extracting VMaps" 0/ \+ L5 a' r) o. K- _$ g. A/ j
  1361.         cd $GAMEPATH
    9 |7 h/ o/ L( ]
  1362.         # Make sure there is no previous vmaps generation that cause issue.* b% d3 K/ ?0 U0 z
  1363.         rm -rf Buildings
    * `0 }+ ]" w: [! O
  1364.         ./vmap-extractor
    2 I, X" q! L" v  V
  1365. 1 R% x% Q4 t' ~7 e4 `* h
  1366.         if [ $? -eq 0 ]; then$ i, }: n7 ~9 w; |# ]2 ?( E, ^
  1367.           Log "VMaps are extracted" 0
    4 K9 _+ q& R! I( e- j0 _9 b6 k
  1368.           Log "Copying VMaps files to installation directory" 0
    # @+ b1 ^) T8 O3 m4 F7 H
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    . A+ q3 p' V% G1 {+ b. d
  1370.           rm -rf "$GAMEPATH/vmap-extractor"
    7 a& m9 {" u  w
  1371.           Log "Changing ownership of the extracted directories"
    6 _- w$ m) `: P1 z% ?) k) C% p, ?
  1372.           chown -R $USER:$USER "$INSTPATH"3 F, `3 S* `% r
  1373.         else
    ) R8 C" v, h. t
  1374.           Log "There was an issue while extracting VMaps!" 1% f, _& x, ]& b' i
  1375.           rm -rf "$GAMEPATH/vmap-extractor"' L' G0 U7 \& O% [2 K: d8 C  h
  1376.           rm -rf "$GAMEPATH/vmaps"% m( N! e/ q% v+ R: G
  1377.           exit 1
    , i9 u! B4 _, z% [5 g# T  n
  1378.         fi: l* K( \. [3 v  I
  1379.       else. q: `0 h, b3 i1 _. q9 _- x
  1380.         Log "Copying VMaps files to installation directory" 0
    3 v  s% S8 z8 i) U# g
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin", \1 v2 a% c3 Z
  1382.       fi
    ' K: e3 P& ~0 v  T6 a
  1383.     else( g( Q- \7 I- V
  1384.      Log "Copying VMaps extractor" 0
    * h+ I- I$ k/ W7 v4 T3 E* x
  1385.      rm -f "$GAMEPATH/vmap-extractor"" F/ s' |- n- K$ d! i8 `
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"1 A* O# e+ D+ s9 c

  1387. 5 H6 D3 s9 f2 e' }4 m
  1388.      Log "Extracting VMaps" 0
      l' [( O& E9 V5 U$ a# a5 Z4 k8 r
  1389.      cd $GAMEPATH: C: x* n/ v8 g+ c# S/ w9 x" I  [( I
  1390.      # Make sure there is no previous vmaps generation that cause issue.
    8 h& s* T! e# J. f3 j5 D
  1391.      rm -rf Buildings
    ' T: ~5 u; a7 w. b% H
  1392.      ./vmap-extractor2 ^& y3 t$ {4 @+ N: w) P9 e" N
  1393. : ~" n* w' k& T* w/ ~
  1394.      if [ $? -eq 0 ]; then' c- Z% p# q/ {( Q8 R1 g1 K; F
  1395.        Log "VMaps are extracted" 0( F+ {3 P' [7 }* x& Z  |
  1396.        Log "Copying VMaps files to installation directory" 0/ r' j, K9 o% O) d* Y, W6 W
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"% Y! Y/ h$ P& H* y
  1398.        rm -rf "$GAMEPATH/vmap-extractor"% o  T+ L7 J  b8 M  U  N( w6 U
  1399.        Log "Changing ownership of the extracted directories"4 [/ F& J9 r% e! F: C) ?
  1400.        chown -R $USER:$USER "$INSTPATH"
    - K5 c2 e  R! S' z' S
  1401.      else
    ' v7 n5 n8 j5 ~6 K- O0 s4 u8 W
  1402.        Log "There was an issue while extracting VMaps!" 1
    " k( O% k' }* o9 f- _
  1403.        rm -rf "$GAMEPATH/vmap-extractor"' I" J. ?4 ~% p: l6 f0 Q
  1404.        rm -rf "$GAMEPATH/vmaps"
    ) y5 W/ A: W8 W2 K
  1405.        exit 1
    + w8 f: n6 m" X6 r) ^& F( x& g
  1406.      fi
    + e, B# t4 N7 [# l# m
  1407.     fi8 t0 c( p5 M2 f* q/ y! N% A
  1408.   fi* p# Y4 b. R, f& h1 l6 D& R( u

  1409. ( A' k+ D# }9 [! a7 u$ E; x0 T
  1410.   if [[ $ACTIONS == *3* ]]; then
    4 ^' F3 L8 s, b: r/ _, m' @2 i
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then5 r. T8 [* ~1 h4 M1 X
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1
    : F# D, x7 l$ O8 _' ?. a  s
  1413.       exit 1
    ( a) W9 }% w' c3 Y* |6 E$ T
  1414.     fi) r- a3 z1 f5 G* t

  1415. 5 m1 Y6 }5 Z9 o/ w. z& J
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then
    % `+ F% E; o/ d! }* U1 g
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    & v) N- {1 J+ E4 n. X& w
  1418.         --yesno "Do you want to generate them again?" 8 60
    ) L1 X- H5 x2 q: h
  1419. : c$ k& m& H1 E7 C9 c, M$ [$ F; c, ]
  1420.       # Check the user's answer  f6 M0 T5 j& i/ _) w
  1421.       if [ $? -eq 0 ]; then
    " i  ^1 U$ }6 }2 H
  1422.         Log "Deleting MMaps previously generated." 1+ q* r% U$ e# M! D' t
  1423.         rm -rf $GAMEPATH/mmaps9 G5 N& C5 @. x  G
  1424. 2 [5 D2 ~+ T% f3 d
  1425.         Log "Copying MMaps extractor" 0  e7 |4 V# F. B( g2 d0 ^" k6 z
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    9 p  E# N' p. A: o4 l( b3 W( V
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    7 V4 }9 H& d8 A9 a  @8 S( D% v
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"- K3 z2 a/ w: {0 z) f
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    , K1 h# t4 E& t: ~/ ^6 n
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    1 S: y$ D, J* Z& `- e

  1431. 5 T) N1 P( W# Z3 M2 }. S( _4 T5 c
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \" f7 J# g* X6 g8 O. ]2 f9 ]' q- _
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)! L( J' o8 a, R; C& B9 `

  1434. 3 w  x- m/ ~. p5 h! y( d
  1435.         # User cancelled his choice, set default to 1.# X2 }4 S4 I" l0 x+ G
  1436.         if [ $? -ne 0 ]; then
    2 g2 ~$ c1 j* Q1 y/ c
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1: i% q2 T# f4 H( K5 Y
  1438.           CPU=1
    1 _$ w3 O9 t" s: S( Z2 [. J
  1439.         fi6 Q8 L( {- B, K9 X1 U

  1440. 0 t: h! w/ j: z; r' c# S1 |
  1441.         if [ -z "$CPU" ]; then
    - u& l8 u3 N+ b, j6 {
  1442.           Log "User didn't gave any value. Max CPU set to 1." 14 \1 G3 j" G' J7 X1 G" j
  1443.           CPU=1* y% d8 W3 S. C
  1444.         fi0 }4 z( O8 r& K7 k) {6 ^5 S) i

  1445. 6 }/ @3 V4 {( C5 A1 {2 W. ^1 J4 Q( @
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then+ @, ]5 W9 _5 l
  1447.           Log "User entered invalid value. Max CPU set to 1." 1
    ' s: {* Q8 M' V' D1 O
  1448.           CPU=17 r! P; i2 P! H8 `
  1449.         fi
    $ Z" x5 P* K( B9 V! z: M

  1450. ' T* Y: p) J6 E
  1451.         Log "Extracting MMaps" 0
    9 x7 U( N8 D0 i8 ?2 {+ \6 j6 r3 [. }
  1452.         cd $GAMEPATH" G4 `  H0 I1 b
  1453.         # Making sure we can execute the script
    " L5 N* W3 b6 `6 A. D' @
  1454.         chmod 700 MoveMapGen.sh2 T/ {1 ~/ U6 L7 w; D
  1455.         ./MoveMapGen.sh $CPU) I2 E, s" [2 T! b( h

  1456. 6 I, d9 z! y; e4 r4 g" i
  1457.         if [ $? -eq 0 ]; then
    " `7 W/ w3 w1 Z
  1458.           Log "MMaps are extracted" 0
    ' ~) p( C. H! e' K; g# p. N
  1459.           Log "Copying MMaps files to installation directory" 08 `5 S* i( r  X" |( G; O0 D* p2 b8 w2 C
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    # o* G" B9 p; `. s% l! F
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ! b, S0 S9 L9 |* U" |
  1462.           rm -rf "$GAMEPATH/offmesh.txt"
    6 V( r* D  k% K. j: W/ _
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"8 y! w: B3 D+ E" Y; p8 c
  1464.           rm -rf "$GAMEPATH/mmap-extractor"& v# c! ~. v. j2 i0 ~
  1465.           Log "Changing ownership of the extracted directories"! P) l, `7 n* b2 o. l
  1466.           chown -R $USER:$USER "$INSTPATH"" K9 k7 [  w" @
  1467.         else) S- ]& _4 F" I* B# r% ~
  1468.           Log "There was an issue while extracting MMaps!" 1
    & J- I& H7 s) W. ~1 f) F
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    9 l  a+ F" _6 X
  1470.           rm -rf "$GAMEPATH/mmaps"
    ; Y/ E% _) k0 V2 r
  1471.           rm -rf "$GAMEPATH/offmesh.txt"
    1 \8 U: g. O# V& R
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    7 q7 G6 {8 |$ d7 @
  1473.           rm -rf "$GAMEPATH/mmap-extractor"- A: ]) m/ {1 ^+ X! b/ U
  1474.           exit 1
    ( H+ p# g# x( ~7 @
  1475.         fi
    5 r: R# \9 O; t
  1476.       else
    $ N# N2 C8 v% W9 i
  1477.         Log "Copying MMaps files to installation directory" 0
    5 U1 F& R( f* E
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"' Z; N- g/ r* ^5 K1 b
  1479.       fi
    ; \4 Y" g( f( o, r6 m" ^- {
  1480.     else( J! X- W( ~* }3 c% O% n- T: o
  1481.     Log "Copying MMaps extractor" 0
    $ v7 L3 T+ f' }# d& R, g- W5 n
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"
    3 x/ P) N' K* F$ e) E! ?/ L4 B- t
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    " y! {3 ]. K7 d9 t5 e- ]
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"
    2 H& r9 c& U5 d* {! c4 Y8 E# y6 ^: _
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    . N& G5 U. u2 k0 D# C8 y
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH", z. }$ D- T: w' X; u
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    ! c  H; a# U: z, {; [8 q1 e0 \
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    ( W, P7 `6 X1 S; M( z: F- s

  1489. ' O) n( R  ~+ @9 n& z0 E
  1490.         # User cancelled his choice, set default to 1./ g/ e6 e4 ?5 s" e6 @# {' ~3 n9 Q
  1491.         if [ $? -ne 0 ]; then- p  X3 s7 F# X$ U* m" h7 K: }5 X8 v
  1492.           Log "User selection was cancelled. Max CPU set to 1." 17 e) c" q" A% U# H$ k
  1493.           CPU=1; m" }# O$ P# m7 h/ }  J% _* [
  1494.         fi6 m# g3 y- R) Q

  1495. 9 d& D5 m* ?$ ?- G
  1496.         if [ -z "$CPU" ]; then+ ]# z4 T: F6 l8 A, U; d4 V4 B$ Q& ^
  1497.           Log "User didn't gave any value. Max CPU set to 1." 1
    & |+ g; X  }5 I3 y
  1498.           CPU=1
    5 L5 j. A+ }: H' E& J( Y) Z. v
  1499.         fi
    + L6 b! ]; S& m+ ~

  1500. ; S' p7 f  m# X6 x9 o  P
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then( x6 j! l" I9 q$ d* R3 u4 I1 v5 b- J
  1502.           Log "User entered invalid value. Max CPU set to 1." 10 `3 a  M+ g0 `$ j4 h. D$ L7 Y
  1503.           CPU=1
    5 {4 H2 `/ P5 W( V2 S0 a  [/ \
  1504.         fi1 G0 c. k# x4 L  x7 f$ R

  1505. % B+ B% q& W! n4 _# g7 x( a& {. p
  1506.         Log "Extracting MMaps" 0* }% }# ~' S7 a" y6 [
  1507.         cd $GAMEPATH
    7 K' q  }3 [2 H6 o- ?
  1508.         # Making sure we can execute the script2 ?2 l  Q1 x' x0 p; A
  1509.         chmod 700 MoveMapGen.sh
    1 `+ Y3 H4 C5 h  w# {
  1510.         ./MoveMapGen.sh $CPU. [, O& l+ N7 K  X, J/ W0 X
  1511. " Z1 b  S+ n$ p1 b( n& t5 r
  1512.         if [ $? -eq 0 ]; then
    ( I5 W4 f' V5 B
  1513.           Log "MMaps are extracted" 07 G2 T5 z, O; a1 |# e# R; K: i% ^
  1514.           Log "Copying MMaps files to installation directory" 0  O8 y' V8 @" l
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    7 `: i& K1 o" O
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"0 X( s$ ~+ a4 w" N9 i$ v
  1517.           rm -rf "$GAMEPATH/offmesh.txt", {. G- ~0 j0 `) l8 f; c5 d: L
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    2 z5 s. R' `* q4 b7 r2 b1 E+ O
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    1 ?5 a( A! _/ ?8 b2 O  ~4 O
  1520.           Log "Changing ownership of the extracted directories"8 u/ i' Z  r' {" o+ f& `
  1521.           chown -R $USER:$USER "$INSTPATH"+ S: e3 c/ k( ~
  1522.         else
    - ~; V1 e+ J" y: E
  1523.       Log "There was an issue while extracting MMaps!" 1
    , e$ l& X5 ^: q: Y9 V
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    / d+ P( w$ ~5 ]1 W( f9 R
  1525.           rm -rf "$GAMEPATH/mmaps"
    - [5 ^  r. l* s2 t, }, w) l
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    2 N* f6 R) w8 G5 [# m
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"7 s! b% B( M- W( w; A+ r  f* V
  1528.           rm -rf "$GAMEPATH/mmap-extractor"
    : l' f# ]( v7 T+ ]* T
  1529.           exit 1& ]" v' ~0 R1 q4 W4 `
  1530.         fi+ p1 N. `. h6 g$ d# ^6 e1 M. ^
  1531.     fi4 R& Z' }. Z- [3 S# y
  1532.   fi9 c8 R" T' x4 ?4 O* @: B5 c: T" T/ v. |: D
  1533. }1 H  o! X9 D/ N6 H  d7 ^
  1534. ; {- c: t# ^! d) F% g: X* g
  1535. # Function to create a Code::Blocks project
    3 ]2 D) r4 o3 Y) K8 m- R* f4 A
  1536. function CreateCBProject
    6 d8 |! r; S: S7 Z! e* L! |: I
  1537. {% f' B0 ^# M/ q) d$ L
  1538.   # Create the dircetory if it does not exist
    0 b; Q! M/ x' r! _5 x' F9 g
  1539.   if [ ! -d $SRCPATH/server/linux ]; then) l' v7 [2 ^: s7 z, j
  1540.     mkdir $SRCPATH/server/linux
    6 ^( v- S) z, v1 ~
  1541.   fi! y2 f* {) b: Q7 C" M1 M
  1542. - ]- L2 p( [/ }: x$ I
  1543.   # Now create the C::B project
    % U' g! U. U: X- @7 L$ W/ n
  1544.   cd $SRCPATH/server/linux
    # d: {7 h# R8 F$ K0 `! t
  1545.   # make sure we are using the cmake35 }* z+ G5 B) p6 q
  1546.   UseCmake34 b2 @, d9 H  c, L
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    # u) u  {+ d: @! M! E% B1 n, w: w
  1548. }
    " x! ~! ?% o2 o$ h3 `9 g
  1549. 8 J# q+ h- y, {2 {; U9 w+ ~' g
  1550. ( a7 Y$ R) j% z- I

  1551. - q5 D1 @7 V' M7 ?$ w
  1552. # Prepare the log
    ) r4 V; {0 G  X' I
  1553. Log "+------------------------------------------------------------------------------+" 0' b3 A% `0 ~2 E: W( {
  1554. Log "| MaNGOS Configuration Script                                                  |" 0
    . w1 I5 C- s6 S" r. Y4 S) A6 S
  1555. Log "| Written By: Ryan Ashley                                                      |" 02 z, g% e( M+ K0 A- P
  1556. Log "| Updated By: Cedric Servais                                                   |" 0' h8 Q3 ~4 v# w* K4 g5 O; e& {
  1557. Log "+------------------------------------------------------------------------------+" 0
    # c! m( R( r& [

  1558. : ~# [7 f+ B$ l
  1559. # Check if user who is running this is root
    8 d' E8 h, r- ?( e, g' G
  1560. CheckRoot
    ' `6 m# j$ x2 _

  1561. 0 @0 H' g! ?, ], i$ `& {: H* x) J9 _
  1562. # Select which dialog to use( j! J! Z* f+ n0 i9 T3 e
  1563. UseDialog
    9 y6 t! r/ M$ U7 v8 e
  1564.   j8 `2 s& C* G8 e7 |7 y, U! w
  1565. # Select which activities to do4 L  o& C" h$ R7 H4 u0 P$ ^) k
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    ! N! Y" e: R1 z+ \
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \
    4 u! [0 w9 l+ i) h' V% x
  1568.   1 "Install Prerequisites" On \4 U3 o' n  _% A- H; X
  1569.   2 "Set Download And Install Paths" On \
    9 H3 w9 H8 a  ?
  1570.   3 "Clone Source Repositories" On \" G1 X7 s; P/ s& W
  1571.   4 "Build MaNGOS" On \
    % ^% |* Q" K* d5 Q$ U
  1572.   5 "Install MaNGOS" On \5 b& d- z& k6 ?3 O; t
  1573.   6 "Install Databases" On \" r: Q; i) e. Y' l) `* J3 H# e
  1574.   7 "Extract Resources" On \
    # h. U4 P# m, U: B, I6 D/ g' C
  1575.   8 "Create Code::Blocks Project File" Off \3 [1 E' c1 y  k* y; x3 [( W, b
  1576.   3>&2 2>&1 1>&3)
    ' m- h2 Y7 T2 G- `8 l% _
  1577. 5 L7 Q. h' h# E2 Z) A* y0 P
  1578. # Verify that the options were selected; K4 O0 t# G# E/ f# o
  1579. if [ $? -ne 0 ]; then
    # n* l' F4 Q( N: |
  1580.   Log "All operations cancelled. Exiting." 1
    * U' f/ P& q( ?0 M5 C" `& Z1 Z) b
  1581.   exit 0( O, o% D# J2 M8 G' w
  1582. fi- v! U3 q2 g0 ?# p7 H1 S" s

  1583. * d( U7 s6 G+ R9 W9 D
  1584. # Install prerequisites?
    8 D  i3 m: p5 H3 x1 h- s) p$ A. i
  1585. if [[ $TASKS == *1* ]]; then
    3 `% O$ c7 {+ M
  1586.   GetPrerequisites9 l8 Z+ v9 i2 R% y0 t: O# R! X" S
  1587. fi
    : M3 `0 s$ V1 H5 b0 x! M
  1588. * P3 A* q( [) H' R0 v: J
  1589. # Select release and set paths?& r, B9 z: d- d; M5 w: a6 g/ y
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    * e! e* L  Q3 y) \: d
  1591.   GetUser( a/ L4 H) Y2 ]. c* v
  1592.   GetRelease' g3 ~) F3 T, Z0 @# z; P
  1593. fi! a$ `$ l7 _4 a! {5 |
  1594. & M2 o- B! M" a/ G) D# W
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then
    ) C/ n+ R4 [. D
  1596.   GetPaths
    - J- K' `8 K5 }  K0 u% V# i
  1597. fi1 N; G- [9 E9 V

  1598. / i3 B0 W& c! M# G# A$ p
  1599. # Clone repos?
    " U: t, U- c" P3 |5 B) Q
  1600. if [[ $TASKS == *3* ]]; then7 w8 q+ G7 J, A, n  x
  1601.   GetMangos) @3 ^7 A( c" I2 o8 c. _
  1602. fi3 H% ?" @& m. z8 m. I

  1603. & d1 M2 \! @- \) `" O
  1604. # Build MaNGOS?
    + i0 p1 k- p1 X+ I) i7 ~* {
  1605. if [[ $TASKS == *4* ]]; then$ m- b! S5 i! S% c
  1606.   GetBuildOptions
    6 W5 |! e& j7 U: K3 ]6 d$ _+ \0 |
  1607.   BuildMaNGOS
    5 |4 a9 W1 K1 j. H, Z. ~
  1608. fi
    : W( h0 @9 N$ r& \7 U) E) ^- H

  1609. 6 K  T1 l. S) ~% M8 Q; U# s! f
  1610. # Install MaNGOS?. q( z- S/ K8 }- K( X. p
  1611. if [[ $TASKS == *5* ]]; then
    $ f' O5 F! q% @
  1612.   InstallMaNGOS
    + i& T/ \; D1 K0 J
  1613. fi, m5 E' }# ^" n9 |
  1614. ( e: i/ z, y5 {* r$ X4 Z  `/ E3 g
  1615. # Install databases?
    % _' M# ?- s* k: {
  1616. if [[ $TASKS == *6* ]]; then+ U+ b4 q1 Y# i: w1 i. i
  1617.   HandleDatabases9 F" U6 W! v2 D; A) |
  1618. fi: s; s; }, d8 ^$ t7 a
  1619. 2 s; U& u  u9 e$ h$ M2 c! h
  1620. # Extract resources from the game?9 e6 r/ b( j% v$ o$ y: e
  1621. if [[ $TASKS == *7* ]]; then* D5 C; q) Z9 m: S. [2 E8 A
  1622.   ExtractResources/ N* h9 }4 e  m/ Z
  1623. fi
    ; B: u$ F4 [' }) K( }6 d; d' G2 T
  1624. ) v' v; g/ a  T4 u2 F
  1625. # Create C::B project?
    ( X) D1 X$ Y* B# |. o3 Z
  1626. if [[ $TASKS == *8* ]]; then* M0 b4 U5 `  @) g+ i
  1627.   CreateCBProject
    ( \/ Q( k5 a  r* Q
  1628. fi
    + I: y2 f- y$ W, s9 h

  1629. # a4 ]: A* o8 D* e& L
  1630. # If one of these actions has been performed, then we know the user.# a& ~$ m; J8 Z; m& b; O* s
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    ( Y9 ]" z2 x+ A4 c9 q0 X( Z8 p9 `5 p
  1632.   Log "Changing ownership of the extracted directories" 1
    4 d; o3 O9 I1 C, B0 H
  1633.   chown -R $USER:$USER "$INSTPATH"5 `) G- d9 M( G" ~" l
  1634. fi  y: y1 ^7 T: [" o5 t4 w; d
  1635. & }5 x! k/ F) Q
  1636. # Display the end message
    ) T8 d- t& w0 f* G
  1637. echo% I, _- s4 K2 M/ L
  1638. echo "================================================================================"
    7 {0 A' L4 A4 }6 R
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"- ?  y! A' l9 P$ c0 V
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"( [  X. W# Q6 N5 _8 c/ N
  1641. echo "server. If you have not configured your databases yet, please do so before"
    # o* t4 D/ I. p' u1 E
  1642. echo "starting your server for the first time."
    3 ]  k( J( o+ z0 |; ^7 d
  1643. echo "================================================================================"
    ( i! e# h) Y. {
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh3 J' m3 r) m7 l( K  s7 K5 b. T/ w
  2. ##############################################################################8 A1 F6 ~9 n; l9 i
  3. # This utility assist you in setting up your mangos database.                #
    ) g, {; }8 L( l/ h$ _
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #
    6 {% c, D  h% g2 I0 r2 V9 t
  5. #                                                                            #: U% x0 G( Y0 n6 {9 z" V
  6. ##############################################################################5 P# k. M$ U8 K! f# ^1 e
  7. * n; ]* J! |+ s- J0 B8 \! R
  8. OLDRELEASE="Rel21"* O& O+ D3 k! ]  O) ?
  9. RELEASE="Rel22"$ A8 W" o1 @! C; P! a! c) o* l
  10. DUMP="NO"- l8 u* ~4 k6 G) H7 c

  11. # Q& k# l2 T& H
  12. dbname=""0 s% J  B8 \. q3 J
  13. dbcommand=""
    ' U+ f" w0 G/ y9 m4 e
  14. / H. p6 |% e2 d- X6 i! l" N# y
  15. createcharDB="YES": u5 L7 C( S0 O: O
  16. createworldDB="YES"9 k* ^: B2 ~3 L, s( G1 Q) q
  17. createrealmDB="YES"
    5 x1 U2 D+ F+ [: P$ j
  18. / z* @2 F, Q4 X1 N. H
  19. loadcharDB="YES"
    % B6 j! b1 f) e5 U0 u: ^
  20. loadworldDB="YES"
    6 f$ q1 p% `$ d( |" w8 P; r
  21. loadrealmDB="YES"3 a( u! d  I# E; g( L
  22. dbType="POPULATED"
    # R+ N" A; _' s. p% A
  23. $ r7 a5 A. Y1 e; Q$ j
  24. updatecharDB="YES", J$ A& c. V! r0 v7 P8 }
  25. updateworldDB="YES"
    ' Y3 G- y, P8 y; t
  26. updaterealmDB="YES"( |# d% k' _1 ]# N& d

  27. * m# X6 n# `$ z6 f. b. V- n5 h
  28. addRealmList="YES"; U4 ?" T# R+ [4 ~7 m
  29. 3 B9 T) l7 l+ `4 [+ Y
  30. svr_def="localhost"' Z" r4 g: r  q" H
  31. user_def="mangos"
    2 b, l1 _2 d. H) O
  32. pass_def="mangos"
    ) A+ L2 v, @4 M5 ~# e1 W  Y6 r
  33. port_def="3306"
    2 \, u* v0 P) ]9 B3 ~( @+ d- @
  34. wdb_def="mangos2"
    - d" D! s- M! h
  35. cdb_def="character2"6 ~2 Z8 v( V' t
  36. rdb_def="realmd"
    ! j9 Y5 q, _+ p2 a; B

  37. / v( w" P$ T/ l' L2 a; `
  38. printHelp()
    % d8 Q8 P& g" H! |( N
  39. {
    2 ^/ R+ j( s/ M3 Q' L: T+ w4 q
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"
    & P) O) ?/ @3 T8 J
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"
    ) v; G# Y2 O7 K5 m& k
  42.         printf "\t-u: Run only the updates of the database\n"8 K6 H0 U) a/ q. K
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"; O* @" f$ J" m- L
  44.         printf "\t-h: Display this help\n"
    . {9 ~/ D: {2 D2 |$ T$ A: X
  45. }
    ' p; O3 k# p8 q+ C# V. k# l
  46. $ S- v& \( l& X- k, p+ _. Q
  47. printBanner()0 x5 p- I- I$ w7 \3 g
  48. {
    " H+ a. r- M2 R) |( b2 J2 l
  49.         clear0 |. u% q1 r$ N) O( ^9 [* Z4 q
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"2 B* s) E2 O! Y% W! \
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"" x( v0 g+ i- ?/ m
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"
    + E/ k& r9 T2 U) H1 A1 d& M- v/ Y
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"9 O. L5 t$ t% @. v' X2 i* A
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"
    8 N0 s- N9 J) _' V1 w
  55.         printf "\n"
    ) v$ z+ z# \. d4 D/ w
  56.         printf " Database Setup and World Loader v0.03         \n"0 c# }9 h$ d; B! _. g
  57.         printf " ---------------------------------------------- \n"5 R/ I) J* m( u, C+ `. d8 N, [
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"* x% e  r" z6 T$ c0 e- q6 Q: B8 b
  59.         printf " ---------------------------------------------- \n"! C6 W6 R) f4 W9 V
  60.         printf "\n"
    / R9 N) o6 I2 g5 F
  61.         printf "\n"7 d6 @5 i4 Q% Q3 p  y
  62. }% C. J$ U2 q# j! H
  63. " U' T! d8 A) D8 k7 d) c6 {
  64. printActivities()% d$ W* j: o( m' V( i5 |" B
  65. {
    & }, O2 B7 P7 R6 T6 y( ^% d( O  W- J
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"
    : p2 S9 p2 }( r2 v. s& {0 r( D8 y2 e
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n"
    0 @( N# x9 {) f  e
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"# y  C5 Y2 G" K3 k
  69.         printf "\n"
    . U; F3 L- H4 P. \9 }1 f0 H! A
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"
    1 V* N, m- V  B2 D
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"          h* o( q: k& W/ [
  72.         if [ "${loadworldDB}" = "YES" ]; then
    ! W' U- u1 G5 C# q
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"# e' R6 B$ Y4 P. v  |
  74.         fi
    # T- U5 D! @$ g0 r: ?" ?- z
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n", I- c1 l2 |# M) Y# _$ @
  76.         printf "\n"# G7 x' Q# T+ M/ [. R" M
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"0 |- T* `; a2 ?. d/ w% Z
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"; H- a6 [9 ~* P2 U
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"
    1 ~: f+ d& t2 w8 B- p3 L
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"        6 G' K- i0 A8 `5 R+ R% A
  81.         printf "\n"
    3 ~0 K0 T& m% w" f5 W0 F. d
  82.         printf "\t\t\t\tN - Next Step\n"5 q$ P8 o* b5 Z7 X
  83.         printf "\t\t\t\tX - Exit\n"! F& v1 {* l( M- C6 i, x5 s. H
  84. }4 h# ^/ q9 ?/ A. B% R$ T

  85. 4 H+ c1 A7 ]( w" l% L
  86. determineDBName()
    7 X6 C) Z* a- ?. R8 P! r/ r
  87. {: o% b, _2 z8 M
  88.         if [ $(which mariadb) ]; then
    4 _' D$ y% z" e+ C
  89.                 printf "MariaDB found.\n". C6 D# n: e! H: k: M: v( D; B
  90.                 dbname="MariaDB"2 T) m6 S' Q; E) S. u
  91.         elif [ $(which mysql) ]; then
    : P8 R' [4 F2 \, r
  92.                 printf "MySQL found.\n"( Z, C9 O6 E) N& g9 G9 L4 T
  93.                 dbname="MySQL"" j' P) [$ N! U. v: C2 k( V
  94.         else# A! ]0 G" |/ g+ G/ G: e2 {+ `# ^
  95.                 printf "Did not find mariadb or mysql.\n"
    9 b& j& N7 D/ D' ?
  96.         fi
    " f! k5 s6 @6 P& f/ Z
  97. }
    2 R* |7 I' n- @0 O0 |0 S4 |

  98. ; r0 K5 W$ r8 p$ R6 i
  99. mysqlconfigeditor()1 t. {; h, A1 J4 f& K
  100. {
    # d2 M! X- @0 R: _
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"& x$ `0 K8 n- y  Y8 X
  102. }
    5 T/ S( `; o0 \' Q
  103. / ~, S: @& F4 A5 E! k. J
  104. determineDBCommand()- P7 M0 u( m5 {6 o6 D$ p
  105. {
    . t$ @9 S% q* Z$ _
  106.         if [ $dbname = "MariaDB" ]; then+ K1 V  c9 u+ V6 P+ A
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"# Z# Q$ J- w4 M4 A3 J
  108.         elif [ $dbname = "MySQL" ]; then
    & I# y+ n5 j1 j; \" S% k% W, d# g
  109.                 dbcommand="mysql --login-path=local -q -s"$ O- d( Q* X/ g3 K, I" }
  110.         else
    9 O$ O' B7 b1 J
  111.                 printf "Did not find mariadb or mysql.\n"5 |* [6 {3 Q; h' K
  112.         fi
    + I( J3 E7 }6 s6 \% \( @; Z
  113. }7 W8 j9 \* R8 a" x

  114. ) M5 X1 w7 Y4 b) Z
  115. createCharDB()* F# r7 j& v7 S  B6 C" q7 N
  116. {
    7 d1 d% I5 J+ j
  117.         printf "Creating Character database ${cdb}\n"/ ]# ]' y2 [5 U9 x3 Q  f
  118.         $(${dbcommand} -e "Create database ${cdb}")2 L) r" ?8 H. ~4 D$ P" v

  119. , d1 b- [9 A7 ~" O+ ~
  120.         if [ "${loadcharDB}" = "YES" ]; then. H6 j2 W. n, [, W. o
  121.                 loadCharDB
    - Q* `/ S7 e% t1 B. b8 k
  122.         fi
    # x" r+ n8 j) i& f+ r
  123. }
    + t$ O; \  c% s& M& \- c* l
  124. ' R+ G) U, C+ L3 L/ K1 ^
  125. loadCharDB()
    - W9 O) `/ G: h" \6 N
  126. {
    . u) [6 p; J4 p; k* P( ~, @
  127.         printf "Loading data into character database ${cdb}\n"
    ! v7 b& g9 Y' X- B) {, o$ U5 l1 e* U
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)' @2 D3 Q; L( n' J8 A' }' a
  129. 5 @& s+ s2 }9 g/ x
  130.         if [ "${updatecharDB}" = "YES" ]; then
    % b- R# z9 d# E7 T/ w" K
  131.                 updateCharDB# r! ?- q9 Q% z) H! k. g6 [
  132.         fi
    , z  d9 b8 [% A$ Q; ?5 H3 q
  133. }
    6 N# \$ @  i, m4 J0 a2 x6 M* }# e

  134. % _& V2 {3 m( `7 F" b. A
  135. updateCharDB()( B* s: T* O' @* D
  136. {4 a; f: q- H2 ?# n! w) E$ Y
  137.         printf "Updating data into the character database ${cdb}\n"4 P4 O$ o5 U  V% W
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')7 m# l) M% s! r& S% ~' d2 R4 j4 Z
  139.         do
    5 y, T; x5 [& q7 y; r
  140.                 file=$(echo ${file} | tr '|' ' '), @- l8 W8 {5 _0 h  `, f
  141.                 printf "Applying update ${file}\n"+ ~3 B" t, G6 J% N9 S
  142.                 ${dbcommand} "${cdb}" < "${file}"
    ( R9 F+ @/ D4 z" A$ \) I
  143.                 printf "File ${file} imported\n"
    / c6 H8 }& q; i/ {5 C. J; e& `
  144.         done' {/ \2 G. w9 C, \( D7 e) b# E4 D

  145. ' G" O) v; E& |. n% F3 _
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    5 Q, o9 u8 q" A
  147.         do
    , w9 _+ {1 {3 p- O: e
  148.                 file=$(echo ${file} | tr '|' ' ')
    * _0 v0 D* `; D
  149.                 printf "Applying update ${file}\n"! M+ H2 R: n8 s( J. `9 b" c2 I
  150.                 ${dbcommand} "${cdb}" < "${file}"
    5 G5 q' g/ m1 p* m- j3 _
  151.                 printf "File ${file} imported\n"; [8 t* V" f) x9 N1 H7 z& s
  152.         done" [3 d& |, r  e
  153. }
    " M1 u5 W2 a8 F2 T# G- k4 ?

  154. : h) M/ g7 u& z9 d9 I& F
  155. createWorldDB()2 j! ~2 e# v! ^2 H" f' Y
  156. {
    4 v- C# @2 C' I' G7 Q
  157.         printf "Creating World database ${wdb}\n"
    % f6 v; r2 `  j! B. F0 E
  158.         $(${dbcommand} -e "Create database ${wdb}")2 C( b( \$ g/ b3 z0 R. f: \
  159. # X$ V8 |0 C) j& G/ t& }/ R2 d
  160.         if [ "${loadworldDB}" = "YES" ]; then0 Z6 i6 w3 C: ^$ c+ |( U
  161.                 loadWorldDB
    4 {, _7 S( ]8 L. T
  162.         fi
    ' k: F3 U' L0 t4 N, ]) o5 p
  163. }9 ?  u6 l$ B8 F

  164. 0 _! B& n6 A2 I4 _$ C! x7 ?
  165. loadWorldDB()
    0 P3 V& p( Y6 J5 ]# h( o
  166. {. O7 z9 r1 w2 Y) x0 F( \. }
  167.         printf "Loading data into world database ${wdb}\n"
    ( H: e8 O, x/ K2 _
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)
    2 d" w" B% m+ `8 R
  169. . E& o+ E% U+ r
  170.         if [ "${dbType}" = "POPULATED" ]; then
    & d# \4 C+ W# y2 R9 P
  171.                 populateWorldDB7 f( o" S% N4 }# C0 T; L  Q1 u
  172.         fi
    1 ?. w6 J9 n* a6 l& k
  173. }
    + Y& c+ K; w" ?' ~+ X! p, I

  174. % V! S$ d1 \7 g. F* [0 `/ E
  175. populateWorldDB()
    % }& y- Z& d; P, L
  176. {
    4 u& G! U, K+ O# W0 J, B
  177.         printf "Importing World database ${wdb}\n"
    4 `3 t( [: ~9 F( Z% x# i
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ') , D5 Q$ r" C% Q" c! a
  179.         do8 }6 J1 z; ?: [( D7 [: N( W
  180.                 file=$(echo ${file} | tr '|' ' ')
    - q1 _1 s: L) F2 {
  181.                 printf "Importing file ${file}\n"
      X4 g, I# y" \' a5 h" _
  182.                 $(${dbcommand} ${wdb} < ${file})
    * |( [& i& s' T+ ?2 `5 ?) t- _2 ~
  183.                 printf "File ${file} imported\n"
    9 p* B8 e7 _" X( J5 S- ]
  184.         done
    ( N% Z4 p7 H, N3 t! ?# p$ y- t; P

  185. ( }+ h/ R8 x+ E/ n% ~2 x6 X- x
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ')
    3 E6 W4 R0 v6 z) S5 E
  187.         do
    0 ]' E# d+ A* Q8 x( R. u6 T$ q! a; s
  188.                 file=$(echo ${file} | tr '|' ' ')
    2 q9 a( Q6 |2 r1 V/ n. ]  [# q: u
  189.                 printf "Importing file ${file}\n"
    7 _% l4 o6 K- T  _
  190.                 $(${dbcommand} ${wdb} < ${file})
    7 p1 j% Z3 k+ e8 H
  191.                 printf "File ${file} imported\n"
    - R5 ?8 C: q0 m& g
  192.         done/ D$ m' {9 j  z; |# g7 N9 K4 y4 y) i
  193. }
    - b: x( V* a7 ?* D! M% i

  194. 2 d% i3 q/ Y$ _# p& P
  195. updateWorldDB()
    2 e" ?: t0 f) K2 Z# c( }" P- @2 x
  196. {3 g4 q, V: S& r3 K6 K4 S. P
  197.     printf "Updating data into the World database ${wdb}\n"
    4 G; E8 A) S9 m/ S3 F: ~4 H$ x
  198.     for file in World/Updates/${OLDRELEASE}/*.sql. R9 K& h& D- ?2 X
  199.     do* ~0 ?; ]7 m7 \, t
  200.         printf "Applying update ${file}\n"
    # Q  i9 B- {; H8 D. K2 @' q
  201.         ${dbcommand} "${wdb}" < "${file}"- f; d( s' w7 h) N+ b
  202.         printf "File ${file} imported\n"
    5 v( ~) P) r( _
  203.     done
    & t3 V7 z' b) j2 h5 N8 F6 C
  204. : W; e4 o- p4 ~
  205.     for file in World/Updates/${RELEASE}/*.sql, v6 y7 R/ S& R7 n' d4 \, g/ ?
  206.     do# S# E7 k  x: q: Q) \
  207.         printf "Applying update ${file}\n"9 H' L/ b) D' Z3 {5 F
  208.         ${dbcommand} "${wdb}" < "${file}"
    3 B: H9 p& [6 H: I3 T/ ^! j
  209.         printf "File ${file} imported\n"
    , Y1 V' q) B" `6 }
  210.     done. l0 p) @6 P/ L  E) [) [
  211. }! l  G: n% y8 T: U

  212. ! P% r- P0 o8 }4 _) Z$ A
  213. createRealmDB()7 A: ^7 t) r5 d- w& I* H# Y$ n
  214. {
    ( m8 D. y3 m( R/ i$ n8 `4 D+ `$ U% R
  215.         printf "Creating realm database ${rdb}\n". t# m& s0 F; L0 |, }- N) N6 ]
  216.         $(${dbcommand} -e "Create database ${rdb}")! T/ P% x7 P7 Y4 v% I" |- ?! Q
  217. 6 G" V+ e5 p; f% v$ R5 g
  218.         if [ "${loadrealmDB}" = "YES" ]; then! ^4 H! ]1 v: H# b, [
  219.                 loadRealmDB; a# r$ w$ a2 R( R9 K# E4 c
  220.         fi, ^4 B' z2 S* S; W0 H
  221. }3 ?/ \: ^- c* P
  222. $ K% |% j$ E4 X' i0 E4 n* F( n
  223. loadRealmDB()6 n" b2 a; S+ W4 n) h5 P+ ]& U' U9 s
  224. {- s$ A7 }2 O- P* J  J( `* d" X
  225.         printf "Loading data into realm database ${rdb}\n"       
    - Q6 d) V6 ~: k7 ^% o
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)- ]5 _3 n9 f4 e: p  t7 `7 u, a
  227. }
    " g# ^: G& n0 [7 m& z

  228. ) d" f$ a! ]6 x( Q
  229. updateRealmDB()+ V) I# `. e" y" V8 ]$ s
  230. {- ]1 ]/ y& g* Q0 Y* h, s
  231.         printf "Updating data into the Realm database ${rdb}\n"
    * g3 l8 D- ~7 x+ F
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    , Q4 R' m" P! L; t8 s+ ?
  233.         do* Z$ ~6 q2 }) d8 z' T" o  [: A
  234.                 file=$(echo ${file} | tr '|' ' ')
    ' K" ^2 q$ E7 Z; }
  235.                 printf "Applying update ${file}\n"
    % O% h8 r2 @6 ^5 J# ^6 z# A
  236.                 $(${dbcommand} ${rdb} < ${file})
    ' _  N3 I6 M- Q* b! w1 i
  237.                 printf "File ${file} imported\n"
    6 ?; W8 B+ P# Y$ V1 n! s
  238.         done) |2 M& G; y- Z3 I
  239. 6 o4 D) `- ~2 Z! _/ J
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')9 C; T& @. @7 Z9 w/ R: t# n, A
  241.         do( V( F* T' a* [( R
  242.                 file=$(echo ${file} | tr '|' ' ')( D8 X* }; W/ c1 x5 d
  243.                 printf "Applying update ${file}\n"
    $ H1 m  @! _* g8 W* O6 R7 W2 [$ r3 q+ r' m
  244.                 $(${dbcommand} ${rdb} < ${file})2 q. c6 ?8 K* {6 x" T
  245.                 printf "File ${file} imported\n", c% O9 f9 J9 A- C7 T6 k# _
  246.         done
    # V- s! K& w& M) o* z4 t1 Q( o
  247. }+ `  j& x0 V; e6 V) T

  248. ! E$ Z, I$ c6 W! M5 P( L
  249. addRealmList()( b% Q9 h; ]4 o7 {- W2 r
  250. {; s# m, }/ j& @
  251.         printf "Adding realm list entries\n"
    - M) }+ s$ O& m/ \+ `
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)9 i' L% P+ f- Z9 @. _; Q$ M
  253. }, T: C" i) L2 h1 K8 p: k

  254. 8 k# D. O% |/ {/ e
  255. activity=""& v2 F9 J" b$ x6 j8 P) v. [

  256. , ]( J/ ?- @  N$ M0 A. ~1 }8 d
  257. while getopts "suh" o; do
    ( _3 f; ]" {2 h; D3 q
  258.         case "${o}" in
    ) T: \) \, ^4 ?' y$ ?' z# K
  259.                 s)( C+ x6 R$ I/ @/ D) s
  260.                         activity="N"
    4 H& d4 I( m9 A0 ]+ X  {
  261.                         printf "You selected silent mode\n"
    $ j: f+ \5 }- N' o/ I) _$ g6 X/ {
  262.                         ;;/ M& e7 y; h* B
  263.                 u)
    - I. }, H3 s7 ]) u% h7 P' A8 Z- R
  264.                         createcharDB="NO"
    8 ]5 W3 {! B7 r$ w& ?1 A& Y; G3 o
  265.                         createworldDB="NO"
    5 a2 ?) s( g5 P- [% i
  266.                         createrealmDB="NO"( W7 A# l+ q+ F1 S% J& h
  267. 2 K$ f" z0 `+ B8 N! {3 a
  268.                         loadcharDB="NO"2 X) n- g& C- t- u+ X4 L& @
  269.                         loadworldDB="NO"/ x- n+ Z# |( ^: N2 q
  270.                         loadrealmDB="NO"
    $ I$ @7 b; H, a2 ]$ ?7 A5 p
  271.                         dbType="EMPTY"
    . A0 h4 d2 E: U
  272.                         printf "You selected update only\n"
    ) }* I4 Y  F, R
  273.                         ;;
    $ ^/ ]+ p" M! A7 ?- v
  274.                 d)
    , O/ _8 h5 a- h- r1 E- z" r' x/ J
  275.                         DUMP="YES"! ], V7 T+ n8 d) b* M2 }8 N. [
  276.                         ;;; D4 Y" j% f1 Y1 M& j2 I
  277.                 h)
    3 {- }6 v- z/ \" D$ ^, S
  278.                         printHelp9 H: ~8 r0 L5 ~
  279.                         exit 0
    ; q5 S" @4 S$ [' U) J8 B
  280.                         ;;
    8 q6 b. E( @) N
  281.         esac
    " m2 I# @5 {3 L8 Y- c! x# C
  282. done
    # E) H$ r- m& g1 G: n2 e1 N

  283. + \5 ^! f" c4 d' W+ s0 a# o8 g
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]; t- v7 x; U8 T' _; H7 w
  285. do8 Z' L1 |+ l+ A
  286.         printBanner, w3 B% e4 Y6 f5 K
  287.         printActivities) ]# r. S- `& k4 T
  288.         printf "Please select an activity : "
    9 q9 L! V4 U5 ~2 h# Y# `
  289.         read activity
    * K5 l7 [5 ~) J5 w+ Q
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )
    - A: H6 ^: P) R- p9 _
  291.         case ${activity} in' r% g' r. r0 s0 Y1 `" y
  292.                 "V")( p5 j+ [7 z9 w1 f9 l
  293.                         if [ "${createcharDB}" = "YES" ]; then
    6 T, w, D! P# g% V: A- }
  294.                                 createcharDB="NO"
    9 \) L! a+ u5 `8 z: |+ L/ i# X
  295.                         else
    ; L& s) q6 s' Z. o
  296.                                 createcharDB="YES"
    % u5 f$ F! Z0 s: m" r) D. u
  297.                         fi
    & c$ t  d0 c# W$ m
  298.                         ;;
    ! f. X3 V7 D8 ^) G- c8 ?- R
  299.                 "C")
    / s5 t; E' e* F* B7 ~
  300.                         if [ "${loadcharDB}" = "YES" ]; then
    , d. q7 B7 N: A% m# V9 N4 f
  301.                                 loadcharDB="NO"0 C4 m! q( v6 Q' |7 B9 y
  302.                         else
    6 g2 w) `- V# V) |( l6 J: U% _
  303.                                 loadcharDB="YES"2 z2 V0 |+ n$ U8 k( e
  304.                         fi
    5 D, o1 U! Q0 ~
  305.                         ;;
    9 ?7 n" c) ^+ N/ a- U+ t3 C
  306.                 "B")
    , L7 r8 f, ?8 ]5 A9 s6 _
  307.                         if [ "${updatecharDB}" = "YES" ]; then! q- y+ z* F( U% f
  308.                                 updatecharDB="NO"7 J1 k) O# s8 \7 L: a3 R9 N
  309.                         else
    / m5 |5 b2 Z3 k6 F! m+ j
  310.                                 updatecharDB="YES"
    - d2 s) v7 @/ j
  311.                         fi0 N3 [  n  H8 ?. J' w+ O5 q/ i
  312.                         ;;
    : I9 `, w1 B* d7 c/ }" u  p
  313.                 "E")' D7 X9 i% ?6 u
  314.                         if [ "${createworldDB}" = "YES" ]; then
    - d. J& D3 t& h# z
  315.                                 createworldDB="NO"; z* K- z% \4 ~2 H2 M+ g
  316.                         else
    - A7 b5 G- }: l
  317.                                 createworldDB="YES"
    ' x# }3 M9 u  j. [' h6 ~7 K  [
  318.                         fi       
    1 @2 s+ h4 H, G& L6 `4 T) b/ N
  319.                         ;;
    ; E+ I/ S8 }1 l5 l
  320.                 "W")
    8 r! E( S5 c" L* {! E8 P
  321.                         if [ "${loadworldDB}" = "YES" ]; then
    # k  s9 }2 W, x0 C9 F: ^
  322.                                 loadworldDB="NO"- v% Z: `' m" {: v& Z
  323.                         else - C1 ?1 D$ x$ x2 f  p1 w$ M+ O
  324.                                 loadworldDB="YES"
    7 b6 `  J) i0 k4 f3 ?8 p
  325.                         fi        : a/ S# a! [/ }! e0 ?
  326.                         ;;
    : ^7 _% Q- d7 K; t$ l
  327.                 "D")1 m8 w2 p  z% Z! R5 u8 a7 c
  328.                         if [ "${dbType}" = "POPULATED" ]; then
    + [! W: n: m- r
  329.                                 dbType="EMPTY"
    3 b: z) ^' o, @+ m
  330.                         else ) s' ~$ l( Z& M: x3 W
  331.                                 dbType="POPULATED"( U  y* ]$ h% x6 K# r5 p9 ~
  332.                         fi                                
    ( q5 u+ {! f8 z" R
  333.                         ;;, H# f( R$ O: V* j+ s0 W
  334.                 "U"): U4 ?, ~5 V: t: b. R+ u. A6 F; X( t
  335.                         if [ "${updateworldDB}" = "YES" ]; then4 Y. \+ y$ W+ J& n7 W
  336.                                 updateworldDB="NO"
    1 H" r; [8 M* e: e/ Y; P2 A
  337.                         else & w8 U' C9 _/ l, I/ o# X
  338.                                 updateworldDB="YES"
    8 T' R: ], G0 q4 L4 a% X: g
  339.                         fi
    ( h5 L+ N; R; L6 ^4 _
  340.                         ;;+ `; Y, h- P# S  I+ |: y
  341.                 "T")
    4 L: |: m3 [% d3 N* p' i1 r1 Z/ O% X
  342.                         if [ "${createrealmDB}" = "YES" ]; then
    ; ]( y# U3 s: r: n' o# G( D
  343.                                 createrealmDB="NO"$ d3 {# ^; W9 D8 i
  344.                         else
    0 p: R1 L: A' B/ \5 T: k5 @
  345.                                 createrealmDB="YES"
    5 {2 I( d. G  i4 C3 T; |$ l
  346.                         fi                                 ' ^5 u. G$ f5 J) X4 `2 q- J- H
  347.                         ;;
    " h( _6 C" I6 k* w, `! ^  B. I& g! ]
  348.                 "R")6 a" s2 i: l. {: u! M5 }
  349.                         if [ "${loadrealmDB}" = "YES" ]; then
    " ^$ v1 w$ v4 d$ B
  350.                                 loadrealmDB="NO"                       
    - n$ Z0 M, W( l! c5 A  [7 Z5 V
  351.                         else ) j" ?7 F. s% |  C9 M
  352.                                 loadrealmDB="YES"7 V) M& I! A. o/ L, R! F
  353.                         fi
    , f! d. \: i" s
  354.                         ;;
    0 H9 J9 o3 O0 @
  355.                 "Y")8 O! N& Y  C  Q7 [" I* o0 N
  356.                         if [ "${updaterealmDB}" = "YES" ]; then1 _/ A; w! O( y3 a2 {# I
  357.                                 updaterealmDB="NO"% g# ~% v7 g$ d% s3 j4 K
  358.                         else ! w8 _1 ~) E- o9 N
  359.                                 updaterealmDB="YES"' ^7 F1 t# F, d  p
  360.                         fi
    - C  v+ n2 }4 e3 T+ c* ^0 g% `/ K4 S
  361.                         ;;
    3 j$ R) @$ B4 N5 I0 {2 e+ P
  362.                 "L")
    $ W9 R  f  g% T; a7 q
  363.                         if [ "${addRealmList}" = "YES" ]; then! O3 U$ d7 B) y. b7 t+ q
  364.                                 addRealmList="NO"
    8 d5 l' l0 B1 e& Q0 V! c0 F" o# F
  365.                         else
    9 w" Q# u, y5 }/ _
  366.                                 addRealmList="YES"- j4 J/ Z  B! O  |
  367.                         fi9 t. P- D( ?- O5 y5 I6 h
  368.                         ;;" [5 H6 }, f6 K" m
  369.                 "X")
    ; p  T8 L7 w: o5 W& I
  370.                         exit 0;;. o- f% d5 H$ D; P! `
  371.                 *)
    : W9 r8 I+ H$ y9 a3 u- A. n
  372.                         printf "Invalid selection";;1 n0 o: F& o/ z* d& p- ~4 @8 o
  373.         esac
    ; M( M! z; q" ^: Q9 P
  374. done: k0 M  X* R* \

  375. ; V* O, j  [# ]9 u" u3 k
  376. printBanner
    & F  e& K, N) H+ m
  377. determineDBName
    8 g0 o7 i4 R5 m1 l/ h3 W( x7 n( ~
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "
    $ S* q* b. {% U
  379. read svr
      e6 ?: z* B6 W# O% l
  380. svr=${svr:-${svr_def}}
    3 e+ B. w1 R2 {4 }4 y
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "8 {# F- V8 t5 S$ Z6 e
  382. read user
    & c8 ?5 b4 g) k
  383. user=${user:-${user_def}}& f4 @$ [" ~" Q# M6 r  y! d
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    + M0 I* d! Z) \* E# ?
  385. read port
    7 d! w1 S: Z9 w) B+ M. \0 a/ _
  386. port=${port:-${port_def}}
    ) ?! X5 O6 U# Z8 C9 r
  387. if [ $dbname = "MariaDB" ]; then# T, b1 E: ~: y2 S4 ^+ U( Z& C
  388.         printf "What is your ${dbname} password ?\t []: "% d6 C9 \' `8 Q" K- l3 J
  389.         read pass' ?! ]9 r- d( ~* s
  390.         pass=${pass:-${pass_def}}8 E& H( a; o% ]7 l
  391. elif [ $dbname = "MySQL" ]; then, {/ Z0 m: F2 G6 }7 x
  392.         mysqlconfigeditor
    & [% J0 b$ v1 k* |
  393.         $dbconfig
    3 `5 c) F  I9 k) f2 T, u/ X
  394. fi
    " X% {3 [& h9 s. \( c# a2 p
  395. determineDBCommand& w. g/ C! V* T  k9 L4 F5 s3 j9 N

  396. % y, G4 b$ g& Y* R
  397. if [ "${DUMP}" = "YES" ]; then
    6 u; q& R1 b( o; y  I
  398.         printf "Enter it again \t[]: "
    0 ^; T- A. E' {4 q: B/ m
  399.         read pass% m# @9 K0 j. D  z0 n5 Y
  400. fi2 v9 O# G; A0 y5 f; H
  401. . E) d" U+ f; V5 G6 x# a4 Z6 ~
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then/ g- _% v4 s, N: R' B
  403.         printf "What is your Character database name ?\t[${cdb_def}]: ") A; H: [# f. T6 j# H
  404.         read cdb
    ( V/ R) A8 n: j: P( G: \* {! E
  405.         cdb=${cdb:-${cdb_def}}
    " E; M7 p: N1 |
  406. fi
    3 N! T: R# s4 M$ M" W3 W& K
  407. ; s; ]3 m0 E; {. e" u
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then6 c- ~% @# [& u$ ^+ f& x
  409.         printf "What is your World database name ?\t[${wdb_def}]: "
    2 K2 I* G1 R8 N% `! D
  410.         read wdb, }- F2 C2 q) b
  411.         wdb=${wdb:-${wdb_def}}: K( M) t! B+ O6 r0 E" I
  412. fi
    ( G- e9 ^: v' \6 D+ d, N3 [5 o6 A

  413. . R: B$ g# O2 T
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then+ U4 [4 U- @" U9 ?- j
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "# I" g8 w* X9 C- ?$ c
  416.         read rdb
    # B; [) Y! t8 n% t2 V' s( w" Y
  417.         rdb=${rdb:-${rdb_def}}/ Z5 o! ]; {& C  B. O
  418. fi5 }6 S1 d9 P+ d* @/ \' H2 v

  419. . N# H0 N; }- F0 s9 m
  420. if [ "${createcharDB}" = "YES" ]; then0 t- {+ e/ j+ \9 s- _
  421.         createCharDB; c4 H" j2 n6 w# X
  422. fi
    1 Y7 A5 ]1 c* K# `, @; w) Y

  423. 7 v! \* {. ?$ p+ Z  n8 {% U1 ~
  424. if [ "${createworldDB}" = "YES" ]; then
      \9 ]" t$ z' A3 G7 v
  425.         createWorldDB
    ! N# T0 g* s$ p# N7 J* {1 Y
  426. fi3 Z7 ], R* H0 t/ R- X; W/ v

  427. 7 P- i6 E# C+ D% M, u
  428. if [ "${createrealmDB}" = "YES" ]; then+ W$ ^9 }: N* i0 v/ h- g# k
  429.         createRealmDB
    " k0 K3 i, h- o0 u& Q! ?
  430. fi" e* [2 V# N! N" Y$ a' o/ O$ J

  431. ) l( {7 ^' p8 H
  432. if [ "${updateworldDB}" = "YES" ]; then
    ! z. `- Z$ y4 d7 W
  433.         updateWorldDB
    - G$ B% f& y, S, a; z5 D5 j5 T3 ?) Z5 s
  434. fi
    " }3 v$ ~2 N+ P4 R" K8 `. l
  435. 7 ]1 ~2 D  B1 }  w; C
  436. if [ "${updaterealmDB}" = "YES" ]; then3 q* |: Y6 P* U- T! I
  437.         updateRealmDB$ d7 G3 U9 Q! K" R$ K2 f8 i, B
  438. fi
    ( @1 e% b- C4 v2 {  E7 Z8 T! r5 k2 B
  439. 6 P* E& ]$ A4 ~; S8 X# d6 D: N
  440. if [ "${addRealmList}" = "YES" ]; then. d4 A" I* Y. Y
  441.         addRealmList+ ?' U) ^* |: W# S& d/ p
  442. fi
    % @$ W% u: ~7 X5 q
  443. / p% F4 {# ?8 W  H
  444. if [ "${DUMP}" = "YES" ]; then
    , E9 n; a. h/ r5 X+ c/ L( `; i
  445.         printf "Dumping database information...\n"! {) e# S" z2 A9 g7 a: M
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf) {6 J5 b' }- E5 b$ A% K% w0 o( O
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf, ~2 I5 w4 b# m1 P0 d
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf6 G9 ]/ _' ^7 {9 f
  449. fi6 H& H3 `' W( A; @8 L

  450. ; l, F- y. |  |7 `/ W. E
  451. printBanner+ k5 n$ h/ _: m# u) y: G. ~
  452. printf "Database creation and load complete :-)\n". p7 h9 s* p8 a& }+ h8 r$ z+ u: z! D$ `% B
  453. printf "\n"
复制代码
' J+ J& V" n1 k+ M4 l
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令7 Q% ^$ v) Q# D9 U

; _$ M* I8 I) Z' ~使用 Playerbot 密钥的指南:
- \0 p. f; z' x+ @1 H, v* P
( C3 `9 h! ]7 K* v$ s标识符说明; w: z3 h& n* j1 e8 W3 X! b
机器人名称    机器人的名称, e& \) I$ }$ h6 ?
朋友    命名机器人或玩家角色
# m8 z& ]! ^1 w" y2 a8 `& j目标    选择目标玩家、尸体或NPC(非玩家角色)
$ B0 @9 Y9 F7 N5 L: Y5 X2 j|    逻辑或
! Y2 i/ S2 J# ~4 q  T&    逻辑与. b+ ~% o* w- m& o! Z8 `& T
..    多个实例
$ e; K( P3 h0 m  B/命令    MARCO 命令: H4 i9 f* b! `) O! Z1 K
/s    聊天:说4 p$ @0 Z8 O, {+ Z8 `
/p    聊天派对
7 o$ B: V" E0 k5 ~8 P6 T/t 机器人名称    聊天:TELL BOTNAME
% ?4 Q( S3 i' c* z2 l: A/ U/ m* p/w 机器人名称    聊天:告诉 BOTNAME
) N& i7 c2 t/ m- j<名称链接>    名字=+ e2 z7 |! W  L1 m
(捷径)    为命令或子命令分配快捷方式2 g7 p) {8 K$ R2 C

9 C" }6 m2 `3 M5 [可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明
# o& X% [2 b) [) p4 z! Y% M6 M6 t.bot 添加 BOTBNAME    为世界添加角色9 M7 f1 \. X2 p7 p& P/ S
.bot 删除 BOTNAME    从世界中删除角色
. F+ K' T$ s0 ~" r
$ R* v3 u. r8 i当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)# |! D! X6 G9 b5 K9 N" F- T/ `8 Q; }" |
.bot < co | 战斗命令 > BOTNAME    分配机器人角色
3 ]0 G+ K) z5 X* D% N7 H+ A7 A+ i' q( h; W2 i
宏命令:
4 g4 J+ v* H6 y3 N% ]% G句法    描述0 f4 x! x$ {9 d: V2 E, Y0 Q
/邀请机器人名称    机器人将自动接受聚会邀请2 H/ w6 t- y+ g( X4 N) h9 l& G
/uninvite BOTNAME    机器人将自动接受派对不邀请/ Y6 y- r, q& v' R  m: u: X

6 N8 q/ b( C9 W0 b; p7 [TELL/PARTY 命令:(某些命令可能不适用于某些内核)
* k, w+ p6 ~2 V9 p  t2 G句法    描述1 a4 d: ^2 _: `/ u# L" }6 ~
协助目标    机器人协助列出的角色,在他们攻击时进行攻击。
2 w5 z/ A% a+ z0 Y/ r- c" V攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式2 n2 c, G9 L! {! p! q
拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..
1 A* E* H3 Q0 q# R& n+ s! B8 z拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..  ]* B) S, v0 B: B7 N0 ?) }
拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..
: L+ \/ p9 W& W1 V; R银行    命令机器人寻找附近的银行家并列出机器人的银行余额
" U3 B. I- O1 ^9 J6 p9 W. k2 H  l银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
8 R  h9 ]( a) o% }" d银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..$ F1 ?' H! s& _; G1 V+ R" u+ x
(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..# G+ o* S5 w& I6 t
©ast SPELL    拼写 = >  ~) ^4 E% J0 e7 R1 D
搜集    显示收集对象选项和当前收集状态
  p$ v- h, W3 ?1 r* m& S收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>8 j2 u6 \* d4 N" [
工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱! w# t# X, k" M- F8 W4 n
工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例  `/ X* k& e  [5 P8 U% o5 Y  y# G, b
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
6 c! ^6 I% @" ^* T; i; j/ {工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习& j; w( B! p) D& C- o! C
工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习' y+ P5 n% U8 S6 y* s, M6 f
工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习" d) j2 j* {; g
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习" h( g. i( O0 m
工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
; h( F0 H; s) U工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习! M8 d9 ]# ^" ]7 J  L( v
手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习; S' T7 S, ]0 U$ D& }
工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习# q1 B, P4 c) A6 z4 m' ~$ H; K' S
工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习
2 F9 w; U$ B, v- J工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习
2 W: n# T! d5 B6 H% ?( W/ `掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..# o, J- M/ C) e" K  }! O. m
全部放弃    当机器人库存变满时,丢弃所有低级物品。
  Q3 b. u: ]% L, U. ~2 G) v附魔    列出机器人学习的所有结界 1< Spell LINK >- C& ~/ p6 q1 M5 d7 O+ e
附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中( N+ l# }. _  ]+ [, {& h
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品: x( k' ?/ f4 x, x! e* Y: u* [
(e)quip auto on    打开自动装备,也立即检查
9 U5 c. _% B. d  z7 v4 O8 x. Q(e) 装备自动关闭    关闭自动装备。3 i" S' Q/ Y+ [4 L" I2 H% r- D) `; \' r
(e)quip auto 一次    运行一次自动装备,然后将其关闭。6 S7 z. S/ u+ [- K; l( C
(e)quip 信息    显示装备自动切换状态(开/关)。6 L% l- P2 e6 t: Q8 P' X) r
(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用
( m4 K  I- h3 }* b( r1 d跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人0 P, G6 w$ V8 h2 v
跟随汽车    切换自动跟随距离(开/关)6 {  C% s( {; K3 T
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)
- N; ]8 q8 C4 ]跟着远    机器人跟随,远离主人。6 N* f9 ]$ n7 x
跟随附近    机器人跟随,更接近主人: \. \- R2 J  w  E, t, [
跟随重置    机器人跟随距离重置为原始默认值% g# N* n" `0 c/ y( {( T* f7 r
(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家. ]5 B) d: ]2 {: G. Z3 U4 w7 p
订单    显示机器人的战斗命令3 i) B9 z: o# K1 d5 \" T
订单延迟<0-10>    在机器人开始战斗之前激活延迟。9 X7 ?, J0 i. M- U2 U9 q
命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。7 p. g. a( q" X  T7 G; c
命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。' q. C* G+ G0 P+ K- |
命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
- ]) |, G, W% B7 {6 c命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。
( `( k! N; Q- x' Z+ E9 R命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。% t& w9 ~9 k3 s
订单恢复    将战斗命令恢复到注销前的状态。3 D1 |  u, S6 Z4 B  t" |) U
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。
4 W' r% @2 B( o* q: l. i6 x; _mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..
+ T" Y, K, y7 T: u3 r5 a: c' D邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..% ^6 E* v5 R0 d) ^$ m  ]9 }
邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..1 T  `% _2 w. A, O  k& @
宠物遗弃    放弃活跃的猎人宠物。
7 m4 v2 V8 w8 [" ?+ [& C0 l& \6 S宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术
! P% ?8 Q7 D. q宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色5 z- }, J0 L! F$ j6 O* o% r
宠物施放法术    拼写 = >) o! j, c" E; j+ o
宠物切换法术    SPELL = >为给定的法术切换自动施法
/ n) f; P$ N/ t+ }# ?  `6 H宠物状态    显示机器人宠物的当前反应模式
2 Z' S4 S3 i6 D" F$ y9 F) \宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>
0 n( o" B8 \9 q" |过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
. S1 y" w3 q$ D0 T3 [处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素2 w, ^3 h; _% @4 {& J7 l: F3 L
过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
. E# ?/ w; @9 h3 X' t& R, ]拉目标    以协调的队伍/袭击方式拉动目标。
" `, |; z, J& U9 r- S拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。
% }/ R$ p! ]; Q/ r# q. a+ A! t准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。
9 `3 K4 R3 b" Z5 _, j寻求    列出机器人当前的任务  d/ U* a+ W" Y. g: _
quest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..  P' y/ x# \2 ?/ Q1 h) R1 w9 T
quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >
: ~) [  v1 V  w2 A追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务0 U/ B* _$ c" J2 z9 e9 x8 M
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象
! ~7 Z0 l% Z  L' ?1 f' `0 U任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..& P: l; `1 L3 y. Q- H# H
quest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到5 J, M  Y+ c( P2 M# T, Q3 b9 B
修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
/ g# \0 U" N" q( V- f3 q# H4 K- s全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品" V  ]# g, V. v7 F
重置    重置状态、命令和战利品清单+ l% ]9 ?6 l& Z
(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..5 E# ?* ?* H! V4 e
(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。: ^7 n: x7 n( Z
技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能
/ X8 H9 A5 B7 ?4 c9 O  C9 Q技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..4 X( c5 I4 i; s: O" ^6 Q( e+ q/ _
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..
- c+ D7 ?8 @3 E7 j% D技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术8 P0 p5 ~' ^$ ~* ]( W
咒语    显示机器人已知的所有法术/ ~# W3 q8 X( _
统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本
+ A" e+ j4 R4 j3 k停留    命令机器人站立而不跟随玩家; m3 o" i( r/ L" X& o. _
召唤    玩家附近的传送机器人( h, D# C- G* n+ c3 f1 L
民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..
0 Q8 i8 F5 I: t7 r7 R使用 1< 项目链接 >..    使用物品(例如食物、饮料等)$ C$ Z% Y1 N8 u
使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)
0 p" V. x0 ~. \6 b句法    描述
% ~4 [& O8 _3 p6 z4 c9 ?天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用
0 q9 o. L/ }1 s: m人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋
6 U" I( g, W0 |# c  d+ u天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2
' t! i* a% U9 t1 l: q5 C人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
; y  _/ f- J% E0 b5 M9 i天赋规格#    机器人将遵循此天赋规范。
7 h; U9 P" k- P; }- @& y' r4 d5 \8 L' ]9 r8 I
1 要选择 , 。
5 L# L4 A; p3 X; _7 |2 每个机器人的税收增加,每次重置天赋。
: k) t' ~+ |5 i2 V8 J$ ?, x9 x% k; ]: S$ v4 F

/ f( R+ N4 H  X7 b- K- Q7 b* e5 ~
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 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)
! A, _4 o; [; M3 }6 k* l) Y8 R6 ]4 Y9 u
1. Make a folder for ACE in your preferred location ( I use /opt); [$ u4 J% T8 g8 P! X4 r

& s1 t! Z0 a0 Dmkdir /opt/ace && cd /opt/ace
+ r7 E) J, B& F. p' Y3 k
; r- T6 `6 y! H, N, `) ^" O3 c! N2. Download and unpack ACE
0 u% E; b0 S5 b) v7 b/ A1 a5 c2 J
wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz+ k1 n  u- N4 v% Y# ?
tar -xvf ACE-6.4.7.tar.gz/ L5 @2 m2 p, D7 x, [
) g' o' U" c0 O# J$ }# k3 J
3. Add needed environment variables& }9 K$ n( J( @+ q6 F3 R3 X

8 i. A2 p( w( r/ hcat >> /etc/profile <<EOF. L1 V$ Z; |2 \6 n
export ACE_ROOT=/opt/ace/ACE_wrappers
: I5 r% V$ b0 B! W" ^EOF" h/ ^- R; }. p3 M& f
source /etc/profile

* K% D0 o2 S( L4 R6 Y
9 [. y. o: {" m  Q4. Add the desired headers
- P( B: j% _" J, ?* {* d, o0 ~  ^5 o; U% k( R4 f
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF! W9 p4 v7 `% Y. k* e
#include "ace/config-linux.h"! T6 |$ w1 t% \3 D
EOF
8 E* r" [/ N+ I, T7 N0 Ycat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF
7 Q8 Y5 O# k! u" iINSTALL_PREFIX = /usr/local
8 H4 S" n$ P0 A' o  y. f2 f0 {include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
3 M* W" d" k/ C  B0 p8 dEOF

* n# J9 m' X* f9 i& u
+ r9 I" @1 q, ]1 H, U6 H5. Build ACE
+ c. `. F; T! q+ w  O/ s' s, F- F% M! n; h- w: n: S
cd /opt/ace/ACE_wrappers
3 R. X; t# I' K9 v: @9 ymake/ f- k- s: T6 Z  _7 Q1 b6 l# d: M
make install
0 ^, _5 Z$ S: V$ U

2 L0 I) S, T+ F5 y2 C. S6. Add the library to the public path, X- g& b7 m; f( l+ R& A# c

& Y( W9 {" V9 @* Q- B, ^+ {cat > /etc/ld.so.conf.d/ace.conf <<EOF
; {' R& L8 a4 W5 \5 h: M& ^/opt/ace/ACE_wrappers/lib  ?2 y. N- \0 ?' A
EOF& w! d+ w7 b; U7 Q/ b
ldconfig -v
6 ]3 [2 V, a) i
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client
! i! P: ?+ j3 s  T4 @/ QTorrent Download) O7 d, a8 }  m) s9 [
7 g& \( ^- _, e3 y9 k, m
These are clients that can get downloaded through a Torrent. We always recommend using a VPN, when you download the World of Warcraft – Wrath of the Lich King Game Client of 3.3.5. The reason is to avoid copyright infrightments from your ISP
4 ]9 ^0 D1 O* L3 J8 L, [! C
9 u& n7 p3 v3 ?$ n7 v    Torrent – Client from Dalaran WoW (Recommended)
! f. C, r: R3 p, x9 E+ {  {. r9 p    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)
* s" o% M1 q9 F8 y9 j    Magnet – Client from TrueWoW
; }5 c1 z+ e5 S5 D& c4 @9 x
3 \; d6 s( a6 h. l" [4 o5 k& \Direct Download
1 o* A  H& s# K
; n) C, D3 I5 N$ G. o7 xBelow, 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./ b3 ~# b2 X5 F8 p
5 N5 N7 ]6 n& Q  o, M; a
    Direct – English Windows client2 l: m3 q+ h- o6 {! P! q- v& _
  n; ?8 D5 V7 g  v+ J- d
3.3.5 Wotlk MacOS Client2 f7 k2 T  Z  \: m3 [% g1 Y# U# g
3 ?% G1 r. a* F6 Y$ E
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.- A4 _7 @4 u  n" S/ \; @+ v
  L2 t" N/ ~" K3 h% w# S$ K3 O2 i# B
    Direct 3.3.5 MacOS Download – Client from Sunwell
/ x# O' |5 s8 Z& U1 J. S) i    Direct – Client from Paragon-Servers (French)(Mac)
! _5 V* h0 H. E6 G
  n6 r3 V4 @! B3 _Modified Clients, LegionRemaster:
$ s6 i( h! q/ W! w4 M& V  i; r/ [1 ?) Q
    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis
, [3 e% M6 h$ ~5 d, ?    LegionRemaster Patch (modified)6 `; f2 I" a8 c
    LegionRemaster ReadMe (Custom) 0 y: \$ T3 d: P) v7 m, |
https://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos
& j& M1 w/ ?  r7 |3 d9 A
4 V* }- p# {' w" i. Y% g4 v在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
2 ]* _* |  }9 b7 R! X9 P$ v4 I' e* ~% ]# n4 f9 e4 s! r' Q- O
本文 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。/ J4 O) Y4 e% V3 J3 M

( W0 t8 V0 C2 H5 `4 g正文如下:2 O0 T4 x: @: c! O" O
. J- W* a# Q8 S  Y$ p
开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。
: |2 Q& U: j' w# d3 @+ M
/ d. V8 J/ i5 t& J暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。' W, U5 l( ~, @( q

& ~1 Y& z  N+ x) P9 m  f1 Z3 x而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。) k6 Q2 m9 F1 L
" e( [1 G3 j) d3 @6 m
  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。2 u# {$ E6 e; e' R2 [  p) Q5 Z( k2 M

3 j/ P! m2 L* j; T4 q开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。! g$ W" i: F0 ]& e# l& E: b1 e1 U

, A# j4 q* @; a! {" y- X2 B$ Gmangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。
% q8 b  @4 v- X+ \- t$ c1 b0 Z3 [$ G, s& k' W8 W1 ?$ y+ r' s
) [+ {7 a" p% q2 {# t5 H0 H9 K5 D
为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。% i0 B' l5 q! s, n# ]$ t* ]

- T  S' G5 D6 J, a一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:
    / a5 n5 c0 r# }8 E
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:, H- L3 y+ [- P6 I; _3 W
    Brien
  • 开源数据库软件MySql
    ) \3 x4 i" ?  F  Z; J: q1 ]官网:MySQL

    $ `* ]+ z6 s4 D; s: U$ I或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库
    " c. ?0 E, y+ n官网:
    / D' J7 A3 i6 {% H+ [; m
    我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。* y1 |) U2 v% Q" X. \9 R" D
    文件名:CompleteSDB156-Mangos3462.rar+ c4 D" v: p1 o, x! l
    下载地址:" l- G& M5 D5 x/ d- |9 K+ R. H

      e) U- A/ w9 s/ N  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"
      $ p3 W- m) H2 `# t  p% O% [- o+ j
    3 a4 l- B( J) B2 ?* Q) u' b5 v% A
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径
/ r  B3 H. ?4 E9 h+ \
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。
    2 p; J& b# E0 p5 O
四、解压安装地图文件3 M1 h  L4 Q6 T- o- ]: y
  • 把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子目录了。4 Y2 F$ J6 p" T4 A: b6 e- s8 }
五、解压安装提取的*.dbc文件# X* w% ]0 T; v; @9 b5 x- w
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:! T+ G# {5 d9 q- |$ _0 f
    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")了。
    . M9 g  h4 R! X0 K- H3 g" K# i& Q
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.: \# y6 W( [+ \4 [7 G9 Z
  • 将下载的CompleteSDB156-Mangos3462.rar文件解压,里面有几个数据库文件。找到其中“realm-database-full.sql”和“mangos-full-for-rev3462.sql”文件。
  • 使用SQLyog连接到你的数据库。
  • 在左栏找到realmd ,点击右键选择"Restore from SQL Dump",找到“realm-database-full.sql”,导入数据库文件。
  • 同样找到mangos, 点击右键选择"Restore from SQL Dump",找到“mangos-full-for-rev3462.sql”,导入数据库文件。) U& c1 t! d& Y9 [
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。
2 Z0 |: I8 E, u8 M" p2 C$ \0 F+ ]
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到+ B$ Y/ q  P- V$ h+ B
    "LoginDatabaseInfo ="
    ' B2 C- c  }. Z5 ^  j% Q2 k/ U改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"" S- r4 I& q/ ]. Q- }1 i
    这里的IP地址可以是你的IP,[password ]是你的密码。存盘。
  • 在mangos目录下打开mangosd .conf 文件,找到如下的内容,并设置如下:
    • DataDir = "."
    • WorldDatabaseInfo = "127.0.0.1;3306;root;[password ];mangos"
    • LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"- K. Y0 ?8 q" B
    1 I- M- d& V' C- f8 N3 ]) O' r3 {4 Q% l$ d
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。

6 b6 H2 r0 ?6 ^# `+ e
: L* z% d9 V- \+ D4 z# v6 S, M" n) H0 q: ~) c
5.安装数据库
* I! M) C1 G$ A' K使用mysql建立 mangos 数据库9 Q6 \" L8 y; `* j3 F+ H6 _

' w, Y% ~/ z$ J9 F: ta1)使用官方最小数据库,mysql用户名及数据权限等请自行设置
, {  f& h. `. X" S( K  M# }8 r3 zmysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据
( Q: f0 V% _+ L5 x; g- f" y1 Z* `" O) n, y9 _
a2)使用sdb数据库,mysql用户名及数据权限等请自行设置2 u& W  b6 J6 h* r* M
假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
' I. ]# j5 {. @mysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据* `  R) Q( s: f3 v. ^

* c1 k% o3 q6 f& t4 Qb)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1: w" B6 ~; B5 }2 c' j0 H; r, |- B: K
* Y4 h5 ~/ W3 m0 a
6.编辑配置文件: s' U* v& r/ I* R% t4 G& H
编辑 /usr/local/mangos/etc/mangosd.conf3 O  F* Y" c% r/ A) U1 n

: B  H% i. K6 L9 `5 U- pa)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"
* Z$ |/ c& w% S1 y& ]) b为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"
- [1 Y, I- G3 n- t, M
$ v0 n9 y) M9 L+ X- |4 e, d+ f, d0 N* Pb)找到 Host = localhost" n7 K' d' U* I! i
为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1# C/ o' R0 r6 t( r: [) V
# G2 k8 }4 V  f! N, _6 {- k
回复

使用道具 举报

985

主题

92

回帖

5万

积分

管理员

积分
53561
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。
: {, t3 T" r' J  v0 F9 R& _9 d% |; \  C# m( v0 D, Q
本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。! j5 Z. {. \( g6 M

: V: k3 b+ v- P, f" f8 c我们走吧..
0 X6 V# l" P8 S' }7 K  ^& A& B7 p+ O' n
设置数据库:$ m- ?, y8 A7 R
: a! l$ Q! Y6 m. h
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。
, \& P) B+ n. E) E: M+ v/ U7 M1 V' X- G/ i1 b- V7 M
启动一个终端,如果还没有,您需要成为“root”用户:
: v8 N- ^- L6 W- \5 Z
' z9 ], \$ m3 {+ G  E2 o" i* l3 W) K须藤苏 - 根, Q3 B* g) M2 X* j" k* \" B
然后,安装 MariaDB:
) p' R) j* Z& s( v3 J  t
) _* I) I% W& O9 ]) E( g1 `& G/ ~& a, {yum -y 安装 mariadb-server
* Y/ J+ w/ E  I. V     安装 MariaDB 后,启动它:3 A: Q. D- d; h

; }) V1 u$ _, i7 P3 L6 Asystemctl 启动 mariadb0 E" k, D+ }) T) p* D; p  s) P& C
我建议您在启动时添加 mariadb 服务以自动执行它:
6 `4 T0 J& k6 J8 N
( C0 Q1 z! Y  n& b' ?- esystemctl 启用 mariadb5 S8 H; e6 t+ p1 D: I
让我们保护您的 mariadb 安装,执行以下命令:1 d9 f! y, w+ L7 q2 W" r

) ]( c: P+ }& o. Tmysql_secure_installation* c. v) J+ F! x
我建议您设置以下参数:
- I. a0 I# w4 K  Z
( r0 L4 H4 s+ e3 o设置 Root 密码2 v" m. I+ L6 p$ `- h
删除匿名访问
! F1 }7 a1 o9 g8 H' q禁用 root 用户的远程访问' z* G, d' f  h9 e$ y( ~5 n: `! C- f* |
删除测试数据库
* G$ ?- H7 }* _3 l! p重新加载权限
$ V8 c  V. A2 N1 U验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:% T* d/ q4 D, I: q: r$ \

6 d2 \; R$ O$ a9 I% D! I" Dmysqladmin -u root -p 版本& R6 e/ k; ]3 b7 ?
如果一切正常,您应该有如下输出:5 D8 O+ t4 M6 q: H5 [- Q/ J

; R' u9 g( `5 L! d: o- p- h3 y2 h4 {" i服务器版本 5.5.52-MariaDB
/ g) o# x1 Y( A. w, m' d! |协议版本 10
8 \  g, l  ^4 Z7 a# V, F& b6 q通过 UNIX 套接字连接本地主机
- H# O( l( Z. s% N4 {/ FUNIX 套接字 /var/lib/mysql/mysql.sock8 c+ ]5 L+ h$ C" O* p' Q# t
正常运行时间 x 秒
$ [0 o" b. r5 d6 i, b$ k$ v0 q
- n. k( [0 U6 Y( ?  K: |, d4 C5 L; _  i
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:
% [$ {+ j2 W" s: C& F
0 y& P# [+ I8 C# l' Q& `- kmysql -u 根目录 -p: w: O  Y; ^9 Y7 ]1 m7 n% P% _3 R
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):
' g- L9 A% X) C) D+ v. \8 R8 t4 p' K/ G( u0 o- F! C, q7 N: u
创建用户“芒果” @ “本地主机”由“密码”识别;; J. _5 _# B+ `3 k! a8 W
然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):
% [1 E$ e' ]& |1 k7 o  H: S5 i, Y! b. i, z4 ]' e0 }' Y
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
" W  ^: `, T5 ^1 w& M' j- M退出终端:
( Z/ g( H1 G2 {8 w  Y* s4 [. z0 h$ C  k  I0 X! C% O
退出8 s) |0 O0 F0 J. d3 A
恭喜,您已经在 CentOS 上设置了数据库的先决条件!5 z! _% Q6 j2 Q# }

1 i/ [8 R% `. V6 @  X . ~4 `% h9 R& X- I. y; T

  b5 u$ ~( j0 R) R& F5 y8 ]# Q安装芒果:
* [/ c8 J1 i% C2 s) f
. O! L+ C7 U" I- U0 t我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:
$ I+ J( n/ l5 A
5 z9 u* I3 V9 ^2 j9 V) A2 o* ~9 }光盘~
( p! U4 s9 X) m# i让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:, I  D" c% D# Q+ y$ x) k9 m
# n6 V( L) ^; ~* R9 o
yum -y 安装 wget/ B1 H3 J* j* q
现在,我们可以下载我们的安装程序:
* F9 |+ U1 `3 n7 U' i
" V. \2 L4 n, l5 v3 uwget https://raw.githubusercontent.co ... /linux/getmangos.sh1 ~6 L) J% f- e
设置允许执行它的权限:* b  c7 B! A8 i- b, M

, u9 b' m7 J/ z( d( S( i0 Schmod 700 getmangos.sh
, T2 x. Y& r+ q+ p并执行它:4 }! k  @" C+ \6 t6 Q
  k" f+ Q4 n4 X1 c$ h& T, `( v
./getmangos.sh
3 ?* F; W) b' ?: w! G在我们进一步讨论之前,对可用活动进行一些解释:
- ~/ u) O( _( {4 z; ]. P
. B4 g0 b* _) p" R- j* K. |6 e安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。
4 f: I# o5 ?. I- F1 O设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。( d9 g# j7 o% @* z# z
克隆源存储库将帮助您克隆Mangos源。默认切换。4 u1 S. z5 k2 ~5 k* g* B0 M3 ?+ X
Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。
0 s& F# f! q. O安装MaNGOS将帮助您安装MaNGOS。默认切换。
6 x0 C* Q& `: `2 k( m1 L$ h安装数据库将帮助您创建数据库模式。默认切换。6 `+ F7 M+ i# l( _: G, \3 r( ^
提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。* \+ @" B  z6 B4 r4 u
创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。) h) v( M# j) K9 x) C8 h
现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。9 w, k# I8 N# P0 c1 ~/ x
; v* B! `* [. q7 w
用户选择:
; G4 U6 Y1 b: Q8 i# e
$ ^2 a  @) x; N. [7 r5 K% G* B! zMangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。$ y8 S4 e  V$ o8 _6 p

" y) ~* g& T2 s如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。5 n! Z5 L( e9 {4 N

  x& i3 y# F  [5 u选择魔兽版本:+ M( ^) ]; v6 A# P

) D4 @$ A8 x8 {( s* [9 V下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。
& ]' p6 `9 m) y2 J4 ]* U' {" T& J8 w
源代码路径:; _* S3 l. s3 j3 v' `; V4 i) M
0 c5 o+ X/ s4 V( @. `
下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:! f# @; I5 O) _; q5 C. k* s
/ U4 s6 o; {5 d4 ]
/home/芒果/zero/src6 V9 [$ l; |  E# r2 H* m( |
如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。
- |( X; y: @9 k6 P0 N
6 @2 Q( G  w  }4 t8 \+ |, f8 Y安装路径:
% Q' x5 F/ Z7 i& R8 m! }1 }( t5 D; {8 a5 f/ R  N
下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:4 u* k5 u3 T6 d; P7 V
, }: ?8 P7 r! u" Y5 A" Y$ W
/home/芒果/零  E2 U: F  B( D, M3 T' F
如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。
9 [( T- \( h+ x- Y  K+ h6 O9 M6 E7 t% v8 i/ H% e
克隆或更新MaNGOS:9 v* i# T6 v. |& g
0 F5 Y% E2 V4 D( |
脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。$ j& T+ E/ G% A# c) D

1 ^, k+ t( l1 ~, `* C安装程序现在正在克隆服务器和数据库存储库。3 p4 I" F. k- i  J! E- l
. e) @' T) }, B; b1 \2 y
构建选项:# r. O- {7 S2 q$ @% v

! X" g  N7 F: S3 G, [" S& D您现在处于构建步骤。此屏幕上的一些解释:$ i* D2 c( y1 t. f& l

* R# F' U  b; M) VEnable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。6 C3 V5 b+ L/ n* [4 e1 Q
使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。
. s4 W' R1 z/ r, k, W* P$ M使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。
) M! ?* ]; r* K$ O使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2025-11-5 01:47 AM , Processed in 0.102576 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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