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

MangOs搭建魔兽世界私服

[复制链接]

991

主题

92

回帖

5万

积分

管理员

积分
55457
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!
# K( t2 w( m) i: N' ?: d考虑再三,我选择了CentOs来做游戏的服务端操作系统。
) I8 D9 q! J) e9 t6 ?  r通过Git获得Mangos的源码之后自行编译搭建服务器。( q- k6 m( J( ^+ R  U/ {# \* X
这么做处于几方面的考虑。* d& l6 v: U# E5 c" C7 i. Y7 m
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。2 x% @; B3 ^0 b4 n" ?' u
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
8 V0 A- d7 z, f% o+ U; P- S把该打的补丁都给打了(yum update)
; z% C/ j' i9 L  }完了之后,咱们安装一些基础的组件和环境。4 |( r1 {; G/ P( E
Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel; ~6 ?+ q5 ~% G5 p& O" Y7 ?5 n# y
如果有些组件提示没找到,无所谓。继续往下。
4 m) q: o2 K# R+ z我编译安装的第一个版本是cmangos。
, R- C* O7 y( O' W+ N/ M( N- E这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。' i$ l' V: d0 k
cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON/ J" }& b, A; `9 ]6 l( K
编译参数中:( ^& A0 K' h# w5 A6 Q* a# R
DCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。
$ k# r% A# B5 Q. O: J( LDBUILD_EXTRACTORS是指是否安装地图提取工具
7 C& J7 f- @5 E' ^( G$ e+ A/ rDBUILD_PLAYERBOT是指是否打开机器人
3 A8 d3 e# l6 u, E/ [1 b这里我做科普2:2 p, y( a& U0 ~. P: _
首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。2 X3 V# z9 u; o- `( g
既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。
# z' S- U- f: H1 b# M8 U6 J至于那个机器人吗?那是个笑话,请自行忽略。6 C9 l1 L; \+ m
我们继续,我把整理好的搭建步骤列一个明细:
% W8 e% j% k9 M" U
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。, J/ H6 h+ N  I0 g/ c# s2 ^$ o
这中间,我把一些别人不会告诉你的关键步骤做科普3:- g, W) v! j, P* m
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)
    4 i. E4 G/ H% \* M2 \
放几个链接仅做Mark:/ W; Z4 k+ k  T, ]3 w$ R4 N
Cmake3 安装1 T+ P! H9 G5 y
https://blog.csdn.net/weixin_38883338/article/details/86408749% d- Q! t4 ^4 N* H' |* n% l
Gcc 6
7 \1 w( L& O/ m8 \+ k5 Ghttps://blog.csdn.net/Al_xin/article/details/92438055& `, j. ~) v5 ^+ C# e; r* [
ACE6.3.3$ Z- @/ D7 j/ c# a" k  u5 l
https://blog.csdn.net/u010587274/article/details/509653693 T) _+ {( U; n0 ^
Git源码和数据库编译安装服务器
4 P) m! G0 F% {git clone git://github.com/cmangos/mangos-classic.git mangos
; d% |8 u" S4 Pgit clone git://github.com/cmangos/classic-db.git
0 u4 ]/ }# j3 J1 XACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
6 A2 I, s8 [! a* x我们来说一下服务器的配置。
+ P' B, k9 j- e; P) \在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:: v0 c) n. N& y6 K
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)% _9 {; O' J  r) v1 @& {
有几个关键点,我整理如下:8 O; V9 ~5 M) c; h
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。
    + F5 M. g: ~0 m" {. t' g
参数名称:4 h( {- f7 h2 P" I
地图目录6 B- }! l: V  I& J" Z
DataDir = “../data”
$ P. i9 w' C& g8 s日志目录
' y) k# f6 M; d* j- mLogsDir = “../logs”3 K& j+ t( _: O" b$ v7 m! I  D; ~8 q" M4 f
游戏欢迎语, U6 n" e- t# M
Motd= “游戏欢迎语”4 r1 C* \, ?, F8 |  }8 A" X  R
出生等级
  R) |7 z; b1 e' R+ C# UStartPlayerLevel = 1! p5 F) x: d# O5 }# j
出生携带金钱1000G
/ o0 }( S' j. H( [0 z3 xStartPlayerMoney = 10000000/ E8 j1 F! Y- T. N& C& L. ~
杀怪经验5倍# \; e, |; @2 y/ @# i( {
Rate.XP.Kill    = 5* ?$ y7 S; {" w
任务经验15倍
8 N2 s, T( d: s' `Rate.XP.Quest   = 15
5 S8 O9 e1 s3 A探索地图10倍
* w9 c/ |) k; S1 ^* H6 @Rate.XP.Explore = 101 n5 n3 G2 O$ y2 l% ]- ]& a# ]
数据库连接(应该有3-4条之多,按下面格式修改即可)) T1 d- P9 U' q6 s- X7 [  a
LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”( j* Q0 p/ |5 ~. T5 N
配置结束,就是启动。
+ X! S) J' k( V3 C1 K1 n因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。( F& s8 T8 u- C3 N
我们需要开启如下端口:
3 P7 \8 i/ X) ]$ A2 Z5 o7 L8085,9600,3724
& D' _& R, e2 K2 w把他们添加到你防火墙的白名单即可。
8 N6 ^* U+ R+ b& j& c3 n2 ?(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)
! F2 z- j2 V" o+ r2 T* ]) F一些收尾工作:! {5 l: F4 q6 }) Q+ K
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。+ [5 h+ q6 b* E- Q- g. Q- T% |3 j

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

server.zip

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

database.zip

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

ACE-6.4.7.tar.gz

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

ACE-6.3.3.tar.gz

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

cmake-3.0.0.tar.gz

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

rarlinux-x64-5.0.0.tar.gz

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

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
. ]- h1 ^7 z- X& I' n0 ?git clone https://github.com/mangostwo/server.git* n% R4 ?3 e4 g9 o' P
git clone https://github.com/mangostwo/database.git& O  q- k* l& [4 t7 I7 h

) r* c! f3 B! }. ]' o
  1. <div><span class="hl hl-1">wget</span> https://cmake.org/files/v3.0/cmake-3.0.0.tar.gz</div><div>tar xvf cmake-3.0.0.tar.gz && cd cmake-3.0.0/</div><div>./<span class="hl hl-1">bootstrap</span></div><div>gmake</div><div>gmake install</div><div>/usr/local/bin/cmake --version</div><div>yum remove cmake -y</div><div>ln -s /usr/local/bin/cmake /usr/bin/</div><div>cmake --version</div>
复制代码
  1. yum -y install centos-release-scl  I  q& B' u8 `
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils5 H% t* D& E) {0 L1 G0 i' m
  3. scl enable devtoolset-7 bash3 e1 s! j" L% z; F) Z% O
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile2 {6 o4 e6 B$ H" a" }
  5. # 查看安装的包
    $ ^0 v$ J) P) t; o
  6. scl -l
    # M$ r8 B% n" c
  7. yum -y install rh-python35# e! @/ H& v* Y0 j& L9 V/ L
  8. scl enable rh-python35 bash8 a% a1 t, U0 q+ r$ F' ^
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    - b# z: G+ ~7 B

  10. - z7 e% h& H; I& x; U6 n. g
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz# \2 i2 z9 c, [% _8 B1 s1 [5 u- E
  2. tar -xvf ACE-6.3.3.tar.gz
    , a) W) p% J0 q: X6 N; t
  3. vi /etc/profile$ b/ o- r- L8 z7 Y
  4. #在文本尾部添加:% V9 n9 y' N3 g1 v% I% D8 z9 m
  5. export ACE_ROOT=/root/ACE_wrappers
    ( M/ @& a/ @. p6 q% g& r
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    ( Y3 b2 i1 y' L3 W& A
  7. vi /root/ACE_wrappers/ace/config.h
    + x/ \& M* h5 @( s
  8. #写入如下内容:  i' s+ T. A* y% a+ N+ J# j
  9. <code>#include "ace/config-linux.h"
    - C8 C4 `0 L* D: v, `+ ?8 R# d
  10. </code>. B4 o  c/ F* \# ^  M7 c
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU
    - V0 l0 _' K0 \
  12. 写入如下内容:8 J. T6 T! @9 h: k2 o: B
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>  p9 O4 C6 y7 c( A& b: s6 ?
  14. <code>INSTALL_PREFIX = /usr/local</code>
    ; m; @7 b7 o2 l5 P# G# |& F

  15. 8 Q5 \6 c- ^. T
  16. chmod 775 -R /root/ACE_wrappers( S# N6 i2 u( r# o! L
  17. cd /root/ACE_wrappers/6 e7 v( z& s: T
  18. make% M( o7 c5 E0 e, K! Q
  19. make install/ l8 L& E2 K$ W3 i+ ~7 F1 m( X
复制代码
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 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
    6 M- k) z/ @+ J% P
  2. ###############################################################################
    5 Z$ R' c/ E" a! S
  3. # MaNGOS Build Automation Script                                              #! N; m$ j5 p! m: m
  4. # Written By: Ryan Ashley                                                     #, \/ H! b$ F- ]
  5. # Updated By: Cedric Servais                                                  #* v# y! R' t$ [; Q
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #9 E! U1 M3 s, s$ o1 p! e3 [5 I
  7. #                                                                             #5 o9 o6 e/ l3 h6 Q7 o
  8. # This program is free software; you can redistribute it and/or modify        #
    ( Y, _/ |  U# M4 b6 u7 n
  9. # it under the terms of the GNU General Public License as published by        #
    ( r1 o3 u' X% `" O& J% k' K
  10. # the Free Software Foundation; either version 2 of the License, or           #
    6 c( z  T( G& f
  11. # (at your option) any later version.                                         #
    , T) s' d$ ?; H0 A7 |5 E% o2 q
  12. #                                                                             #5 Z6 f0 x1 ]5 p" t" H# Z
  13. # This program is distributed in the hope that it will be useful,             #
    1 z* ?$ q) s8 w8 S
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
    / Z: m! T( N1 _! W: i1 \' f; a
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #
    4 W: B0 k+ l1 A! T" r% o
  16. # GNU General Public License for more details.                                #
    1 L% Y" l) T; S5 g. K
  17. #                                                                             #
    : i5 {3 N6 f: N' S. Y) o
  18. # You should have received a copy of the GNU General Public License           #& \( M( X, e: N, j
  19. # along with this program; if not, write to the Free Software                 #
    6 D& w  r8 u+ P
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #
    : I8 o2 Q# b. [8 f1 O4 r! E
  21. ###############################################################################
    . C2 v) S- R3 a4 v2 [6 F) M
  22. ( l" l. S3 L! h2 l9 g
  23. # Global variables- E9 T" e% V/ a2 B/ M
  24. DLGAPP="whiptail"% c* s; ~1 i: l5 ^; V$ Z
  25. VERSION="2"4 R% l: i3 {; ~2 Z% J( m  n
  26. ROOTPATH="$HOME"2 I: x: Q9 p; @; m8 h( T( a8 M# e
  27. SRCPATH="$HOME/mangos/src"
    $ z! K% U1 m" c* V/ s% @2 p7 q1 r
  28. INSTPATH="$HOME/mangos"
    7 r1 f: J5 e3 g7 X3 v: A9 A
  29. DB_PREFIX="two"  S# S7 Z. Z9 p
  30. USER="mangos"
    2 }/ a7 d0 K( b# ^
  31. P_SOAP="0"
    9 `% H4 I- ]5 W  k
  32. P_DEBUG="0"" b& v$ Z8 V7 Z$ N* A; T: P6 ~; w
  33. P_STD_MALLOC="1"; S0 x' \2 q" v, N
  34. P_ACE_EXTERNAL="1"
    ! b. D# a1 ^4 U+ p) W/ C
  35. P_PGRESQL="0"
    + L' \! h/ u$ n; _- w* z+ T
  36. P_TOOLS="0"
    1 e. w1 F* P2 k* ?( H. C# b
  37. P_SD3="1"
    $ P7 r9 e9 z3 }# [) A, x# E, [
  38. P_ELUNA="1"5 x5 p3 T% z3 Y/ P" H* n& R! Z+ x
  39. P_BOTS="0"4 v' q5 L9 L1 o: ~  [
  40. CMAKE_CMD="cmake"3 l- n3 _0 m% T: o) k) T& t( u! q
  41. + P8 v, W/ l2 `. ^3 d( Z; o$ v) H" g+ f

  42. - L8 v7 b+ G# I% S8 `& ]) z6 c' n: \
  43. function UseCmake3()
    & n  X& g6 l" u" l5 \
  44. {
    % q9 X% G7 T) Z1 G, }3 z! Z
  45.     # set the command to cmake3 if its there
    : N7 {' C9 `2 N2 j% c) m' C
  46.     which cmake3; E% q: `' S' |6 Q; F
  47.     if [ $? -eq 0 ]; then  J1 D5 w: D% s2 r% K: {  b# ^
  48.         CMAKE_CMD="cmake3"
    : h( J3 `+ v! M
  49.     fi$ D+ x9 W/ N4 v5 n  ~
  50. }
    * ]0 I* c/ J% u2 U! L5 [* y! a
  51. ! x! ^6 a% {/ W; N. R2 o" f; a
  52. # Function to test for dialog
    1 k: S- T9 @" @) A/ Y7 `
  53. function UseDialog()
    6 s1 s0 I. u6 D. n0 h
  54. {
    - S. ^" S9 U! x" U) k
  55.   # Search for dialog( R! g5 O3 |$ m9 N8 J
  56.   which dialog' z, z) }, I" k) d2 y8 _

  57. # Q$ F' f2 R  ?: n
  58.   # See if dialog was found4 ~  _3 B1 w% Q8 O
  59.   if [ $? -eq 0 ]; then1 y6 M7 v& g4 Z" V( {
  60.     DLGAPP="dialog"6 w1 z: O" ?  B" C/ C! R" P- T( A4 w
  61.   fi; ]+ v; p) x6 l: D5 P
  62. }
    $ s# G3 P5 u4 R" q* |5 L+ N% j  e

  63. $ z! W  y2 P/ q+ Y
  64. # Function to test if the user is root or not! S" J) {  k# n& P2 X, u4 G
  65. function CheckRoot()& n- t" \$ w6 J4 n0 ^. w1 K" I
  66. {, ^* q9 M$ o5 M# S' j7 E
  67.   if [ "$(id -u)" != "0" ]; then
    * e+ f4 c: m, w, q
  68.       Log "This script can only be used as root!" 1
    - m9 x; `: {+ Y( |9 v+ p9 a6 ?
  69.       exit 1
    ! u7 H9 B* y( M& v" S' g! s
  70.   else# g. B6 J% m' T1 k" ~, D! [* Q: H  Q
  71.       Log "User is root, check passed" 02 n. T  h  M4 ]0 R- F4 b. ]7 }& U; e$ ]
  72.   fi
    5 f' l- @+ q) N& ]0 o! b4 {) G
  73. }8 U1 Y5 M* Q7 H, y

  74. " t- R. x. z! F5 Z; \  f# [  l
  75. # Function to detect the repos( L* w2 D( D$ _: R/ l2 ~# U
  76. function DetectLocalRepo()
    7 N; W+ o' e' Z, D# k5 N
  77. {# p- {2 H" \& ?  F/ N1 M; l
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    5 {, ]  O5 Q1 }' T; n# L

  79. ; c- [: G/ [" O4 T
  80.   # First see if the Windows stuff is in place
    ) d$ t5 [$ X. B8 R
  81.   if [ ! -d ../win ]; then+ q: h& A0 Q7 {
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0
      o8 |3 h+ o( H4 G
  83.     return 0' h: L  c: N9 L0 s9 y  @! z6 [
  84.   fi
    3 ?$ p8 B! i( F5 u" C
  85. % s- i& L! r3 ^( w8 l
  86.   # See if the sources dircetory exists2 f8 k# a  p. S3 h$ U7 W
  87.   if [ ! -d ../src ]; then
    3 i: v" Q- s; q. B
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 06 c" ~$ Z( p: q* I+ p5 ]
  89.     return 0  W/ \# t3 `0 B0 M0 I6 `' c  [
  90.   fi! L! D( Q  {7 C6 b9 {5 A) D/ @
  91. 6 H- Y0 F, o- A& E4 N
  92.   # Check for the CMake directory
    1 M$ ~7 A% N5 H
  93.   if [ ! -d ../cmake ]; then8 a) `, m1 K' E8 @7 w, T3 h1 J
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 02 H9 C8 C) B) W* c
  95.     return 03 O' N% q, f! H9 p' o& P
  96.   fi
    5 ?+ q: L' k6 E3 Z! ~

  97. 9 l8 G' o5 ?" c, ?6 n  k! O
  98.   # Set the default paths based on the current location
    9 S" L6 y. s- j) f. ?! j: L
  99.   SRCPATH=$( dirname $CUR_DIR )9 Q3 J3 D# r2 G4 [/ X
  100.   SRCPATH=$( dirname $SRCPATH )
    ! N5 @! y" c% l3 [+ L5 P9 R
  101. 4 s' k. y/ G( l8 P
  102.   # Log the detected path
    * I) z. f2 d; J0 {' F
  103.   Log "Detected cloned repository in $SRCPATH" 0
    2 k' W+ X  M2 W% O; Y
  104. }. c: w/ }7 x8 f

  105. $ |2 m0 p  E% C! Q

  106. 6 `4 G) M0 G) _% v. Z) v  ]

  107. 2 e* ?7 w+ a0 y1 k- N6 z$ @
  108. # Function to log results/ b; u! k6 p  G- w" t4 P
  109. function Log()
    # i! F& u* T$ o4 }& `; }
  110. {9 r9 g4 B, o3 n( ^* |3 U, P/ |6 V
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )
    ; B3 W+ V& f# G# i

  112. / ?! A% I; ^8 i! E8 m3 Y! m
  113.   # Check the number of parameters+ [; d  ~" L2 c1 L+ @* F
  114.   if [ $# -ne 2 ]; then2 R& \0 Z& \0 G
  115.     echo "Logging usage: Log <message> <echo flag>"5 ]9 F  p8 O# w+ u9 o
  116.     return 14 L1 E( J& h' |* e, V# i5 f
  117.   fi
    8 K0 b. s2 k& S8 Z: j  k

  118. 2 \' ^' c# S- l3 C+ i8 d
  119.   # Echo to the console if requested
    / ~/ c$ g& T% v
  120.   if [ $2 -eq 1 ]; then; W9 J7 T3 r2 ^
  121.     echo "$1". P9 X- P" c2 x. a7 J
  122.   fi
      l0 a9 q+ r% q' R2 F

  123. , e4 V# A4 Y4 k! z4 A
  124.   # Append the string to the log
    3 @8 W: ~2 o" T
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log. w# n6 L! S' [! T( c
  126. }4 Z" g& e! g8 E; Z9 c5 U8 J

  127. * Q/ C/ g4 p/ P8 k1 H

  128. $ n* M) n# m  M$ M& [

  129. 6 Y6 a: U5 j: R0 g2 i
  130. # Function to install prerequisite libraries
    2 }1 X7 K. J! v0 j! O) w
  131. function GetPrerequisites()
    : w0 ?8 [: |' r1 Y
  132. {- Y+ t( P( u) x: i1 f. l* A/ o
  133.   # First, we need to check the installer.
    $ v0 l, i  J- o8 {: x/ t' s0 F6 K7 O
  134.   installer=0- Y4 z' J4 V1 V( e* m
  135. $ `7 {1 G0 K+ C, t
  136.   which apt-get% S! ~2 h8 [+ P# {4 ~7 |  C
  137. ; D& a* o, n/ r
  138.   if [ $? -ne 0 ]; then( {7 M+ k, \. O7 U5 \
  139.     Log "apt-get isn't the installer by default" 1
    3 M7 b0 j2 n. D; o. X8 t
  140.   else
    ( ~; B; U- t1 y
  141.     installer=1
    . b. x: y+ C2 E) X1 s1 v
  142.   # On a fresh OS boot (EC2) libace was not found without first updating 7 r$ {2 `& O3 v& C2 J4 o
  143.     apt-get update -y && apt-get -y install git lsb-release curl
    - {( h/ s; M% B  a, @
  144.   fi
    9 t' `9 Y  j" H$ p) }6 y8 A/ b- Y

  145. & D! |" Q' {3 O2 m. {
  146.   which yum
    # q9 G% z0 W& Y! O* T
  147. . C6 M" T% j1 s3 H, \
  148.   if [ $? -ne 0 ]; then" N' N0 j  ]' Q
  149.     Log "yum isn't the installer by default" 1
    . t/ d) _+ z. g
  150.   else) A' ]; z! ~: P% X
  151.     installer=1
    + z; Z+ _* f' Y* _
  152.     yum -y install git redhat-lsb curl
    . a' I. a' \! n7 a* z
  153.   fi7 z0 F: v& ~# O7 |* h2 v* r- ?. j

  154. + C/ v2 ?/ E0 H  n; N+ C. J
  155.   which aptitude* G7 S' F- {; O( ?7 H; ?
  156.   if [ $? -ne 0 ]; then
    / S4 K* B* G5 @0 ~: K4 e+ T
  157.     Log "aptitude isn't the installer by default" 1
    $ s) Q( k0 S- J2 R4 H! p6 S* P
  158.   else
    3 l' W5 m( ~5 L/ Y& i1 U
  159.     installer=1! I" S7 s/ t, h
  160.     aptitude -y install git lsb-release curl1 u8 x: E- {" Z8 Q8 z% U
  161.   fi
    7 b4 M. G5 }- j/ N
  162. * G" z$ x) `% i: D
  163.   # Then, let's check that we have the necessary tools to define the OS version." N1 g7 W# D2 [& Q9 O8 T* q3 }, i
  164.   which lsb_release4 \4 ?# ?& \3 N8 o- r3 Z
  165. . c; E2 G7 Y4 N) L$ r, q
  166.   if [ $? -ne 0 ]; then: o6 |% W. A; a
  167.     Log "Cannot define your OS distribution and version." 11 ^0 k9 ]% t% a0 Q) s6 P) U
  168.     return 0- |! a1 M; R' n$ p
  169.   fi+ d8 A. A3 I& l5 M% g0 u
  170. 5 Q4 R2 M! i5 a% ?  G9 g
  171.   local OS=$(lsb_release -si)
    / `' E- `! S) a
  172.   local VER=$(lsb_release -sc)/ `3 d9 @% S+ H: }+ V# S& l
  173.   local OS_VER=1$ r6 |6 r  H0 X$ U

  174. 3 v! c& Q  |( N' N0 o
  175.   # Ask the user to continue: R7 O1 \  d1 F, f- u# X
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \0 j3 H& x$ u) G2 O* P
  177.     --yesno "Would you like to install the required build and development packages?" 8 60/ @% i) I* O. z' `: |' ]

  178. ! J1 i8 q: k* N) P* O" ^
  179.   # Check the user's response2 N9 p1 ?* C6 c0 u. R! k; h
  180.   if [ $? -ne 0 ]; then
    + K  h8 J! C7 Y0 K: M' M  d6 f2 [
  181.     Log "User declined to install required tools and development libraries." 14 l7 a  z) Q) r9 j6 e. v
  182.     return 0
    4 g+ g" i6 D; V% N# t
  183.   fi
    3 _, U- d6 Y5 \! D9 C
  184.   {2 ?( Z2 n  G& s; N
  185.   # Inform the user of the need for root access$ @6 V5 d$ x% g  u: [3 W
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \) h9 S4 _1 M# G3 [
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 608 n5 Y& s/ i. R+ B* h3 E$ V4 Z
  188. + v, ^) \# T  c
  189.   # Check the user's response
    : p, a. H+ Y3 m# Y- H) t) O1 V9 B
  190.   if [ $? -ne 0 ]; then$ p: Q/ N+ y' J
  191.     Log "User declined to proved root access for package installation." 1/ m  }- k( x0 }/ p5 G
  192.     return 0
    + Z1 m# a1 u2 G+ A
  193.   fi0 w4 {! S: z  b- K1 ]3 z8 X( e( e

  194. 1 y$ ]0 M+ L" a$ A( G
  195.   # Handle OS
    6 g/ }0 [2 k* _) i2 H- m( X5 a
  196.   case ${OS} in7 v9 K& b% ]  Y; ]
  197.     "LinuxMint")
    ' X# Q8 s7 K& [" t4 @
  198.       case ${VER} in
    0 `; j0 i. B* o2 n
  199.         "sarah")
    & w, {6 y( M. y6 y  Y8 h; E1 i
  200.           # Linux Mint 18 - Ubuntu Xenial based: V1 l- ~" m" ~' ]' B, s1 v- _% N/ u$ q
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root2 H: T; b& C6 v4 b2 S4 Y* D
  202.           ;;
    ; }3 T$ A0 @" d( P. g
  203.         "rosa")5 F) l  c! I; p2 Y/ r* h
  204.           # Linux Mint 17.3 - Ubuntu Trusty based
    ! I( i0 h7 W1 B' V/ z
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root9 h. Y9 O7 \. C% X  z8 W1 q
  206.           ;;5 S! `- [5 }0 a- s: J
  207.         "rafaela")
      h4 v9 [5 [4 o  C2 N$ P3 [
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    2 W% w9 K5 Q* c
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root1 u$ Q7 |( H6 [' K! x& Y3 [- ]
  210.           ;;
    $ X/ ?% G3 @. \6 x
  211.         "rebecca")
    0 q8 B! L1 @5 Z" y
  212.           # Linux Mint 17.1 - Ubuntu Trusty based5 E) q- r3 v3 w& W# q
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    + j* x( N3 S! M
  214.           ;;
    # G) g7 d7 N4 ?' u) a: s
  215.         "qiana")
    % N& c  o! C$ ~& `3 h
  216.           # Linux Mint 17 - Ubuntu Trusty based
    / N# w" U+ w2 b
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root7 i: @, S% u% m5 q. B4 R
  218.           ;;' b. E$ S$ h9 b; D
  219.         "maya"). H! J  [+ p8 p
  220.           # Linux Mint 13 - Ubuntu Precise based
    - P1 N% w- N& x" g% N; A4 i' Q
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    ; ^5 F, o1 q/ }( m
  222.           ;;* Q6 [* f  H  k4 Y0 n
  223.         "betsy")* i- C, Z: s) u& C* Y
  224.           # LMDE 2 - Debian Jessie based1 j8 D. {' P$ W. a5 H. I* r9 W
  225.           su -c "aptitude -y install build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev libace-6.2.8 libssl-dev libmysqlclient-dev libtool zliblg-dev" root
    9 p9 x. i% ]1 ?" L
  226.           ;;
    8 ?/ `1 o3 J6 k' B# l8 H4 i: g) r
  227.         *)
    6 g- E, i) E2 Y2 q3 i- U. c
  228.           OS_VER=0$ ]( r9 y) E: h7 w
  229.           ;;1 _8 e8 O, |3 }$ f5 @
  230.       esac
    ) O1 \0 ?- ?" K! n6 j; o
  231.       ;;
    * T% |' G9 A6 N$ A  V4 B" [
  232.     "Ubuntu")) I6 I& U% U7 Z1 V1 c
  233.       case ${VER} in
    3 c! g6 n. w2 G
  234.         "precise")
    ! q- B' |3 A, L. o. U9 i& _; }
  235.           # Ubuntu 12.04 LTS
    6 G& c, X2 {5 b
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ! ?6 K6 A+ X8 k% P4 r0 V6 \. m$ Y
  237.           ;;* d, h" j' R3 w6 _5 H, z& e# U
  238.         "trusty")& V1 V5 O9 I& _3 E0 n1 x' P/ y
  239.           # Ubuntu 14.04 LTS' B1 z) f* Z, M/ _9 @
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root/ c& x9 A7 s; U; [
  241.           ;;* l7 c5 ?" W" G  t) F
  242.         "xenial")
    / E' F. K/ l: l+ B4 D: l8 s
  243.           # Ubuntu 16.04 LTS; O0 C7 _% E* U
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    # ~% G1 _( E* E+ r
  245.           ;;
    & w* b' K! q7 _: N; G
  246.         "yakkety")
      L9 g" G% v& p
  247.           # Ubuntu 16.10  R' g! Y  v4 N2 J, B2 r' ?/ S
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    + B* c& s7 S  G. v$ h, o  y
  249.           ;;- ^9 I3 t1 `5 _
  250.     "zesty")
    % f0 d; p9 G1 H7 p( W8 C
  251.       # Ubuntu 17.047 ?$ v7 `# y9 O1 P( _
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root$ w) i9 g' R% B( K. e
  253.       ;;
    2 C( P" a' G. {& U; p
  254.     "artful")9 D* @8 d( e, U$ T3 }% T
  255.       # Ubuntu 17.10
    ' J- i* q& j, p
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    * ]9 s8 r, M, f
  257.       ;;* @  z% |0 v' g0 Q( K) q
  258.     "bionic")- c$ S& j; d! b- @' X0 B
  259.       # Ubuntu 18.04 LTS: A2 V& C' T0 N! W: i; p
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root+ P, p3 a1 @7 b# v' R+ f( U1 `
  261.       ;;
    3 |" F# ?. Q: X) F' n
  262.     "disco")
    ) U4 K5 N" t( B/ X% G
  263.       # Ubuntu 19.04  s3 E) d( f, f! z# A- K3 P, A
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root: [/ n! ^: k: i' c5 O
  265.       ;;: y3 g" Z# E- }
  266.     "focal")9 T1 `1 c5 I% I3 @+ t
  267.       # Ubuntu 20.042 s' a* ]) S6 \7 z) J
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root/ f; E% [2 c  w. j$ ]$ Q" q& [
  269.       ;;- f4 X# {" y) u: m: C6 f
  270.         *)
    9 a: x& Q6 }  Y3 Z# p, x
  271.           OS_VER=0
      V+ z; ]5 s! V3 S6 N# W& x& ]
  272.           ;;! }$ ^% _* Y  x- ^1 a
  273.       esac6 }; X* |' i2 \9 V5 z/ o8 E
  274.       ;;
    ! b' U& J$ e' I3 U
  275.     "Debian")  f" [$ |: q& s* [  E$ Y  _! J
  276.       case ${VER} in
    ' Q0 i& o; l# a: j: c9 n2 @
  277.         "jessie")
    3 _5 N0 c9 Z2 z: k- t/ @2 w
  278.           # Debian 8.0 "current"% X7 k% c6 \7 s+ j
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    ( h% N" \7 w5 b1 F& u
  280.           ;;( {- I" U, y. e7 M4 _5 S
  281.         "stretch")
    " N% Z! Q. o; G: X( v
  282.           # Debian Next
    - m# ^$ {; E9 _7 F2 Y" p  Z7 m
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root; b- L3 T8 v5 l4 p0 k
  284.           ;;9 s3 L3 j1 |7 T! V' d" @
  285.         *)
    5 m% |( k% S6 h2 q
  286.           OS_VER=0
    ( V1 \1 q6 K# b2 y) q* E
  287.           ;;& A! U, {0 `+ v, n* t, X" z
  288.       esac' z; w! h; F$ M1 ]
  289.       ;;
    1 n) E5 s( U8 R' \' p- _: O  u
  290.     "RedHatEntrepriseServer")
    : h+ G8 j' t' n) ?( ~
  291.       case ${VER} in
    ' K! g+ I) q2 Z; U  c" w  s
  292.         "santiago")
    & o9 f; @3 F' J2 N; U& C, n. G
  293.           # Red Hat 6.x* Z1 f2 N: f1 a9 c( z
  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
    8 x: O9 ]! ]% A+ E) m
  295.           ;;. ~" ^  s# U% R+ [5 }
  296.         "maipo")
    , S  m$ ^- S8 h$ [
  297.           # Red Hat 7.x3 H2 H5 t4 {, |, i
  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( T3 T0 ]- v& [" s
  299.           ;;, r# K2 s+ L7 O$ j+ Y6 o6 N* a6 w
  300.         *)
    ' O0 o; P' D' G" I0 @# d
  301.           OS_VER=07 Z* `0 u/ {# {. O+ d
  302.           ;;
    ) M$ K- W4 B- e# A2 @/ M
  303.       esac
    ' D4 x: a* Z  ]. L' k
  304.       ;;: Z" K9 h9 J0 r1 U. v6 [
  305.     "CentOS")
    - U. |) c3 G6 I
  306.       case ${VER} in
    " ]  b! H) f. N/ d. P
  307.         "Core")" a: V  E# f4 V( @; z, d7 D
  308.           # Default CentOS - Adding necessary RPM third-party.
    ; G, w% u" b. t) k
  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
    5 n+ m' d* e! c$ ?5 |# ~
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm
    6 o: N8 a' u" |6 p  Q. F1 W1 C
  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.rpm9 X5 v/ l7 a+ K: ~
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm
    / ?( ]# w6 w* w. D! X1 Q; x4 ^6 _
  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.rpm8 q4 t7 H: t6 j  T; |# _
  314.           su -c "yum -y install epel-release"! I9 t  @7 W6 O; R+ s, n
  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" root4 L% y* _3 o) d+ m3 G
  316.           ;;
    & w; `8 W0 {+ R% M- W+ P1 A
  317.         *)
    : C- g8 d# }1 n7 w' _9 B
  318.           OS_VER=0
    ! r& C3 F# Q/ H, z3 D" o
  319.           ;;6 C/ U+ X- v6 G, k
  320.       esac
    # w9 `' D) }! D$ X
  321.       ;;
    5 d! S3 v. O1 Z6 v" w
  322.     "Fedora")
    8 ]5 k1 o4 N: z6 D# _
  323.       case ${VER} in
    9 n; ^5 r7 G* U: {1 @5 w
  324.         "TwentyFive")
    . l! y" \* w3 u; @+ A, z1 ]% z' D
  325.           # Fedora 25 - Adding necessary RPM third-party.
    " N" X5 ]' N3 k7 |3 S' E
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root
    0 j. D  e& v) ~: W! s
  327.           # Getting and building ACE. Not provided in RPM for Fedora...3 B" o) c; N8 G& m
  328.           rm -rf ACE-6.3.3.tar.bz2
    4 U* r; _9 y) ]3 u! S( I6 @) A
  329.           rm -rf ACE_wrappers7 k# M/ h6 p4 {
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2
    $ l, n6 i" m) @, Q+ R$ k
  331.           tar xjvf ACE-6.3.3.tar.bz2
    : c3 T3 ^" C7 P; u6 M
  332.           export ACE_ROOT=/root/ACE_wrappers
    - l& W# ^( A* b0 B9 U2 N/ K
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h/ d$ x* y8 @7 Z! O3 d
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    ( V4 d/ g0 L) _3 _8 c; Y0 ]) d6 f9 C
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU& M& k, M1 r" H( a
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    1 D: u' E' U4 Y
  337.           CD $ACE_ROOT0 z- [! u4 G- s8 d6 F/ \4 e- D8 F
  338.           make$ d8 G) d- k: s2 q( d
  339.           make install
    # g) k. i9 Z0 C: z3 V, v
  340.           cd ~1 f. z' C& Q4 I& p
  341.           # Installing remaining dependencies..9 B2 g' Y6 ^7 w* S. c/ l7 z3 }8 u# m
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    3 B) ?, x' Q1 f5 x. ]* }
  343.           ;;7 _" R/ j2 |2 z2 h
  344.         *)
    % J6 D' L1 L2 \5 B: p6 y' @
  345.           OS_VER=08 t6 W) H) D! h% @/ [
  346.           ;;5 N% g# m1 M0 n7 [
  347.       esac6 t" Q0 w' C  v) l9 ]8 q, g
  348.       ;;
    ; I8 `" X7 O5 ^6 M5 a' k, j/ P! i4 w
  349.     *)
    ' }4 M! S2 R8 i; Z: o
  350.       OS_VER=0
    7 l4 V) o% }' T) x# [! I
  351.       ;;4 F" ^3 P% c3 o
  352.   esac# F+ f" x& d; v" f3 H

  353. % T5 \0 V& z8 K0 o- f3 N6 L% ]
  354.   # See if a supported OS was detected7 E# K) D+ d* ]
  355.   if [ ${OS_VER} -ne 0 ]; then0 o7 o2 V, c# f7 N( t% j
  356.     # Log success
    . I( h. U: y8 M- i/ |' d% g
  357.     Log "The development tools and libraries have been installed!" 1: x  v- h/ i8 x- w
  358.   else
    ! ^. R: @. ?2 U8 ]8 ?
  359.     # Note the error
    " Y& J/ u9 G2 R  O- S0 X, g
  360.     Log "Could not identify the current OS. Nothing was installed." 1  G# M5 w# V, _5 k6 m: J
  361.   fi
    1 ], e* h1 B# W
  362. }8 t5 N% V6 W. X0 y) _

  363. / P4 I, R, Y# l( z7 x) R
  364. ; G9 H0 {+ `7 f

  365. $ `7 M% Q! m( {0 \, F6 k! D
  366. # Function to get the WoW version
    & |, ^9 z+ ]% \1 o/ h7 f/ B$ D0 Z. P
  367. function GetRelease()' s% {6 r7 y1 p5 S8 n
  368. {
    0 g4 H: _5 h, O$ e% [2 j
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    . F; Y4 u+ a- a4 [( ?: A7 L) E
  370.     --menu "Select a version of WoW" 0 0 5 \6 B" [0 S- s! U' p. \) g
  371.     0 "Original Release (Vanilla)" \
    , ^# x! T6 r% D. i2 g8 l, U
  372.     1 "The Burning Crusade" \! r) {; e7 K, V. d; I; f
  373.     2 "Wrath of The Lich King" \- T- G( D* Q* g) S( H; f( J* j. {1 r* b
  374.     3 "Cataclysm" \9 W0 x' u  I* E6 O# K# Q4 |
  375.     4 "Mists of Pandaria" \5 ^$ V8 B6 c2 l: ~# B6 F
  376.     5 "Warlords of Draenor" \" j7 l6 @6 g, p% V4 P
  377.     3>&2 2>&1 1>&3)3 [  W) o9 h6 k3 [
  378. . h+ R/ _$ e8 y3 q* i
  379.   # Exit if cancelled
    / @8 F$ b' V; y
  380.   if [ $? -ne 0 ]; then
    . q" {& e3 Z1 g! \
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1( }" {" Y% A* B$ [1 [1 ^+ U
  382.     exit 03 a1 o+ ^3 o0 p+ h7 t
  383.   fi
    6 e5 R2 i! K7 C# |/ y! y

  384. 7 n2 x7 @5 P  ]! S
  385.   # Set some defaults based on the release
    " S0 \# c( ]4 P6 n
  386.   case "$VERSION" in
    2 O1 |- ]: R. I+ ]6 N
  387.     0)  p4 m+ `1 K6 X
  388.       SRCPATH="$ROOTPATH/zero/src"7 s, d- O' E2 o; @; N
  389.       INSTPATH="$ROOTPATH/zero"
    . c+ I  S( o) U
  390.       DB_PREFIX="zero"" U' i5 i( @/ T4 I$ Z
  391.       ;;
    5 j5 F" t( F1 b0 V0 g( C# d
  392. 0 v/ Z0 G4 A  ~% v# [) q) T# x2 g
  393.     1)% X+ ?0 I3 e: o6 a* B6 u- j
  394.       SRCPATH="$ROOTPATH/one/src") m9 N" x) T9 ?/ v
  395.       INSTPATH="$ROOTPATH/one"" U/ E8 V; g) }/ J$ G
  396.       DB_PREFIX="one"8 D' R* n; i+ y6 c2 p, T
  397.       ;;
    * W0 p# p& C  W: S$ p" `$ c

  398. . J; \6 U1 \3 T! @; H
  399.     2)- E4 w. W1 C% w+ ]
  400.       SRCPATH="$ROOTPATH/two/src"( u7 ?' Z' A8 G3 N7 ^, B  _
  401.       INSTPATH="$ROOTPATH/two"
    3 }# f% h" m8 F  F5 R
  402.       DB_PREFIX="two"
    . s/ s6 o" \# c6 P0 `
  403.       ;;" l, f/ ^( `, a) p! R1 Y

  404. 4 \5 N: w$ S1 f% \: E
  405.     3): j  K& [; z" n! I) M
  406.       SRCPATH="$ROOTPATH/three/src"
    5 J/ p, n% Q0 Z9 t- o9 z- z
  407.       INSTPATH="$ROOTPATH/three"2 r" e+ C5 O7 {" v6 X0 c& l1 H- G
  408.       DB_PREFIX="three"1 U7 T, u3 v$ W6 T3 j
  409.       ;;
    ; x- ~7 O4 a% V- \5 e9 {
  410. 8 C! {9 Z$ P# @+ P; r
  411.     4)3 ?: }, B, o  M8 R8 W1 t
  412.       SRCPATH="$ROOTPATH/four/src"
    ( K. ?( p1 F! P7 k2 N5 D3 L
  413.       INSTPATH="$ROOTPATH/four"- x+ {% _' `2 c5 l* Q
  414.       DB_PREFIX="four"+ C6 G7 i; y5 o5 n, r
  415.       ;;
    " [3 x* I# \4 g
  416.     5)
    % I) U" _& O5 O
  417.       SRCPATH="$ROOTPATH/five/src"
    + g6 m& z0 k9 {* g4 ?, H% s; ?
  418.       INSTPATH="$ROOTPATH/five"
    . O. i/ ^9 F; C* Z
  419.       DB_PREFIX="five") P) q( C5 Z5 z2 v5 p
  420.       ;;
    9 n2 f8 U; `9 d7 I, R1 p
  421.     *)
    4 Q# e; V4 x$ |$ O8 J
  422.       Log "Error: Unknown version selected!" 1  m( v. W$ C% b" E0 M
  423.       exit 1- X; P! n5 f. B$ \, Z
  424.       ;;
    8 S( u9 ]/ v/ e. ^7 J
  425.   esac- b* C" M3 X! l3 a1 M

  426. . D  W, C; Q, `1 I! z& N
  427.   # Now set the correct source path if the repo has been cloned already7 G9 U2 P6 J" G; ^
  428.   DetectLocalRepo
    4 ]1 ?% t4 u- |
  429. }
    6 y0 H6 T$ m8 B: F, d
  430. / q5 s" r, `4 X! H7 Q
  431. # Function to setup the technical user
    2 u) W7 O. l: X( R& g3 n/ ?
  432. function GetUser()
    * p0 h3 z1 q4 `7 Y5 Y
  433. {
      x( K) A6 M# J$ w& c& m; L& o, d
  434.   local TMPUSER="$USER"0 r# `2 _- ?$ v% u
  435. ; f# x5 S8 n" y5 l
  436.   # Set the user
    ; a! p* p& N. d
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \7 ]; x  \8 m& L) z: h& @# b
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)+ h, z8 W. P( ^0 e4 ~

  439. ) |" s" c- V# `; e; K8 _
  440.   # Exit if cancelled7 _9 d! m! r9 v$ X5 M4 w; \/ P
  441.   if [ $? -ne 0 ]; then
    2 |7 e3 }& ]8 M; ^( D) h+ H
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    ) V- p5 ^: S; g  a# |+ k' P4 ?  }
  443.     exit 0
    1 M; O; u1 `$ b# G5 Q! K
  444.   fi
    9 h+ C$ E( M4 ~4 i6 z
  445. $ T# ]# [' [6 O1 X# z& c
  446.   # Change the user only if it was modified
    . G& U+ u& B; \" d: J9 n( b1 U( Y
  447.   if [ ! -z "$TMPUSER" ]; then
    / m) U1 T8 c  e1 |# o4 c: r
  448.     USER="$TMPUSER"6 {5 P2 I3 K# s1 v: v3 A  W
  449.   fi
    + c" z9 B8 {. D3 g. J% q

  450. & ?( N5 |& E' R4 i# n
  451.   # Validate user9 T' h" t0 {. y
  452.   id $USER > /dev/null 2>&1
    5 e3 N9 X; ^" W  R4 k' r, B
  453.   if [ $? -ne 0 ]; then
    " A# q6 |- `( x( R: \
  454.     Log "Creating user: $USER" 1
    : D, T0 C2 T/ B9 w' o( Y
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
      g8 @/ {& T" h7 z

  456. : y6 L$ H8 A8 g1 l/ i- D
  457.     if [ $? -ne 0 ]; then1 A1 G- g, P, @0 B0 a6 H
  458.       Log "Error: Failed to create the specified user!" 16 D5 w3 X% @$ h8 j, C7 |
  459.       exit 1
    * N; O$ e8 L8 x# r
  460.     fi
    1 M1 H  k& m+ j. R; i
  461.   [! w( o0 Z7 ?; F
  462.         usermod -L $USER > /dev/null 2>&1% n: L, P- e2 y) J
  463.   else- `9 }1 S2 F' Q& f. j, a/ o( z6 x
  464.     # User already exist, asking to keep the user# w5 d$ s( `) V' A
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \& i2 e* m9 P- B4 X$ m
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60, z" C% e4 s6 V
  467. % t9 j" B0 B1 D5 ?" a( d
  468.     if [ $? -ne 0 ]; then* ]6 b3 }4 o9 S" e6 O( }
  469.       Log "Removing user: $USER" 1
    ' E9 w1 k( A" S$ s  N  f
  470.       userdel -r $USER > /dev/null 2>&1
    2 g- N, \3 k0 T7 V* G. W

  471. ) `, ~3 X; l$ n$ [9 y( |
  472.       Log "Creating user: $USER" 1
    + i6 @+ U& W& f' c
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&11 Y4 Q: i# N/ H- b! A/ J
  474. 1 U1 R' ~! Z% H! q. J5 ]
  475.       if [ $? -ne 0 ]; then
    3 S' S# |! ~) C1 Z5 E8 {
  476.         Log "Error: Failed to create the specified user!" 1
    ; Q9 q8 o/ _( k7 X7 j; z2 l, I' I! x
  477.         exit 13 f/ J8 N: N. [" I7 t
  478.       fi
    2 W- ]+ W4 f2 y; {
  479. 2 M- g; A, y4 y; ?
  480.           usermod -L $USER > /dev/null 2>&16 b- V8 V, R9 g' n; N
  481.     fi
    * ?4 C# h7 M( T" `0 N' ^5 V
  482.   fi5 g' @, `0 |' q9 B) ~8 R& E

  483. 1 L3 D/ F( X2 v$ [8 T
  484.   ROOTPATH="/home/"$USER
    + Q& U5 q5 v8 X' C% ~& a
  485.   Log "User: $USER" 0  k! `) T, W% n) [! G2 C+ f
  486. }
    5 C4 R% _1 S- e

  487. - C7 W& V1 q9 V! P- c
  488. # Function to get the source and installation paths
    : Z$ B- j% x) K6 g1 x" O6 Z
  489. function GetPaths()
    ! a/ y9 ?6 K- I. m( R' E5 }8 W
  490. {2 k1 v3 O3 |8 d' U% L; z" E$ A
  491.   local TMPPATH="$HOME"
      J8 `3 a% P5 h, H8 W% d7 {# {: R

  492. ) u% S( M. z* D6 V% g
  493.   # Set the source path! K; Y1 F0 i* X; U0 O) W
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \
    7 n0 U* {9 U: \
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)4 q/ k& b8 b/ S" Y2 A6 R' Y, C) A
  496. : Z6 @* a5 i! j$ e3 z) I- h, e
  497.   # Exit if cancelled+ \: W) W7 R8 M2 s$ _$ S1 U
  498.   if [ $? -ne 0 ]; then
      }* \, z) c+ h7 Z  k' M
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1
    - y# C. r' g6 y7 Z3 q
  500.     exit 0" n# O- k& }2 V' T- q% {
  501.   fi
    ' v/ O  N1 C( n8 A: Z8 l3 i

  502. 3 Q. F# X4 G6 F; W8 T
  503.   # Change the path only if it was modified
    9 P2 ^& G% N- |7 \0 q& }
  504.   if [ ! -z "$TMPPATH" ]; then
    & J# H& C. i1 _! @2 m5 W
  505.     SRCPATH="$TMPPATH"
    + L, o% N7 c' z8 c
  506.   fi
    : g# B' ?5 P  R0 {

  507. ( O! h/ T/ r5 B- C5 a
  508.   # Validate source path7 H( p% X" G+ \% a' ^
  509.   if [ ! -d "$SRCPATH" ]; then
    7 P+ c% p6 J( }5 t" \' D
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    3 }+ c; G5 U8 Y' \  x! u4 F
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 605 t3 @% U  m' Z/ A
  512. ; c3 Y9 o) m! e7 e
  513.     if [ $? -eq 0 ]; then  }; r8 l1 s+ k; Y) I) Y
  514.       Log "Creating source path: $SRCPATH" 1
    + B0 r( _6 i( ]5 W: i2 o
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    5 G3 w$ a$ N: {' ~4 o- X

  516. # b0 z: T" ?4 I) s+ `* {% e$ Z% A
  517.       # Check to see if the directory was created, t, G+ D- {  h0 s! |' G" y1 ^
  518.       if [ $? -ne 0 ]; then- o4 H4 N+ a+ q4 t7 d$ W1 P% O
  519.         Log "Error: Failed to create the specified source-code directory!" 18 p+ G% d8 _) _) e; R
  520.         exit 1
    * T( J- _( H1 @6 O
  521.       fi: r4 a4 J% k4 G2 T
  522.     else
    . K& Q+ l( Q# V. n
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1; w  a* k8 d( s8 c3 E9 r) W
  524.       exit 0& C- o) `! ]; d, a( s' ]. E5 j0 J
  525.     fi
    : e! ]( A" @/ R3 U) l, R8 |
  526.   else& k& p* e# ]6 y; I) k! B7 W/ O/ \" B
  527.     # Check for old sources6 t- `4 d: v( o3 r1 C( x$ D
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then9 C# u1 q/ i. z
  529.       # Ask to remove the old sources
    ) R; h+ q8 \# G6 g# d5 V
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    * o$ \  O# j+ n! D4 C! \, y
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60
    8 L6 ]! s0 h0 h
  532. * v2 @5 v' `1 _" c! a
  533.       # Remove the old sources if requested
    - F" V$ y0 ^, D+ G% d- U
  534.       if [ $? -eq 0 ]; then( ~( B2 E4 g! O  y, X( a
  535.         Log "Removing old sources from: $SRCPATH/*" 1! R2 V( x9 Y* S8 H' b( o" ~
  536.         rm -rf $SRCPATH/*
    : w) r% y8 r$ T9 t
  537. 7 x- S5 t( m9 U2 c6 M6 |* i  b
  538.         # Check for removal failure
    & @8 y, k& [# v7 t: H" m. \+ |
  539.         if [ $? -ne 0 ]; then
    1 _+ N  i. c4 g7 f- h8 w
  540.           Log "Error: Failed to remove old sources!" 13 v$ z4 T5 z7 Q% _
  541.           exit 1& J: r  f8 s+ i7 I* J. I  m
  542.         fi
    * G3 H! \2 A& b
  543.       fi/ O3 @$ c; N; W5 N0 n4 E
  544.     fi! s" ]0 S# ~% t7 v0 \. X' E
  545.   fi
    : o+ m+ T. D9 \" t  X# f7 F& U- P( q
  546. 9 H& A, d, v4 V0 W
  547.   # Set the installation path
    : x3 ~( v  T2 C3 p' k  i' o8 h$ ?9 P
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \# g3 j5 F$ R; w' X& d$ o0 @1 I
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    % d4 ]/ `- [9 ?9 O- c, h

  550. " ~" ?- f8 R: e- j) s
  551.   # Exit if cancelled% j- [) e, s$ z" N
  552.   if [ $? -ne 0 ]; then
    1 I, s9 u* L) g4 ~/ Y, `% V& q9 M
  553.     Log "Install path selection cancelled. Only the source path has been created." 1
    2 ^+ ~7 l" }6 X# a. c
  554.     exit 0) a! |1 u5 }: C4 Q7 @
  555.   fi
    % y" P2 J' F/ S$ I; o& X
  556. 9 E7 q; w6 Y0 w/ G  T) p$ E, d$ `9 P
  557.   # Change the path only if it was modified
    ' ~% k0 I. b8 s2 s) J8 J
  558.   if [ ! -z "$TMPPATH" ]; then
    % K' ?3 ]# @* j5 l9 G
  559.     INSTPATH="$TMPPATH"
    ! I; k+ S9 c4 l- x' X
  560.   fi. z% M9 }1 x% [. O/ K

  561. ) b! q5 r) [9 S3 i
  562.   # Validate install path2 j5 s6 r- U; F6 Y" s) N* X. ]
  563.   if [ ! -d "$INSTPATH" ]; then
    5 x6 O- g  Q  x5 p0 L
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    * \7 E+ m8 d2 D/ |: S  H
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 608 K& Q; L/ e; |& Q- P: I

  566. . `( a: C0 L; T5 h+ r
  567.     if [ $? -eq 0 ];then
    4 k! S! {7 D, V* @* ?5 a4 W
  568.       Log "Creating install path: $INSTPATH" 1
    ! d9 \0 w# k3 K. E/ k
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
    : i9 w+ `% o: Q
  570. & T  P$ R' t/ y1 P4 T
  571.       # Check to see if the directory was created
    1 X. D% t; a1 `0 |5 c
  572.       if [ $? -ne 0 ]; then3 i: C* [. z3 c; X2 P# o( M0 s- j
  573.         Log "Error: Failed to create the specified installation directory!" 1  ~2 l! T4 P1 [8 j( T
  574.         exit 1
    ' _2 N0 `$ p4 v! }( n& `$ |
  575.       fi
    * J, {" K( a: c0 C1 L' g* H+ d! K
  576.     else, \' L; u( r) c' Y: ^0 `% e
  577.       Log "Install path creation cancelled. Only the source path has been created."; i2 X9 M8 I7 P0 ^8 Z7 V6 `
  578.       exit 0
    9 n7 r$ t* h  U4 h. {
  579.     fi
    3 C1 D; N" ~  f" c$ P$ j
  580.   else3 L. N: i9 N& `9 p0 ^
  581.     # Check for an old installation( j6 m: ?* u6 e7 G- a
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then/ g5 R6 }- q+ E; t1 g& E7 P

  583. $ |0 j! _3 J: z7 l: N- y; E; ~" v. {
  584.       # Ask to remove the old installation
    ! t' A& ]/ [  P1 B/ F; S
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \2 O& r3 \" J* H2 ^6 }+ w$ j
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 0+ h4 h1 R+ F; I$ @4 W" K$ h

  587. - c: n' ^6 h& ~1 h0 i% l
  588.       # Check the user's response
    ) u( k! R! v( x
  589.       if [ $? -eq 0 ]; then
    " L" x5 j7 w: a" \6 z
  590.         Log "Removing old MaNGOS installation..." 1; s7 j; D+ e# ^# R1 p* e

  591. # A# |+ t( }9 Q; h4 r
  592.         # Clean up the binaries% p( S. q( D' e% @$ K$ G) R
  593.         if [ -d "$INSTPATH/bin" ]; then
    & J' \6 \& A% A& t
  594.           rm -rf $INSTPATH/bin
    - b) T6 _0 c5 O& L3 @$ `  }
  595.         fi
    ! G/ |" _& U5 o' h
  596. / @" p7 C/ J/ U
  597.         # Clean up the old includes' U. R" U- l  U2 ]* v) E  S4 ~
  598.         if [ -d "$INSTPATH/include" ]; then- i' Z. p/ G8 c0 k7 q  H: T
  599.           rm -rf $INSTPATH/include
    + }8 {+ F/ s, X- B. q. L
  600.         fi: X7 E' f( T0 e+ q

  601. ) h5 W0 F5 }. Q* ^" d. ]1 A& h
  602.         # Clean up the library files6 N3 Q, @5 u6 d  N; ?% q  A
  603.         if [ -d "$INSTPATH/lib" ]; then$ U* ~, |- I" A$ h
  604.           rm -rf $INSTPATH/lib
    " k& q9 v! w9 n- u5 `
  605.         fi
    - Y* E& }6 L5 W4 I. Q
  606. , w9 P, n% C" P/ [' }. N
  607.         # Clean up the old logs6 m  R4 h5 r; C$ K
  608.         if [ -d "$INSTPATH/logs" ]; then
    + l) `% w/ r1 i+ D
  609.           rm -rf $INSTPATH/logs/*
    1 p4 c7 i; j3 K& d3 G! E- x: }7 i
  610.         fi) U6 l2 Y9 _+ V- S7 `
  611.       fi
    2 z1 R0 P4 h) L7 n" ?. x. v, W
  612.     fi
    # }! |# E5 C& \8 r. ]1 I
  613.   fi2 A9 `$ P; M0 u% F  ^, O: z  z
  614.   U. C! V8 Z' C
  615.   # Log the settings
    / g5 c2 U8 e! w  f
  616.   Log "Install path: $INSTPATH" 0
    & j/ {( p5 ^% ]. w  w1 W8 V- |' X
  617.   Log "Source path: $SRCPATH" 0
    4 }" O4 g' N) Z2 {6 B6 I7 i/ q
  618. }* B9 q) V( `* s, l" @  ?* V
  619. ) }1 ~0 f, E$ j$ a) a
  620. * q4 f) f  o6 t+ ^0 s1 ^' {: @
  621.   h9 O; A/ g8 M
  622. # Function to clone or update sources
    % c8 x- V4 Y. Y* H
  623. function GetMangos()
    2 k! T1 O9 b3 ?) ~2 G! a* |
  624. {5 {; v! E; E4 M5 y( b
  625.   local CLONE="0"
    : N) V# ~, \4 `
  626.   local BRANCH=""
    2 \* a9 d( N- y( I: g# R. R

  627. 9 f  P, A" i9 W0 h+ g) c- ^; i
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \& t, F: t0 `( I# d/ L
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \" j( X. _" {- Q! F8 E. V2 q8 u7 A
  630.     0 "Clone a fresh copy of MaNGOS" \' i: p' Q3 r7 l6 e* `4 j
  631.     1 "Update your existing copy of MaNGOS" \
    / q# K5 u9 q. k; e* H
  632.     2 "Use existing copy" \; _: C  C& X3 J( e: ^2 P' g
  633.     3>&2 2>&1 1>&3)4 f) h& K, u. `+ _9 D, K: g" a
  634. 7 ?' _) t% o) }  i/ {
  635.   # Exit if cancelled
    $ S# _+ N1 b! I3 R3 J6 ^6 y4 r! x
  636.   if [ $? -ne 0 ]; then
    ) p* |# c& K% p" O+ s8 {
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1/ a( c7 f5 ~! }- e
  638.     exit 0; h2 i2 Q1 y! \0 n4 q  ~& l
  639.   fi
    : t# ^- t& n' A# w$ d, e8 i
  640. 4 F- E7 l$ |* W5 \
  641.   # Clone from scratch if selected
    ( v, }5 I+ h) {7 F2 v
  642.   if [[ $CLONE = *0* ]]; then+ ~5 b* S/ y3 R9 g
  643.     # Pull a different branch?
    ' N4 P( b7 \& |
  644.     case "$VERSION" in) g3 T, j. c% @( X" |2 ]
  645.       0)
    " G! M. |8 R! w/ [& U" _
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')* W& ]0 H% M, z( s0 D2 v
  647.         ;;1 A3 H" Y/ X  n) S, b. `# V0 E
  648.       1)8 T2 v; K$ I4 W+ M6 j3 h
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')+ I0 v/ n. O* i1 N
  650.         ;;" b6 Z( q7 X  ]
  651.       2)
    8 `7 _. N- s+ C" @
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' '); u8 j" v3 k( @; b% C$ G# l) g  j
  653.         ;;
    ! s9 x) B# {3 ?6 r' X( x7 ^
  654.       3)
    $ w  q2 @' Y  L+ n4 w- D1 [9 C0 c
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')! j9 Y  |3 g* t3 W& X& x: W
  656.         ;;
    - Z" h( L5 x) p9 d4 I/ S4 \
  657.       4)
    * {4 f4 \$ R7 k3 a# R  X& a0 W
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    4 s+ n" ^9 D* I! V
  659.         ;;" Z# `2 V/ C* F
  660.       *)
      \/ U1 K( m/ N& H/ O
  661.         Log "Error: Unknown version to select branch" 1
    5 _7 g. L# @/ l' O- W
  662.         ;;
    - d# ]# j3 w' W' h
  663.     esac
    + H! c+ s) g' p
  664. - G+ P, Q% C' K
  665.     COUNTER=12 z1 T6 e$ r& o& w& z
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog
    # W9 e, d0 r  ~4 d/ k- h0 b0 M: g
  667.     for i in $releases; do
    5 h0 Y/ w0 I7 I" Q# e. V& z3 W
  668.       if [ $COUNTER -eq 1 ]; then9 w2 {; v* v8 L5 ?( I% }3 G2 x
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "
    . E: k* O" }" f% Z) u5 ~
  670.         BRANCH=$i
    * H8 n7 n8 h% ^) M$ e' K% |# r
  671.       else
    9 ?! m# }! S  l9 z; S: ]+ C" {/ j
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "9 R- `0 `( O7 }8 b1 d* l
  673.       fi8 ]+ @# W" [7 ^/ _" {2 d, `% O" L: A
  674.       let COUNTER=COUNTER+1* @) m2 }3 d7 ^* Y' L( p& y' q& q
  675.     done
    6 z! C$ R& A+ c6 k$ w" i" I

  676. 3 H2 R1 k6 {4 F2 ~% m1 D
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \( u4 t6 Y7 z3 W8 [! k9 b
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    3 n" u( i* E, w
  679.       $RADIOLIST \
      }8 Y9 e3 M# `$ \+ _
  680.       3>&2 2>&1 1>&3)! U% x7 k7 r( g3 P
  681. - ~0 L$ m2 d- k1 l
  682.     # Exit if cancelled
    % L* O8 u  v' Y# m, _
  683.     if [ $? -ne 0 ]; then5 x2 O2 h6 ~0 h
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1
    . |/ U# ^1 w# v9 n* ]/ e# H
  685.       exit 0
    4 r; _  w$ y& g: I7 ?
  686.     fi
    $ q8 b6 s3 _. z1 r

  687. ' a+ n5 C  m- ~* ~( M
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')5 @# l1 X: o" \( b0 G: Z

  689. 6 l1 C7 ]8 i+ e  F( P
  690.     # Set the branch7 Q  r5 ^" K/ a- U! K
  691.     if [ -z "$BRANCH" ]; then
    + U  X; h* G* V8 k0 |
  692.       BRANCH="$releases | awk '{print $1}'"+ r6 ~) g* f: m; X: R" j; b. f7 d
  693.     fi
    + p2 z0 P& m7 }7 [! W+ J
  694. 1 o; a7 }( T0 j+ H
  695.     # Clone the selected version, E+ w! |$ C/ m. \  G$ Z2 |2 f) S1 S
  696.     case "$VERSION" in
    ( I4 @7 j' e$ ?( k% L: p5 ]% }+ q& {
  697.       0)8 K3 `& o! P% S6 F" @! Y! |
  698.         Log "Cloning Zero branch: $BRANCH" 1
    $ p& f! M* u8 A: g  l
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive+ O( r2 x$ J7 u. j% P9 y6 X% d( B
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive
    0 v" L0 q0 B9 R3 F6 [* L0 o
  701.         ;;5 h1 _- D) d& d/ `+ u. E1 e& D, s

  702. 4 s/ \" S; L/ f. U$ I
  703.       1)
    ( R6 |6 ]' [6 ]* ^1 o  x, o9 }+ v
  704.         Log "Cloning One branch: $BRANCH" 1
    ' b* H) u7 a+ G3 X$ g% e
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive
    6 v+ H0 W7 T5 b! g
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive
      I% d% H9 A8 t! }: P4 B
  707.         ;;; d* W8 I9 \1 x4 S

  708. , m" b$ }" y6 r5 y6 T4 w
  709.       2)
    ; E. S: g% I# r! w7 h% C
  710.         Log "Cloning Two branch: $BRANCH" 1
    2 V# O- V* L& b7 A$ @0 L' R- S& d
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive. D4 Q& _- Y: R8 ?. J7 _. E5 ]
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive
    8 V! H  c" d" W! g
  713.         ;;
    ( z6 g$ s* @; z4 o
  714. : i* f2 K1 k$ W- s% k0 v
  715.       3)4 i* D. I0 x7 |
  716.         Log "Cloning Three branch: $BRANCH" 14 O. a3 H' U9 p. n) ^4 m
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    # c3 J" h# h. {6 }6 N# B
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive; o4 l1 k6 @# j9 y
  719.         ;;
    . R+ h( V& h' {( \3 Q4 \
  720. 6 n) L1 `3 }/ w9 I% j( h; ]4 L
  721.       4), K7 u8 G& b; e' x5 F3 w+ M( K
  722.         Log "Cloning Four branch: $BRANCH" 1
    2 V" G% j6 t) h2 P* n0 U
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive
    : z3 x6 L2 Q% \8 D7 A
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive, u9 P) C0 h& O) t
  725.         ;;
    6 Q; D0 H; x7 \4 N" B" E
  726. 4 m+ ^$ t; t9 H, ?$ S: r; M
  727.       *)
    ! ]5 n+ P# t" [5 {
  728.         Log "Error: Unknown release selected for cloning!" 1
    / K/ j+ @* E$ L4 {5 ]
  729.         exit 1
    1 x$ k  [* U; u
  730.         ;;
    ! O# T4 R+ t# Z- d0 ^. c
  731.     esac) V" o. y/ }$ s

  732. 4 R* Y! V. t- W% E
  733.     # Log success# _' X% {- N" R+ g" \2 H: c3 d
  734.     Log "Cloned the selected repository!" 1
    & G) ]4 A. @" O+ W2 Z; A
  735.   fi! o1 E1 m6 [; Z" Z: A# x+ v
  736. 7 Q8 `* e( u* ~4 {9 V  Q
  737.   # Update the local repositories if selected
    6 j8 R5 l. u# x2 e8 N* j
  738.   if [[ $CLONE = *1* ]]; then; v7 j% G4 _2 l& G3 N
  739.     Log "Updating your local repository..." 1
    : R+ Y+ i' [8 K- V9 `7 }) B, j

  740. ! y/ g4 U$ i/ c6 S5 e5 V
  741.     # Update the core sources% Z- m9 C- r) z$ C  Q4 C/ R4 Y0 m
  742.     cd "$SRCPATH/server"
    8 Z8 B" O1 i8 g( ^# `5 Y  d
  743.     git pull
    2 W' R5 n& Y/ O$ P( m; V
  744. ; q$ e  G0 r/ I: S
  745.     # Now update the database sources
    7 _; |5 R8 Z  B& f3 E
  746.     cd "$SRCPATH/database"& S% E3 e" Y: G
  747.     git pull
    % T3 _. \# _$ ?* n& Q9 j  q
  748. 2 j4 r" c& m$ ?* ?6 s4 v
  749.     # Log success
    . E5 D" c- v2 f" t+ Q8 f7 N1 U
  750.     Log "Updated the local respository!" 1. u6 `/ ?2 ~  {& h* G$ E; _
  751.   fi
    5 w4 K3 F0 N* d4 }7 N
  752. 5 y' t3 _" T- k: g# u% ?2 v7 S
  753.   # use existing repository
    2 R' j2 F8 I  J7 O) n  a
  754.   if [[ $CLONE = *2* ]]; then
    ! e# G4 }/ |( A' a* h: l' x
  755.     Log "Using existing local repository" 1
    $ m+ S0 Z! i+ `7 r4 O
  756.   fi
    2 ~# [) _' F% P' N
  757. }
    , l$ l! U' `) {  F

  758. : E: {( q4 n, l; s. n' o

  759. $ o. K3 U- ]! m. J; E
  760. ' \6 ~7 h" `" K5 R' s
  761. # Function to set the build options# M* T8 l( W9 u1 S6 K6 V6 _! G% D
  762. function GetBuildOptions()
    ) M- x* g' c& a1 x4 l1 n
  763. {2 X3 E7 |: J5 P9 i9 @/ j- m) M+ I
  764.   # Select build options3 G+ \& U3 F" m% G0 P
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \' C/ K* T! x! @/ b, w- S; E
  766.     --title "Build Options" \& Q& Q  y  K% \" w+ E' O1 C
  767.     --checklist "Please select your build options" 0 56 7 \
    ! O0 p. W, p) w
  768.     1 "Enable Debug" Off \7 R  [6 l# U4 w* U8 i
  769.     2 "Use Standard Malloc" On \
    # ~' [5 ^9 e0 r$ q  T
  770.     3 "Use External ACE Libraries" On \4 K& T) M9 l' n% G! l) i
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    % z: f- D) _% A# @
  772.     5 "Build Client Tools" On \3 {5 r* R* K. n; K# T
  773.     6 "Use SD3" On \% f* F3 i' A4 X8 y1 p* f
  774.     7 "Use Eluna" On \
    4 E5 X0 P: K5 H  @4 c' m0 S& s
  775.     8 "Use SOAP" Off \0 ]$ G1 Z# ^$ J) `/ F) y
  776.     9 "Use Player Bots AI" Off \
    5 e6 V, \8 d) D; I9 h
  777.     3>&2 2>&1 1>&3)
    1 l1 C8 v: d" i" ^
  778. ; {" u/ {$ Q% ^! b3 y
  779.   if [ $? -ne 0 ]; then( x1 R; W1 ^$ `5 s, W! J
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    * J) V1 m# N- ]+ d' E3 @( q, F  c
  781.     return 0
    ; s9 ?6 t% V7 j  ~2 ?; A9 u' ?
  782.   fi
    4 Y" x. A' y* u1 }0 r5 l) x

  783. ) q4 D% D  Y; |/ e5 a
  784.   # See if debug was selected
    ; W" |' E3 d% h! I+ Y: L/ g
  785.   if [[ $OPTIONS == *1* ]]; then
    5 C# h- m3 s# Y1 M+ F0 H8 q# D% c' s8 b
  786.     P_DEBUG="1"0 @2 S" c  H% D2 Q
  787.   else* ?: N6 Z; I6 e$ V" p
  788.     P_DEBUG="0"
    . i* p, n- G5 h( e% F
  789.   fi
    % r/ B' S. @+ T! H# U, p

  790. & I% Z& z. R) V" A" M
  791.   # See if standard malloc was selected  X; D4 q: \) l6 h; S: S+ q
  792.   if [[ $OPTIONS == *2* ]]; then# t- F2 T5 u; u. e' L
  793.     P_STD_MALLOC="1"8 z2 |- V! a9 n+ U0 f
  794.   else$ n' s0 {9 w+ U
  795.     P_STD_MALLOC="0"7 `* n1 k& z5 O% J, z* i& N
  796.   fi0 B; ?, E1 {3 r$ v( |) t4 q

  797. 9 M* K. C" m3 J' {4 A) V
  798.   # See if external ACE was selected
    & j% z/ i: Z) M# a
  799.   if [[ $OPTIONS == *3* ]]; then
    ! Z. x: l' k5 E% t6 s! }- \% Q  M
  800.     P_ACE_EXTERNAL="1"/ a7 S0 J+ x' a( X* @
  801.   else& e% ^* H7 o' F$ N& A1 C
  802.     P_ACE_EXTERNAL="0"' g* z! i9 a5 q. u  t% q: b% @
  803.   fi1 w" B2 Q' i) R3 U
  804. ; [8 a4 z+ G) b
  805.   # See if PostgreSQL was selected
    ! ]  o6 ~; M$ J( m! [) B7 s' ~7 P
  806.   if [[ $OPTIONS == *4* ]]; then
    4 p/ s: x" n4 U( G- \  l
  807.     P_PGRESQL="1"
    . _' d* U* N  t3 w
  808.   else
    ) V; R" F9 x6 t5 ]) b" _/ ^5 `; Q4 V
  809.     P_PGRESQL="0"8 c0 }! M( `, U! N0 U1 H7 X8 t
  810.   fi+ w8 X( o! K1 a7 }# Q" L! z' \) A

  811. / a. s& k  t2 h2 H* K. w5 R6 ?
  812.   # See if the client tools were selected( \5 P& B# a& Z, z8 T; G1 ]3 \
  813.   if [[ $OPTIONS == *5* ]]; then) ?  G4 J; G0 m# b. z5 I6 m/ p
  814.     P_TOOLS="1", k- m0 ]  h$ W1 s4 X: y: ?
  815.   else2 X1 H3 o7 L. s; a& V6 D
  816.     P_TOOLS="0"
      `& Z2 j6 L0 ?- W1 L7 Q7 s
  817.   fi1 w7 [* X0 N2 X
  818. 0 l" D6 \$ s: ~* z# I
  819.   # See if SD3 will be used
    ( v; B& M6 r1 t3 p2 Z& @/ w
  820.   if [[ $OPTIONS == *6* ]]; then
    $ @9 o: w* C: k3 b
  821.     P_SD3="1"
    6 \9 H" {7 t5 J
  822.   else; N# B9 A, H6 M8 X) Y
  823.     P_SD3="0") Z6 C) R7 z# w3 E& Z: z& e0 V5 u& [
  824.   fi9 C) r' {: [* D+ K

  825. 8 e  Y+ B+ \/ F) d) V0 H$ ]
  826.   # See if Eluna will be used$ E( j$ X$ b8 E$ F2 N- F& Z
  827.   if [[ $OPTIONS == *7* ]]; then
    . i! H, ]/ l4 q# v" A
  828.     P_ELUNA="1"1 d( `* A! b  U% U+ n4 u4 ?) ^
  829.   else9 V8 w" K. B2 W, d) k
  830.     P_ELUNA="0"4 v! e: @9 j7 T( ^
  831.   fi
    # x% Z4 K4 J; d& @
  832. 2 E$ n; i; n5 C0 L" A
  833.   # See if SOAP will be used- A; b$ c* r1 L$ f0 W2 |3 r2 R
  834.   if [[ $OPTIONS == *8* ]]; then% H  f" N* U+ R( S) Q
  835.     P_SOAP="1"
    1 c* R7 f* h; q4 D5 c, g" b
  836.   else  A6 i% T5 G. |: A
  837.     P_SOAP="0"
    . F) I1 O9 \. k: m: a
  838.   fi
    / L9 [( W2 K$ n; J  G

  839.   T1 O' L: K7 u. h0 x" |* t
  840.   if [[ $OPTIONS == *9* ]]; then! C' N5 F7 Z  R* n
  841.     P_BOTS="1"
    % g6 F6 h- y; H- @
  842.   else
    5 Z# E, A3 ]( @4 q6 c$ y
  843.     P_BOTS="0"% c3 c/ u8 p% _. B) m. V
  844.   fi
    . `: k4 j! [8 Q5 R6 V: L; ^
  845. % y! x+ T! Z) I5 N  O5 V; C
  846.   # Verify that at least one scripting library is enabled9 w& E8 Z  a: B  {% H: m
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then% D% c4 L7 ^! c1 P! a) t8 q1 t
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1
    2 A( k' ]* g4 a7 l5 G
  849.     exit 1
    , U' M1 D, s9 r% F( P
  850.   fi9 q, L5 V+ x$ N
  851. }4 y/ r' m5 P5 Z; C7 w- i) E* V4 n! u

  852. $ s- y- i, |1 ?. _; T

  853. " E# @9 y$ ]  Q9 S; W. Z
  854. 1 b% ]  K4 E+ q5 O9 ?) k
  855. # Function to build MaNGOS
    8 }+ Z! {0 K1 V3 M: Z
  856. function BuildMaNGOS()" [2 R' O9 M8 X! F  V* B
  857. {: e$ x1 s$ l6 y5 ~/ l% ~7 M
  858.   # Last chance to cancel building4 g5 H2 |" o& d- F) V  s
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \( r- d; ]% p8 e+ k) Q! G/ P
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60, h3 o, k" p5 s

  861. 1 w1 _+ [" Z/ {$ D7 j
  862.   # Check the user's answer
    ' Y' \. L4 o: c. \
  863.   if [ $? -ne 0 ]; then
    . [3 b9 U% W6 O+ W; d+ `
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    6 e1 f( q3 N9 k3 x+ F6 M, b
  865.     exit 02 z1 j6 l8 T% x
  866.   fi% x. ^. n" c! v! G: \
  867. 5 V& _3 i, O9 x/ w% n
  868.   # See if the build directory exists and clean up if possible: [' T8 ]8 A% [
  869.   if [ -d "$SRCPATH/server/linux" ]; then$ I  C/ [6 s6 u! A& S, m0 z& m
  870.     # See if a makefile exists and clean up
    - W, |7 {) I# t) T' P5 k
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then
    * K% G; P! C4 M7 S
  872.       Log "Cleaning the old build..." 1, d& P1 c2 [) d
  873.       cd "$SRCPATH/server/linux"
    - j! a0 i1 S5 H- w' c6 ~8 ~9 C% B1 r
  874.       make clean
    # O+ n3 t; O9 {$ E1 P% V
  875.     fi
    ! a' R$ h% B: \7 Q' B# S
  876.   fi
    + W# ?3 _  u& ?, c% t8 P: u
  877. 9 ]7 o- f. W8 L  l8 O
  878.   # Attempt to create the build directory if it doesn't exist
    # r+ n6 y9 z) g
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    & i8 M$ G- w8 r0 m
  880.     mkdir "$SRCPATH/server/linux"
    0 y8 ^4 o1 a; O/ y9 }# i% j. |
  881. " s+ {& Y! [- U  B
  882.     # See if creation was successful1 L2 N. u( f8 R' c  U- C% R
  883.     if [ $? -ne 0 ]; then
    2 h; f# |: C4 P/ U+ s
  884.       Log "Error: Failed to create the build directory!" 15 Y' P, h' ]9 E& `( m
  885.       exit 1
    ; X( S1 [" n0 L0 e! c$ w5 H* e
  886.     fi
    * d4 V9 ?/ H  ]  C
  887.   fi
    2 Z/ R1 E" Q7 v" u6 e  t; s
  888. % l! m% g' B% n; @2 G  u  c) [
  889.   # Attempt to configure and build MaNGOS
    5 L; B4 e0 Y0 {3 }# p& J+ V
  890.   Log "Building MaNGOS..." 0
    % T) D5 q! l8 F: C2 [
  891.   cd "$SRCPATH/server/linux"
      ^/ o( m# q6 `8 c: Q
  892.   # make sure we are using the cmake3
    2 ]7 z$ E! R5 A+ ~( r9 u2 @8 C8 q
  893.   UseCmake3
    4 b/ N% D+ O1 _" @, e3 j( v
  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"! k. O2 a; m0 k4 `* [  R
  895.   make
    / w$ O2 h7 R, V1 c# t) n8 ?. r
  896. 4 b( j4 ^8 U7 o2 a$ v4 T
  897.   # Check for an error
      D! s+ B+ U( w+ l, ~5 D! o& U/ `
  898.   if [ $? -ne 0 ]; then
    - V' ^/ A4 h$ m$ z
  899.     Log "There was an error building MaNGOS!" 1
    ! Y, T9 _' o. z: z4 A
  900.     exit 16 C+ F4 b* Z3 U6 t' I. w/ Q7 ]: R
  901.   fi
    1 |( ?9 U+ C6 e1 K5 u

  902. " J$ {% k  h) a: O* k; o' q: J& f
  903.   # Log success! F9 v  m2 U5 s$ d3 Y9 _2 D2 m4 k3 D
  904.   Log "MaNGOS has been built!" 0
    0 v  s, j$ F' G7 B: K
  905. }
    / \% @! v. t/ E" Q; r; q* n

  906. 6 `: m, e; Y* x( y/ q) p% f. A
  907. 2 j% L, A" z5 M0 Z0 A! i) J8 r, |

  908. . g* ^- b' T# {7 j
  909. # Function to install MaNGOS8 A/ W% @" @  K! o  s$ @8 P
  910. function InstallMaNGOS()
    ' n2 y7 m( ?: ~5 c. Z
  911. {1 F. p, I/ U3 s/ O- x7 o
  912.   # Ask to install now& q% D" T: y8 y/ \1 M7 I
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \6 ]1 q4 y! j2 h& O- q
  914.     --yesno "Do you want to install MaNGOS now?" 8 0
    - {$ r4 B6 N6 p) J

  915. " E2 S, w, f8 p5 a# q4 k6 `+ ~" N
  916.   # Return if no
    . q' Z# d3 g9 T6 w( U9 V- H
  917.   if [ $? -ne 0 ]; then
    . D; E2 _! b& W( f. Z1 P% c9 p+ @
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \! S1 o3 Y: ~9 _7 N
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60$ ]6 a" X" e6 H( h

  920. - v8 z9 _2 A, @1 c( e
  921.     Log "MaNGOS has not been installed after being built." 1
    $ }& l" j6 r6 \" j8 ~# Q6 g: \
  922.     exit 0
    + f# t8 x2 A" b! N
  923.   fi
    9 _8 \& R2 u/ {0 O( ~

  924. $ T# \  O" c4 p/ a7 ^$ U$ k' M
  925.   # Install MaNGOS4 Q! l" V1 F$ Z  x% ]; D; X
  926.   cd "$SRCPATH/server/linux"! Y7 R/ f/ R/ W$ \
  927.   make install* L6 I/ E. V1 `( ~, |$ ^( P
  928. - c7 L2 A: J* l
  929.   # Make sure the install succeeded+ O" [2 _9 z! m0 Z1 N6 e5 D
  930.   if [ $? -ne 0 ]; then
    . u+ W" g+ g& ]' N) _
  931.     Log "There was an error installing MaNGOS!" 1! i% c# ]. V. S
  932.     exit 1
    2 x9 z% {* Y# d
  933.   fi
    5 ~" I9 K- @6 P2 z% _
  934. }0 B2 Q& g: d+ W* h7 u; ?
  935. + b6 g. w/ `6 l
  936. # Function to apply database updates
    3 g( {$ a% L* t8 E+ s
  937. function UpdateDatabases()
    ! f- g2 K' D& V9 I8 u& S$ f+ b5 j
  938. {3 v1 T8 _6 }4 K9 U
  939.   local DB_HOST="$1"
    $ \8 z9 D, B, i0 W, J. O
  940.   local DB_TYPE="$2"7 Z% Y: k( d' E! p3 a
  941.   local DB_COMMAND="$3"; c1 d% g. t* I' }
  942.   local DB_USER="$4"' q( q4 `5 d" d9 z& C* J
  943.   local DB_UPW="$5"
    ; g' \0 u' O# T/ y/ ^2 m  v9 s
  944.   local DB_REALM="$6"7 F" W8 z9 Z5 L& u; O8 I+ b
  945.   local DB_WORLD="$7"$ |5 f5 A# J2 [5 c+ N, `
  946.   local DB_TOONS="$8"3 f6 X% b+ x0 ]* p' @! Y8 P

  947. ) A. r( H+ r) Z; V6 h2 q6 y2 D
  948.   # Loop through the character files
    5 m! a8 b2 w$ J+ B. c# F
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    $ L' c! j( m& U  M; C! q
  950.     if [ ! -f "$pFile" ]; then2 P2 ~2 I. [* j  A& n" d! C( O
  951.       continue
    9 y8 R8 u' a5 x1 `/ n$ A+ A
  952.     fi
    + d/ p3 G# u3 x, [$ v
  953.     # Attempt to apply the update% [& i/ h) I3 i. K" N4 I: [! C( P
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1
    9 b2 g* ]2 U1 _3 A

  955. ! ~: C6 N; ]7 _& }  Y
  956.     # Notify the user of which updates were and were not applied2 a/ k0 X2 q9 o
  957.     if [ $? -ne 0 ]; then
    * c1 F# b8 Z, ?
  958.        Log "Database update "$pFile" was not applied!" 0* C5 x. D6 }% Y% U! w
  959.        Log "Database update "$pFile" was not applied!" 1
    , F8 v' M8 d3 d2 N4 }, v8 u+ }
  960.     else
    7 H4 [* A" o: w4 B7 m
  961.        Log "Database update "$pFile" was successfully applied!" 0
    ! x7 R1 o4 V7 _* B) F4 V. }7 y
  962.        Log "Database update "$pFile" was successfully applied!" 1
    : B  L% @$ s( J* R# I& i% ~
  963.     fi
    5 T( x, ^+ m# u1 r; B4 F
  964.   done+ _! B( Q2 Q- h. k$ k
  965. 3 X4 p( f" Y9 q+ F9 G9 i$ w: J0 w
  966.   # Loop through the realm files' N' ~/ W2 Z* G
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    & ]% m* _3 C% n. O* [: B0 S
  968.     if [ ! -f "$pFile" ]; then& }# c# V) o4 t& @# M) v
  969.       continue5 N. f5 ?, G6 q: V8 \5 }
  970.     fi
    . [9 ~# Y; T+ q; _
  971.     # Attempt to apply the update
    " A' {+ v4 H: d# U. c4 J7 W5 `
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1  y9 @% S: V2 D. J. r3 S  k
  973. 1 `) k3 D' `# O, ]
  974.     # Notify the user of which updates were and were not applied6 H, L) x$ r2 U* H8 G" N6 x7 W* r
  975.     if [ $? -ne 0 ]; then
      l9 N. j. i7 g, Z
  976.       Log "Database update "$pFile" was not applied!" 0% h4 j% B) z/ c5 \
  977.       Log "Database update "$pFile" was not applied!" 1
    3 v/ f* z2 _" n6 e1 c. k, T
  978.     else
    1 D) K% k* l$ `* [! c( d& |+ o
  979.       Log "Database update "$pFile" was successfully applied!" 0
    3 H! J7 M! h2 T- g! o0 p+ K6 G0 ]
  980.       Log "Database update "$pFile" was successfully applied!" 1
    5 @4 r! O3 ~6 e- |. ]! E( Y, n
  981.     fi
    # v1 ?- S. c* R! F$ C% a! X
  982.   done$ @, I" T0 x7 F$ `2 y

  983. 0 u8 T1 B. N3 T6 ~9 k' q" {
  984.   # Loop through the world files
    6 n: z) h1 `( h- Q7 m
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    6 q. M4 Y' e# w- `  R4 b+ \; ]
  986.     if [ ! -f "$pFile" ]; then
    8 f( |) I7 j8 @) E. y5 U$ E
  987.       continue
    ; }( `) d" U% \' {$ H- Y. Y# R
  988.     fi
    / F) H  c6 V# {0 p
  989.     # Attempt to apply the update* c9 P1 F9 |1 D- ^# n) N
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    9 u  X, A2 C" J6 L4 z( ^
  991. 4 N& M8 V6 I6 B- B! {& }! c
  992.     # Notify the user of which updates were and were not applied
    ' F) g% u; {. S9 D& T9 p2 o
  993.     if [ $? -ne 0 ]; then6 A' k! |+ N* F' H! W/ ?1 |( B
  994.       Log "Database update "$pFile" was not applied!" 0
    3 e+ J# V* X% K6 I, l+ y: y8 l3 S0 h
  995.       Log "Database update "$pFile" was not applied!" 1+ |# ~' `. `3 ?. p# v8 q
  996.     else2 l, b. g* e6 ?
  997.       Log "Database update "$pFile" was successfully applied!" 0' ^6 P+ w& ?/ Y
  998.       Log "Database update "$pFile" was successfully applied!" 1
    + J6 S; ?- f2 @: S( [5 k' k; {7 }
  999.     fi% z- o* x$ X& H& ^$ q
  1000.   done& P. b$ p5 \7 R: z+ q4 B) y+ W
  1001. }. h; f9 L7 U3 m. Q& m" ?% g, E

  1002. 6 u  T- `- G0 w& ]
  1003. # Function to install or reinstall the databases
    3 e! p: D' @2 C4 j/ ?4 J" i5 h
  1004. function InstallDatabases()3 b7 b' z# B: F5 @' C# j4 q$ {
  1005. {
    9 H9 Z& R5 E0 w
  1006.   local DB_HOST="$1"
    : `5 l5 S' k, v8 j: B
  1007.   local DB_TYPE="$2"9 W; g9 `  O( L5 ^: T* s) `
  1008.   local DB_COMMAND="$3") \) y2 S. ^' p2 p, B; h
  1009.   local DB_USER="$4"! h% H0 ?4 g1 \6 |- l+ m
  1010.   local DB_UPW="$5": ~4 T! ~9 p: G7 v
  1011.   local DB_REALM="$6"
    . O1 A" j+ N! d# U
  1012.   local DB_WORLD="$7"+ e2 ?, t3 d! ?6 q4 n
  1013.   local DB_TOONS="$8"
    ( H3 }- A" o3 M3 P
  1014. 1 g! Y$ E( P+ F/ C" k+ j/ I/ s
  1015.   # First create the realm database structure
    0 f: W- ]- W; M1 y8 y. j
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql( f; @' m; Y" q

  1017. ) u- }' Z& I. W- o2 W
  1018.   # Check for success
    : w( E# l4 }5 t- @, v
  1019.   if [ $? -ne 0 ]; then0 A; j/ e/ W% o" E+ A. [& ~3 }) r
  1020.     Log "There was an error creating the realm database!" 1; e* a2 j/ A; E# o6 Z3 x( ^6 L2 a5 v
  1021.     return 1: t1 `' p, n5 O- Z
  1022.   else2 K. W8 H" {5 k8 o( K' {) E, i
  1023.     Log "The realm database has been created!" 1
    $ ]" x. |' P7 a7 H
  1024.   fi$ T0 `9 E7 g' {

  1025. ( Q4 S/ ?  |3 X  s" y  H
  1026.   # Now create the characters database structure: `, U, [/ r" X; U
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql% R, e1 V; D/ X
  1028. * W( M+ U  V3 i
  1029.   # Check for success3 ?! c8 |5 S0 r- J$ q7 m' Y  _  V; z
  1030.   if [ $? -ne 0 ]; then3 C: K9 n! _/ J# j! c" ^/ X
  1031.     Log "There was an error creating the characters database!" 1
    2 d, q2 l& Q# H# H2 z( T0 i
  1032.     return 1
    . m7 r/ \; I% [' U9 Y
  1033.   else
    . [+ W9 y- {  C! X
  1034.     Log "The characters database has been created!" 18 Y; j; s4 k% x; Y3 q) V0 \9 s" o
  1035.   fi) G  M6 N" i3 j9 x, T% S% {
  1036. % X, O: E: \  m& F8 k* E) l7 g  Y0 F
  1037.   # Next create the world database structure
    ( N: k* v8 V( g! Z
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql
    4 S$ F2 @/ P, A- F: K; p' `0 `
  1039. 8 i+ v, W) O8 `- T, n- {
  1040.   # Check for success
    $ z2 @' V, D7 P: O* m5 k
  1041.   if [ $? -ne 0 ]; then
    2 p4 c/ H2 K$ b- Z( ?* B% d( [
  1042.     Log "There was an error creating the world database!" 1
    0 a/ p# Q( H: P- C
  1043.     return 12 T# r3 G9 x* i$ z- a' C7 a
  1044.   else. y1 Q+ n2 g& o, O9 [
  1045.     Log "The world database has been created!" 19 A* J% z3 R' R9 N; ]8 q
  1046.   fi9 M6 c" |4 m$ |. k1 O) K  u5 X

  1047. $ h# Y) b9 y) n2 F% [' b1 N1 E# E
  1048.   # Finally, loop through and build the world database database
    ; _. w8 ?6 _5 G+ q: [% d7 W4 _
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    4 Q9 h) k# o; D5 l( X+ }3 X6 _
  1050.     # Attempt to execute the SQL file
      E. k' s# B) A' H% l/ I; R8 j
  1051.     $DB_COMMAND $DB_WORLD < $fFile+ P8 ?$ K4 |. d: z( X

  1052. 6 M5 [! Q. }! D! r" G
  1053.     # Check for success
    , Q: Q) L, e! I. e" a
  1054.     if [ $? -ne 0 ]; then* `0 R# m" R0 x) c3 G
  1055.       Log "There was an error processing "$fFile" during database creation!" 1. p, j8 c/ C3 z, A3 H% N3 S1 B
  1056.       return 1
    1 Q8 A4 U7 a" Y6 p& m( d2 t$ \
  1057.     else
    # G5 J+ d- Z+ h  H
  1058.       Log "The file "$fFile" was processed properly" 1
    : v  k+ d1 w0 q# r6 c  \) X
  1059.     fi; L6 w9 g2 e$ y8 J6 G7 P9 p
  1060.   done( @  z. a& g7 p; Z6 c
  1061.   F. N, `9 r( |. d
  1062.   # Now apply any updates0 x5 N  G7 X  k# F( Q/ I
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS+ X3 e7 v6 L' @5 E8 `" W7 R1 v! e
  1064. }/ M& O1 V" a% Z! H' T
  1065. ; [. v1 u+ @6 R1 i9 ~3 N
  1066. # Function to install or update the MySQL/MariaDB databases
    6 Q1 c/ H' [' ]" k& \
  1067. function HandleDatabases()( k- F! q( M: p
  1068. {, [6 N% U: Y  l0 z( v* m3 f
  1069.   local DBMODE="0"2 H* {9 K& S4 {" F2 l
  1070.   local DB_TYPE="0"( s8 L8 e: }+ C7 n  K  |1 R# ], h
  1071.   local DB_COMMAND=""
    3 x( X5 ?! J7 q0 `
  1072.   local DB_TMP="0"
    # C0 }' t3 O  V3 }$ B  H
  1073.   local DB_USER="mangos"
    & t5 [- j1 R4 N; K
  1074.   local DB_UPW="mangos"
    / N: z) q/ X  R* ~) M, X! c+ x
  1075.   local DB_HOST="localhost"4 o! Y4 ^% V9 P5 k
  1076.   local DB_PORT="3306"
    . A6 W" L6 t8 k* m5 m
  1077.   local DBSEL="3"! [; n7 V9 K" C8 ^  P' e, u* M
  1078.   local DB_REALM="_realm"
    , _, a; e1 n2 W1 _
  1079.   local DB_WORLD="_world"4 y0 r4 V/ Y5 f$ G
  1080.   local DB_TOONS="_characters"
    # M+ `' h* F# P) p
  1081. ' L- R$ o  P) }  v
  1082.   # Ask the user what to do here
    7 S% s9 M3 a4 j- z
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \& y# O7 @- h0 z2 p, F" w
  1084.     --menu "What would you like to do?" 0 0 3 \* s& _% U  c7 \  P, a
  1085.     0 "Install clean databases" \' ]/ R" M+ q$ g# E5 ~
  1086.     1 "Update existing databases" \- e2 C3 B$ ~, U7 e
  1087.     2 "Skip database work" \
    $ k  J3 @; n8 o% H; H
  1088.     3>&2 2>&1 1>&3)
    , r& B3 ^& S4 z) e+ H9 L

  1089. 1 q' |- R% g# c) t% I7 R: A9 y
  1090.   # Exit if cancelled) j8 f; O. m! V2 N
  1091.   if [ $? -ne 0 ]; then
    - L: @' w2 [- w5 F6 @% Z
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1! G; }2 \; X  K2 q8 M5 U2 _+ S# W
  1093.     return 02 t5 s! v% b& z
  1094.   fi
    4 x5 q' I2 p0 Q3 C$ o

  1095. 3 @- \* a; t& }: R6 Z* J; l$ c
  1096.   # Exit if skipping
    3 L9 }( K$ C5 Z3 b* D1 l; k9 N
  1097.   if [ "$DBMODE" = "2" ]; then9 l! Q8 Y$ C! e. A: p4 P" |
  1098.     Log "Skipping database work. Nothing has been modified." 1
    & k: q" L* h' q. r+ K+ i
  1099.     return 0, m# [5 D8 s2 U; B
  1100.   fi6 C3 ?2 \( M- c' t2 g' x/ v4 _

  1101. 0 h; N. |) n& @/ @
  1102.   # Ask the user the DB type! Y4 \" `% E% O% V
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \  X: n2 l9 Z4 E8 K
  1104.     --menu "Which database are you using?" 0 0 3 \  m$ J8 a& N3 H9 i8 ]
  1105.     0 "MariaDB" \4 B* L9 m, g9 ]; `' n# V
  1106.     1 "MySQL" \: e( F. i! c0 T- @) O. t
  1107.     2 "PostgreSQL" \
    / f2 M/ l% ^% P# i4 }
  1108.     3>&2 2>&1 1>&3), f6 M% a4 h4 R$ E- _  _
  1109. 1 R! m& }$ K' \$ N/ F
  1110.   # Exit if cancelled
    $ w2 l6 M1 E7 I  P
  1111.   if [ $? -ne 0 ]; then
    # W9 i, y1 M7 G0 @# J
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 1
    . T2 U  Y9 `, @0 e, F- [6 \
  1113.     return 0
    8 B( D0 A8 b/ O% }& r
  1114.   fi
    6 H- P+ \0 Q1 S6 Q
  1115. ! S7 p* ~! K8 L
  1116.   # Get the database hostname or IP address
    8 W& T& {1 g! l' `  J
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \5 s# G1 k/ z3 ~* S7 j  M1 y
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)
    / u- K2 b9 [4 c4 E& c6 N

  1119. 4 C! |; k# B  I, L; d- K- i, c
  1120.   # Exit if cancelled- Q, v3 F( D1 ?& }& q2 }% P
  1121.   if [ $? -ne 0 ]; then
    ; a! S2 Y2 o6 M3 l) K. h
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 13 y, \1 H) o! t% e  U$ n
  1123.     return 0
    8 h( g6 _  h# s) j. o$ @! I
  1124.   fi
    5 J( A7 i% I1 f4 D# A: C
  1125. ; B7 `. H; Z$ {  D
  1126.   # Set the hostname or IP address if one was specified& O4 d) O7 Y1 u+ D! z0 |# i/ h
  1127.   if [ ! -z "$DB_TMP" ]; then  G, a- U- `* Z
  1128.     DB_HOST="$DB_TMP"
    3 r  X" @2 g' v2 z' |
  1129.   fi* Q  u" U7 k" d: U" [
  1130. & _! {% E1 ]7 r& u" k3 G
  1131.   # Get the database port6 d2 ~* `9 o; c
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \
    ; f* q, t; O' n0 u" P% N( L0 [
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)
    # Z. V6 A- N+ a/ j+ d3 J) Z
  1134. 0 F- @6 n5 @* H1 [' }" h
  1135.   # Exit if cancelled" Y3 b. l) ]) C& l
  1136.   if [ $? -ne 0 ]; then! H, H$ c! G% Y2 E+ x( ]6 p" c
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1
    4 _3 c7 @; ~5 s8 v, @8 w
  1138.     return 0
    4 k2 ]- }2 W, V3 V: F
  1139.   fi
    . c2 H6 }6 A4 m' z  _1 d  [
  1140. $ t/ u4 P7 R: j4 ]. j( U. A
  1141.   # Set the port number if one was specified
    4 L: {3 E2 O! N
  1142.   if [ ! -z "$DB_TMP" ]; then. \+ m4 G5 Z# C
  1143.     DB_PORT="$DB_TMP"
    , Q5 ]6 w, V# ^- x6 ]5 |
  1144.   fi
    $ Z) T2 V2 {% u% \0 J4 i$ D

  1145. 1 r# G' j& }  b6 j
  1146.   # Get the database user username
    ; A  `/ b" ?7 u& L
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \
    2 V" e2 |: M7 c  n4 s& U
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)
    , c/ ]- \7 P" M  g4 K

  1149. 3 z" z  w& T, V- l9 V. {" B
  1150.   # Exit if cancelled' O; i5 M3 w) u, Z5 \. M0 z( s9 ~+ B
  1151.   if [ $? -ne 0 ]; then( P% D5 t+ s* f9 O) f+ X0 \
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 19 g6 m% {# I6 M8 n/ e
  1153.     return 0. O8 o. {+ \* {, z+ A3 F( d
  1154.   fi1 ?8 l) q9 v' `: |& w8 }# e1 b2 o

  1155. 8 y2 E& l" q0 g  j1 s. L; Y
  1156.   # Set the user username if one was specified
    / F$ t7 e3 u. G
  1157.   if [ ! -z "$DB_TMP" ]; then
    ) G4 B' y& K) B1 o& s2 K
  1158.     DB_USER="$DB_TMP"
    + k+ ^( V5 y" X* D0 p' s) f9 t4 Q; t
  1159.   fi
    ! x7 p  j! b; A) z
  1160. , t9 m. w7 O( d3 V
  1161.   # Get the database user password
    : K' v3 C0 N: T" i: I4 F
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \- D: a* E. |" Z7 {
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)
    / @3 K# }8 w4 T: i: j: v

  1164. ( [/ I% \$ C' b0 r3 V" M' i/ w& G
  1165.   # Exit if cancelled; ?6 n0 N! s/ ]; s4 v' a- @5 U
  1166.   if [ $? -ne 0 ]; then
    4 z9 |  R$ S. ~, W
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1; y: ~& k% V3 F, v% K9 x3 {
  1168.     return 0
    $ Y7 Z8 W: U" t% I4 }
  1169.   fi
    $ H. T5 W4 K. x3 o$ R1 z
  1170. 3 Z9 s9 j4 l* b
  1171.   # Set the user password if one was specified: \9 y2 `( ]1 @, F9 b
  1172.   if [ ! -z "$DB_TMP" ]; then6 B- _8 E, @1 W# ^
  1173.     DB_UPW="$DB_TMP"
    . e; U3 v- m! r: p9 j1 l. t
  1174.   fi1 k7 o8 t! Q# f

  1175. 0 a8 M" w+ H+ D0 e" T, k0 e3 c
  1176.   case "${DB_TYPE}" in8 n# \! s% k3 Y! k# N, D7 g
  1177.     "0")
    9 M' U  J* n! @4 y6 ~
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "% H" j& E; S$ d% _/ p1 I# b
  1179.         ;;% Y  u3 |) X: s0 M8 X& z
  1180.     "1")( H% J( Z2 v) H: Q
  1181.         printf "Confirm your MySQL password\t, "1 E2 d# g# X9 J9 }2 }  Z
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn% |5 N1 m0 M" k: n, m
  1183.         DB_COMMAND="mysql --login-path=local -q -s "9 P+ a7 @! J; O" g# f
  1184.         ;;7 r, s' L) ^: F6 e; b) t
  1185.     "2")  o* O% i, V7 [& p. R
  1186.         Log "Currently not supported." 1
    . j& u5 `% |' x$ a
  1187.         return 0
    5 O/ q: B/ p% o# |) U# m% D
  1188.         ;;
    9 s& y) s( b) R$ H6 i
  1189.   esac
    4 o4 E/ }- l8 j* T
  1190. 1 j2 ?/ F4 k7 {4 H/ a
  1191.   # Setup database names based on release
    2 {) X" Y& z9 f( o. B9 g
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"3 o1 F( v* j4 g) D
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    # E' I1 I- S$ @/ A
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"
      |7 J3 [, d3 V
  1195. 5 \5 i7 ?6 c' \
  1196.   # Install fresh databases if requested4 i7 f* ?1 W5 V* N4 ^6 E' Z4 n2 T* d, @
  1197.   if [ "$DBMODE" = "0" ]; then8 {' B! {) P  ~: ]9 g; q
  1198.     # Ask which databases to install/reinstall
    ' M- e0 m. C' _' A6 t
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \
    ; d/ n, g2 K/ i8 a' M  K
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \. O- v1 f1 J- l6 n; o: S2 z% y: L
  1201.       0 "(Re)Install Realm Database" On \
      o  t/ w1 l( y# R; f
  1202.       1 "(Re)Install World Database" On \# \. P4 K" n& x  V5 c! K
  1203.       2 "(Re)Install Characters Database" On \0 C7 L* `$ f* V% @
  1204.       3 "Update the realmlist" On \
    ' B. N! p/ Z  j7 h, J
  1205.       3>&2 2>&1 1>&3)
      b$ }+ K  r+ d# H" a" Y& j2 \

  1206. 8 S7 B2 R+ p+ D" V
  1207.     # Exit if cancelled
    # q( V, t+ I7 F# R; g
  1208.     if [ $? -ne 0 ]; then
    ( D& b! k  C. d: n* A7 ^
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1" U+ @1 A5 p$ @% r& J* F
  1210.       return 0+ Z6 a9 v: f0 c, h/ u5 h. n) \
  1211.     fi
    + S6 E% P# ^1 _/ J3 k# b) O* V" o

  1212. 5 g- C6 M( F8 s4 d* a* o5 O
  1213.     # Remove and create the realm DB if selected
    7 E$ n2 I! f7 r6 D9 o1 \: `' j+ C
  1214.     if [[ $DBSEL == *0* ]]; then5 v4 H  ]; H7 d% D5 U
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"
    - a, P$ W% f$ F4 h' m
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"' E% J& s% M; y4 o2 ~
  1217.     fi
    7 c2 H$ Z( ?& Z3 E& ^- ~$ f. l% u
  1218. 3 S* e6 h3 N: o1 W" s
  1219.     # Remove and create the world DB if selected
    - [# n6 x- Q0 v/ Y; \# r
  1220.     if [[ $DBSEL == *1* ]]; then# i  h" R  @6 e4 v# @- i! W
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"
    0 c5 z. B$ m) S1 X: \
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"
    & q# K& ^; J4 J; }) e- L
  1223.     fi. k6 G1 _* Y# [5 H
  1224. ( m7 ?( ~% b+ \) j8 I
  1225.     # Remove and create the character DB if selected6 P+ g8 o, p1 ^9 ~
  1226.     if [[ $DBSEL == *2* ]]; then7 _& v; ?4 m8 p% i- Z' H2 u
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"( n% {# T( T9 B5 Q
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"
    8 C: K4 [& ]' _' }$ B) t4 h( p
  1229.     fi
    # U7 Y& [" e& e) [

  1230. # m$ a6 K* A9 k9 @( ]1 q
  1231.     # Validate success
    + H% K# @. p  @% [. I* K" `
  1232.     if [ $? -ne 0 ]; then
    7 w  M8 B, v! M; E
  1233.       Log "There was an error creating the databases!" 1
    & p" `: |8 s' X+ T9 J7 V
  1234.       return 1
    0 Z7 l3 j" E% e9 t- N
  1235.     fi# M* E5 F/ R6 P9 l

  1236. # S0 k+ e' e$ R" V1 b& \; ?' u
  1237.     # Finally, populate the databases) e- Y- W/ a/ d% Q& Z2 {$ B
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS" |( [4 X1 j# }4 l2 {* z

  1239. , `  T9 e  j2 l+ \$ _' f% d
  1240.     # Updating the realmlist
    # N% f* }# U& {2 j) Q# P
  1241.     if [[ $DBSEL == *3* ]]; then/ P) m/ U5 r* X8 [  a: u0 _5 `+ D
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql" T2 v' H0 w; t  K. H2 b
  1243.     fi# u" V( p. {! w0 T' u
  1244.   fi* L' e" o0 u+ y
  1245. $ Z! x9 T1 Z8 e# ?1 N! ~& D1 d3 A6 n
  1246.   # Update the databases if requested
    ( q! J- W/ L( P
  1247.   if [ "$DBMODE" = "1" ]; then% y* `" d' v. j( w: U
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS$ ]: L; g6 D% v2 d$ R3 ?
  1249.   fi4 v2 G8 B  ]8 W$ f' Q% J  e
  1250. }
    0 s. T2 a: X  g- v  J

  1251. % X/ o5 m! O( M1 V# _8 v1 q
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
    , n2 i# h* u: x/ P, }( a9 ~9 Z
  1253. function ExtractResources
    & |: ~& {0 R( ?4 q8 l% w! w
  1254. {" {# B! p6 ]2 e5 G/ b6 [
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))
    3 \4 h' N+ W2 Y  W6 j

  1256. $ m" k, b/ C( h- E, h9 b5 s
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \% [; Q! |. _2 o
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)+ X# W% r6 H4 D  \; ^3 o
  1259. # t! p; ?  h* P7 y
  1260.   if [ -z "$GAMEPATH" ]; then; h; s7 P! L0 k2 X
  1261.     GAMEPATH="$INSTGAMEPATH"4 v, B6 k- r( E
  1262.   fi
    ! L) D/ j* v4 l
  1263. # I9 X0 p3 D$ `
  1264.   if [ ! -d "$GAMEPATH" ]; then
    ! X; C1 J% M' T8 e/ B
  1265.     Log "There is no game at this location" 1" k$ ^+ ^& z( [) y' t
  1266.     exit 1
    3 }& u9 D) e# Z, z- @. o: ~
  1267.   fi  x' w( X; w; Z9 L* Y' ?8 @

  1268. " t2 D0 T' [+ K5 ]) c& o+ L
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \9 j& a! T9 P, u4 L
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \
    3 V. m$ N/ n; s
  1271.     1 "DBC and Maps" On \1 \* x( P# w; Y5 [. ^5 O
  1272.     2 "Vmaps" On \
    0 P' k3 }9 K& D$ w
  1273.     3 "Mmaps" On \: C* d$ D# x" K6 [% d/ C1 ^
  1274.     3>&2 2>&1 1>&3)
    ( G1 M4 V+ z- Z/ `" I' U
  1275. ; u6 s4 X  O6 J: A$ i0 [& G) U
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    - p: ]. E( O3 [' E) h9 B9 b) Q/ \
  1277.     Log "The client tools have not been built, cannot extract data" 1
    # g8 |# x2 h% D+ D% o& [* e" ?& i. p
  1278.     exit 1
    7 ?/ Y, m. Y: e% }$ _: W
  1279.   fi6 E( A$ D5 l+ P! k5 U; o
  1280. + P' S& c0 M9 [" a' l( F
  1281. #TODO What if DBC are not yet generated ??
    # p1 l) v# p; s! B% ?* m
  1282.   if [[ $ACTIONS == *1* ]]; then
    - ]# f3 E$ y1 r* J
  1283.     if [ -d "$GAMEPATH/dbc" ]; then6 b1 u! V5 K" `) s3 D: `
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \
    * R% L, y4 _2 [( }5 I& z' w
  1285.         --yesno "Do you want to generate them again?" 8 600 i1 I1 M! F$ }3 W  T7 n) ^6 q

  1286. 0 [$ p+ t, f' k, y
  1287.       # Check the user's answer# I4 ~- r$ k  H- c# d  M5 P! k/ Q1 b
  1288.       if [ $? -eq 0 ]; then
    * H" a5 ^) m3 J% f) j/ A' a
  1289.         Log "Deleting DBC and Maps previously generated." 1+ }4 E; T! j. @
  1290.         rm -rf "$GAMEPATH/dbc"
    " F7 S6 r# b: y/ M! n% A
  1291.         rm -rf "$GAMEPATH/maps"
    * A, D% |4 x, V2 Z. Z- R( U6 P+ A" [' Q

  1292. : P' w0 L. K) V
  1293.         Log "Copying DBC and Maps extractor" 0  S9 p- v, J4 I1 S; ^/ S+ \$ {
  1294.         rm -f "$GAMEPATH/map-extractor"7 `* r; s" }. s; d
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    ( K1 `/ X# Z) T/ M

  1296. " S6 x" r6 a9 T2 q0 l
  1297.         Log "Extracting DBC and Maps" 0
    & m8 U1 K: O6 T7 b
  1298.         cd "$GAMEPATH"0 j$ l. D1 t& [: E3 S
  1299.         ./map-extractor
    ( s4 G: v1 D5 X) c3 Q. F
  1300. 1 b4 _. @, k+ @- ^& T1 C3 [
  1301.         if [ $? -eq 0 ]; then
    ' K" X7 R: x6 Z1 w' z$ ~; h
  1302.           Log "DBC and Maps are extracted" 0
    3 c6 q5 @7 D: g& f, R% n
  1303.           Log "Copying DBC and Maps files to installation directory" 0, j, j: q. v' \" a3 ]9 x" s
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"2 A  X4 F7 m0 o7 N4 r) R) x
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"- `5 ?" r( j. Y5 B+ `+ N1 p
  1306.           rm -rf "$GAMEPATH/map-extractor"
    / _% R" ?. j# F
  1307.           Log "Changing ownership of the extracted directories"
    6 j0 d& D6 T9 I1 i8 @3 d/ D( u
  1308.           chown -R $USER:$USER "$INSTPATH"
    - T6 f' r' N! _8 _. N4 v
  1309.         else
    8 s4 C: @' X6 ^
  1310.           Log "There was an issue while extracting DBC and Maps!" 1# c5 K+ x: l/ d4 Q- j
  1311.           rm -rf "$GAMEPATH/map-extractor"
    " c, i4 U- n2 }
  1312.           rm -rf "$GAMEPATH/dbc"0 R# P: W# p0 Z4 v  Z3 G# L
  1313.           rm -rf "$GAMEPATH/maps"% ?( e/ R8 j# Z
  1314.           exit 1$ g0 u, ~$ |& u2 M9 c
  1315.         fi
    3 L0 u, }/ i8 J- g/ y
  1316.       else1 D0 e( l  e; G5 z
  1317.         Log "Copying DBC and Maps files to installation directory" 0
    " b$ V; E2 A2 p
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
      B+ J- D8 ?" d9 r- T- ^& ~& I* j- a
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    1 l0 ?! f$ i3 s: m/ ?+ v7 [/ U
  1320.       fi1 B6 c" v/ C8 n
  1321.     else
    0 D' U; x3 L! d* T, X  I7 U
  1322.     rm -rf "$GAMEPATH/map-extractor"
    ; J; Z$ N- p4 q& g# p, p
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    3 [" `2 y: A& ~5 H. Q
  1324. $ c) l$ L  ~& Y/ L& a: Q- x
  1325.     Log "Extracting DBC and Maps" 0. l% |" {. }3 P+ r% o( P
  1326.     cd "$GAMEPATH"
    & h4 u. S, S; v/ ]* V
  1327.     ./map-extractor' \2 y3 Z! L4 W) X, S, n6 E5 I- m, H; W
  1328. 0 B( \; \) p7 ~3 x% H5 ~, x
  1329.     if [ $? -eq 0 ]; then
    - v5 H# Y9 u, k, q
  1330.       Log "DBC and Maps are extracted" 0& C! P7 c' E. ~! e5 h" L
  1331.       Log "Copying DBC and Maps files to installation directory" 0
    0 l3 t8 U& y2 u8 p4 Y% ^2 {
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    - h2 W! W) U# W/ p
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"& p8 i/ v% e0 E9 k$ s  Y
  1334.           rm -rf "$GAMEPATH/map-extractor"! ]5 u' F2 e9 Q1 K
  1335.           Log "Changing ownership of the extracted directories"
    & w, d- D  |8 c# l+ h
  1336.           chown -R $USER:$USER "$INSTPATH"
    " A3 U0 s' O5 Z  }6 M; R; r0 p
  1337.         else
    4 N7 k* a7 J% {: p6 H0 `& {) n
  1338.           Log "There was an issue while extracting DBC and Maps!" 1
    / ]- x# L$ o7 m, L% u
  1339.           rm -rf "$GAMEPATH/map-extractor"
    8 \. L5 R# \  Y; p3 ]2 l2 |% P
  1340.           rm -rf "$GAMEPATH/dbc"
    # t% {" c8 G6 ]9 @
  1341.           rm -rf "$GAMEPATH/maps"
    ( o' N7 j1 J+ \9 `
  1342.           exit 1
    9 d4 |- O: [8 K, h! m
  1343.         fi
    $ X) N5 g0 a; \0 y2 L
  1344.     fi
    $ K# c$ ]5 y  A! q2 D
  1345.   fi
    7 C; h! E8 X  \* q  a' M; ~0 N( D% b
  1346. # o" {8 L5 |# F& x, t
  1347.   if [[ $ACTIONS == *2* ]]; then
    0 {; e8 u/ w" f- ~6 y3 |9 \
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then1 G' _- ]# }0 x
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    $ z+ P/ X0 L  U5 R+ T& r. T1 P
  1350.         --yesno "Do you want to generate them again?" 8 60
    ; c2 A7 v' L  U& h' k* T1 z$ F' ~, @
  1351. ! l& ^# v2 t3 j& U6 R" ^( N- S
  1352.       # Check the user's answer
    # v! k6 }% L- B
  1353.       if [ $? -eq 0 ]; then
    2 ?$ M$ R0 l5 t  f+ H
  1354.         Log "Deleting VMaps previously generated." 1
    . R+ h! B+ |) r7 ?: O+ u0 u
  1355.         rm -rf $GAMEPATH/vmaps+ K- b: e" r1 U0 n3 q, q- F' s/ I
  1356.         Log "Copying VMaps extractor" 0
    ) G  \& y: G. r  s
  1357.         rm -f "$GAMEPATH/vmap-extractor"/ l$ d  B+ P$ K
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"/ C, ]$ h5 H& T

  1359. # u3 Q% I0 x4 r' ?' B5 P" S
  1360.         Log "Extracting VMaps" 0
    - W: l3 A/ u3 Z1 A& j6 F$ b, |
  1361.         cd $GAMEPATH
    6 i( w9 k: H3 z2 u. J/ K
  1362.         # Make sure there is no previous vmaps generation that cause issue.
    : i; A  D& c7 d- \% N
  1363.         rm -rf Buildings- @+ q: s$ S, M
  1364.         ./vmap-extractor- j1 u* v5 o- d6 J1 n, U  F
  1365. , @# J7 v0 [, M4 h* G1 @, R
  1366.         if [ $? -eq 0 ]; then7 c- l$ m. R5 }
  1367.           Log "VMaps are extracted" 07 r& |9 m5 Y. k5 h$ @* E
  1368.           Log "Copying VMaps files to installation directory" 0
    7 F; v& L# p" d( f
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"3 \& z& e4 Q3 E, i0 X0 H
  1370.           rm -rf "$GAMEPATH/vmap-extractor"1 [% m# y" ]3 U: |8 X
  1371.           Log "Changing ownership of the extracted directories"
    ' H% o; {2 ~+ d
  1372.           chown -R $USER:$USER "$INSTPATH"
    0 g) ^4 L- d3 Z  Z. n
  1373.         else( T9 S2 U/ D0 M) |* T
  1374.           Log "There was an issue while extracting VMaps!" 1$ z/ {7 e; l: m6 ?( j
  1375.           rm -rf "$GAMEPATH/vmap-extractor"/ L! b& f3 Y  H" r* b- m
  1376.           rm -rf "$GAMEPATH/vmaps"' e% [7 s! R# }$ m; @
  1377.           exit 1
    ) F3 {# R' S& ~- G& t: F
  1378.         fi
    5 {6 c: ~; ^; c/ Z$ D  ~
  1379.       else! f9 X( B2 l5 s( z
  1380.         Log "Copying VMaps files to installation directory" 02 S, }' s" B9 \) q: }) S
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    ; C- T" M% m* O: _
  1382.       fi9 g. Y5 u8 |9 H  t) w5 G0 j
  1383.     else
    / S) {; m8 R9 X: K4 b- N
  1384.      Log "Copying VMaps extractor" 0. O0 i, O1 i9 c! A
  1385.      rm -f "$GAMEPATH/vmap-extractor"
    ) \+ D) V# G# w4 X) `* j0 ?
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"% D. @9 n+ y0 b
  1387. 7 t+ R8 D& b5 z; T9 e5 z+ X
  1388.      Log "Extracting VMaps" 0
    ' }/ q' K. e& L( ~% g2 ~- Z# n7 y- v
  1389.      cd $GAMEPATH  p" L9 d% h! C( [9 @! P
  1390.      # Make sure there is no previous vmaps generation that cause issue.% v7 g6 `  h3 }3 t" H+ u
  1391.      rm -rf Buildings
    / A% a5 j9 I3 \9 r$ ]- Z
  1392.      ./vmap-extractor/ t/ n" R! T8 g  U/ J* ?# @, c

  1393. % V5 R' E+ m8 J- F/ ]
  1394.      if [ $? -eq 0 ]; then
    & P& b$ }: E, O! h4 u9 u
  1395.        Log "VMaps are extracted" 06 M! K& |' F; s
  1396.        Log "Copying VMaps files to installation directory" 0
    7 J) o9 B4 d" e8 W; G! v$ {- g3 d
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"3 j% q5 _+ p7 E# D, A+ ?* n
  1398.        rm -rf "$GAMEPATH/vmap-extractor"
    9 z* m; }3 \, P8 h+ ?
  1399.        Log "Changing ownership of the extracted directories"
    ' }3 E, S) P' f* l' N" |* e- }
  1400.        chown -R $USER:$USER "$INSTPATH", s; M/ J: G: f: q  u( _
  1401.      else  Y: i9 i% t2 H$ l/ ^* x  E! J
  1402.        Log "There was an issue while extracting VMaps!" 1
    8 n& _/ m' j6 Z2 C" i% y
  1403.        rm -rf "$GAMEPATH/vmap-extractor"* ]/ @( U* s* v
  1404.        rm -rf "$GAMEPATH/vmaps"
    * y! k- U4 C/ R7 R7 E0 i
  1405.        exit 1
    + d; c7 G4 |, I
  1406.      fi5 P5 D' R8 _; E5 |7 G% g- s' R
  1407.     fi
    3 Z% Q( p. Y# f
  1408.   fi0 d% Q, L. Q6 C8 W

  1409. * h& e& V% p  _. N- b
  1410.   if [[ $ACTIONS == *3* ]]; then
    2 ~: H$ P: U9 `+ @4 Q7 a5 d
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then# n' ]7 ~; x# ]3 p8 e* P7 |* c
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1
    . S* R7 O6 ]0 I  o& U- i8 K; C5 E
  1413.       exit 1
    ; F4 K" d5 Z. {* t& a, b4 ]" ~) y
  1414.     fi
    ) ~! H0 v* X, v) L3 F% @
  1415. ; k! ^+ `0 y, V, w- _3 s. A
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then
    , V9 L2 }1 E, p/ a
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    0 G$ S; L" d0 ?4 n: Y$ [
  1418.         --yesno "Do you want to generate them again?" 8 601 }0 ]4 r% M4 T7 a% b

  1419. 9 _9 T) W1 c+ F# b6 Y
  1420.       # Check the user's answer
    ' S& m+ B  D9 c; w# K
  1421.       if [ $? -eq 0 ]; then, D; D' J  R' y, i3 `; u' Y
  1422.         Log "Deleting MMaps previously generated." 1. n: G- J1 o$ s8 V: w; e4 O: D
  1423.         rm -rf $GAMEPATH/mmaps; N: A% w: z" v6 e

  1424. % y. B$ i+ y! f+ b& ^
  1425.         Log "Copying MMaps extractor" 0
    % {" D) p) A- `* c' m( n/ k0 H
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    ! K+ v$ @7 |: i$ K# a; d! l
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    * ]4 L6 A( g3 p1 N6 o* P, A
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"
    0 S3 C' N3 r, k6 b9 M: f( x
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    / H3 `( }' J2 `5 P8 x
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"$ p3 O: d) W, Y. N% R0 k: L) z' _
  1431. - |& `! h1 e: x' m8 \
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \+ W6 F: d( \  O: M- W( p
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    + Y/ e( }( r' S3 ?

  1434. & {- u; Y9 |9 a4 l; _* I
  1435.         # User cancelled his choice, set default to 1.
    ' o4 W* A% G4 {4 }" v  t# R% A
  1436.         if [ $? -ne 0 ]; then) k; p( o$ ]5 I' P
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1' C9 m% `% r/ P4 L6 i% `
  1438.           CPU=10 Q9 \' a5 ]0 B8 v. X9 f/ G  t& q+ B
  1439.         fi
    1 D/ M- y2 R: W* r
  1440. 2 F+ |4 D3 M. c: P6 \
  1441.         if [ -z "$CPU" ]; then
    + f6 D: \/ c9 F% _  D
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1
    + [# J! g8 d( T% x* O* B$ I
  1443.           CPU=1
    , a. D2 ^& w+ X
  1444.         fi5 n( ^; B* R( r- F9 J/ C" M( e

  1445. 5 @; i# b1 X8 S6 L8 s+ A
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    8 A# z6 e; K( Y( q
  1447.           Log "User entered invalid value. Max CPU set to 1." 1
    ! D7 E6 ?: u8 D# s' D
  1448.           CPU=1
    + f( e. u9 F' Q+ o# i' r( q
  1449.         fi
    ! _; h% N0 k. m

  1450. 4 M/ Y" _' ]3 ~, X
  1451.         Log "Extracting MMaps" 0- ]2 [% z5 ^) F# S! j+ o$ E2 Q2 P4 J
  1452.         cd $GAMEPATH( w* a! ?/ N; Z3 Y- R6 W5 r
  1453.         # Making sure we can execute the script+ t: Y( V. S- L
  1454.         chmod 700 MoveMapGen.sh% w0 X3 w7 p1 c4 g5 R
  1455.         ./MoveMapGen.sh $CPU# Z* ?  y! O% F, S3 f' c

  1456. $ P  `& k; e  K3 \- J; M: C& a5 ~
  1457.         if [ $? -eq 0 ]; then
    5 S+ C7 A& t" ]9 F
  1458.           Log "MMaps are extracted" 0% \% d& x" ~1 J9 u% ], A, N
  1459.           Log "Copying MMaps files to installation directory" 0& |3 a7 \" L$ g6 ?
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"/ k* B+ l1 a, ?, r6 D
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    6 A6 k, v- d; I9 A, H
  1462.           rm -rf "$GAMEPATH/offmesh.txt"
    ) ^: t* @+ H" b/ o
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"9 S0 E' P6 W/ s) I* w9 f
  1464.           rm -rf "$GAMEPATH/mmap-extractor"8 S+ B! \! g( B2 E4 r" n; G
  1465.           Log "Changing ownership of the extracted directories"
    6 _/ H; ?" Q7 C  m, k+ c, ]
  1466.           chown -R $USER:$USER "$INSTPATH"4 W; ~' _2 _) n3 `! }( E- X
  1467.         else
    : J! [* I  A6 r' ~: D
  1468.           Log "There was an issue while extracting MMaps!" 1
    # Q: D5 P, F! ]8 X+ _' l
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh": A; ?/ w; U! a* e/ k, W* k: a' s
  1470.           rm -rf "$GAMEPATH/mmaps"5 `) K% Q% a9 f* d
  1471.           rm -rf "$GAMEPATH/offmesh.txt"
    : G9 s. l' y/ d) w# n! h, o# B
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    0 y. J( H. X5 m- Q
  1473.           rm -rf "$GAMEPATH/mmap-extractor"
    ! q! X; X: J4 K
  1474.           exit 1" |, Y" K* o! [& o+ Z; H% K
  1475.         fi( ]+ T. E8 q% g' R* x
  1476.       else5 e5 R% |( |8 V/ c: Z* Z, J
  1477.         Log "Copying MMaps files to installation directory" 0
    ' Y7 e2 z* P. U$ z
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"4 r$ L* h& B3 \1 t: C% Y
  1479.       fi
    3 p2 |% I9 a) N+ n9 d8 U) e0 }6 x
  1480.     else
    + j. S4 C0 g9 F$ r- N: s7 h
  1481.     Log "Copying MMaps extractor" 0
    3 ~7 e+ D4 W  Q4 E5 h
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"6 z. j: p$ C+ [4 j' F
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"  q0 U& [0 C9 K& C
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"3 ^7 n0 @. R$ W- Q
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"0 c) f6 ^6 Z4 |5 ]
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"$ l8 L3 m. U. x2 F* q& K
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    + j, i+ N3 D! |2 D8 k4 b
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)- z) z, S5 X1 q9 C- p

  1489. 8 ?* D: G5 ]% h/ N( Q
  1490.         # User cancelled his choice, set default to 1.
    2 J6 u# n& n0 c3 E4 b* q! \
  1491.         if [ $? -ne 0 ]; then
    $ d. {1 ?/ C4 x- P4 P
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1
    + h7 P, _- I/ E9 T) J  u
  1493.           CPU=1) e$ @9 S) ^  W6 j
  1494.         fi
    : D1 ]/ I6 |0 N) m$ A' x- B
  1495. 1 G6 S" w; ?2 x  e
  1496.         if [ -z "$CPU" ]; then" ]* ?6 X0 ?( ]- K5 w% ]
  1497.           Log "User didn't gave any value. Max CPU set to 1." 15 W, i6 l' z( B/ o. x, Q- `
  1498.           CPU=1, _$ @# u9 E+ `( m* F
  1499.         fi
    - k4 ?) K- B2 M! j+ q- O; R$ g
  1500. , _  s; u/ S5 R8 ^( n1 |7 h
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    9 S2 f1 p. a$ k* J) K
  1502.           Log "User entered invalid value. Max CPU set to 1." 1; B* }% X; u/ D" G( z
  1503.           CPU=16 ?7 e0 q% H( J
  1504.         fi( J- |, B+ ?& }0 j( |) F$ P' R
  1505. 9 P+ Q- D. F% a  T0 c1 B
  1506.         Log "Extracting MMaps" 0& l3 G' U) @' T; O# [
  1507.         cd $GAMEPATH# m& a7 C( u4 o/ K/ Y; Q4 L
  1508.         # Making sure we can execute the script
    6 C- H5 X2 m. s8 N
  1509.         chmod 700 MoveMapGen.sh  z6 y4 E( z* L# V
  1510.         ./MoveMapGen.sh $CPU
    # k, `8 a4 C* k, t& k  s9 @+ M( F& G
  1511.   E; U5 |7 E9 G# m- I; M
  1512.         if [ $? -eq 0 ]; then
    ( `/ ?' m8 A6 z
  1513.           Log "MMaps are extracted" 00 K7 m+ x" |/ a" p4 i
  1514.           Log "Copying MMaps files to installation directory" 0* q5 Q4 s2 T- l8 ?( S$ q
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"" R0 d1 z2 H" O7 K3 A; B( ]. f+ C
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ) _9 U7 }) |0 S4 ^
  1517.           rm -rf "$GAMEPATH/offmesh.txt". N+ M7 ?6 G* q6 X, T0 b
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    2 g/ X0 a+ v6 k7 y0 c; n
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    , F( H: r" R9 C( P$ K1 a0 e
  1520.           Log "Changing ownership of the extracted directories"
    4 O) T6 U! x( X. v1 v/ k( v
  1521.           chown -R $USER:$USER "$INSTPATH"+ P9 y  t$ b& j' N* g5 x
  1522.         else8 P6 n+ W; t6 `& z" C3 [& n/ b
  1523.       Log "There was an issue while extracting MMaps!" 15 y  ]' W- M- W2 j. W$ t
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"; \3 n9 i) q/ t' |2 Q) a: @
  1525.           rm -rf "$GAMEPATH/mmaps"6 f7 K1 M$ ]7 m  g2 F2 f
  1526.           rm -rf "$GAMEPATH/offmesh.txt"; J( u$ r: w& T0 n5 J; B
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"! s0 V4 [4 r0 K& s9 `( q
  1528.           rm -rf "$GAMEPATH/mmap-extractor"% U$ y" t3 ], h5 Q/ d. [" |: Z
  1529.           exit 1
    ! }) a* |- g* ]# @5 Q
  1530.         fi
    3 R, W& x% B1 O) C
  1531.     fi8 k6 j8 }# Y1 A' `
  1532.   fi
    9 o% j3 |2 q. \: N1 `5 b
  1533. }
    ! v  C7 ~# B7 d/ R; n3 O) T
  1534. 9 F% m6 n+ R9 r& s
  1535. # Function to create a Code::Blocks project8 d% x) [7 b! A8 M
  1536. function CreateCBProject
    , h2 z5 n1 h. d8 k) S
  1537. {/ n6 t3 j1 f3 O; X% }1 g, V
  1538.   # Create the dircetory if it does not exist
    2 u2 I( T! g8 ^  ?4 \, K
  1539.   if [ ! -d $SRCPATH/server/linux ]; then
    6 H; A1 ~# o) K- t1 t) [
  1540.     mkdir $SRCPATH/server/linux1 g. }( q' B6 Y9 V
  1541.   fi
    - w& w4 @0 D; ^: u( P3 q
  1542.   f8 a# @/ w/ O1 p. p
  1543.   # Now create the C::B project3 e; `5 \; I% h- c" F* [, r" I
  1544.   cd $SRCPATH/server/linux
    2 R. M. o0 ~& p- P# t2 T
  1545.   # make sure we are using the cmake31 \4 Z& a3 N# N, i
  1546.   UseCmake3/ f, ?/ G  s; _5 T
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    2 G& J3 B2 ]- ?4 b& p" \; A
  1548. }
    ' E3 X/ I' f. V: L! |
  1549. / x" l. w6 j; Z, I+ o% q. L
  1550.   l( h& f9 T/ M: L
  1551. $ }' x, J2 z7 y9 D
  1552. # Prepare the log
    & O! k+ E  @& f+ c1 G* O
  1553. Log "+------------------------------------------------------------------------------+" 0
    9 p2 S# t; O; S: H) R4 f
  1554. Log "| MaNGOS Configuration Script                                                  |" 0. H2 O6 r+ ?% W$ i
  1555. Log "| Written By: Ryan Ashley                                                      |" 01 G6 \- y, I# c4 ]
  1556. Log "| Updated By: Cedric Servais                                                   |" 05 }" E6 e/ W4 ^3 f0 Y2 f
  1557. Log "+------------------------------------------------------------------------------+" 0  |) }6 x# V" r# s0 Y
  1558. ! K1 U1 [# b& R5 z0 S  M
  1559. # Check if user who is running this is root
    % G' K0 e  n" B6 N$ ?2 Q
  1560. CheckRoot
    - {+ i' M7 M" o2 O' D
  1561. - G. L7 B9 v* V, Q
  1562. # Select which dialog to use
    + a) S  `) p7 l. i' G
  1563. UseDialog" Z) {: o$ x& c3 F
  1564. ; b) L/ a5 Z3 x6 t+ {
  1565. # Select which activities to do
    ! [+ K1 W2 C7 f9 B5 R+ _* Z5 K
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    6 V1 L, A  ]" A; ]4 Z' h2 w1 G4 d2 _
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \2 W+ x9 L7 z% h/ k" ]
  1568.   1 "Install Prerequisites" On \) R; N4 D! F8 `+ `% m7 S
  1569.   2 "Set Download And Install Paths" On \9 Y3 V+ i$ ?+ j( {0 A( i
  1570.   3 "Clone Source Repositories" On \9 v5 N0 {  E6 a9 O8 ~& l% R% i- Y/ _
  1571.   4 "Build MaNGOS" On \8 t( `3 K1 N2 A( X. i
  1572.   5 "Install MaNGOS" On \
    0 W" p4 q/ _# c8 w
  1573.   6 "Install Databases" On \- C0 `2 A* |) J5 ?2 Y/ k
  1574.   7 "Extract Resources" On \+ U4 }. Y0 t7 [8 m. G
  1575.   8 "Create Code::Blocks Project File" Off \3 o2 K: C  o2 P# h% x  \
  1576.   3>&2 2>&1 1>&3)
    . `! `; H7 n4 W* g. [
  1577. 1 s: R4 Y7 k& i
  1578. # Verify that the options were selected
      c8 u) \/ x) }/ \3 f  G9 R: t3 C, o
  1579. if [ $? -ne 0 ]; then
      W  q1 p9 y$ G: C, h9 w5 ^
  1580.   Log "All operations cancelled. Exiting." 1  T+ G0 d( h6 Z7 s7 v
  1581.   exit 0
    7 f5 D/ n2 Y$ @4 B4 |3 ~
  1582. fi, H1 u. r% k7 e6 |
  1583. + Z5 W) t/ W1 {
  1584. # Install prerequisites?* _  s: E. ?3 i; S$ t
  1585. if [[ $TASKS == *1* ]]; then
    8 A- ?& W% A  U  M
  1586.   GetPrerequisites! ~9 e5 W! W3 I2 _: d3 A$ X
  1587. fi
    $ D+ E, H! i  r7 \" T, \

  1588. 7 ?, Z  u: k4 q
  1589. # Select release and set paths?
    3 s8 P8 e: h: u/ U% s1 B
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    6 G! `, B" N, j: |' G( O9 E9 ?2 d* Y
  1591.   GetUser: G: @. t& `! M) A5 f
  1592.   GetRelease5 H6 }/ R% [) X9 Z
  1593. fi5 a  }* v% h; F6 W$ v0 P

  1594. , Q$ V3 u3 h7 I2 Y" k
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then$ G8 W5 P5 m7 N$ u( V
  1596.   GetPaths$ P  a$ A3 B) w$ ^! }7 k
  1597. fi
    . Z! C8 v7 A1 h0 }7 X

  1598. 0 g, g% a2 m+ s* I
  1599. # Clone repos?
    7 f7 W0 W# f) z7 [! R
  1600. if [[ $TASKS == *3* ]]; then5 G/ ~6 t, Z+ B8 m. w$ z
  1601.   GetMangos- p. r' y0 }  x8 d* U) L! G8 B+ t
  1602. fi# j* g: N; X0 g  ?- x1 z

  1603. ( M5 s- f7 T' G- ~& X. @
  1604. # Build MaNGOS?
    - S" D6 R% {2 v1 m1 b* o
  1605. if [[ $TASKS == *4* ]]; then1 ^. ]: q1 E; a! E) [
  1606.   GetBuildOptions6 A, M  J8 b  x2 B
  1607.   BuildMaNGOS/ v! ]" `" P3 \$ T
  1608. fi
    * j2 e2 }  n& e1 [- {
  1609. # c6 p5 M2 O  R) o3 Z% _; x1 W; @
  1610. # Install MaNGOS?
    - o/ k( @* I. q  z8 _: F7 v$ y7 `
  1611. if [[ $TASKS == *5* ]]; then; u+ r7 V$ ?5 s: ^& S
  1612.   InstallMaNGOS1 f' h& b1 v9 Y/ q
  1613. fi
    ' L& ]  v( ~4 ]* ^3 ?4 r( e4 ]

  1614. / u7 X1 k( r+ N8 E8 |+ B! l
  1615. # Install databases?9 ?; w2 i# c2 Z6 a3 Z3 B9 ^
  1616. if [[ $TASKS == *6* ]]; then3 T5 V1 H' N1 P  P. ^
  1617.   HandleDatabases+ r5 \3 t4 E& o8 r4 K! z/ W
  1618. fi
    " n% o4 t' N9 }7 n

  1619. ' J/ D6 ]$ X; ~, d1 M8 r% T! Q1 n3 K8 S
  1620. # Extract resources from the game?! b$ ?# J1 O' T
  1621. if [[ $TASKS == *7* ]]; then
    " ]5 x5 X( |6 I5 h% V7 ~, ]
  1622.   ExtractResources5 Q7 N7 R! n; L& ]; h
  1623. fi# ^" K  Y  {, J8 J5 _
  1624. " J& y- V; |0 ?3 @
  1625. # Create C::B project?) ?* C5 z& q8 M* U# d+ R
  1626. if [[ $TASKS == *8* ]]; then
    5 X2 c' T8 @- a' E5 X* \/ R
  1627.   CreateCBProject
    5 I' r' a; p0 p1 X
  1628. fi2 q% J, t3 x) C2 o

  1629.   Z5 H* S  h0 Z/ w2 A. w
  1630. # If one of these actions has been performed, then we know the user.
    : h6 o1 P5 s0 y6 T' _$ \7 M5 b1 F
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then' s8 f3 k2 ~+ F0 f  h* o
  1632.   Log "Changing ownership of the extracted directories" 1% M( @! q* ?1 o: ?/ _9 H5 r- n% z
  1633.   chown -R $USER:$USER "$INSTPATH"9 s' `3 Q5 \) d; K6 v9 ^
  1634. fi
    . A5 A4 ~  z, A5 p* u+ h

  1635. 9 O" G/ {% j/ G+ O$ _5 y+ c# \  j
  1636. # Display the end message+ D- B( |  P( x1 R3 L& {
  1637. echo
    ! P5 X# ?# r5 G- D( j( E
  1638. echo "================================================================================"
    $ \8 j1 N4 k/ q
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"  n( C& {9 q& m5 t, w5 x
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"+ ^5 o& @, C, S  ?  `% Y" {
  1641. echo "server. If you have not configured your databases yet, please do so before"
    4 g0 V- D- K, g1 W4 y+ x
  1642. echo "starting your server for the first time."
    % W3 Q7 P9 j$ W* l. F+ H
  1643. echo "================================================================================"
    + K, C( C$ w' z+ W& Z; N7 G( g
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh
    * p) [+ K: N- U- c3 p. e7 T
  2. ##############################################################################
    * \% `% w- p6 i( w5 x
  3. # This utility assist you in setting up your mangos database.                #
    ' q& L' N/ H& j8 k3 @% v4 o4 i
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #0 w* O* u2 `- V8 R; r3 J1 H& C
  5. #                                                                            #
    / z, K& f' p* ^4 m$ V8 P5 }1 K
  6. ##############################################################################, g! u! F) F& J1 o+ r; ^! f8 C

  7. , C- }, q  q  s, l
  8. OLDRELEASE="Rel21"
    * @- @  ^; b4 H0 V% R7 V
  9. RELEASE="Rel22"
    0 l! \8 h; C0 m4 o: }' U
  10. DUMP="NO"
    ; Z/ w! ?8 O! H
  11. , @6 e( w( v/ _* Y; C
  12. dbname=""
    ) Y) C: x9 c  k3 G. \
  13. dbcommand=""# c/ f# ~" {' u; x  s" f4 r
  14. 1 ?' w; b6 @* \$ b9 ^
  15. createcharDB="YES"
    $ |3 C4 p$ S4 c: T7 {2 P8 R" c  T
  16. createworldDB="YES"2 O# }7 |. w' ?, W1 N% f" g" b2 ]# J
  17. createrealmDB="YES"$ A' Z- \6 r. i* L: K
  18. & `0 v1 o5 O2 A( r4 I6 w* o
  19. loadcharDB="YES"
      z  }! Z( H. K3 w( Z' R/ k0 f
  20. loadworldDB="YES"
    * q& s: ?7 p6 T# g/ }; T5 @
  21. loadrealmDB="YES"
    3 K3 ?0 b' ]2 x; k5 e' h
  22. dbType="POPULATED"+ `6 I% b5 t7 S) T  [" P6 ~

  23. / |+ z# H0 K# J) e% o
  24. updatecharDB="YES"
    0 |, J" `1 c( s* |1 L
  25. updateworldDB="YES"0 `) q, g& p/ Z, D& N1 N/ `
  26. updaterealmDB="YES"
    & N/ y: S3 F' G1 w& `" c/ g
  27. , B( l) V8 B2 @/ W* B  Y+ M  E
  28. addRealmList="YES"
    : R( d& f2 g( ~0 M$ y

  29. . o% g/ P: `- _8 j
  30. svr_def="localhost"
    # q5 i2 z; l$ k2 \
  31. user_def="mangos"
      ~4 j" O3 l/ b9 R( n, m- x( k* s9 y
  32. pass_def="mangos"
    ' _  B( \( {, w, x9 r
  33. port_def="3306"
    ( `" c: o, W2 E5 Z( b9 P
  34. wdb_def="mangos2", p! D* @: L0 o9 D0 N3 a6 \
  35. cdb_def="character2"* b+ d' i: d, m0 L8 F: _
  36. rdb_def="realmd"" w3 u6 J! b/ c, D- p8 g8 }
  37. " k4 {& x5 U1 u7 W: U! h% n3 V
  38. printHelp()
    * e8 h1 R9 ?; I% c
  39. {! l! l5 R9 _' g) A9 M5 o/ m
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n": V5 n, [$ J6 [; |+ V8 {0 b$ b! P
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"2 P2 U+ Y' V6 t9 h1 l
  42.         printf "\t-u: Run only the updates of the database\n"( m4 i9 r7 T+ U% v0 d- c5 `7 L
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"( g: w* r# r$ A. w7 T9 T
  44.         printf "\t-h: Display this help\n"" N' T6 I$ L4 \0 n+ D
  45. }9 L0 F* V% N' x7 Y

  46. % k5 c; R% R8 y6 |: L  s
  47. printBanner()
    & m2 V& x  w! D
  48. {2 C2 t  c, m" ?7 W* Y
  49.         clear  ~  X( `6 O( k  r
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"; Y; ^- t8 k8 d' j* c5 A% @' n
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"
    " o. ~: F9 v  [4 L4 S) N
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"
    ' N0 J8 ]5 m& @: N9 N
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"! S' D$ H7 C" T: o: I
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"  b* M) H3 y: ]; ~+ A, I' U
  55.         printf "\n": Q! \, ?: ?& r1 |
  56.         printf " Database Setup and World Loader v0.03         \n"- N$ A9 w) f* j0 j% i
  57.         printf " ---------------------------------------------- \n"6 d, |% K7 n5 l  i" v) e* R( }
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"
      I* ]) ^8 b7 J; G
  59.         printf " ---------------------------------------------- \n"
    8 |3 u! z/ M  r4 j9 n. s$ Y: m
  60.         printf "\n"! t% n9 l# }( ], ]
  61.         printf "\n"
      _9 U( x3 D1 q3 u" d: g
  62. }
    2 o. G1 Q6 p' x( i; D- \2 w+ y6 p
  63. . o" i3 I. ?3 I0 u, Z' J0 \
  64. printActivities()) _4 w' c; N8 w; e! J
  65. {6 y$ N1 D/ \, F$ i
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"
    + s0 i8 \3 a5 T: Z5 C/ @4 S" n+ t
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n"
    ! W1 k, m% v0 C! @
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"- O, v" I# K+ b8 m2 U
  69.         printf "\n"
    8 w* K* ~# w5 k) N9 m+ V! m+ G
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"
    : k- \9 J0 _1 {8 N0 j' \
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"       
    & {! `) K' I! r- F
  72.         if [ "${loadworldDB}" = "YES" ]; then* y4 W+ [' j' H7 l, d
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"
    ( y8 n% v2 T- s8 ~7 A
  74.         fi
    ; A% A. u2 w( U5 e) l0 M
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"& C* |3 d" u' R8 M" M& z
  76.         printf "\n"
    $ W5 l1 I9 }$ L8 r: p* o* `9 f$ Y* E
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"
    + T* s& v! l5 {/ ]5 k2 S$ Z4 i
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"
    1 m" x; i8 R2 t8 b! A& ]. N
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"
    1 Q& I7 X5 Z- L2 u+ h6 a
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"       
    : \. R7 U* J! @5 k
  81.         printf "\n"  `& w  o0 T* }, z  {6 C6 @; u7 Y
  82.         printf "\t\t\t\tN - Next Step\n") p& }- h8 o0 d4 C+ Z0 i# y9 r3 d. @
  83.         printf "\t\t\t\tX - Exit\n"" C5 O8 N, j! _% T, w
  84. }  E( e+ Z' t$ A& u0 n- q

  85. , R: ]' \; \1 d( A" n
  86. determineDBName()
    ! }7 f% P) Y- k% c3 C+ |
  87. {
    * [& o* \9 ]0 _0 Z* ~
  88.         if [ $(which mariadb) ]; then6 N; B7 I2 ?8 z& f, g* B
  89.                 printf "MariaDB found.\n"
    ; V' Y, r6 I) H2 @* M
  90.                 dbname="MariaDB"9 M0 y$ t( h5 U4 v' l
  91.         elif [ $(which mysql) ]; then
    . g( h) Q" `$ ^  [3 c( s! d
  92.                 printf "MySQL found.\n"
    3 U4 N7 J4 O1 Q' X
  93.                 dbname="MySQL"
    # H  [9 Y% ]8 B3 N6 o
  94.         else- q/ k9 q  I) B
  95.                 printf "Did not find mariadb or mysql.\n") x8 l- I5 J* ~% l
  96.         fi" Q1 F/ S' j' j$ K9 F( O
  97. }
    8 v5 _$ F3 m7 s! i1 U/ Q, v3 W
  98. + c" c- B9 Q) Y' B5 M6 l# B7 p
  99. mysqlconfigeditor()
    / T/ J; \) V7 [4 z" O
  100. {* H0 i* s' N8 M: M- ]- D
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"
    ) c+ x6 D& L8 O0 ]- X
  102. }
    3 J( M5 S/ z  Q7 G. X( k: R
  103. 8 m- O$ e: _" K% L
  104. determineDBCommand()* v( n# a; A3 j5 G) L
  105. {
    , ?" Q4 B1 m! k/ f% r( k/ O) ^* H; S
  106.         if [ $dbname = "MariaDB" ]; then
    9 G  v9 j; N& p; r$ U/ x" N
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s") Q/ |( {1 m' B" l9 t
  108.         elif [ $dbname = "MySQL" ]; then% a( {  \; b9 M6 c( P
  109.                 dbcommand="mysql --login-path=local -q -s"
    + s5 p. f$ H( c
  110.         else5 f1 _# S' `8 l& F; F6 h
  111.                 printf "Did not find mariadb or mysql.\n"
      z. z" M! W9 J1 t# r
  112.         fi
    4 s& \- L9 q  _% ~0 s
  113. }
    ; t# u! r( ]4 I: [
  114. 9 M' N4 A9 m. m5 i' `! u: n
  115. createCharDB()
    9 U# ?% l$ M' F2 E
  116. {3 @" \$ f  Q" I( [$ t4 ]; T
  117.         printf "Creating Character database ${cdb}\n"9 O/ \  ]9 B4 a
  118.         $(${dbcommand} -e "Create database ${cdb}")
    $ [+ h/ R0 {6 l) ]( [8 P6 o
  119. ! F- }+ C; D5 m1 B
  120.         if [ "${loadcharDB}" = "YES" ]; then
    ) ?" P6 d1 K- R+ V" j1 |+ s. _+ k5 D1 }. h
  121.                 loadCharDB8 C; `  c, [0 X1 d& g
  122.         fi2 Y" x$ z2 H5 P' v8 L  A, t
  123. }
    % c$ x+ d$ D# k* t9 e2 g+ a- W

  124. - m' {8 g" }& A
  125. loadCharDB()
    8 y8 b% b! c3 o
  126. {% A8 X* `' W" b% J" ]" C$ t5 [
  127.         printf "Loading data into character database ${cdb}\n"; X  H3 \- e% G  h! d
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)
    & h- p/ v9 F5 s# `4 f3 J
  129. . X* Q3 n% h1 O. }( D8 e
  130.         if [ "${updatecharDB}" = "YES" ]; then/ ~0 \0 z/ F$ C- l( f, m$ S3 R
  131.                 updateCharDB
    " R% S5 b  }, c# Z
  132.         fi
    , N9 q5 z( }- Y! W1 G: O# G) G
  133. }* g2 j6 Z0 v1 U: |' m1 l

  134. * N2 u' ]& X; u. S4 Z! s
  135. updateCharDB()6 S- W4 q: _1 ~( r/ a
  136. {3 V* R, v+ }: c% b) |( Z" l
  137.         printf "Updating data into the character database ${cdb}\n"
    2 }6 }8 Q" w$ k$ b% o6 ]' I1 h
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')( b/ n" k0 K7 V+ C& {+ Y' M! J
  139.         do: T6 k2 W4 S2 J" ?1 }  `
  140.                 file=$(echo ${file} | tr '|' ' ')" a7 S$ `* B" a8 V  j5 C
  141.                 printf "Applying update ${file}\n"" K6 C, B0 M. }3 S- o
  142.                 ${dbcommand} "${cdb}" < "${file}"; j( E; V6 x" @" T0 {7 ?( Y- V
  143.                 printf "File ${file} imported\n"
    0 A( D2 V3 m% E7 t0 ^! D
  144.         done
    " m' K  h* J3 k
  145. ' J) q% o" r4 Z, {" ?- v; }1 x
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    ' c9 d# \. z( r5 W. E; B, R& ~
  147.         do
    " W. J, O+ {5 g* X; j# J
  148.                 file=$(echo ${file} | tr '|' ' ')+ x- W9 [" c4 Q  b% D" b) h
  149.                 printf "Applying update ${file}\n"
    & q) E; C3 g# B' j( f
  150.                 ${dbcommand} "${cdb}" < "${file}"
    5 d' }; z# F! t5 j4 ]6 J$ w
  151.                 printf "File ${file} imported\n"
    " }1 g, v! z; Z6 x7 [/ r8 ~
  152.         done
    ; B3 g7 P4 b0 [" R/ r* N8 G
  153. }! ~. w. q& u  ?! H

  154. 2 a9 B2 R5 J1 ~. p! D) |
  155. createWorldDB()
    * _5 V, s/ Y" G
  156. {! T% B8 o  F9 t% w: F$ e/ N
  157.         printf "Creating World database ${wdb}\n"
    3 _8 M5 I6 O, ^/ i" E
  158.         $(${dbcommand} -e "Create database ${wdb}")
    7 x2 ]) {* @9 _0 e
  159. & }2 m( ~. ]+ S
  160.         if [ "${loadworldDB}" = "YES" ]; then4 \" f3 x1 X: Y% v7 U# S
  161.                 loadWorldDB
      h$ r$ a+ ^9 ~% p5 ]! n& A/ N; X& S
  162.         fi* I  g- J# I% k
  163. }2 C$ s. \7 R' F4 M

  164. 2 p6 P3 Y: a+ ?4 j3 \. s- a
  165. loadWorldDB()
      J0 p; {' ~" W& Z
  166. {& N6 r; b; X1 u" ~- x- l$ |
  167.         printf "Loading data into world database ${wdb}\n"$ v7 Z. {/ _$ f
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)
    # e# P# U! _( U/ P# Y  f
  169. 4 L" x" j1 }) Z- p" h$ Y
  170.         if [ "${dbType}" = "POPULATED" ]; then
    ! k$ b0 J, d* T7 x1 s
  171.                 populateWorldDB1 m$ N# |( i3 z% X; {* d
  172.         fi) v7 q6 Y& f5 i4 ?: U  o# F
  173. }
    " S; _1 w3 ~/ M% h% b' A
  174. : C, T( T' ~. d+ C  H. Y+ C
  175. populateWorldDB()
    : L# F  W6 Y+ J& X
  176. {: K8 v( M( S, C2 H! b! k$ V
  177.         printf "Importing World database ${wdb}\n"+ ~; w; J% F. H! p
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ') 1 w% t1 }  p4 I$ p: U
  179.         do/ ?' R* `# ]5 F  h3 Z
  180.                 file=$(echo ${file} | tr '|' ' ')1 Z$ t8 ?" r' ^9 a2 F, z' p
  181.                 printf "Importing file ${file}\n"  [8 J8 Z% P3 T7 T  n
  182.                 $(${dbcommand} ${wdb} < ${file})
    ) v7 ?; x5 f! n5 |3 p
  183.                 printf "File ${file} imported\n"# w! ^0 O. f$ @% {3 t
  184.         done
    + _: [: b# W6 g6 ^" y" X6 {, L

  185. ! N* o1 }- v( `4 L# K8 [. B$ G/ |* e1 a
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ')
    # O- M2 w, y2 S# g- X  Y( N, J
  187.         do3 f' V0 z! P+ |$ z1 U- k, e! l
  188.                 file=$(echo ${file} | tr '|' ' ')
    - |# z5 Y* Q4 O; j. z' X' |# A
  189.                 printf "Importing file ${file}\n"5 a7 I1 x) j# C) n, @' {
  190.                 $(${dbcommand} ${wdb} < ${file})
    ' U1 w' ~, Y& C5 ~0 k
  191.                 printf "File ${file} imported\n"
    * y) f1 b, i2 C
  192.         done
    / A; p6 s9 c. @
  193. }
    8 f4 P5 I& \* u  E- t, T4 \3 s
  194. , {- [" M, g  K6 t! E  `  a9 }9 c
  195. updateWorldDB()
    8 X% \; w  {- |: q% n" {
  196. {5 J. D/ g0 @3 l' F8 Q3 ^7 Z
  197.     printf "Updating data into the World database ${wdb}\n"
    9 u: b2 s5 }" y/ f, L/ w
  198.     for file in World/Updates/${OLDRELEASE}/*.sql% H3 W% n2 i7 ^0 O- U7 I6 o9 ^
  199.     do1 D+ C. M% P: l, k% A1 A
  200.         printf "Applying update ${file}\n"
    $ _( N2 R  |( \" _4 ]4 d
  201.         ${dbcommand} "${wdb}" < "${file}"
    ! e5 G+ }7 l; p+ w, C& d
  202.         printf "File ${file} imported\n"+ [3 ~; z/ A: Q7 _: e
  203.     done. H1 }3 u3 C' k7 @* B1 l; }/ D) X9 G
  204. . w/ t! ^# k% R! I% w
  205.     for file in World/Updates/${RELEASE}/*.sql
    $ a  k4 s4 [5 l! u& G
  206.     do& I* D3 O* K2 _' G
  207.         printf "Applying update ${file}\n"
    9 _8 H3 N: _% c7 t) \
  208.         ${dbcommand} "${wdb}" < "${file}"
    ! `; U. R4 e2 m. }8 m5 M
  209.         printf "File ${file} imported\n"
    ( \2 G5 \# x, K/ s, d. |1 Q
  210.     done
    # r9 D- b1 ~' z1 U/ c2 P
  211. }
    ( `/ z+ L% E% R+ r- e: ?* A
  212. + i; D( b+ P/ I6 r2 q; y
  213. createRealmDB()
    ( u4 L" }! U3 U( g" _. P
  214. {
    & f) ?) d3 Q4 a$ Z2 f! i* B
  215.         printf "Creating realm database ${rdb}\n"0 L2 |2 P' W, G1 E3 {7 C
  216.         $(${dbcommand} -e "Create database ${rdb}")8 t3 K. U  o  ~$ c% I

  217. ( e: b- u1 B; ?/ z& p& b, G- n8 L5 S
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    1 R8 f! w2 t, i. L" r( A
  219.                 loadRealmDB6 [( _7 D" U& o
  220.         fi* S1 ^: u% u# D" |
  221. }
    / X  o; U  e' v2 z8 B1 y4 o

  222. # E' i" q5 U  ~7 x9 p  E
  223. loadRealmDB(); e* P3 w! @9 c# m
  224. {) U: H+ g7 Y) X6 g4 p6 s
  225.         printf "Loading data into realm database ${rdb}\n"       
    & E2 s. @: ^' f, x) k
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)
    ) j) e" R! S4 ^% x3 O
  227. }
    + _3 x1 Q( ]5 h0 j3 K4 w

  228. ) J. ]1 I; n* R+ j, i+ k. u" ], O
  229. updateRealmDB()
    & Y% X/ W5 c0 Q/ V. P
  230. {; l5 z( b0 U2 V
  231.         printf "Updating data into the Realm database ${rdb}\n"& @! B  q6 g. E% i
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')' l) a1 b" |2 A+ j! D' C: \
  233.         do
    0 c* u. M# M: X
  234.                 file=$(echo ${file} | tr '|' ' ')
    , t$ Z' \6 L( h0 A
  235.                 printf "Applying update ${file}\n"
    + T. a9 p$ u/ J3 e( q4 V, L
  236.                 $(${dbcommand} ${rdb} < ${file})
    : ]! {4 K- t% W' d. ^0 D
  237.                 printf "File ${file} imported\n"
      Y% G4 i: X2 ]
  238.         done
    # J2 J* H; R' x6 w+ g, A

  239. 6 V9 k8 S2 }# O3 X, h! h
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    # C0 i, g/ y1 ^$ W. c. V
  241.         do
    0 `" [  q, N' r
  242.                 file=$(echo ${file} | tr '|' ' ')4 e1 m* y% h4 F- Q9 s5 ^
  243.                 printf "Applying update ${file}\n"
    ) m! R( k4 ^# f5 Y. M1 I
  244.                 $(${dbcommand} ${rdb} < ${file})+ u! G5 b( {9 T: c, w6 v
  245.                 printf "File ${file} imported\n"
    ) `# a6 P6 E9 C$ ?$ U7 b* q
  246.         done
    ) G- a- x# {  F- k3 G( C
  247. }/ }( V: l/ Y, \. R! l
  248. 4 n6 a3 i# `+ Z- Z' X% E9 ^4 H
  249. addRealmList()4 c9 H  H6 b' S1 C- D* V
  250. {
    ; v' {; P9 m" ?
  251.         printf "Adding realm list entries\n"
    / g+ I$ c' e/ b; u& ~/ [
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)
    " D, k& r/ {# G" @
  253. }/ d' D& N& @+ `; \
  254.   v( Z# y' P' x$ S/ T5 Y, l
  255. activity=""
    8 k* T: a9 g2 O  n  @( `

  256. 6 Z! C& m$ ]5 j7 s4 z2 g4 z, J
  257. while getopts "suh" o; do
    ' g9 T: v& M: @9 @( V, m
  258.         case "${o}" in' m" b5 p5 }. u; C
  259.                 s)2 H* f! v+ v( N9 T7 k6 }6 \
  260.                         activity="N"& m3 |' S- B' R0 p& o0 D4 A6 v
  261.                         printf "You selected silent mode\n"3 w: f" z5 r6 o0 l9 ^
  262.                         ;;7 D: `- `5 _% J5 F. z; E# N
  263.                 u)
    ) j6 s4 e+ I- _" o3 x/ z
  264.                         createcharDB="NO"0 ], R1 |- A4 e( }0 ]
  265.                         createworldDB="NO"; x1 g/ u( v# E! [
  266.                         createrealmDB="NO"
    9 G4 z2 N9 Y' ^! a- }+ z- a0 P, k6 L
  267. 9 q8 N, v, R; H& B; G
  268.                         loadcharDB="NO"
    ; ^  D! @: L8 b. Z; M- X2 b8 u
  269.                         loadworldDB="NO"! u8 m. Z1 S: O+ _; y
  270.                         loadrealmDB="NO"
    - c& ]5 H% T3 p& F& s
  271.                         dbType="EMPTY"
      v2 G# ~" F( K9 `6 o
  272.                         printf "You selected update only\n"7 ?4 x+ d; q- _; v4 w9 @: E
  273.                         ;;& Y: T% J; G# F/ \- X) R
  274.                 d)3 C' g# z3 \9 E! W) X* ~: N2 t
  275.                         DUMP="YES"+ W( C# J) M8 V/ R
  276.                         ;;
    2 T; \7 U5 z  t! S8 }( D3 m+ ^
  277.                 h)
    3 B- c+ C( [8 [/ \% i* t+ ?
  278.                         printHelp  ?, _% b4 p$ y) s
  279.                         exit 04 z$ M/ Q6 ^6 ?; I, M% _
  280.                         ;;) y! b2 F3 w8 _6 C; I% K8 m- E9 `
  281.         esac* [$ p7 a+ p3 i9 Q8 f0 \
  282. done
    1 s, `& O5 \- U" ~- i
  283.   {& z7 ?9 @4 m) u
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]% G; d2 {1 k/ g: {1 \
  285. do8 g# q% G2 w+ L+ n  X: p
  286.         printBanner
    7 Y0 \# s5 @, R# ~1 ~
  287.         printActivities* Z  o, e* i6 p  B' Z0 a; d% `
  288.         printf "Please select an activity : "
    " _( P  h! \& O" \; i
  289.         read activity2 _6 G( Z2 W9 L! `: T
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )
    . z5 a- R/ Z' g' Z
  291.         case ${activity} in
    , Q, D- Z' H6 d- A, z
  292.                 "V")
    # B& T7 r' `* ?; g& x) P6 U
  293.                         if [ "${createcharDB}" = "YES" ]; then
    * s+ x' Y0 S' y$ A2 A
  294.                                 createcharDB="NO"
    - G! q* I0 p; ?8 Y
  295.                         else 9 E: L8 Q  q: Z) W
  296.                                 createcharDB="YES"
    % P$ q: H. Q/ }2 T& f
  297.                         fi
    ) U7 r1 y6 k4 T" g7 c+ X
  298.                         ;;
    0 @# B3 y. f* ~0 K/ [6 A% d& ]
  299.                 "C")
    ! B) v) i3 s. K0 c* x3 M. H
  300.                         if [ "${loadcharDB}" = "YES" ]; then) e6 @: x4 F: ?' D/ Y2 S" w
  301.                                 loadcharDB="NO"
    + @% M. q- K7 M# |
  302.                         else
    % {, v- B3 C- M, g
  303.                                 loadcharDB="YES"( ~& E- f0 Q9 C9 R/ h- S' Y: g, V4 G
  304.                         fi1 ]; ~1 |; Q0 i3 G
  305.                         ;;
    1 j1 C. h" o, E  p6 C
  306.                 "B")7 Y# V2 g' _. w) s
  307.                         if [ "${updatecharDB}" = "YES" ]; then& c1 c5 T* }8 o* c) q
  308.                                 updatecharDB="NO"4 K8 J/ G4 u& ?  k( _
  309.                         else 5 P) ~& p$ k8 ]  O$ ~+ g7 \
  310.                                 updatecharDB="YES"
    9 G, n/ c; ^+ }" r& I1 [( h
  311.                         fi
    ) e9 W2 |7 {- C# g1 R
  312.                         ;;
    6 E& \3 d$ ?7 R9 Q  a  o# N6 i  m
  313.                 "E")- R2 z/ i* E: c1 i( t
  314.                         if [ "${createworldDB}" = "YES" ]; then2 _/ `& T* ~+ t: G  b
  315.                                 createworldDB="NO"
    9 W( ?4 ~5 |1 I! A* f0 R$ E
  316.                         else 0 ~9 l) T1 |" B, s* P  z# ]
  317.                                 createworldDB="YES"% {# s; S: g6 ^  y
  318.                         fi       
    # s4 _8 }& ^3 Z; P7 l4 i
  319.                         ;;8 D8 S* T1 b; P6 h, l4 m
  320.                 "W")
    ) u) j# s2 }; T
  321.                         if [ "${loadworldDB}" = "YES" ]; then& G. d3 t) v2 d1 i5 B
  322.                                 loadworldDB="NO"
    + u6 h: E5 x% `# n& r8 F
  323.                         else
    ) W  d& x* ^# R+ s5 l# z4 e
  324.                                 loadworldDB="YES"1 p- q+ b% j7 s9 I
  325.                         fi        1 c7 U3 l0 C9 @  o; [8 h) j" q% R$ G8 H
  326.                         ;;
    ) A* x4 n1 U0 e; B( S; q  n/ U
  327.                 "D")
    9 i3 d  z1 i9 H# b  z5 ]5 D
  328.                         if [ "${dbType}" = "POPULATED" ]; then" }6 R" e: p4 y3 r$ w1 D' Q
  329.                                 dbType="EMPTY"
    , \: @2 _- F3 T/ q5 t
  330.                         else
    4 i7 Q) K/ G; C4 A8 S3 U
  331.                                 dbType="POPULATED"* b' \9 m; D8 z: }
  332.                         fi                                
    & q+ u# f8 B* H7 F" X) [- t4 |
  333.                         ;;
    ! v+ w! K9 S. j% L2 [! B
  334.                 "U")
    ' g; R! r- N  Z! i- M+ Z1 f7 G; @
  335.                         if [ "${updateworldDB}" = "YES" ]; then! C3 l6 s  _& h/ H: ]- r
  336.                                 updateworldDB="NO"
    + _3 \2 }8 q# h6 u) H- s
  337.                         else
    * M" S7 |1 L2 `/ R! x: S
  338.                                 updateworldDB="YES"9 j/ }1 a) O2 W$ O- U% t" I! h
  339.                         fi6 L/ G+ d- H/ i" Y3 c
  340.                         ;;
    $ u, w* i+ l/ ~( I) k: s# g
  341.                 "T")
    % w+ P: }" q9 ?3 `# I. }/ b8 Z; j
  342.                         if [ "${createrealmDB}" = "YES" ]; then! ?6 d; `8 K, Q  R0 j7 q3 h) X+ o
  343.                                 createrealmDB="NO"' J4 B, j2 c  t5 X; y1 \4 K
  344.                         else , C$ o4 Z& p7 w0 N' N
  345.                                 createrealmDB="YES"
    9 C# N6 I* b$ N3 ^6 {3 U
  346.                         fi                                
      k; ^1 U/ @% U
  347.                         ;;9 [7 V) b& r! D4 r6 @
  348.                 "R")
    ; u+ f# g9 e8 f$ D1 h# N9 u
  349.                         if [ "${loadrealmDB}" = "YES" ]; then
    * Y4 Y1 O; Y- ~2 z( n
  350.                                 loadrealmDB="NO"                       
    0 n5 y: @) o# F; J
  351.                         else 1 W* L) g" u# o: f: N; |
  352.                                 loadrealmDB="YES", K& b# V( N( B- V; v6 X
  353.                         fi
    3 T4 P& Q& C: F
  354.                         ;;. N3 w) I, r/ V& u
  355.                 "Y"). e4 r  }0 g6 X5 @( L) N7 J
  356.                         if [ "${updaterealmDB}" = "YES" ]; then; O# T- @- f$ h" _$ D
  357.                                 updaterealmDB="NO"  _) V  O2 m, p& k7 P4 M5 K: @
  358.                         else + E, [+ ]( h2 H& ]6 L
  359.                                 updaterealmDB="YES"
    % Y7 q% r/ `* a4 G# J
  360.                         fi1 ^9 J( i1 p( [8 \
  361.                         ;;; D* s, C4 S3 D! w) N3 \
  362.                 "L")
    * w, R) u' D* h3 z
  363.                         if [ "${addRealmList}" = "YES" ]; then
    " O" `" Z$ V8 I$ @6 Y- i
  364.                                 addRealmList="NO"
    - J$ H1 G* M( D, [; |8 a( i) s6 z
  365.                         else
    * ]# S0 C; D$ J* L  f3 e. Q
  366.                                 addRealmList="YES"
      e2 h6 |; l6 J, Z/ v( s
  367.                         fi
    " E( C* e; j# U
  368.                         ;;  b( Q0 A" I4 p, ^; ]" u4 H, j* ^
  369.                 "X")
    ' ?2 M' Y( \" z7 [3 J, [% Y/ P
  370.                         exit 0;;9 Y8 }$ A7 h# k. f
  371.                 *)
    - X5 g7 g* s& ~$ |6 i
  372.                         printf "Invalid selection";;( s4 S* B. t$ C4 u2 Q# ~
  373.         esac( P6 f9 U) a' q- Y8 L) |
  374. done
    - j- k. H0 [; ]& F
  375. ' Z3 |* ~% `  }: V) h
  376. printBanner
    / d7 u/ U3 [% u/ H: }5 N
  377. determineDBName7 f6 T) O# a) w5 z* h
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "  |  g3 N2 J: v. J. U$ y
  379. read svr; R6 W' p7 w3 l
  380. svr=${svr:-${svr_def}}+ n2 \$ O" G! h2 P: ?
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "
    # {) q" R( _- n+ H+ v1 e
  382. read user
    3 Q/ Q. ?- ]& V* F% Z6 z
  383. user=${user:-${user_def}}
    : [0 H9 D: `5 w
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    3 t0 u) X2 W1 s0 D/ o) U& r% j
  385. read port. U4 g: O5 Z, O/ ^! F7 ~
  386. port=${port:-${port_def}}" D# c6 O/ l7 }) d; t! \/ A. k
  387. if [ $dbname = "MariaDB" ]; then
    1 C, H- Y' U# l* l
  388.         printf "What is your ${dbname} password ?\t []: ". a- }1 C; W4 n1 O/ u3 o6 `
  389.         read pass5 C9 W& {2 r6 s
  390.         pass=${pass:-${pass_def}}7 l- w; N# b& e% u0 z9 x
  391. elif [ $dbname = "MySQL" ]; then
    " l8 [+ H' M3 Q6 s0 H
  392.         mysqlconfigeditor: a! O: D7 Q( j8 a
  393.         $dbconfig
    * P" U; y4 r- H: h0 ^: X, }9 }  T
  394. fi4 R; }$ F. O1 O2 L5 P' m
  395. determineDBCommand0 u! E0 `- t3 g$ j8 R& M$ k
  396. 9 F8 s1 b: h9 `2 u+ b) c; _! {, m
  397. if [ "${DUMP}" = "YES" ]; then
    8 U, |" c7 Y. y3 ?& r
  398.         printf "Enter it again \t[]: "9 y$ L% K" j; x+ E2 L
  399.         read pass% S, ^; r+ \& G  I( Z2 |
  400. fi+ y: _5 V. @7 o5 H
  401. 0 `2 M* l+ r7 s4 q% u5 {
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then
    % D) K: h. ?( S4 E! P
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "; ], n$ w& `3 A3 P9 N5 g. y: |
  404.         read cdb0 B, \; l1 |8 l+ x; D, R! a
  405.         cdb=${cdb:-${cdb_def}}
    - |' a0 [* {- W5 i9 P: W4 U6 U
  406. fi
    : q" l1 g& K" Z& Q1 k
  407. ) h# O. }" ]( z' d/ l* ]
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then4 h1 }: V3 [  P" m( S. O
  409.         printf "What is your World database name ?\t[${wdb_def}]: "
    ! W8 T( ^; o; Y2 \
  410.         read wdb; u1 U# @8 C1 j. q3 B7 [
  411.         wdb=${wdb:-${wdb_def}}
    ( D7 [- e. m) N$ y
  412. fi! g' U9 q2 G" N& T- T+ {3 s

  413. 3 Y* @/ t0 K$ l7 X+ h3 h
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then
    3 ^9 {( [+ a) U2 H
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "# Q7 _8 Z! ?  q
  416.         read rdb  B& ]# M' s' B, G' R- i6 ?  U2 ?
  417.         rdb=${rdb:-${rdb_def}}9 V5 ?+ d* m) z) j. P# L* \5 W
  418. fi% m6 {; w1 R% N) o5 n6 p  _

  419. 7 I. K+ K" T; l1 w# L4 n$ n
  420. if [ "${createcharDB}" = "YES" ]; then* N7 N. }" W+ @
  421.         createCharDB
    - k+ L2 T" x1 n* N, A' n0 l$ S
  422. fi
    # H  w, A, X6 \. _7 W

  423. ) I4 t# }4 b$ D5 S5 L4 x; x" j  z
  424. if [ "${createworldDB}" = "YES" ]; then
    % `' [- i" J! x9 s: C0 ?6 L
  425.         createWorldDB' z! f' Q6 K8 s3 r; a
  426. fi
    & T% n/ h; K6 G( i* U
  427. ( r" L5 @4 E$ ~5 F1 v6 I
  428. if [ "${createrealmDB}" = "YES" ]; then2 n7 h, P4 r! ?/ \( T
  429.         createRealmDB7 P) g5 M- O4 i: }; o6 ?/ N
  430. fi6 X! p1 k  s# m

  431. 1 f$ Z8 S5 Q: U% Z) Y; R" q7 V& J
  432. if [ "${updateworldDB}" = "YES" ]; then! S; q. c! s0 i4 {5 F: }1 {
  433.         updateWorldDB
    % t* e& u& `* u% \# {: `/ t# G
  434. fi
    5 O% v: n5 W; H: ^; j) k
  435. # C0 n4 L9 y% C4 l7 L
  436. if [ "${updaterealmDB}" = "YES" ]; then( d" J' P. \8 G7 k  O
  437.         updateRealmDB
    + K# X, Q1 L$ h, E2 U: J
  438. fi' ^2 i) i; {0 g$ q, |

  439. ( |- i+ T8 R- ]) W" U
  440. if [ "${addRealmList}" = "YES" ]; then  \7 E  H3 ^( a* H9 ^0 Z
  441.         addRealmList
    * _2 W* @$ T* K3 I/ z4 @
  442. fi
    7 N: P$ F" ]* K1 O$ Y2 P

  443. ( x% Z6 z. h6 T+ H  U3 Q
  444. if [ "${DUMP}" = "YES" ]; then3 |4 w6 R# V' i4 @
  445.         printf "Dumping database information...\n"
    - g0 s4 w6 _! u" ]1 N
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf
      X+ {. w: o+ o2 v( o0 o
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf0 z& g6 |' j: I, m- m
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf/ C* B% b( o* m$ ~% z, D8 o# |8 S1 O
  449. fi
    / R8 a" x0 Y+ W6 ~
  450. , k; s! @# T. u
  451. printBanner9 N' R; X! P& {1 e. Q, t
  452. printf "Database creation and load complete :-)\n"
    - d. x& ^$ c) `( `; w8 e5 y( C
  453. printf "\n"
复制代码

- A9 t( X, k* h
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令
, R! T  T' U# C7 F: }8 S) x+ n% |6 u+ C8 |' ?* O3 {  h# Z- @
使用 Playerbot 密钥的指南:
% B% x0 `4 d0 S7 ^
% t# r1 H. R/ W2 {# Y标识符说明
9 b% [, F/ _' d9 Y- c机器人名称    机器人的名称3 m( ]& G! Y# q7 {1 Z4 z7 Q* Z
朋友    命名机器人或玩家角色6 _- E' @, q& A8 X+ G
目标    选择目标玩家、尸体或NPC(非玩家角色)6 a: @) S$ c1 \5 T. }$ m
|    逻辑或
. C4 p* p& j$ m* O2 I* k7 [% r&    逻辑与
8 [+ i( b! N& B# ?8 i# U' n( `7 z! _..    多个实例/ ]0 y( ^4 Q1 K* j$ i+ t
/命令    MARCO 命令5 k4 T2 [( |- P# }
/s    聊天:说1 G: X4 l" s0 x( b( B
/p    聊天派对( S% [2 \# }. J2 v( P1 u& L
/t 机器人名称    聊天:TELL BOTNAME% G* b: w3 ~& _
/w 机器人名称    聊天:告诉 BOTNAME
, W0 `6 p# o1 q; x) b4 q<名称链接>    名字=
$ L3 Z' @/ ~! l4 f# A1 U( k: s(捷径)    为命令或子命令分配快捷方式/ n3 [: @# G) Z9 V1 c

8 A' c/ Q! C; M1 X! @8 q7 b  i可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明3 U# v2 A! v- R& ~$ e/ ~
.bot 添加 BOTBNAME    为世界添加角色
4 e9 R6 E: w. X.bot 删除 BOTNAME    从世界中删除角色  L% n$ S2 Q4 E! i1 z& m( w

: r$ L' ~% V1 R( A: |* i当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)# K' o& r. S0 v" T# C
.bot < co | 战斗命令 > BOTNAME    分配机器人角色
1 w* m% T, e* A4 ?3 L# Z( d+ N
; N' ~# [0 g9 R$ Q6 @7 H5 N$ {宏命令:+ ^9 G" {2 L$ O" }4 A- }# Q" c
句法    描述5 r4 u, G4 q. N/ R) a& W% e: g
/邀请机器人名称    机器人将自动接受聚会邀请7 [1 B" ^0 c: C' J, X7 P# Z/ F
/uninvite BOTNAME    机器人将自动接受派对不邀请
  s; X- y+ ]/ _+ S
( r4 W: K4 m1 B5 q! ITELL/PARTY 命令:(某些命令可能不适用于某些内核)7 C7 W# g) L4 @5 N+ ^
句法    描述
% o1 j4 t. t: Z( p- ^( z" p协助目标    机器人协助列出的角色,在他们攻击时进行攻击。
6 T5 ^: W) O% R/ T, t+ i0 u攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式
* n7 E0 N# p/ j6 A) J拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..7 Q% A( L, e- d  a0 v
拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..
# v- `2 P2 c- l拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..1 D5 k, f) U/ i  r/ [: L
银行    命令机器人寻找附近的银行家并列出机器人的银行余额6 P( {  E7 Y% R. @, U, v3 B1 ^
银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行3 r# J/ q2 r1 n2 x* A
银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..8 w0 _6 e0 W+ w: I
(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..
; t. e: i$ ?! l) L, _3 n©ast SPELL    拼写 = >$ ]. G- n# Z0 ?6 S/ E4 R- U( L% U
搜集    显示收集对象选项和当前收集状态
% h6 ^+ y" o* q6 V0 V收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
4 b. F; E; s2 u, ^工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
& @' F$ Q4 `4 a1 _工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例. e3 X5 {4 o( s3 D
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
# }2 p5 ?% W8 V# H5 ]1 @" {5 }工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习2 `" j  S4 H* T* g9 C" ~
工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习" _1 `+ t, M+ e( o8 L) @
工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习4 D4 L( t8 x* n) A$ b8 K
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习8 R: J/ b9 W3 }) N+ O$ h5 |' H
工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
& \0 _, h/ p: j" V& x) `: T工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习
; Y" c# @0 E8 j& Z, V手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习4 M" `9 S6 L/ a3 @) T* Q4 G( }
工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习
7 {! U3 ~. I. o# P! w8 D) f工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习5 T6 U% s% j5 V! t( V; |0 l5 C
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习
) m0 U4 I+ t. J+ }' q+ u/ }掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..+ L7 j0 y8 H2 G! G7 ]
全部放弃    当机器人库存变满时,丢弃所有低级物品。8 B8 W: I" b$ \/ ~$ d
附魔    列出机器人学习的所有结界 1< Spell LINK >
9 v# {9 f" t2 v( L附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中" s9 D. y% u6 v
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品. C, A, v- N+ n( m+ E, k' x! Z' U
(e)quip auto on    打开自动装备,也立即检查0 P% |9 @9 @  E+ D4 a) s
(e) 装备自动关闭    关闭自动装备。  Q6 ?' {$ \& A8 O' @: Y- I$ B1 v
(e)quip auto 一次    运行一次自动装备,然后将其关闭。; W% D4 ?7 U" z7 C  t) L
(e)quip 信息    显示装备自动切换状态(开/关)。
/ r0 p+ h# y; `7 M' j  l+ L(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用
5 Y5 E5 K1 C, s跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人
6 h0 s/ r' N5 o1 ]2 g7 X跟随汽车    切换自动跟随距离(开/关)1 U8 \8 I( F! y: H+ y
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)) R. i/ S' ?) @7 _2 ]
跟着远    机器人跟随,远离主人。
% H* R' b4 F, g跟随附近    机器人跟随,更接近主人
2 X5 Y& A+ v2 Z& w. D跟随重置    机器人跟随距离重置为原始默认值6 a( v. Y1 @) H9 N
(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家
  W* Z+ P3 B5 P( Q. Z. p! `! H; p订单    显示机器人的战斗命令+ ]# s- I, P4 ]8 i
订单延迟<0-10>    在机器人开始战斗之前激活延迟。
, R  A. J( b' V命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
* w/ S9 w) t( v8 f$ U# Z2 q命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。4 o7 f% G6 x! h
命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
! e4 s5 E$ \  D命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。
/ E; r* F8 W9 D  l/ P$ D8 \命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。5 w' o  d8 e& ]% \
订单恢复    将战斗命令恢复到注销前的状态。$ O/ x. ?7 g& _; h. l' v6 F" b
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。
# Y2 ?. m( ]; F& j) Smail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..
5 W; o; b2 ~" V( w/ E6 l* S0 C邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..0 R: r- u1 t) Y0 ~6 |6 A  P
邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
4 D8 e4 }5 B. f! K! m* e宠物遗弃    放弃活跃的猎人宠物。' _: D# n4 q+ j. w( }: x5 f  ?
宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术* r& b. ]" @" B4 E5 o6 G
宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色
1 K/ E6 h7 P. n; r6 K* k宠物施放法术    拼写 = >
+ X9 }0 a4 T8 ^5 E& S) s宠物切换法术    SPELL = >为给定的法术切换自动施法% F" v" A1 [+ Q$ h+ q
宠物状态    显示机器人宠物的当前反应模式6 K4 E$ q8 g$ R6 L5 |! b
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>: o5 D4 W! h! H
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
+ d8 C. Y0 ~$ @4 n处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素1 A# d) [! e. \. a0 i
过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
. A# y8 g$ K& v, J, b8 y拉目标    以协调的队伍/袭击方式拉动目标。7 {* I* K4 N) y$ M9 O2 e) y
拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。
' c5 F7 Y" P" o# }准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。
2 G/ _" G5 V: n0 t5 K0 |寻求    列出机器人当前的任务+ X8 {: d7 X! ^1 p& e/ }
quest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..: y% q+ A; M5 {0 `$ [& o4 g
quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >" x5 e! a5 i5 [: g
追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务6 s+ d) q- O2 p: P9 \
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象
% v1 d9 b1 e/ p4 L& U/ S' I$ C+ c任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
) v) T# S& b: R2 xquest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到  F* p& x; i! x
修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
1 J3 _7 f# R( ]( V全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品$ H7 ?. O8 s1 K
重置    重置状态、命令和战利品清单) B5 ~# F% X( w, C% }( \. }4 A' {
(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >... [* G" s7 ~' O1 N6 G
(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。
+ w6 m0 F4 ^( m; @+ S$ X/ `技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能4 S' w2 c6 l$ Z
技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..
7 n& o, t! k, F  r& ~3 [技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >.." t& ], _! H! X% b8 i3 J
技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术
( l# T  n4 a5 \7 `; S& I咒语    显示机器人已知的所有法术
( n. |' j9 g5 ?! J8 h0 A统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本$ |6 E, D$ o- g2 L
停留    命令机器人站立而不跟随玩家0 T" ]2 v/ a* f) e  ~" _. `
召唤    玩家附近的传送机器人
: {2 [% q( h1 z; R* ]民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..7 X. Y* }) F& W" X7 }
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)3 j, {1 _( V# @* W
使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)+ H7 A7 U: s' ?+ f6 \: v6 \
句法    描述
+ {8 f9 M% l2 D天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用9 K* L- V' ?% K5 B) n
人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋; Z7 g2 X5 ~/ G0 @- h2 _
天赋重置    命令机器人寻找附近的班级教练并重置所有天赋21 c* t5 U: M' Z$ b+ _
人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
- A1 e: x* [7 I5 r2 x6 I天赋规格#    机器人将遵循此天赋规范。
+ E6 V/ R! d6 X/ n3 p, x: g9 x! v/ C/ W1 H  [/ F
1 要选择 , 。
- h' R9 v! T! y; d# W+ `3 g2 每个机器人的税收增加,每次重置天赋。
5 t2 t% H7 }4 C2 e8 o* q. U
8 N$ C- k' a2 T" h/ b! R
3 ^4 g) C2 t0 ^) \& B) x
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 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)) K+ n1 S+ g8 h
7 s! L1 D! `  b7 O6 d! ]5 J
1. Make a folder for ACE in your preferred location ( I use /opt)
" A" D+ x$ {# D# |8 r4 n
7 B3 R! h' p& B4 c6 F$ Amkdir /opt/ace && cd /opt/ace7 P- {5 I8 \  H: ]
: ^6 r6 d' Z) n
2. Download and unpack ACE
4 q+ {2 ^' q( Y. t8 ~5 c: L
+ {' Y4 l" f5 }. ]wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz; }8 ^# k' S; ?/ X: q
tar -xvf ACE-6.4.7.tar.gz
1 o5 ^* b0 B( \' w1 I4 }5 T9 m& W8 I* O
3. Add needed environment variables% G1 B1 z+ P1 k" D7 M/ s

* o$ ~6 s, ~. Y; O+ r! Ecat >> /etc/profile <<EOF5 o: Z, E6 [! _( N: a0 `3 A
export ACE_ROOT=/opt/ace/ACE_wrappers1 z6 D* d! {0 S  L
EOF
) T; w& [& b/ m! y5 f5 |source /etc/profile

, [+ {  r; T: L) e# m/ a9 G+ @
$ z% v& u+ T0 _9 J6 ^8 Q6 {4. Add the desired headers
7 _  q* p! a1 _5 {: X) c  Y; L% U# F* A6 G; t. c- V
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF5 X9 F  T$ _. U% z# [: d. {
#include "ace/config-linux.h"
8 e2 W, }- m) X  j" X7 KEOF% V6 g# S% e" p
cat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF; k* a) d/ b& E3 V& r, R
INSTALL_PREFIX = /usr/local' G9 d7 x# v& n( {
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
- z  i: v& x2 ?8 R4 Q; ?EOF

  c; C$ h- V4 D6 j0 S
+ U, I: D( o6 e8 P2 r( S1 e' u# D5. Build ACE
. u9 N+ W0 O& j  K1 a( g% P$ z+ H
cd /opt/ace/ACE_wrappers
" U: W1 r1 p; B1 V* hmake
4 `5 ^7 m" u: {  [' G; mmake install

% P& Z3 J3 A2 U# @' r0 q6 Y. X; z3 b+ z4 n( b0 ?" V
6. Add the library to the public path  Y% F1 ~' x% z( H
3 I7 z  P4 Q1 W0 I4 Y: W
cat > /etc/ld.so.conf.d/ace.conf <<EOF. g. w8 |0 C! `$ V% s! P" m5 u
/opt/ace/ACE_wrappers/lib
8 @- f. P% b$ lEOF/ t- n0 P% `. h$ S
ldconfig -v

' E2 a0 V3 m- K/ u5 p, D
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client5 U$ z6 B2 a$ i) @% y1 D
Torrent Download
) Y  J0 X8 o  N, Q2 ~  C7 T1 p: r* b5 a( e" C/ f2 l2 y, }  S
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
2 U5 ]) x) V$ L, G$ l/ F7 t4 e+ l9 O+ ~4 _+ R: p# T
    Torrent – Client from Dalaran WoW (Recommended)9 Q8 v1 ^4 B: N$ C5 Q
    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)
1 ~  d: ^1 r2 I5 @, W2 _- s    Magnet – Client from TrueWoW
& l# K; d( [/ S4 v+ Q
9 ~6 Y, y, C% h- i6 B' r& _Direct Download
: f+ P( [8 j- [6 A3 _7 v2 h/ G# ^! Y) j' L# l! f& j
Below, you will find direct client download links. Instead of downloading through a torrent, it will download through a media upload service. If you can’t download through a Torrent, we recommend the ones below.
- k6 V, G5 I/ ~- O9 a5 s
5 r# P$ _( D( ~& i, j    Direct – English Windows client
* b4 ~2 v& @7 z" ^5 o' E! M' Y7 l1 L* D! V
3.3.5 Wotlk MacOS Client
0 Z4 R7 d( |* M- u* K- M
+ {# [4 ?  a; a8 q1 [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./ o: Z; q0 R. v$ r

* N. X: ^. w- y3 n1 |4 |7 U& l" T    Direct 3.3.5 MacOS Download – Client from Sunwell
2 b6 w# i: h9 F! u+ h7 v  h    Direct – Client from Paragon-Servers (French)(Mac)- t7 Y! `: @8 J- ~, N
9 H$ x! z0 p5 M. Y
Modified Clients, LegionRemaster:
: `' g6 I% ?& x! ~- e$ r$ a
0 M$ h$ j9 _9 f5 W- Z    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis% ?/ S5 s5 }; [' L
    LegionRemaster Patch (modified)- ~0 ^- o7 }* w: A) R, A# D! W2 H
    LegionRemaster ReadMe (Custom)
" T+ ^4 }2 ~$ r0 d8 G3 d% phttps://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos( A' i! q3 z1 Y/ e5 X0 V) q) ^) r

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

; T) ]. O/ O  Zmangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。  x+ e2 p) y! L; Q. L
% Q5 V0 M: J  P! N" z" A

6 J& m+ a9 Y3 h- K0 b3 O为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。0 }/ N5 Q# h2 U" @" l8 v- k
1 y; a9 g/ i: o
一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:
    6 B' b( N' E; r8 W7 P
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:: x8 w" w9 o. z  }/ t
    Brien
  • 开源数据库软件MySql
    + z/ ^; S6 v/ r官网:MySQL
    ) ]2 m1 m  _4 ~' E
    或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库
    7 b9 p2 \$ ?  j) H" ?9 z官网:
    - p  ~+ G5 N2 G3 Q
    我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。
      p, K/ q: G# ?$ N$ Z文件名:CompleteSDB156-Mangos3462.rar* }" G9 `) `! c0 D8 Y& l+ G1 J8 Y
    下载地址:
    0 b, o- V7 o# v

    " L9 [' o" A, G7 S) x7 l
二、安装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"( S3 c: l+ r. V# s! I- g' U; Y
      Z' a: B  R; i! u1 R9 Y; |! |
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径
/ m0 I6 @$ U. _6 R
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。* Z. H! R$ y0 v  Y3 ?! n2 Y  d
四、解压安装地图文件
- T, S7 S5 i# C4 X
  • 把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子目录了。/ d+ H0 Y9 d3 s7 K
五、解压安装提取的*.dbc文件
; m+ v$ {( ^2 x6 @, P9 u2 [4 k
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:5 `; k+ h4 A% O* A8 ^0 U
    mpqe /p dbc.MPQ DBFilesClient\*.dbc
  • mpqe工具将魔兽的游戏信息提取到了\MPQOUT\DBFilesClient目录下,整个结构为:("C:\World of Warcraft\data\MPQOUT\DBFilesClient")
  • 当mpqe运行结束后,可以将所有的*.dbc拷贝到你的mangos的dbc目录下:("C:\MaNGOS\dbc"),你大概有158个*.dbc文件。
  • 你可以安全删除魔兽世界下的dbc文件目录:("C:\World of Warcraft\data\MPQOUT")了。
    / P; Z2 k6 M  {! P+ P
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.
2 A6 I1 N( K5 F/ N% b; M
  • 将下载的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”,导入数据库文件。
    ' j! }5 w- O4 X& q* m4 v
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。# z" f$ D" a+ ~( a1 j& P
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到
    + ?& }+ D( p4 F- c"LoginDatabaseInfo ="
    3 F4 I- |$ Z0 p1 \8 Q# l改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"
    4 D/ B9 d5 M# C4 ]* Z8 T& h& ?这里的IP地址可以是你的IP,[password ]是你的密码。存盘。
  • 在mangos目录下打开mangosd .conf 文件,找到如下的内容,并设置如下:
    • DataDir = "."
    • WorldDatabaseInfo = "127.0.0.1;3306;root;[password ];mangos"
    • LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"
      ( o& W0 M; {" P5 n
    9 G% J& h" w7 Q4 X
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。

1 S2 G. I) v4 e' F! h$ t
) g/ c9 m$ M: i7 w" X
. F* j  |3 @" C5.安装数据库
5 |8 j  B2 L5 w" x7 c7 ?, R' t* j使用mysql建立 mangos 数据库
5 ]7 W0 ^8 d, z
. R9 Y! C  k7 t5 A5 E7 Fa1)使用官方最小数据库,mysql用户名及数据权限等请自行设置
8 S2 r& Q  X9 z3 J9 |6 J  y/ r& Jmysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据' h7 M, E9 o' _. B% h
/ l1 A8 j1 g0 Z
a2)使用sdb数据库,mysql用户名及数据权限等请自行设置
$ ^8 l* }) {7 ~- p7 S, l假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
4 h% ^  m3 P( e: U/ hmysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据
; P, I/ n. S' D) G$ B* L
. W% q2 s2 F: m: ab)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.14 A" o& _$ x2 M7 O
% k" s7 W2 X4 M" J+ L
6.编辑配置文件4 N$ `6 [+ ]# X' B  ^. Y8 l, n9 z9 o: f
编辑 /usr/local/mangos/etc/mangosd.conf
1 F8 {- q. a8 [0 n4 A/ b0 B
+ T0 b  V' v: y7 @+ c3 @; c% }# ma)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\": A9 x. K6 M4 H7 j
为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"
' J0 H; b/ ~. v$ G/ H, _! c5 W8 ^
b)找到 Host = localhost% l1 p" j4 w7 O; s( _
为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1% H. A7 ]5 x$ M3 X! E& F
+ M) H+ e9 M3 C3 O2 J! t
回复

使用道具 举报

991

主题

92

回帖

5万

积分

管理员

积分
55457
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。
; i2 z( r) m8 I
* }/ [9 \' ^. s$ p+ W% J本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。
. c$ `7 G8 w2 f* q' f1 {, q9 Z1 m8 j' r7 ?1 x) t
我们走吧..
6 a4 n" X: x) U8 l' H2 [% ^  n4 J8 \1 f! {$ u7 K7 Z
设置数据库:+ M% H. u/ M. |$ v$ v
% R3 x1 _" Y! O  _
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。
9 b& s$ `% I$ [1 W6 a9 c9 }3 b" N
启动一个终端,如果还没有,您需要成为“root”用户:
4 Q( v/ V8 N1 m5 g4 S
3 O% I9 r; U6 W1 t4 s0 a须藤苏 - 根5 ], Z" ^, k2 {! N0 K5 [9 F
然后,安装 MariaDB:
- }, J( t5 W4 B! v) E0 k, @' \7 Z. z* \' S9 I' I! |
yum -y 安装 mariadb-server* v) M6 S) r0 L& f( N
     安装 MariaDB 后,启动它:
  ?) d( x1 D' [/ B
9 o+ d$ v; G% {3 P& qsystemctl 启动 mariadb- ?/ }3 c; @' W! K, b7 T
我建议您在启动时添加 mariadb 服务以自动执行它:
% B8 d: ^( j2 v9 ~
7 u. @8 R" V$ T/ csystemctl 启用 mariadb
  h- L3 v+ |0 D' H; d" B4 f, \让我们保护您的 mariadb 安装,执行以下命令:% q  G; I* u" L; y2 R# O/ C
0 H2 R5 y; ^% u3 h6 W+ ^
mysql_secure_installation! Q6 K& q8 h  m  s. R. @
我建议您设置以下参数:
; j, [2 K! X0 P9 x0 j- d* E* k  i
- D5 d) b' V7 E0 Y设置 Root 密码
- }  ~- ]+ w6 H删除匿名访问
& a5 u$ E1 J5 N6 d" Z禁用 root 用户的远程访问' C$ q, j5 ^6 ~9 B
删除测试数据库
# O8 r3 P7 r1 y* v* v重新加载权限! o( m1 C/ T& F2 }, E
验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:3 g. w4 a3 F  B. S7 Q
4 D: |" I( M$ i0 a
mysqladmin -u root -p 版本  ]. K) `( `7 E6 X, Z$ n$ M
如果一切正常,您应该有如下输出:
8 u% E; Z, B/ v' o" H7 H7 T' \- i! G( l6 _
服务器版本 5.5.52-MariaDB
$ f8 l6 @# b( H协议版本 100 [% @3 ]3 P7 I8 I% ?+ j
通过 UNIX 套接字连接本地主机
) b' C" j. M& U3 Q8 gUNIX 套接字 /var/lib/mysql/mysql.sock- c- }; `' x$ R5 r" k$ N  R
正常运行时间 x 秒
* V6 g" y( O1 e8 N6 n9 T
& ]1 G$ q% T2 d- l$ t* U4 }, w" ]9 p, n  V9 x( f
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:6 @) g: ~0 ?" s3 _2 Y8 s
5 o8 y# @& {' O
mysql -u 根目录 -p) v9 n/ j0 p9 ?/ [+ ]; t6 |; ^
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):
  C% w4 }, w; n5 O4 X5 [. g
+ O4 S/ |" M( i3 b& B创建用户“芒果” @ “本地主机”由“密码”识别;
; a% a2 _% z7 H+ M; f8 b5 l然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):
  ^+ J5 F- @7 O* B: v3 q: I: N3 B! z& p7 B' P
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
4 f+ V* v) J5 O4 o7 S3 v: Z退出终端:1 U8 u/ i, M! A7 B! o& k

- C* @3 D" r3 v退出
" V! b3 N% i4 ^5 J! Q/ \恭喜,您已经在 CentOS 上设置了数据库的先决条件!
. r+ V+ [$ {8 Z$ ]6 {5 m) g7 K$ e

/ w- z7 m8 i4 G  P
0 P. b. @, u7 A: O$ q) x安装芒果:
% a4 f! d# H% E6 a; v. @3 A& Q% N& Q# g. C
我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:, D/ A* S/ d% ~( _# q; _  l
0 T0 O) Y  x: x
光盘~9 q, G+ {1 J4 G4 Z# |( p1 e
让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:
4 `: [( X2 c+ F4 N5 J; W! M& f
7 Y5 g* X/ B% P- g. J' x, W4 Jyum -y 安装 wget
; L6 U) K' K9 t# }5 Q) C% Q2 I现在,我们可以下载我们的安装程序:, m) s+ ]  ~" d  `
! U, Z9 b6 o: n% J0 f: T
wget https://raw.githubusercontent.co ... /linux/getmangos.sh
! z5 Q8 F: [, Z9 g2 m" z设置允许执行它的权限:
7 c1 c5 i- t! `! `: U, }5 ]/ a# W5 Y9 X) O6 R* Y0 Q5 d
chmod 700 getmangos.sh7 Z# b7 w: J  }  X5 `, h4 q, X; v4 c8 n
并执行它:
7 y  @" i6 j: p/ l: a- L1 ^6 u
7 }- ]6 F5 M$ f0 q$ C& V./getmangos.sh
( ^4 e8 `2 G4 ?$ E9 @5 y在我们进一步讨论之前,对可用活动进行一些解释:
+ J: ~4 ]1 E+ ]2 w
9 ]% B# E' x. M0 d( E安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。, C4 R, g; G3 H, _! t
设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。
; \, y: ]7 z2 {/ O* K& _, N' e( w  m克隆源存储库将帮助您克隆Mangos源。默认切换。, ]* M" S' s* s2 Z, k4 [; l. C
Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。9 |* \2 E4 N5 \- T- ]5 x, t0 L! B
安装MaNGOS将帮助您安装MaNGOS。默认切换。
; e; X4 D% ]8 a7 Y! O$ y8 ~8 C安装数据库将帮助您创建数据库模式。默认切换。
6 e! R, Q: {' N/ w1 B( Y提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。
# C( Q$ ?; H; Q创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。
: A: H$ O. B/ O8 F7 M; R+ K现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。  D! O4 c& k2 K/ {  O
) \# M, ~. F7 v
用户选择:9 p$ K/ H' a: t
- f. k9 z  o7 s, T
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。
4 q  ]$ u0 K. X$ c
! C: j$ t3 R$ u# u0 i4 c% W, g如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。3 q8 q9 D: Y; P
7 ?* a) ^9 U% x  w; D, v2 ]
选择魔兽版本:5 [* i- N# D2 _9 D- r/ `, j

9 Z, h7 E* v- Y3 L9 @2 ~下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。; q. s4 k5 i! z: c4 T' ^8 B

; N5 F! |6 c( I& H4 p* y' g源代码路径:  J% W8 V% R  h& O8 M2 F6 S  j

( ~% e+ Q4 g5 C; Q/ K下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:. S, w3 n+ m- q1 j& K+ T& R

1 T5 [2 g% p% D  ~8 z/home/芒果/zero/src
( @" p2 H  m) U- ^如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。
& B, d7 o' e2 w( ^
+ U6 N: w- `+ L, `4 Y安装路径:
! Q' h, M3 {7 O# [* O0 m: f& Y( p  F
下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
' Y& v4 t9 G. L- g+ Z) n3 ]* b* K1 H
/home/芒果/零
/ E& A# z5 l* ^  P如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。- o. N( y6 W! x
+ z2 C, M8 i' p1 G0 ?8 ?- d
克隆或更新MaNGOS:
+ w3 x! h2 m6 D! C% e- I: o2 B5 q# {# p1 ^# h) M# A! c
脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。
( ?' p+ K/ l0 w# w  ~. |) D
: o3 M$ n) Z  |6 C/ z9 d/ F# K) N/ t安装程序现在正在克隆服务器和数据库存储库。
: e) F5 D$ d/ f, r" o8 Y& M% F' ]1 A! U) G, U
构建选项:
: c1 V' G2 f' \- p4 p8 c3 [: \7 P0 F
, Y9 @0 M* C5 @( w3 Y4 ]4 q您现在处于构建步骤。此屏幕上的一些解释:
: f4 Q$ S0 S4 Y7 r: g! Z0 {6 u3 o" t+ \
Enable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。* Y% O$ B! D3 H/ I
使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。) G2 ~# R8 n7 x; J9 o
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。8 e0 P7 Q" b- d
使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-8-5 03:25 PM , Processed in 0.107203 second(s), 25 queries .

Powered by xyh-moon X3.5

© 2001-2026 Discuz! Team.

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