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

MangOs搭建魔兽世界私服

[复制链接]

986

主题

92

回帖

5万

积分

管理员

积分
55255
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!" Q" a6 x8 v7 i8 n) m! Y0 A
考虑再三,我选择了CentOs来做游戏的服务端操作系统。! ^$ S) w4 e  m6 b4 s
通过Git获得Mangos的源码之后自行编译搭建服务器。
+ M- q4 x0 P. @; w这么做处于几方面的考虑。! }+ Q  W9 r( Z: c
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。# b' a% \1 S, ]' H. f  a
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。
3 A; Y$ N* N6 d* ^9 A把该打的补丁都给打了(yum update)
0 _9 c# d' {" V! |& F" ~完了之后,咱们安装一些基础的组件和环境。8 U& O2 V* J" G, n
Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel
+ ^* A* J( @7 ]如果有些组件提示没找到,无所谓。继续往下。5 U9 t4 [3 U! @
我编译安装的第一个版本是cmangos。" ~1 h( |& x& O; ?( }$ K1 F3 }" g
这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。; q! P. u- }3 I1 }) `' n
cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON, z& Z, n  V" |; j4 r9 J
编译参数中:
# E% `3 I* x$ O; pDCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。
( W* ^+ z, c# m: U8 g4 uDBUILD_EXTRACTORS是指是否安装地图提取工具) g5 h6 a8 p1 }" t, _
DBUILD_PLAYERBOT是指是否打开机器人
, H" M! @$ t, z; s6 u( ]这里我做科普2:
$ g' ?7 x- }' A: q! R7 G首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。
9 s. ^" z0 P9 r& j既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。" ?5 I; c) `3 M; a2 V( m7 G% e
至于那个机器人吗?那是个笑话,请自行忽略。- J! N/ i0 r0 ~; `% F0 ^8 N
我们继续,我把整理好的搭建步骤列一个明细:6 _0 J% o7 x% ?: j2 p8 K' j
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。  F: c$ b! k: z# z9 b8 [
这中间,我把一些别人不会告诉你的关键步骤做科普3:( P1 Y" n1 t, ~+ I3 m: a
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)
    - Q& z' o6 p8 z& Q" ]
放几个链接仅做Mark:  @' A( U# P) L# P* d
Cmake3 安装
% h: y5 V5 W8 e9 g  e" W$ ?. D% [4 B7 Fhttps://blog.csdn.net/weixin_38883338/article/details/864087491 ^: z# b& x9 V. d; R
Gcc 6
. W+ J$ j* x' j+ q& ghttps://blog.csdn.net/Al_xin/article/details/92438055
5 R( H7 T+ j, _3 a1 O# `ACE6.3.3
" Y! X) @$ T: D. o0 n1 F  A2 Whttps://blog.csdn.net/u010587274/article/details/50965369  M  i0 c+ G8 i7 Y( i+ K, R
Git源码和数据库编译安装服务器
; F  k/ i5 C; \git clone git://github.com/cmangos/mangos-classic.git mangos
, F$ a' O) s6 @6 \4 Tgit clone git://github.com/cmangos/classic-db.git5 j1 t1 k' t9 _% f- l
ACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
" w5 E# _  M, p6 _; }' }  B# ?我们来说一下服务器的配置。
- L% l% |* g8 A% ]: f  ]+ G在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
# y" [0 z+ K( }/ a
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)
    : k: ]5 f) ]+ x. L+ C
有几个关键点,我整理如下:
2 c0 A: Q0 z8 e
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。9 l3 H# ~# X! a3 Y! Y& f
参数名称:
' W8 }' \, @6 S0 Z9 R/ `9 x1 a6 h" A地图目录
" C4 _, r5 p0 ?) YDataDir = “../data” . ?/ u+ a2 Q: y" y
日志目录9 e( L% j+ n. v% e- C
LogsDir = “../logs”
; o, G5 \. j& @游戏欢迎语/ O! Y2 J0 M1 c7 L5 b0 f
Motd= “游戏欢迎语”5 K; \1 G  q5 J) [3 w  a; u
出生等级
! @1 H8 o7 G; \" t+ tStartPlayerLevel = 1& s, M. p3 T# T
出生携带金钱1000G
+ j; e5 [5 t" t  A' f3 i- a3 ^3 m! oStartPlayerMoney = 10000000( \2 A0 D4 x9 U3 k) D) E% k
杀怪经验5倍# P& s! @. T/ d6 C: ^" B, k: G
Rate.XP.Kill    = 5
+ i' W& I# n9 l: j6 j  i任务经验15倍* q; x- q! {- @0 |* z5 p1 b
Rate.XP.Quest   = 15* W$ s" d& `7 `6 p: X7 H# S
探索地图10倍- E* {6 C, `$ v' ^  F  S* i6 _
Rate.XP.Explore = 10/ H& H% J' e# R1 a9 m
数据库连接(应该有3-4条之多,按下面格式修改即可)5 K* k* F$ u9 m$ B+ L
LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”; ^" V7 {" W& S# a* W/ b/ e# V
配置结束,就是启动。
2 M  z( Q! T/ G3 T  w3 p+ e因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。
& a% c6 X4 V3 \0 _3 p5 T我们需要开启如下端口:
5 p! t1 u- V; a5 ?+ R+ y8085,9600,3724! [1 R4 _) C8 t' T
把他们添加到你防火墙的白名单即可。0 b* w, y2 a/ p4 P  m
(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)0 U' x/ O" w1 ^0 ?% h+ _( {6 S
一些收尾工作:
/ V( f& `4 S' \8 X
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。
    1 x% f0 n" b' n; {) @. n: g# q

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

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

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
' C  t  r, {* }* Y$ H5 Kgit clone https://github.com/mangostwo/server.git* c7 B4 Y, W( R& m* G
git clone https://github.com/mangostwo/database.git% d" g. M" B0 t, k* r

% @- c: j$ p6 V( O) \0 f' ^$ v
  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
    8 E8 ]; D) n4 ?, J( }' `* z3 ]
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils
    " q& o7 T# d5 [+ [. ^
  3. scl enable devtoolset-7 bash
    6 C- M8 g. {  @+ M/ J1 y
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile0 ?5 m/ m2 G$ x" w$ M6 `  m
  5. # 查看安装的包
    ! v' _2 A! t% v" |( ?1 {1 J: t
  6. scl -l + a9 p4 o  Y' t  G1 Z0 q4 B
  7. yum -y install rh-python358 g$ `* J" y- X5 n1 u+ t
  8. scl enable rh-python35 bash3 |+ }- q7 T( l& c+ O! J
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile" x; x, J( @6 @/ S) J
  10. ; ]# y7 e' C; \2 P* N) L
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz8 b2 a2 b1 @- Y! h+ q7 ^
  2. tar -xvf ACE-6.3.3.tar.gz
    8 M7 g, D, W8 ~* w! @
  3. vi /etc/profile2 t- X/ d# Y+ U0 d5 [: B, _, a
  4. #在文本尾部添加:& f4 B9 L; M" H! ~; Y# i
  5. export ACE_ROOT=/root/ACE_wrappers$ B0 \/ z: A5 M4 J' v. L. `9 j( e) P
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    9 S& J) m) E' w0 I3 |1 k) G1 ^# _
  7. vi /root/ACE_wrappers/ace/config.h: z+ m3 E9 L9 P/ s
  8. #写入如下内容:# H* i4 I$ r6 Z- O- c. x3 c
  9. <code>#include "ace/config-linux.h"$ Y. \( O, i  x9 F9 \6 ]& m& z
  10. </code>
    8 E' P( W( D# x0 c# C
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU) ^* ^. c" E3 S4 B' I" ~' |
  12. 写入如下内容:
    + Y" t# [% a' t8 k% B: t% K- ^
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>7 |; `" }" _: P2 I) a# T9 K
  14. <code>INSTALL_PREFIX = /usr/local</code>$ N) i6 ]/ j$ U/ K
  15. ; l0 v+ i) x; }; M5 V$ J( P; m
  16. chmod 775 -R /root/ACE_wrappers3 f# r* i* M7 F  @
  17. cd /root/ACE_wrappers/
    , c/ h# \0 `: E2 O
  18. make/ U& S8 ?! e5 e! d: A5 ]
  19. make install7 q3 x; O6 v" T6 u  Z
复制代码
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-29 17:20:43 | 显示全部楼层
  1. wget -c https://raw.githubusercontent.com/mangostwo/server/master/linux/getmangos.sh && bash getmangos.sh
复制代码
  1. #!/bin/bash# D; m9 x1 ^) x6 X( m0 c. H# B# i
  2. ###############################################################################
    ( c2 t+ U9 [  k  W+ L- N8 e
  3. # MaNGOS Build Automation Script                                              #
      G( d8 j( B+ }: a% e
  4. # Written By: Ryan Ashley                                                     #! A9 Z' p8 w3 x9 B2 v
  5. # Updated By: Cedric Servais                                                  #
    & l% Z9 o9 o2 d( M, ~& q% X
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #7 V, h) d4 |' s
  7. #                                                                             #
    5 m. j1 v2 ^: j8 G) M8 t  V
  8. # This program is free software; you can redistribute it and/or modify        #' _6 R# b$ Q' h( E. y* l
  9. # it under the terms of the GNU General Public License as published by        #* G4 a. V0 `" T1 m
  10. # the Free Software Foundation; either version 2 of the License, or           #$ w" H0 f, B# ~* ]
  11. # (at your option) any later version.                                         #
    2 S4 p1 \5 N/ C+ X" V* V$ O
  12. #                                                                             #( c0 [7 A1 {/ X. \- ?+ L# D$ a2 q
  13. # This program is distributed in the hope that it will be useful,             #
    5 ?+ J# r$ m! ?+ J" q2 j9 A
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
    5 o! s/ {2 k6 z' O) r
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #7 r( Z( m) z0 {) Q
  16. # GNU General Public License for more details.                                #! s; ~' u7 c% n3 r2 c+ F% u; g2 d" p
  17. #                                                                             #
    8 j; @  [8 P+ w, E1 S, G
  18. # You should have received a copy of the GNU General Public License           #) Q5 F; C& m% x
  19. # along with this program; if not, write to the Free Software                 #
    " u( f4 r% w4 E/ Z8 G+ a
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #
    ( [6 H) }7 C. N) \3 m
  21. ###############################################################################3 V0 `+ Q* y9 P( T& }1 Q2 o9 r# _

  22. ' h8 v8 I) X# D* v: C) D
  23. # Global variables
    ! E' \* q$ E. h6 \# w
  24. DLGAPP="whiptail"
    2 o2 J1 x8 ?. }( A
  25. VERSION="2"
    ( [( I! P0 A- e5 {3 h
  26. ROOTPATH="$HOME"$ L& |. ~5 g9 i) {- B
  27. SRCPATH="$HOME/mangos/src"( |0 j8 Q3 j3 |3 e& M: f
  28. INSTPATH="$HOME/mangos"! m! c+ `2 f% M2 M5 O
  29. DB_PREFIX="two"
    , y, K& P% M/ G% ~. E; X1 U
  30. USER="mangos"
    ; l" h' T1 |% x
  31. P_SOAP="0"
    5 y, d. k- ]2 N1 d9 V4 w5 j
  32. P_DEBUG="0"9 G* m4 p( ~& _
  33. P_STD_MALLOC="1"
    9 U/ V# C$ f4 U  W
  34. P_ACE_EXTERNAL="1"7 i( G; K* @( G* o) V
  35. P_PGRESQL="0"
    , ]  R- g( n1 m2 i; n  @+ ~: ~9 ]
  36. P_TOOLS="0"+ R, l" `5 i$ A4 X- ~# R& x* w
  37. P_SD3="1"
    ' N" N  D# c8 O4 B, S
  38. P_ELUNA="1"+ r* b; O0 h* Y6 q4 I0 U& @4 R
  39. P_BOTS="0"
    * A& g* U4 Q# G0 P% k
  40. CMAKE_CMD="cmake"
    1 }. x# x2 H6 S' n
  41.   h+ h- a* K# E% a8 f* G: }

  42. $ b" I* G, ~: \3 A  U7 g4 u3 v
  43. function UseCmake3()1 I3 a! ^  U0 N# m
  44. {
    1 L2 `# d/ S% w& P( T5 E6 F
  45.     # set the command to cmake3 if its there# A0 F# T" l/ v) H0 @! K! V  [
  46.     which cmake3, l% U6 o- d. C4 c: I/ Q
  47.     if [ $? -eq 0 ]; then- F4 C* v# O/ O5 A' F
  48.         CMAKE_CMD="cmake3"
    6 J% V  _2 G3 j* O7 {9 j! t
  49.     fi/ |+ y. x8 ?6 B+ {5 d* g) @
  50. }
    % a, T3 y6 H5 ^# @

  51. ; ]  L! o& Z) a. ~, }
  52. # Function to test for dialog
    7 `5 P6 k( N) y7 ?0 ^5 C4 @
  53. function UseDialog()
    5 O- y( c! n* k7 C/ j# U
  54. {' S: e4 q7 }" b( f0 R" y2 n1 ]
  55.   # Search for dialog5 S3 d4 P# L+ b, t! H" i
  56.   which dialog
    , J* L7 M9 n# }2 \4 O0 a8 @

  57. 1 R6 M) _# I. y) @' f! h
  58.   # See if dialog was found/ |1 ^; L9 n* I8 t4 x1 T- F7 J; I7 g
  59.   if [ $? -eq 0 ]; then& H* Z* Z# e& B& Q
  60.     DLGAPP="dialog"
    ) t: X4 ]. M! h' x$ W* a
  61.   fi4 Y! n( D/ q$ _+ y$ ^  u& a2 z" u
  62. }8 K: n/ e' j! c
  63. # r( ?! K6 o: P% l$ }
  64. # Function to test if the user is root or not
    : ]/ U( h+ m; m! K/ v
  65. function CheckRoot()/ [6 ?/ ?- Q5 \; P
  66. {
    & N, d1 s/ ^, Z7 V$ t
  67.   if [ "$(id -u)" != "0" ]; then
    " o: ^% d# z& a
  68.       Log "This script can only be used as root!" 1
    3 A6 B/ n% R  x" V. w8 R  o
  69.       exit 1" S% y2 A6 k# F
  70.   else
    & Y- S9 ]- b( g* k) O
  71.       Log "User is root, check passed" 0# Z9 Z9 o- T$ Q1 a
  72.   fi. m* T6 N+ m# s/ _5 ~3 ?' Z
  73. }' }' }0 @2 Q2 v8 `% q. ~

  74. - V" f3 N  {& ~' B! _0 b
  75. # Function to detect the repos
    0 f& K; ?8 ^# @6 U
  76. function DetectLocalRepo()
    . E, w! p. X' X5 I. r
  77. {! u  s2 O2 \6 r+ y7 Y' [' h
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    5 c2 L. o0 P0 ?1 u$ T7 ]

  79. 3 |1 {; t* z/ O/ U& F6 \" R8 R- \& N
  80.   # First see if the Windows stuff is in place0 ~3 e7 c$ `, q5 `. |
  81.   if [ ! -d ../win ]; then
    + I( z' ~! o' Q8 f0 E+ U2 D
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0+ X6 Z" E6 `2 \
  83.     return 0: e, i7 M- L5 E' d/ V0 y3 [2 T  a" Y
  84.   fi, z: m" y1 l' {7 p

  85. : x5 N5 v1 [! ]* y( k  t& t: z8 r; S
  86.   # See if the sources dircetory exists$ b1 ~/ i$ f  V! c0 Z! w, m. @: D
  87.   if [ ! -d ../src ]; then
    4 O5 V0 K$ ~7 X9 B# i& a
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 0( ~2 t% X' S1 Q4 j
  89.     return 0
    , f1 c- b& l* W
  90.   fi8 f- d2 I; f( M

  91. 4 D* s8 b& s0 Y5 s
  92.   # Check for the CMake directory( j7 a+ s7 c" [" k5 F, b) q
  93.   if [ ! -d ../cmake ]; then
    4 n: M# g" L+ h  N
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 0
    : N+ ~! Y0 q4 z! e4 i. J1 o
  95.     return 0+ \$ Q; Z; q! z3 J5 u& ^
  96.   fi
    , s4 ?% q/ A* s! l5 m

  97. " h7 Z" O0 W1 z
  98.   # Set the default paths based on the current location4 y9 S7 E; x1 r# R
  99.   SRCPATH=$( dirname $CUR_DIR )
    - ~& h$ q7 ]( M% X9 W. a: V' U
  100.   SRCPATH=$( dirname $SRCPATH )
    " i& X) C% h4 Y2 O. p2 J
  101. - A+ {) X5 g( @0 T) D
  102.   # Log the detected path
    2 I6 ]8 I. B+ }! o" g' ]5 w; S
  103.   Log "Detected cloned repository in $SRCPATH" 0
    + c; M$ _$ H5 l% o) |7 n5 S! w
  104. }
    0 b* {5 L7 G: E* d9 F. H" S

  105. ' G' [! ?; J6 _( b4 S
  106. 6 q2 [& s. t+ U- J  s$ ?
  107. 4 N& d1 {" L3 ?
  108. # Function to log results
    % p4 V, ^" x( B( Q
  109. function Log()
    $ ~% q- N" r6 O& b4 N* A! V1 J
  110. {; ]9 H: g- Q& E
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )' B5 s* e* T- v8 x
  112. . ^0 ]' C9 }6 c6 k; C
  113.   # Check the number of parameters
    5 q8 c4 I' Y) J! X- t
  114.   if [ $# -ne 2 ]; then5 B: @' e+ ?" `# U/ {" `. b
  115.     echo "Logging usage: Log <message> <echo flag>"" R" l0 m2 q) L$ a% y& }# H) K7 F% R9 N: z
  116.     return 1- @2 ?$ S) t8 M6 @
  117.   fi6 c* r: ?3 S$ A; _% U
  118. 4 X/ x3 p/ J) N; E
  119.   # Echo to the console if requested
    ' e, n) a* T7 D+ x& @9 k
  120.   if [ $2 -eq 1 ]; then+ ?# Z9 M" h: a4 F/ A4 g; _
  121.     echo "$1"
    4 A# J0 {: _$ u& a4 A  I
  122.   fi
    # Y9 h+ n! |  G  K% m6 J7 k/ p
  123. 0 k. q- C8 S$ f$ R; d! Z
  124.   # Append the string to the log& g: X! L! t4 p) z/ ^$ T$ a
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log1 A; [$ A& W7 R2 K
  126. }6 v1 ], t8 z" [9 v4 }# B! I# V; \, g

  127. . \3 S0 Y6 I8 n% b" ]

  128. ( W: b7 Q5 g4 X, t: X

  129. % T5 l+ M0 R9 C, P5 U
  130. # Function to install prerequisite libraries
    . v3 O( {0 N3 B* Z
  131. function GetPrerequisites()) d+ F/ M: j6 K3 D/ P
  132. {/ q) x' ^7 m' Q# `
  133.   # First, we need to check the installer.
    ! @3 A0 C+ ?0 ~: r
  134.   installer=01 n( ~1 a7 v6 s9 P; S
  135. . Y; `7 a" i. L; q! I/ l
  136.   which apt-get
    9 C; R) y: u$ y. U* F

  137. ; ?; k/ p. |: f$ |: W- [" [
  138.   if [ $? -ne 0 ]; then3 |; E2 k0 E9 `
  139.     Log "apt-get isn't the installer by default" 1
      d$ p* _* R! S
  140.   else
    ; F7 A% O4 _/ l, c- @! U
  141.     installer=1& B; w* k: f# p6 {+ {
  142.   # On a fresh OS boot (EC2) libace was not found without first updating
    4 k" s* S( Y  B5 Z' w3 i8 I" f  P
  143.     apt-get update -y && apt-get -y install git lsb-release curl8 \* m/ z( n% R
  144.   fi
      C9 e9 J/ w; G: I1 }0 p6 j

  145. 1 N, k1 t# ?" ]( A1 y' Q# ^
  146.   which yum$ B, m1 \3 r& O2 @3 k

  147. . m! x. n9 H7 q
  148.   if [ $? -ne 0 ]; then- I3 F. V8 I  V7 B  E
  149.     Log "yum isn't the installer by default" 1
    " k4 h9 E' t% g
  150.   else- a' q3 g% O- x$ e% G6 L
  151.     installer=1$ F3 N9 h7 f' R4 |* s
  152.     yum -y install git redhat-lsb curl* @0 C- U* S/ I" b
  153.   fi
    8 s4 B7 C$ n6 f: h

  154. 3 {: ?2 q! j  ?2 Y# T
  155.   which aptitude
    % X. ], G; J) g0 }3 l3 \% l
  156.   if [ $? -ne 0 ]; then, v" {0 X& \/ ]8 ^0 T) g
  157.     Log "aptitude isn't the installer by default" 1
    1 J0 Y# z. A# M5 U: _# h! d# `
  158.   else
    5 g) h# b8 f) j5 e; k" J# y
  159.     installer=1
    * ]2 K' R7 l- o2 h% v1 y  T
  160.     aptitude -y install git lsb-release curl% G/ Q; E, _- h, ?5 _
  161.   fi4 `+ g/ ?) s: k
  162.   U0 d2 ?9 t, a6 ^
  163.   # Then, let's check that we have the necessary tools to define the OS version.# v) X% T7 [* B2 E5 q+ o. O* z
  164.   which lsb_release. @/ W! o# B, \1 B0 g2 C; p+ L

  165. ( v/ `+ M- t2 I1 P! Y$ x
  166.   if [ $? -ne 0 ]; then- J2 ^4 G* }  b( s4 r$ u7 _
  167.     Log "Cannot define your OS distribution and version." 1; S; ~' t, ^. {
  168.     return 0
    % V, t+ G/ m# J8 h3 Z8 `- N5 S
  169.   fi
    / d( T+ _4 @+ I" _

  170. 2 B3 m; N; G3 a
  171.   local OS=$(lsb_release -si)+ J  c5 w: v- z7 N' B/ O
  172.   local VER=$(lsb_release -sc)
    " u# F2 \; E# S  t# _: M
  173.   local OS_VER=1" Q$ h) e' n1 r( `' N

  174. 2 x& a# d1 g6 o* V! W6 N: O
  175.   # Ask the user to continue1 v- _( z# E" e& V! w$ z
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    # Y& l. R9 c1 r$ B4 n9 \
  177.     --yesno "Would you like to install the required build and development packages?" 8 607 d  `' P1 _: U  ~& F

  178. ) `, k8 C' r: u8 E: ^
  179.   # Check the user's response
    7 Q4 b7 w0 e$ `7 _: _5 @  L/ g
  180.   if [ $? -ne 0 ]; then3 T4 S0 }- H4 ^6 B1 `6 r
  181.     Log "User declined to install required tools and development libraries." 17 ]9 a3 R6 V8 H
  182.     return 0
    / U4 z( E9 T. U1 k; @7 @, q
  183.   fi
    2 b7 K) D- L+ _8 Z" t: x

  184. ( n+ S  e! Y1 C
  185.   # Inform the user of the need for root access! y( E2 }; I! G
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    $ T, _3 D7 r5 y0 m- n
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 606 y* M3 N0 _9 P

  188.   {( o; B- c: K* o8 E! H: E
  189.   # Check the user's response3 y& C! W3 j2 ]4 z0 q. K# g
  190.   if [ $? -ne 0 ]; then
    / O2 K6 l7 E3 k0 ]
  191.     Log "User declined to proved root access for package installation." 1: @9 K6 o, S+ g) I( Y9 d
  192.     return 0
    : b0 j, K4 L; o7 q2 C+ _+ B, l# {# ~
  193.   fi
    % X/ X2 k3 |& c, ]' U0 c

  194. : o1 U: [* G% [" i
  195.   # Handle OS
    " f4 O* D5 d, d" p3 Y( |* X
  196.   case ${OS} in" s# n" c) D  {; M6 J* I
  197.     "LinuxMint")
    , r2 S, E: @  R; o( t
  198.       case ${VER} in) @- w) ~5 ~7 z  |
  199.         "sarah")
    ; V0 j/ [2 M8 f  Z# ?6 i
  200.           # Linux Mint 18 - Ubuntu Xenial based/ w+ I0 z! r: n# j1 X
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    # F4 C* }( k/ q
  202.           ;;
    % y0 M4 q- i& ?
  203.         "rosa")5 P" V; r9 ~: K' P
  204.           # Linux Mint 17.3 - Ubuntu Trusty based
    * V6 t: n) T' |
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root" g3 o  l4 _- }! x8 ~8 u
  206.           ;;
    # N1 d" B: F  k9 c& o/ ~
  207.         "rafaela")
      S1 u* n  e) U9 q' y, l& r
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    # Z& q! ^3 z9 v' Y
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    5 @) h( A. W+ I
  210.           ;;. e8 ]; ^$ [' l9 D9 c8 @2 C* V4 k
  211.         "rebecca")+ X# ~8 I9 W/ p9 D1 B" ~4 s
  212.           # Linux Mint 17.1 - Ubuntu Trusty based  g* a: V$ {( G; d: U2 L, K
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root( H6 W1 `9 Q: p: u
  214.           ;;
    8 i. L# P; J' T# Z* q8 u
  215.         "qiana")! B+ V& O9 m- G9 ?8 |
  216.           # Linux Mint 17 - Ubuntu Trusty based
    6 [2 ]5 Y3 ^! o) g1 Q) T
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root+ L1 R" P: [5 j: Q) V" Q
  218.           ;;9 c' |" ~' z$ C6 G
  219.         "maya")) U: v# a" @( t- `% Z; F
  220.           # Linux Mint 13 - Ubuntu Precise based1 R. k2 }1 X/ w2 R; n& k
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root( V  ^" b: k7 Z3 ^1 i5 k% x
  222.           ;;
    & J$ }# B1 }. n& I
  223.         "betsy")
    # D) c5 Y8 e! E* h$ D
  224.           # LMDE 2 - Debian Jessie based
    7 i3 `8 A* _4 ?
  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+ l1 J7 T  ^, G; f1 H& r9 b
  226.           ;;
    ' D6 P/ t+ h; c" x; b0 Y" r
  227.         *)* r6 i' K# F2 f- w
  228.           OS_VER=0
    # t+ V0 H0 z* R
  229.           ;;' X8 b+ q- D7 g4 O1 M: Z
  230.       esac7 r/ M* G# |; x; [) b4 R
  231.       ;;
    4 g4 Z+ H) f5 y- ]4 r+ G0 ^. `- z
  232.     "Ubuntu")
    / u# q. t  x6 Z8 f2 b2 z2 q- Z
  233.       case ${VER} in) X/ E( v& A) }4 I& U1 Y* r* Y
  234.         "precise")0 \! g# z% ~* I$ |" s7 Q: N
  235.           # Ubuntu 12.04 LTS
    + u2 b3 r6 P1 O! s9 B
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    * }% d4 L. W" \: o7 j
  237.           ;;2 I0 W0 t! F+ p) p' Q* [% K
  238.         "trusty")
    1 ~1 M0 A" r" x7 s2 G
  239.           # Ubuntu 14.04 LTS  [3 m1 j, o0 d. E
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root+ m: R0 L* I: M+ l) `
  241.           ;;
    % L6 U+ _5 p. L
  242.         "xenial")
    ' J9 l/ B5 h7 e* Y( W, a
  243.           # Ubuntu 16.04 LTS
    ! r6 w# \) k' r: x' Z; I: T
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ; |1 b, Q  m; |' g- Z% r
  245.           ;;
    # r1 t2 ]. |, @+ ^) {( H7 M
  246.         "yakkety")# s4 V+ l+ e  I" \" Y
  247.           # Ubuntu 16.10
    4 x3 d5 P" v: b: M# }( B
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root; T9 e" x& @3 v- @8 w4 z
  249.           ;;
    4 x  f( L2 m% R
  250.     "zesty")( I1 M" B+ t0 F# \" J* `5 B1 k
  251.       # Ubuntu 17.04' o+ R- E$ x8 E3 A5 R# ^! a9 R) }: v
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    , L4 c( c! x  l$ D" ]
  253.       ;;
    0 j0 G" R0 n7 f2 I! I
  254.     "artful")
    ( B& n- T2 n6 \- `5 I/ C8 z0 z
  255.       # Ubuntu 17.10
    ) `) p6 f# x; U
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root5 I: U; B* B5 X. u. N
  257.       ;;* }( ]; B4 c/ @. S: H9 ~
  258.     "bionic")
    # _- g2 E9 T- S
  259.       # Ubuntu 18.04 LTS
    6 i$ g% ?) j0 e# @5 p0 R; O. E
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    : P, M; W1 F; E9 u. N
  261.       ;;
    ; u1 k/ r6 u0 {+ f# f
  262.     "disco")7 D* y1 x' E3 B' I5 }
  263.       # Ubuntu 19.042 h6 ?, W* @' L9 E# `
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    0 e* e0 Z0 l) \& m4 S5 Y7 q8 o
  265.       ;;
    / l7 d4 ^7 o5 F7 ?1 j
  266.     "focal")+ z: H2 H0 x' u
  267.       # Ubuntu 20.04
    8 w! V' G9 ?4 s& {
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root4 T, _1 H8 Z" S5 n8 P
  269.       ;;
    8 r# r5 U  N. ]0 E# Y# B
  270.         *)( `1 f8 y& n; ^
  271.           OS_VER=04 O- `/ C( a0 q$ f2 _
  272.           ;;
    - z% b1 B5 V7 C8 C3 f# M- p2 [
  273.       esac
    8 k# I9 C/ ?' H. \7 V3 y9 a! e  j5 {
  274.       ;;
    & U  g) H- B& b0 U/ Z9 m
  275.     "Debian")  p" ^/ K) Y5 n0 q8 M  O6 O. }
  276.       case ${VER} in5 U. y* F1 j  s! N6 D8 x2 y
  277.         "jessie")
    7 D% t( Y/ ?4 n$ k7 F3 a$ b
  278.           # Debian 8.0 "current"
    $ o* v0 e' H" k/ a4 r4 r
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root7 R4 U: d6 I0 `" y, m
  280.           ;;4 G: A! T1 s8 m& S" F% L0 u) s4 s
  281.         "stretch")
    : D' J7 I% O. e  ?9 h+ X2 z
  282.           # Debian Next
    9 Y: ]- U9 d5 f* [  W
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root/ Y0 R5 _. h% H) ]& G( y% d5 c! U
  284.           ;;. |* j* z9 V* Z
  285.         *)) j' D, t3 ~& o
  286.           OS_VER=00 m& A7 Y" A; o
  287.           ;;
    # M* F( \$ ?- e1 [
  288.       esac/ D: o1 l/ [# g3 k* ?
  289.       ;;
    1 Q* E7 b! S4 Q+ {
  290.     "RedHatEntrepriseServer")& L4 J2 A% B2 e' p8 ~  J
  291.       case ${VER} in- r( ?/ M* @$ g! S6 o% M, j
  292.         "santiago")
    * R" q/ i; e/ y/ R+ J
  293.           # Red Hat 6.x- |6 Z+ D  v" M$ }1 B9 v  M
  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" root6 H2 J$ c' r4 H/ v0 |6 Q. ?2 g+ G
  295.           ;;
    # O6 X" L" q! L/ w
  296.         "maipo")' M: a0 A0 @9 `
  297.           # Red Hat 7.x3 k) R  k7 z1 U% ~
  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
    # D5 f: z% |3 U; j& Q8 G
  299.           ;;
    6 W( s& D( z2 x: q
  300.         *)
    8 c8 {4 `3 |& F" R9 V8 ~& n
  301.           OS_VER=0
    1 Z' `* f& ?% \- y  h# d
  302.           ;;
    ! D# Q8 G  @0 v5 K+ o% i- b
  303.       esac
    + \- `" r% _& a; e7 c* l. |
  304.       ;;+ W4 G: W7 R9 }3 K
  305.     "CentOS")
    5 B( R- Y. e. i  c3 a4 }4 G
  306.       case ${VER} in* ]/ I) w7 }; ~3 o# u' @
  307.         "Core"): z5 \9 Y2 a& c3 Q2 o9 N- h
  308.           # Default CentOS - Adding necessary RPM third-party.! A2 R+ f8 {, u3 O* @: s
  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
    ) y) T) j0 ]+ S; {! B
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm; f, }# N; X, N' L6 R
  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.rpm3 E; O+ M, F  H" P) K% L
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm
      N* p1 u7 p: e. B
  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.rpm9 [9 _: G- }$ h
  314.           su -c "yum -y install epel-release": `4 Y# v1 B6 Y6 f# k& I/ O7 o) 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" root
    7 @. E! Y6 C# Q+ S! h
  316.           ;;
    ( X7 o+ M( q' t8 d0 n. }; Q
  317.         *)& ]4 x  Y# n. X
  318.           OS_VER=0
    8 U* R8 g! O; H0 b
  319.           ;;# _: Y& g5 U+ W( V
  320.       esac5 L( Q# D2 a) B. f
  321.       ;;( u* b- h& @' y- g. {
  322.     "Fedora")
    % ~. x* Z! S4 X0 j) x! U% M' x
  323.       case ${VER} in
    0 G# R$ `) J! H! h2 s- L
  324.         "TwentyFive")
    " u3 Q: p2 K$ S& r3 @1 j
  325.           # Fedora 25 - Adding necessary RPM third-party.
    $ q0 V" x* o6 d% f% P) U8 V8 I
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root; }. r# ^  L1 {
  327.           # Getting and building ACE. Not provided in RPM for Fedora...
    , k3 B1 D, }% U% Y
  328.           rm -rf ACE-6.3.3.tar.bz2
    + ^- v. U8 }2 h. k, Y0 q
  329.           rm -rf ACE_wrappers4 `; s$ T3 v* m! T) ^7 P
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz22 x+ Y: `: h+ O& l! t/ N% B
  331.           tar xjvf ACE-6.3.3.tar.bz24 s) T& @# `0 l' Y, j$ `! K% F% g4 W
  332.           export ACE_ROOT=/root/ACE_wrappers. G9 S) e, I9 K* @6 G5 i
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h% e) `: |9 w4 \0 Z1 L" D+ K
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU# M) K- z& w2 i1 j* T
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    5 b3 R5 ]. @) @* L
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    " E1 n6 M: Q) h* `
  337.           CD $ACE_ROOT% h$ ^6 U1 ?. F6 z, G3 Y8 F8 M
  338.           make) U& x' p" d3 }) @
  339.           make install
    * I- C) [4 e" b9 J# M2 v9 K
  340.           cd ~
    / F0 |- F1 l/ ], s6 z2 u
  341.           # Installing remaining dependencies..
    6 j% r$ w. I6 y7 ~" y6 O
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    1 H  C) `; E6 X/ ]- E) x
  343.           ;;! `- L! t& j+ R$ ?; c
  344.         *)$ J/ ^0 Z$ w& P
  345.           OS_VER=0( j. V. Z* k; [8 B% L* A
  346.           ;;/ X& B6 m; |: b' _$ q( |
  347.       esac
    6 Y$ q" ~+ \9 w+ w3 T& o
  348.       ;;
    ) x/ j$ V  f7 F4 u0 R" Q
  349.     *)
    2 g) A  f6 |, l2 s/ t5 }( @# z
  350.       OS_VER=0; M6 k' a! Z5 K
  351.       ;;
    ( u& `+ [. O2 y, Q1 P
  352.   esac
    ) b3 e4 J& t. _5 e
  353. ( i( Z6 V# S3 X! w2 C$ S
  354.   # See if a supported OS was detected5 S, e! l! d$ y# R" |1 b
  355.   if [ ${OS_VER} -ne 0 ]; then
    3 r* Z( E2 z5 [" [8 D. ]
  356.     # Log success
    4 H- p* n0 Z; v- L  M
  357.     Log "The development tools and libraries have been installed!" 1/ a) b, m1 C% a# ^
  358.   else# _. l  O+ S, Q! _6 |5 h
  359.     # Note the error
    4 J3 ?* B: K+ h3 z) W
  360.     Log "Could not identify the current OS. Nothing was installed." 15 s+ b7 t& o! m  F. y3 F
  361.   fi
    2 t% d9 f, w/ ]% _8 d
  362. }
    / _# a$ d  F9 c% w6 o" m/ P
  363. : [! n& S! \9 Q1 d/ E. V) D% ?5 }

  364. $ G$ j* t2 @" r5 @) Q
  365. 8 v' |9 J/ w- j
  366. # Function to get the WoW version
    - O; ?& z) n' q- T8 K& [
  367. function GetRelease()4 v) y6 X- f  F5 T1 c; R
  368. {
    ! r; ^2 }. D3 L% A! D$ |
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    ) ^5 g6 Q% ?. ]: G' h' |5 p+ L
  370.     --menu "Select a version of WoW" 0 0 5 \
    - e' {* ?; t0 q5 L5 j
  371.     0 "Original Release (Vanilla)" \# O) J* P  L# z) L
  372.     1 "The Burning Crusade" \
    7 Z; Y* V6 m# v
  373.     2 "Wrath of The Lich King" \+ W4 L2 F7 U: @9 n6 o/ }
  374.     3 "Cataclysm" \
    6 F. v3 y. p$ l  ?
  375.     4 "Mists of Pandaria" \- L# Q3 s7 F  T& o. E
  376.     5 "Warlords of Draenor" \$ t/ e) B/ `  n1 S4 T8 u
  377.     3>&2 2>&1 1>&3)/ L7 ~6 m# R3 W4 ?

  378. 3 O! ^7 l( n  s3 m8 |# b1 {# G
  379.   # Exit if cancelled4 R0 k4 x5 ?3 A
  380.   if [ $? -ne 0 ]; then
    # m$ }0 z4 X: p9 X( o- U* s
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 15 P) r- }5 i4 T6 u" y& k
  382.     exit 0
    ! v: y4 `# `- l: T* ^
  383.   fi
    ) `0 Q& Y: i$ z# [5 c3 j
  384. $ b$ }9 a4 ?, X% ~4 r0 c
  385.   # Set some defaults based on the release  o( L' @! t# H/ E  x+ r& I
  386.   case "$VERSION" in; B# O2 N7 F0 k" m/ X7 v! s9 l
  387.     0)
    6 _7 z- o" i5 s4 M: d: y
  388.       SRCPATH="$ROOTPATH/zero/src"
    7 E+ h  ~: k' d. p4 @
  389.       INSTPATH="$ROOTPATH/zero"0 D( T9 J% f2 D  `4 B- K
  390.       DB_PREFIX="zero"
    " F6 L( p" l& r3 n, w5 m/ |0 n
  391.       ;;4 ]* C& W; H* j4 |7 P7 Q7 l

  392. , R9 }; z. I+ I' |; V1 z
  393.     1)
    2 z1 U2 q+ g6 |4 l
  394.       SRCPATH="$ROOTPATH/one/src"
    - S! ^* u! p3 X4 A7 O5 i6 h: ~9 K$ X7 |
  395.       INSTPATH="$ROOTPATH/one"0 n- a4 \9 u. K9 ?
  396.       DB_PREFIX="one"
    & b$ i( \1 f/ {9 b! B& G
  397.       ;;
    , L. ]: c7 r- E9 S

  398. 6 W( ^* @/ `3 Z! s4 O& k, D
  399.     2)
    0 x, F, C4 M( G3 t
  400.       SRCPATH="$ROOTPATH/two/src"; Y% q$ N8 [9 ~) j
  401.       INSTPATH="$ROOTPATH/two"" @3 }( Y! l+ n, r1 n9 l1 B5 O
  402.       DB_PREFIX="two"7 G& K! ]) `: n# X! [6 O
  403.       ;;7 P3 V- G% H  w, I6 [( \4 V# m+ p

  404. % e& L4 ~+ ?( [- Q
  405.     3)5 D3 j8 [" m4 i* q2 E6 I1 S
  406.       SRCPATH="$ROOTPATH/three/src"4 [8 [; O* U* c# y
  407.       INSTPATH="$ROOTPATH/three"
    ; M6 f( e; H, I/ P' N9 }/ l) |# L4 U
  408.       DB_PREFIX="three"
    $ ^" T; E2 \& k9 G( n
  409.       ;;4 H( y: D1 k7 M0 l& r

  410.   {! T0 m2 h0 N- [- I
  411.     4)
    + ^) b7 ?7 w5 [; Z# t$ B6 {- P; T) e
  412.       SRCPATH="$ROOTPATH/four/src"1 n( w/ \, B+ t, Q9 r0 n( b6 s( E
  413.       INSTPATH="$ROOTPATH/four"4 t2 V, o4 Z% J9 c
  414.       DB_PREFIX="four"$ C) x2 H1 G5 V5 S, V' G- S
  415.       ;;
    2 e3 a+ E& N4 g/ q
  416.     5)( t% W/ A/ C6 w( }
  417.       SRCPATH="$ROOTPATH/five/src"
    . R8 s7 }5 d; T; t
  418.       INSTPATH="$ROOTPATH/five"
    ) }/ s* e" U9 o- O. L" y4 F# J, U
  419.       DB_PREFIX="five"' ?9 j5 o6 a( P1 D
  420.       ;;0 E" `1 \1 r& j- N
  421.     *)
    7 d: g. J% \" Z# C0 u
  422.       Log "Error: Unknown version selected!" 10 ^+ V" B  O4 }! p  w
  423.       exit 1* X! a* `2 c, {0 d! }% @  J! ^
  424.       ;;- G3 u9 H2 J  e1 n( \3 b! Z
  425.   esac- r# X* l$ E8 ]

  426. 8 V* {5 S. x9 m* C0 L* s" U
  427.   # Now set the correct source path if the repo has been cloned already
    + z1 r. ^6 Y9 C+ c6 \4 E: _0 }
  428.   DetectLocalRepo8 o' u8 y, R# t" B+ R. ?1 @
  429. }
    * \, ]# h- s. g& Y1 f/ k# X

  430. 6 X& n# K" X7 X$ t. d
  431. # Function to setup the technical user! n1 C2 s, r% ~4 t
  432. function GetUser()
    ! X7 B7 C: x, f* P  S3 c
  433. {3 c# n8 Q: g# x& F, E9 l
  434.   local TMPUSER="$USER"
    7 O% G6 b# b( ~3 M
  435. $ [! X; `4 X3 {
  436.   # Set the user: q# j5 H: n4 ^; I' H$ J5 ~
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \
    5 m0 ]* @  B1 X& n
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)' B! p( s' Z1 O4 V2 r# Q) s8 Z
  439. 8 f% A% q& Y! u/ `$ V) \
  440.   # Exit if cancelled: Q9 f7 r) ]! M+ s
  441.   if [ $? -ne 0 ]; then
    ( S) j6 a8 p* U  I# ]( w
  442.     Log "User selection was cancelled. No changes have been made to your system." 16 A% J9 m! V. t; k7 T3 n, ?. ~; a7 W
  443.     exit 07 J- m4 u( E2 H! g
  444.   fi4 L0 O) `5 G: d' ]% H9 k
  445.   E% u5 b2 C* H( q# z9 c  [* l7 S
  446.   # Change the user only if it was modified, v5 r- t9 Q& T9 g. D( d
  447.   if [ ! -z "$TMPUSER" ]; then: C  `8 y$ n3 s, l: E! J( b4 J
  448.     USER="$TMPUSER"
    % E3 Q. ^1 e0 k" t
  449.   fi
    ( ?5 E$ y2 x: I  q

  450. * r7 V0 u% Q, @: F# M  R$ G
  451.   # Validate user
    . Y5 g* G0 d' g. O: A) n
  452.   id $USER > /dev/null 2>&1
    " e2 u, q. r* S" q" q
  453.   if [ $? -ne 0 ]; then7 T. `/ K- n/ C9 v/ Q! [
  454.     Log "Creating user: $USER" 1; T1 {! g; Y) L: n6 h; ^& p% h
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    " i0 J5 E/ Y* m3 t" x" o- _( A
  456. 1 d/ j) C  P4 n' K$ ^$ P" s, o
  457.     if [ $? -ne 0 ]; then7 ^0 i0 z8 i8 T: v: Q; h3 u
  458.       Log "Error: Failed to create the specified user!" 1/ M' P0 t, X" X6 p, Y1 B
  459.       exit 1+ `9 w8 g& ?; {# z
  460.     fi7 t5 o, q$ m+ C
  461. " f% }9 `5 P* b( ^
  462.         usermod -L $USER > /dev/null 2>&1
    * Y7 U6 l  E3 k) q" c' R
  463.   else% [/ c( l) r: l& h! C1 N2 d
  464.     # User already exist, asking to keep the user/ l$ w  D6 [: e; t- y
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \
    4 c: ?* m; U8 ~& }2 a% ]7 g1 X9 D  Y
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60, s; W( {# X" _
  467. / v1 {) c4 M+ K; k' v! Y
  468.     if [ $? -ne 0 ]; then
    ; o8 o* U$ U$ q
  469.       Log "Removing user: $USER" 1* b) ^1 f1 n+ u
  470.       userdel -r $USER > /dev/null 2>&1. R5 S& V, d- Z( _
  471. ! P. r+ t5 t, Z/ l9 F, T
  472.       Log "Creating user: $USER" 13 Y% k8 X! G( l1 v! R4 W, I
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1) Z" l+ W, V- ~- h  o$ }) `

  474. - M5 U; ?5 I6 g8 h& v, t, T3 e; ~/ ]9 |+ O
  475.       if [ $? -ne 0 ]; then# I7 J$ r( p0 i' H5 i% @3 ~
  476.         Log "Error: Failed to create the specified user!" 1. Z, v4 n" F- ]7 J0 S
  477.         exit 1  Y( x5 d: g, Y- W
  478.       fi: o( Z& X4 I8 L3 I
  479. " Z! i  R! v2 b1 l1 |' G% f7 Z0 _+ u
  480.           usermod -L $USER > /dev/null 2>&15 t, c& P2 q! d7 Q, R& b1 P! x
  481.     fi
    3 ]* A3 r6 S. n, }6 u( _4 j
  482.   fi
    9 Z/ a+ V8 o0 t: }

  483. ; S9 Z5 E+ x# V* ]! O
  484.   ROOTPATH="/home/"$USER
    ' z/ \3 P' E: s
  485.   Log "User: $USER" 0
    " K2 G' e+ H  A5 m1 ~& T1 M7 n8 j
  486. }
    1 r( w- `: a& f  B& h) h

  487. ! ?; H) h# }+ _, c2 b/ \: [# I8 L
  488. # Function to get the source and installation paths2 f9 n) r6 F: k) M8 z
  489. function GetPaths()9 p1 Z3 J6 P% M/ [3 q
  490. {
      z. o- a) D$ u5 r; g7 `9 X
  491.   local TMPPATH="$HOME"% {  P# X' C2 l- |: u8 C! |

  492. - r% F1 o6 J: v# [. Q- D; n8 `
  493.   # Set the source path" ~4 S6 S( d6 x3 e! d, T
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \  ~0 o4 g9 K2 C8 X: h1 I- J
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)
    4 V( S! w0 u+ S8 k  z
  496. " ]/ }) F) q) l* J. c0 w/ S- C# v
  497.   # Exit if cancelled, F( S; W( R! c, q
  498.   if [ $? -ne 0 ]; then
      s' |, b% k2 b6 K1 f* k
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1* y4 j: _: ~" j+ ~! x
  500.     exit 0# L! L4 z8 p+ ~& v! g
  501.   fi
    - x9 y, i! D6 ~

  502.   e8 j' T. A! @( a
  503.   # Change the path only if it was modified
    / a' c  f- A- g! f% ]8 F  Q5 t8 C
  504.   if [ ! -z "$TMPPATH" ]; then2 ]) J5 K$ v# ^4 k- W' ?
  505.     SRCPATH="$TMPPATH"
    8 a, N1 Q. Z7 Q+ R
  506.   fi9 G5 q" _, o: h' f9 j

  507. - B6 D; ]  D* e+ y4 V- K% [
  508.   # Validate source path
    , I9 F3 R8 q/ v6 Z: {6 M4 J
  509.   if [ ! -d "$SRCPATH" ]; then; K5 V8 A& n0 r+ l+ f; a
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \. N. I: v3 ~  x. u  \3 f3 n
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60* s+ G, X) s1 F) D# h  ]

  512. / V; }# L7 R1 g1 |0 q% B& B  j7 ~- i
  513.     if [ $? -eq 0 ]; then5 p" {5 |1 O4 U' a  E; k/ s+ a& N
  514.       Log "Creating source path: $SRCPATH" 1  d' P# ~2 m  C% g- t. C% I$ l) L
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1% N- m# b! ~: k- I7 B* a* u
  516. 4 q" i5 c1 }, d' M2 h0 o1 H
  517.       # Check to see if the directory was created
    2 {$ E" o% x1 M; Q
  518.       if [ $? -ne 0 ]; then' [- @/ `6 p" G! {! b" @
  519.         Log "Error: Failed to create the specified source-code directory!" 1
    2 t; ^3 h' n) P: b
  520.         exit 1+ e6 e. z6 L1 _( u
  521.       fi6 k& k' B% l- t# S5 g
  522.     else6 f6 X( {9 B( u) k$ T
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1
    0 Z+ w5 b1 m- M7 z6 o! y/ E
  524.       exit 0
    . K7 N1 p% G# O  n& l8 o$ G0 g
  525.     fi# t; w2 D' l1 N& _
  526.   else: I, A) j3 Z* l8 l
  527.     # Check for old sources- B. i/ c  t' _- Q& w- T+ A) u- c
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then# V9 d8 }. v! ~
  529.       # Ask to remove the old sources
    ' I( S, t! m2 R' k. Y
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    + X3 q  z$ J+ W1 J+ R! i. ?
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 602 t6 {. o7 a8 v: A
  532.   M' m3 E. V$ C: ^
  533.       # Remove the old sources if requested
    . I" t; H1 ?' V4 M
  534.       if [ $? -eq 0 ]; then2 f/ A) L. q- e, k# o9 q# u# s
  535.         Log "Removing old sources from: $SRCPATH/*" 1
    1 w( @$ Y& K$ H5 B
  536.         rm -rf $SRCPATH/*
    , q. O7 S- ?/ J/ y

  537. $ Z2 ]3 ?0 e, w
  538.         # Check for removal failure- z. o: J. g. F5 Q, ^( Z2 L& g: E# E
  539.         if [ $? -ne 0 ]; then
    . N; H4 i7 ?2 u3 Q  c9 \1 {
  540.           Log "Error: Failed to remove old sources!" 1
    # }0 U, ^2 a) \6 H9 l# |) e
  541.           exit 1
      [. m; O& ]7 C2 n& d
  542.         fi
    9 Q. h5 W& c- Q4 D4 A# [
  543.       fi; l8 Y. x- ?. y/ P3 ~. P
  544.     fi
    8 a  q8 d* b# R8 B$ W4 }' |
  545.   fi0 G- s% z* d" b+ e; K2 w  I3 d
  546. & H4 I  T- G! d  ~! T  ^7 @* ~0 f
  547.   # Set the installation path: D! z5 K. N) Z/ t' g' a
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \9 I* t: y; p. Y5 X6 U
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    + [+ L& u* X% O- B
  550.   c8 G: L0 S) G! }& m
  551.   # Exit if cancelled% t% U: P* K. a
  552.   if [ $? -ne 0 ]; then
    : v: ?# c; y4 C/ N9 \( R0 f
  553.     Log "Install path selection cancelled. Only the source path has been created." 1
    3 G6 j. U2 c3 |2 X( m/ P# H  s0 `
  554.     exit 0
    2 u8 l/ R- U$ P# A
  555.   fi% l# i# J" \, g# a3 a

  556. ) M0 @; u; k2 S' Y7 X% g4 S; i/ V
  557.   # Change the path only if it was modified
    5 o/ ?; K" u& I- p. L9 v9 J
  558.   if [ ! -z "$TMPPATH" ]; then
    & {7 z! ~  z6 c, F. b6 X/ B8 i0 |
  559.     INSTPATH="$TMPPATH"& s  H; Q9 z5 f8 r
  560.   fi9 \5 x2 `. i" s
  561. & l, m- V) b8 ?5 [  c; o) T6 M
  562.   # Validate install path) C1 v" k2 Y1 ?) q
  563.   if [ ! -d "$INSTPATH" ]; then; [, ^! w- j2 ?$ `+ _
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    # a$ {# m6 D; E  `. ?
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60$ \; Z4 W' P% \' p3 q8 j

  566. 8 o' d  F1 a% ]: N! V
  567.     if [ $? -eq 0 ];then( b! C9 p: s1 s
  568.       Log "Creating install path: $INSTPATH" 1* K  k, E& i; B+ ~
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&14 |4 i) r" ~5 ?* g7 Z
  570. 5 E' V. T/ h9 a1 I' |
  571.       # Check to see if the directory was created
    9 Y* W% p, D6 s. A$ h' M' o
  572.       if [ $? -ne 0 ]; then
    5 D" i* O7 }, ?6 ~; Z; t7 n# [; M
  573.         Log "Error: Failed to create the specified installation directory!" 1
    & W* e0 J. I1 @5 f! b
  574.         exit 1% B7 C' n9 X! ?5 u, ?3 r
  575.       fi5 L( v- l5 y' T' _- Q
  576.     else
    & h. V0 Y; ^# i  ^: `% |1 u
  577.       Log "Install path creation cancelled. Only the source path has been created."
    + B( R5 ^3 I1 Z# F
  578.       exit 0
    / W+ h3 y/ P" R1 u. ]; a) t, X
  579.     fi& e; e" C% _0 O& P# y/ g
  580.   else: q" y7 t  I! v7 J
  581.     # Check for an old installation; R  h0 u  v! s
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then
    & Z3 ^8 {. s9 i) m
  583. 3 q! V& Z4 S9 ?  N3 o
  584.       # Ask to remove the old installation
    . Q( S+ ]  B. c+ {! }& ^, x4 V
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    6 Z% }& ]6 h* g- j
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 00 c9 C& z% a& L& B2 q7 ]+ d, A
  587. * \: l2 J0 g9 ]
  588.       # Check the user's response8 E6 |* b4 Y5 J! x
  589.       if [ $? -eq 0 ]; then
    . h4 y1 K  G0 Q% W
  590.         Log "Removing old MaNGOS installation..." 1# Y$ f! ~- T$ T1 V9 X8 b" |

  591. / e* w2 B) d5 R$ p8 e
  592.         # Clean up the binaries
    ' X% w* p: K" j1 @4 F
  593.         if [ -d "$INSTPATH/bin" ]; then
    $ Q& u# j4 o4 K# \8 P6 u
  594.           rm -rf $INSTPATH/bin, Q) G# b9 Q. y9 K
  595.         fi
    " `* O; ]# w* n/ C

  596. 5 S6 L3 }/ O8 P; ~4 e
  597.         # Clean up the old includes9 b: r; W3 K& i% q8 S8 v( P
  598.         if [ -d "$INSTPATH/include" ]; then* `( N6 X: L3 m3 C6 y7 A: ~# {
  599.           rm -rf $INSTPATH/include
    3 p3 e% p* V( j. q
  600.         fi
    4 a5 h8 K, Q5 V& S  a+ B/ E3 h
  601. ; J) d7 k: a9 T3 H& u. B5 E
  602.         # Clean up the library files' H* J5 @" x0 m- k# K! A& X. a4 K0 F
  603.         if [ -d "$INSTPATH/lib" ]; then
    # U0 t* N3 [( g: i
  604.           rm -rf $INSTPATH/lib$ X  i2 K! l# `0 a* @( O
  605.         fi
    6 C5 B; t  n2 v5 `( b6 r) L% t! a7 L
  606. ) x. e! O3 P! B
  607.         # Clean up the old logs: ^1 {" R6 d9 U! F! E% J
  608.         if [ -d "$INSTPATH/logs" ]; then
    + M3 B% b+ t: y! K8 W- q# F
  609.           rm -rf $INSTPATH/logs/*
    1 \/ y+ n  N6 o/ E" a; J* [
  610.         fi
    $ R" p9 Z  j- I3 o$ t  q: P3 G
  611.       fi
    0 W" ?1 w" q/ S$ W1 q0 X
  612.     fi9 o+ C. h, O: B* l2 I
  613.   fi- r# `$ Y3 z& B9 k  I) Y

  614. , @( r  m  r7 c; |4 k/ C  s
  615.   # Log the settings# ?9 o! J8 N% D* p  Y
  616.   Log "Install path: $INSTPATH" 0- l0 [9 ^6 B' h; C+ x
  617.   Log "Source path: $SRCPATH" 0" U8 N8 i. A, m* k8 T/ I, D
  618. }. B& @% |$ ]) P) T2 G- g) b3 [2 @

  619. 0 s6 R) g2 t  y: P; T- v

  620. 2 r  L# J4 e, z& ?7 f

  621. ! n# a5 [) f) n
  622. # Function to clone or update sources
    . }( m6 @5 X! X4 Z. l* j! l' U
  623. function GetMangos()4 u* k+ [  l. n8 d* Q0 p% S/ f! L
  624. {
    ! g0 ?6 p- _7 k/ w' V6 W% L3 A$ ^
  625.   local CLONE="0"
    $ A9 {: i/ `+ e: _" m, X2 L+ `
  626.   local BRANCH=""
    6 P  s& X) t# a' ?, K/ C( D# E
  627. / D& L) c5 D  t4 e
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \0 G: e" H2 G& g; d- v
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \; r2 ~3 ^0 M" @; g2 `6 u
  630.     0 "Clone a fresh copy of MaNGOS" \- A1 s9 k; k* O7 |8 Q0 a
  631.     1 "Update your existing copy of MaNGOS" \
    , W/ J) ^4 O/ g; H* [. s
  632.     2 "Use existing copy" \. i! X/ i  h7 L7 l
  633.     3>&2 2>&1 1>&3)0 G0 Q+ `! r6 a5 f& w

  634. ) I4 B" Q: T- f) K9 q
  635.   # Exit if cancelled: s7 ?" g% U5 a3 F. @
  636.   if [ $? -ne 0 ]; then
      ~, B$ i$ Y) ^% C
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 12 }& p4 s. V4 O5 W, l' a: p
  638.     exit 0$ e+ b& s# [, q, ~% y7 h
  639.   fi( o6 b* i# m  o+ p$ N+ F
  640. , M9 ]: ?( i, N* I
  641.   # Clone from scratch if selected
    2 s! N* D! F4 H2 M
  642.   if [[ $CLONE = *0* ]]; then
    5 H* ^; p; X) _
  643.     # Pull a different branch?
    9 l% L$ d+ F* v& ?- i" A7 H% h- o
  644.     case "$VERSION" in0 f; a* D, s8 [. Y% a. Y% E
  645.       0)
    : H  R+ t! ]3 W
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')- w; k8 B; w. l2 K
  647.         ;;7 R/ n* J6 P( v3 o$ j* A1 w
  648.       1)5 ~, F9 M4 r' X* z7 c
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')3 I- H% w4 Z( @" P: _
  650.         ;;
    : W" k. m6 C  S
  651.       2)
    9 T6 }! K# ?* j) }& X# t, p
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    : M8 y3 [9 n& r. E- F9 e& ~
  653.         ;;
    ) ?$ S/ N/ j* B. G/ T0 R& _
  654.       3)1 ^/ l0 Z2 M6 J5 z1 u* N: T
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    : B# ?8 G9 K& }- p
  656.         ;;; J( p1 u" w2 j9 y1 L5 n* p! V. T
  657.       4)6 j4 m( ?; h( J  b0 Y! G
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')9 _& X+ m1 w1 j) V- m$ H
  659.         ;;6 F* T  @  ~0 j' I) K
  660.       *)
    % J5 [& |1 u9 D( L  U' @9 C' z6 c
  661.         Log "Error: Unknown version to select branch" 1# q2 C( D% }$ C) ?# R" C% D( i
  662.         ;;4 M. F3 U2 M( y4 d( T
  663.     esac
    ) p' z8 p. @+ d; [) k2 J3 ]
  664.   S2 A1 B3 A8 r
  665.     COUNTER=12 M- W, m1 S5 U. ^! b
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog0 h$ q1 g8 t  p
  667.     for i in $releases; do- k8 k( k& r4 E# |# B
  668.       if [ $COUNTER -eq 1 ]; then( n; o3 G# ]- G, x1 g) {+ r1 f
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "$ D# y) r7 f- C0 o. O
  670.         BRANCH=$i* z! {  I' H9 u4 K2 Y% i
  671.       else
    8 i5 \  M! W$ z  n5 J' w  l
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "/ b9 i2 ]5 l; Q8 @/ e
  673.       fi
    4 t8 }* z. X: N$ ^9 T/ {0 a) @8 h
  674.       let COUNTER=COUNTER+1- w  p/ x5 F; B' q9 r. a6 S
  675.     done$ x& Z1 t: m# ^- b8 O' K4 s( T
  676. 9 `  e9 S" K3 n/ Y
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \
    % B2 S. j7 a' r4 k
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    - I" X4 G; T0 H3 x( T8 j
  679.       $RADIOLIST \8 }$ b4 I$ p/ H
  680.       3>&2 2>&1 1>&3); L8 i, {5 Z$ E7 G# T

  681. 3 @1 [  w" V) g* T
  682.     # Exit if cancelled
    # A2 t" g+ p% `3 U
  683.     if [ $? -ne 0 ]; then" p' C6 r" c8 d' d& ~: I
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1/ E. ?. ~# W$ o) w/ V
  685.       exit 0
    4 d# A8 p' b9 i0 N: x4 n
  686.     fi; C' _* Y& W& T: `6 y' q7 Y0 l

  687. - i4 a6 R, U' L3 z1 X7 x
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')
    - a9 J, R) R/ `6 y

  689. + `& }- M- l# c) J9 _8 t- A
  690.     # Set the branch
    * `8 l+ }  @6 y8 P$ w3 S0 T& G# N- G
  691.     if [ -z "$BRANCH" ]; then7 Q6 c8 C/ ]9 a
  692.       BRANCH="$releases | awk '{print $1}'"
    % {* g2 _& T7 y& V* Z2 b
  693.     fi: d/ ?* ?: p* D0 }. Q! x; u

  694. 7 a) w2 C4 g( ^! P- z# T7 `* \# h
  695.     # Clone the selected version
    - N7 D! _6 |4 e( G) y
  696.     case "$VERSION" in  y) J7 O4 [: ]+ }% y
  697.       0)
    + A1 ?2 J* U$ V+ X' b/ _
  698.         Log "Cloning Zero branch: $BRANCH" 1
    ' g3 Z8 D- W  ^
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive
    2 p# q! p. j6 k% I9 f7 j
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive
    5 N2 p2 I4 i, `6 z1 P2 Q2 W5 O! ~0 W
  701.         ;;* k$ f6 v1 v" p! \1 S. W

  702. 9 e, e8 b8 H% ?& H* o- r
  703.       1)
    ! K% a0 N9 ~$ d6 a7 b
  704.         Log "Cloning One branch: $BRANCH" 1
    & ~/ v; j- B! X8 ?! w# H
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive$ T! S8 A1 k- A' f8 K7 w0 {- I# v
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive0 W. @5 i$ f. D: c* k( q
  707.         ;;
    - L- o  w7 q, z7 M; N
  708. 2 _1 n# B: B+ E8 h4 H" i0 g1 Z) E
  709.       2)0 w9 W$ p, T. S( ^# U' o- s
  710.         Log "Cloning Two branch: $BRANCH" 17 `- ]& ~$ I; R+ y( Z" [
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive
    * D- {  l# E: t: `0 z
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive
    % {/ X8 G$ I; L. L1 y
  713.         ;;
    3 o. G1 @, Y8 u: G1 E

  714. 6 h1 U8 t- j/ X$ s
  715.       3)
    5 P1 C& l. D7 N8 v9 u: p
  716.         Log "Cloning Three branch: $BRANCH" 1; l1 S6 j" y8 m6 ^4 x/ a5 \
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive# A" d# F. N  r! Y
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive8 s$ d5 _4 k1 \' i- T( ?3 c8 c6 r, O
  719.         ;;
    . \6 x5 g6 Q/ e. a. W) {  H; F! z
  720. " g, o5 }* Z' l1 ~4 L
  721.       4)3 q' P& ?! y8 C
  722.         Log "Cloning Four branch: $BRANCH" 1
    4 r7 ]9 j& n& B5 ]' X/ \2 q1 Y
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive
    2 {. g/ b0 H! Q. W3 m
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive
    " X6 h" P; A! N0 p" _- I
  725.         ;;
    * i( k6 u+ j2 \2 {9 X9 |6 s$ y* L

  726. - E0 o6 E7 l5 k1 g  D
  727.       *); |) d  y4 i6 n, n8 V" u, u/ g3 X  O
  728.         Log "Error: Unknown release selected for cloning!" 17 _+ C3 Y% t8 u1 K( ~6 x' F. B
  729.         exit 1
    . C3 x+ l; d/ A1 K
  730.         ;;& z  V) |+ Y8 Z6 a1 U
  731.     esac6 Z/ D4 w1 g2 j/ m1 R
  732.   D& Y8 {/ g) M( e0 Y
  733.     # Log success
    3 m. t' W+ U2 A* E  P
  734.     Log "Cloned the selected repository!" 1. q# P  y, B$ W6 f
  735.   fi
    6 h* d, N" M2 ?" u
  736. 0 W2 {. C7 {. e
  737.   # Update the local repositories if selected
    : }9 e7 I" M5 b* w! l
  738.   if [[ $CLONE = *1* ]]; then
    $ W8 X- _1 l7 \( Y- N
  739.     Log "Updating your local repository..." 1; y- c, g5 A( G. J/ ?

  740. 3 N7 h; I4 Q) _/ `# H3 Y: S
  741.     # Update the core sources
    , ^: e; O# C% B1 q4 ?* P
  742.     cd "$SRCPATH/server"
    ' N) ^: _+ y3 Y7 f7 u, }
  743.     git pull" z1 C: k: J0 c; M" e
  744. / j9 S7 U& l* Q
  745.     # Now update the database sources
    ' E7 ?5 Y0 C9 x1 x+ Z9 k3 r+ @
  746.     cd "$SRCPATH/database"
      p! Z% f3 B# V0 ^; q
  747.     git pull% E0 Z( P- C2 s' V- z4 U

  748. + @9 h# ?+ O7 ^1 I, |+ ~; x
  749.     # Log success
    ! m2 ]( C2 t" |, l% }
  750.     Log "Updated the local respository!" 1
    # |9 x; z3 g% \' K# ^
  751.   fi) T: z- p, L3 N, Q$ }$ e# H$ S
  752. 9 J- c2 a9 Q. N# i+ w) G0 m8 d
  753.   # use existing repository3 g' l6 [/ k9 X' I5 c' c
  754.   if [[ $CLONE = *2* ]]; then
    ( c3 s: b% a3 I' A9 h2 `
  755.     Log "Using existing local repository" 1+ d' M' c; B/ X9 C* U- q( }1 ^
  756.   fi
    : n3 f' u( w& y1 Y3 y0 _
  757. }
    . s. \$ ^# s9 g7 B2 {5 Z" v
  758. ; M, o; {- b8 B0 X$ c+ c

  759. + m1 W: d7 Z3 L" C7 t+ v  d
  760. / Y7 C: i' [! Y: _; L- Q2 U
  761. # Function to set the build options4 {$ o7 Y( j/ n" p- Q
  762. function GetBuildOptions()
    " v& ~; t4 T2 H( T3 q; e8 H* D
  763. {
    8 Z9 s: g9 s) d+ F' W1 d+ w- w
  764.   # Select build options
    % E2 a$ b+ r6 u% M4 N% a8 J7 P4 }
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \
    ' j" Z$ l; e1 ~+ A# I( u" e/ {
  766.     --title "Build Options" \
    6 l* R7 ^+ P; Y& c( U
  767.     --checklist "Please select your build options" 0 56 7 \
    3 ~0 K; X0 `: z# t$ a, X5 z) ]5 Y6 R
  768.     1 "Enable Debug" Off \3 s8 {( x2 j8 {2 T; T8 |
  769.     2 "Use Standard Malloc" On \
    ( U! {6 H) `0 U* |0 Z  s" c
  770.     3 "Use External ACE Libraries" On \
    3 Y; B7 F7 W& _/ Z- }
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    $ D7 q# j! n  V1 v; ?- z
  772.     5 "Build Client Tools" On \
    1 t# E; x. s; N5 O
  773.     6 "Use SD3" On \. t9 S- ^6 Y: Q
  774.     7 "Use Eluna" On \
    4 r: ~8 b8 {3 q' }- T: b
  775.     8 "Use SOAP" Off \
      k- w$ u8 W0 w4 I, F! S) K) f
  776.     9 "Use Player Bots AI" Off \4 U; T7 p) i3 v; R+ @& j
  777.     3>&2 2>&1 1>&3)' n& }7 I/ J  x: x

  778. & e2 j, n% X6 a
  779.   if [ $? -ne 0 ]; then
    + w# d1 u# Q" y( Q8 z: H
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    9 t/ o9 o; p/ k2 i- S$ U' I
  781.     return 0
    : T8 X. h+ N# O/ h/ |' J
  782.   fi
    ' T: D6 L7 g0 o6 r

  783. / o! C# u* ]- [' [( T* n
  784.   # See if debug was selected# u3 {) z/ c  x  [" u! Z* S
  785.   if [[ $OPTIONS == *1* ]]; then
    ( q/ y) g' A5 |" |1 |, a
  786.     P_DEBUG="1"
    , l) y, m! E9 Y6 n& x! \, |
  787.   else, [- b, ^1 f% M& L" q
  788.     P_DEBUG="0"/ o$ F, s5 c4 t. U9 c9 X( M3 J' I
  789.   fi, I0 Q3 g' y1 e( Y+ ]# k9 F' ]

  790. ; @7 ?6 \5 ~* m* b
  791.   # See if standard malloc was selected3 I0 [8 i/ X2 `: m- G9 }
  792.   if [[ $OPTIONS == *2* ]]; then4 Y* x8 z  }7 F7 _
  793.     P_STD_MALLOC="1"
    6 N/ s  {7 Y$ ^' ?8 A- I& e% J' f
  794.   else
    5 ]/ x5 i5 N; H% I7 ?
  795.     P_STD_MALLOC="0"- \4 n4 @, @  p9 r$ A/ A
  796.   fi
    2 L) \6 |9 T0 y3 X

  797.   m7 Q% f% ]0 W! r! [* q4 O0 x# h
  798.   # See if external ACE was selected9 W8 E9 p3 i: A! X+ D
  799.   if [[ $OPTIONS == *3* ]]; then  l" d4 q+ W: h7 _0 Y' ]& h
  800.     P_ACE_EXTERNAL="1"/ q5 C; M) D6 l& R; A
  801.   else
    $ j# P! }8 q( |
  802.     P_ACE_EXTERNAL="0"
    6 m7 b& e! X# b; f: ?. j9 l) H
  803.   fi: ^! g  e* Z' B2 n' ^
  804. 6 A/ ]& J% e) Y) R4 ]. d8 W
  805.   # See if PostgreSQL was selected
    5 E) ]0 Q, V6 Z0 M
  806.   if [[ $OPTIONS == *4* ]]; then) z7 d# D1 \# a- H
  807.     P_PGRESQL="1"
    0 Q) t/ O& S# E1 j$ Z. a, S; ?* }
  808.   else, Y5 c% ]9 @3 x; M9 }5 g% ?
  809.     P_PGRESQL="0"
    5 {, I2 f% g0 T2 H0 ^/ o6 R" D
  810.   fi
      l0 p4 O" s1 V* D. j. y7 M! _
  811. , \* E; x  ~% \! U8 o$ W
  812.   # See if the client tools were selected
    : d; j: S& {& S0 T
  813.   if [[ $OPTIONS == *5* ]]; then
    ! f) C. K3 `/ H5 s
  814.     P_TOOLS="1"
    7 X0 t2 ~) [  X$ w2 o5 M& x4 B6 h
  815.   else
    - X8 a! r6 v7 I- T
  816.     P_TOOLS="0"2 o0 m% R7 ?1 g
  817.   fi4 D5 i7 c7 ]: t8 x- A9 ^

  818. ; M; {% \$ ~8 L9 c8 g
  819.   # See if SD3 will be used1 p$ c) V; N( s# u. X: M, W) T
  820.   if [[ $OPTIONS == *6* ]]; then) N$ @& N. O4 e, b# o
  821.     P_SD3="1"7 E$ C, R3 i5 A$ K
  822.   else6 l5 d  Q5 h3 u% U# @
  823.     P_SD3="0"3 u% v; ?7 W  E4 S! V3 H7 x! F
  824.   fi
    4 J- p0 g! l5 X' C. E, L  c

  825. - B' f, T) z* z" w" _
  826.   # See if Eluna will be used
    / [+ [# a9 {0 `( T
  827.   if [[ $OPTIONS == *7* ]]; then
    . e; W) F& Z7 M: Y' s5 k
  828.     P_ELUNA="1"
    # p0 y8 O! M* E/ D8 ~
  829.   else% w4 E1 E; v, t8 i/ q; _) o! W
  830.     P_ELUNA="0"7 l; N# G7 n" E# Y+ t
  831.   fi8 S! Y( x% z: u  l7 f

  832. 9 e9 H* e4 ]9 D% W' m, K
  833.   # See if SOAP will be used
    " g8 l4 k" M- T, E" Y5 Y5 @
  834.   if [[ $OPTIONS == *8* ]]; then
    ) |7 q5 q5 z. s4 c! i
  835.     P_SOAP="1". V, G5 _  i0 O" K( g0 L" q
  836.   else( m2 p/ O% @& N4 Z. W# ~0 [) l
  837.     P_SOAP="0"1 E# e+ U+ z) e7 U: \
  838.   fi
    3 J5 Q' q2 Z: W. f& g! K2 c3 A6 b
  839. ) I$ s) }$ F5 u4 ?) x, b
  840.   if [[ $OPTIONS == *9* ]]; then/ e1 D" c" \% S) R1 V1 F
  841.     P_BOTS="1"
    8 q5 ]& R& _4 i, Q
  842.   else
    5 B% e' o  B4 H$ O! c
  843.     P_BOTS="0", B+ f  b: V9 x! O6 J1 q! {
  844.   fi
    " i+ }5 t) Y& q0 v; D: D) ~# l

  845. 7 F7 r! _. U( c" w, m) A
  846.   # Verify that at least one scripting library is enabled/ ^# N6 w% @$ D: m8 v& R0 F: o
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then
    % K. g- t- t+ [* |. R* m
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 13 w  G& [- h2 t6 Q/ V7 \
  849.     exit 14 w2 F6 v* m; K  L  p
  850.   fi
    0 _2 M7 s1 ~' ~7 t2 X7 C# v
  851. }
    ) g) u( A7 t8 S8 @
  852. 9 y4 Y! l7 J& g0 B! ^
  853. ) ^. a  O: q: j, f+ [: L  f

  854. ' G: Z$ h6 @8 t
  855. # Function to build MaNGOS
    / D+ b5 X. s0 A4 U% U0 B* h
  856. function BuildMaNGOS()7 F, d$ Z, y: R4 ~* f
  857. {
    - C. [5 Y- N& l% D# a
  858.   # Last chance to cancel building
    3 h" U1 t4 B. n# X
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \/ f! J1 L4 b  x* k$ b- [
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60
    , w8 `% s- ]) ~' I4 Y9 ]
  861. 0 d# H3 [4 w  I
  862.   # Check the user's answer3 U8 l9 n, k/ L$ s- `( i
  863.   if [ $? -ne 0 ]; then
    7 x& D$ F" m; u$ H
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    # `5 o; R& s, V" j3 e- o2 C5 Y
  865.     exit 0( R, ]/ H1 P& s
  866.   fi
    ' q$ e% Z' Z+ m0 q2 v

  867. : H5 b: S% y4 h5 K
  868.   # See if the build directory exists and clean up if possible
    " V+ M3 \0 y9 {8 m' g$ o: C
  869.   if [ -d "$SRCPATH/server/linux" ]; then
    " E' J+ k- C9 F8 ]+ w6 x9 W! F( F
  870.     # See if a makefile exists and clean up. J2 Y/ V! K% |) M
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then- B* l. K3 u3 c: k
  872.       Log "Cleaning the old build..." 1
    8 D+ [9 y& d& {1 w- x6 w
  873.       cd "$SRCPATH/server/linux"5 h8 Q7 P; n- |
  874.       make clean
    3 o8 x$ `6 y; r! X3 p8 K2 k5 Z
  875.     fi
    , }$ W9 B# d$ a9 o  o
  876.   fi2 d. @) w/ o+ _( X4 C* o; e% U+ v

  877. - `& N5 O4 G$ G! v" x2 a+ |$ q) f( _
  878.   # Attempt to create the build directory if it doesn't exist5 w; [' \: l: m' `3 _
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then( t7 w+ l0 f6 C9 i4 h
  880.     mkdir "$SRCPATH/server/linux"
    9 ?* S6 \% H! t1 k% }8 Z) F
  881. * l2 x  F0 f3 l$ S! Y6 `) H
  882.     # See if creation was successful
    0 N) y, [# N8 v5 r- E
  883.     if [ $? -ne 0 ]; then- T- O- x' k3 w* i
  884.       Log "Error: Failed to create the build directory!" 1: f6 ^  ?$ Y3 M
  885.       exit 1
    - X; H6 @4 X0 X5 S/ K  m; u: X9 E
  886.     fi) ^: N8 _2 V& o* Q' l- o1 E
  887.   fi3 O; O$ G; j9 y
  888. + I6 d2 Y4 Y- C1 L8 S$ c) \; n5 M; ^* o
  889.   # Attempt to configure and build MaNGOS8 ?& P4 _: X) J+ d
  890.   Log "Building MaNGOS..." 0
      `: x) n# s2 S6 ?' N  k# v
  891.   cd "$SRCPATH/server/linux"
    1 h/ R( c9 t& I9 `
  892.   # make sure we are using the cmake3
    9 H/ Z" l9 ^2 N& a" T  q& I
  893.   UseCmake3$ q- g# x* s, F2 h. S' d9 X  |
  894.   $CMAKE_CMD .. -DDEBUG=$P_DEBUG -DUSE_STD_MALLOC=$P_STD_MALLOC -DACE_USE_EXTERNAL=$P_ACE_EXTERNAL -DPOSTGRESQL=$P_PGRESQL -DBUILD_TOOLS=$P_TOOLS -DSCRIPT_LIB_ELUNA=$P_ELUNA -DSCRIPT_LIB_SD3=$P_SD3 -DSOAP=$P_SOAP -DPLAYERBOTS=$P_BOTS -DCMAKE_INSTALL_PREFIX="$INSTPATH"# v8 C% @4 J$ ]3 N' X# a" ?
  895.   make
    . @4 U# o; \/ E; c: V& f5 O

  896. 4 k+ B! ?! b8 O6 ]. @7 P
  897.   # Check for an error
    ( ]6 v% `* W  H( T' L+ ]% C( N7 e
  898.   if [ $? -ne 0 ]; then' _* n' l2 ~5 m$ H" l$ f
  899.     Log "There was an error building MaNGOS!" 1' r; C1 w$ z7 O! F" M/ K6 x( Z
  900.     exit 1
    3 ^3 {& O2 {  L  X# f9 r
  901.   fi) {! W2 Y) Y# ^" p) q

  902. & ]+ |+ D/ P; [  {$ C' I
  903.   # Log success
    0 P& ?  ?1 ^5 K2 ~. y
  904.   Log "MaNGOS has been built!" 0( P1 Z3 c* [2 |1 ?, b) r" Q
  905. }4 H7 B6 }, U( H& \7 k: u
  906. 1 J  l% X: L7 ?, g
  907. * `: l7 l- r+ t9 S4 n) Q

  908. ' C4 r/ Q) u& ]2 ~
  909. # Function to install MaNGOS
    ( e: Y; k2 M& i  h% u
  910. function InstallMaNGOS(). Y* A3 }8 d$ {* ^9 M: p
  911. {
    / b; s5 Q, o5 X8 @5 d9 N
  912.   # Ask to install now2 _" W2 b$ N+ ?
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    0 }1 c8 `' L8 F0 S9 p
  914.     --yesno "Do you want to install MaNGOS now?" 8 0- a; n5 Y. D  U" f. |& ?( z7 A

  915. 8 k) R. _; f2 @: J& E( Q
  916.   # Return if no7 x% _  Q- `6 d) \# k; O  e
  917.   if [ $? -ne 0 ]; then
    . r+ O6 c# m' l# H: f; k
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \( R! |' C8 }! ?% H3 ~  z" |, e
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60
    4 Z' f. F# a" q

  920. % L8 l8 Z& R' k, F  o% T0 c$ A, D6 P
  921.     Log "MaNGOS has not been installed after being built." 1$ p) X: v" `+ _! s+ o$ a# ^
  922.     exit 0
    ) p7 s6 Z) t' c( @  @/ p
  923.   fi
    # B7 f. I2 \' B
  924. / \- ^4 J6 k( L" r
  925.   # Install MaNGOS
      x1 r; y7 m  W8 ^! S/ U
  926.   cd "$SRCPATH/server/linux"
    . C* R- R/ o2 c
  927.   make install% _* |5 b5 J) T

  928. 2 \' i8 C4 W4 M3 c
  929.   # Make sure the install succeeded( i8 N3 u/ i3 i; z7 b: ^4 j
  930.   if [ $? -ne 0 ]; then
    & g0 ^! n5 P( P4 G+ a4 |4 w/ ]
  931.     Log "There was an error installing MaNGOS!" 1
    * ?$ Z8 `& M' t$ R6 y
  932.     exit 1
    ' [/ {( `9 k9 m2 R+ {, ~! R4 s
  933.   fi
    , W( E0 M6 i9 F9 e
  934. }
    8 R9 a  }+ p2 d7 G5 o: k! t4 n( q

  935. : G) J) R' I5 f' \7 S+ B
  936. # Function to apply database updates
    ) N6 }( G  J) v8 e' p. ]
  937. function UpdateDatabases()! e! u6 f& L% b# N: n
  938. {9 A$ i7 y1 o9 {- W) w1 e  _
  939.   local DB_HOST="$1"8 a/ a) i! O- T& \
  940.   local DB_TYPE="$2"! Q0 F7 k! P. m) {) a+ z
  941.   local DB_COMMAND="$3"( m0 c! v+ v) U; N4 D" C6 O
  942.   local DB_USER="$4"
    4 k* G9 `/ n. i( q  V, R6 S" R, h; V
  943.   local DB_UPW="$5"
    0 b9 q  P, u" o5 t& _8 T8 G: D; j
  944.   local DB_REALM="$6"
    , V9 O" h6 k  N6 Q& P2 s: O
  945.   local DB_WORLD="$7"
    0 {  N/ K! A7 p3 B
  946.   local DB_TOONS="$8"
    ; _3 a1 g! Q. o2 o" ?

  947. 6 [2 ?( f+ v- y9 x6 L
  948.   # Loop through the character files
    / J9 r* U" \9 A) I' X4 ~0 M
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    * c- q7 u/ ]# M4 l
  950.     if [ ! -f "$pFile" ]; then2 q! X; d' r' e) c! n# a
  951.       continue
    & w# I" z; b' {$ ]7 J
  952.     fi
    2 r$ W. a+ x5 a4 s' \5 A
  953.     # Attempt to apply the update
    # s6 b( m1 ]0 l' k: x; e% o
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1/ ~+ ~2 a. u5 C, M8 n2 y( A% i

  955. , r9 Y2 d6 L8 }$ c+ C# W- u. z
  956.     # Notify the user of which updates were and were not applied
    ; G/ {2 m3 |2 f/ j0 a" F
  957.     if [ $? -ne 0 ]; then
      I7 G4 A6 q8 Z+ h
  958.        Log "Database update "$pFile" was not applied!" 0! [  b3 l- u" t; h1 w! |' t% k
  959.        Log "Database update "$pFile" was not applied!" 1
    . M3 w- w1 R& k) h9 Z' S: U
  960.     else
    0 _/ q7 t! r* Z, o2 }& I
  961.        Log "Database update "$pFile" was successfully applied!" 0( p( r( m8 j- k" s* L
  962.        Log "Database update "$pFile" was successfully applied!" 1% W4 V- J' H9 t* @8 ]
  963.     fi
    * A, `9 i, v6 {
  964.   done  v" L9 }: u* N# U  l6 C* i

  965. # I2 C% F. P  M, N* M7 i5 C/ s
  966.   # Loop through the realm files
    . |% |- k9 b" ~* M, T9 \
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do' v) U0 q9 m& _- q6 F0 J
  968.     if [ ! -f "$pFile" ]; then1 y, L4 p) i9 ^7 f/ Z
  969.       continue
    6 S" X0 {1 z3 J" L1 e. E2 ^" h
  970.     fi
    ( q6 q" E/ W1 X8 f/ u
  971.     # Attempt to apply the update
      O  q0 g5 M- c0 V" m5 N5 k
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1- A; M% _. M3 _% P4 b& [
  973. ; v5 d& G1 |! c
  974.     # Notify the user of which updates were and were not applied
    8 W* n, R# Y/ e4 L1 A
  975.     if [ $? -ne 0 ]; then3 \  t0 l+ h9 \0 Y7 i& y
  976.       Log "Database update "$pFile" was not applied!" 0
    + E9 N6 s( g9 u, S
  977.       Log "Database update "$pFile" was not applied!" 1. U' {3 F- Y. I3 @- E, c* U
  978.     else
    0 W; A+ t! Z" @- m" E0 |
  979.       Log "Database update "$pFile" was successfully applied!" 0' d5 @- |) \4 y) i" y% Y
  980.       Log "Database update "$pFile" was successfully applied!" 14 ~. P, J' j3 ]  u+ D1 X
  981.     fi, d6 G+ `$ _) F: }
  982.   done
    : ~$ C0 x6 Q; ~% c8 d  k5 G

  983. / q/ Z  r( L) f) _
  984.   # Loop through the world files
    2 P9 t9 \9 q+ F5 Y
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    7 \+ A. p- |# ^; u' ^9 {
  986.     if [ ! -f "$pFile" ]; then
      s0 B' j1 \( J7 z; [
  987.       continue) X$ W1 D, T8 }- t7 g# Q) y
  988.     fi* S  x$ u: s! l8 W4 h. c7 A
  989.     # Attempt to apply the update9 S* a5 t8 N6 H8 G* v8 S6 V$ z
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    / I: p; A; I0 E' H# e2 F; i

  991. # m& k3 j  M% o4 |& c3 w! F
  992.     # Notify the user of which updates were and were not applied% c/ G) Q" {% A& H
  993.     if [ $? -ne 0 ]; then
    , Q  e: J3 B( K. h! m1 @
  994.       Log "Database update "$pFile" was not applied!" 0
    8 G7 ~1 d/ j. Y
  995.       Log "Database update "$pFile" was not applied!" 12 ^! T1 p% K) H3 q
  996.     else
    , h( z$ r' ?$ t, J# m! w. R8 {" |) k
  997.       Log "Database update "$pFile" was successfully applied!" 03 c) `2 n& g% f) c* w' `
  998.       Log "Database update "$pFile" was successfully applied!" 1
    + D4 o' Q3 p, S0 \
  999.     fi! P! G( X/ N. n: v% B6 d1 c
  1000.   done
    9 f# m- ~5 I" y$ C# \, n( d' Z
  1001. }
    2 H0 c9 j  k0 G$ n
  1002. 9 |; Z- B* R* v1 P' {% M' |7 s
  1003. # Function to install or reinstall the databases. ?: I! d$ Q6 `' M3 L
  1004. function InstallDatabases()& M1 s- r- f9 b+ ~1 D9 O; C2 \! z
  1005. {; q7 |* L1 R7 T) L, e
  1006.   local DB_HOST="$1"
    ' T4 i# ~0 X: }" g$ l* {
  1007.   local DB_TYPE="$2"
    ! t2 I4 R' o8 r
  1008.   local DB_COMMAND="$3"
    ! [3 f( Y8 d) D) N6 [
  1009.   local DB_USER="$4"
    5 S( H4 @+ H9 o$ C. s( G
  1010.   local DB_UPW="$5"6 q5 x+ d0 `" u# P
  1011.   local DB_REALM="$6"
    / k" r3 y: R2 q! h7 H
  1012.   local DB_WORLD="$7"
    ' d1 R) E8 L( t8 ]4 l4 B7 Z
  1013.   local DB_TOONS="$8"5 J0 j4 X. a- m+ z7 [  Q. `

  1014. * {4 a1 m" s& o
  1015.   # First create the realm database structure$ c4 w  v+ R9 J, W/ {
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql2 y% C. r+ Y$ [6 i4 e
  1017. 5 f  O6 L6 w2 C: O4 Z+ E
  1018.   # Check for success
    5 s2 U+ c: l& o
  1019.   if [ $? -ne 0 ]; then
    - j  `6 @+ G" L. Y6 e$ v/ j- m
  1020.     Log "There was an error creating the realm database!" 1
    + O5 G( |' W9 Z2 C; o  }, b  z/ e
  1021.     return 1% h9 @$ \# ~+ j$ _
  1022.   else
    * A! h% d( c; z3 k6 `) m
  1023.     Log "The realm database has been created!" 1
    , l) E6 j. \: a/ D- v+ e
  1024.   fi
    3 c) s* @5 O  P/ \" s
  1025. 8 g4 x9 @  ^7 [& G! l8 U
  1026.   # Now create the characters database structure4 g. f8 t! `6 M
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql8 W- z3 _: Y; P9 G  {

  1028. 3 O$ C) t. \  ~3 T- Q4 N
  1029.   # Check for success8 }0 k" P6 b5 X: [- {) w% d. M
  1030.   if [ $? -ne 0 ]; then
    0 Q" w0 B6 J$ h9 |% `
  1031.     Log "There was an error creating the characters database!" 1
    5 B# B4 R2 `9 V+ O
  1032.     return 1
    4 K: K1 i* t$ \
  1033.   else
    % k* Y3 O1 Z& i& e; B; G
  1034.     Log "The characters database has been created!" 1; f1 q' A0 [$ Y, l8 ^
  1035.   fi& p) o$ @9 _9 g* J7 _- ~# I, V  a; l
  1036. " O$ {) j$ Y- K2 \
  1037.   # Next create the world database structure
    2 v" p5 }4 l6 L# w$ S
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql4 Z  {2 [9 j* A. T  R3 b
  1039. ! Y" ^$ \, N) k# m$ V3 @. H, f7 U
  1040.   # Check for success
    * H  d& y* l3 k2 q# Z
  1041.   if [ $? -ne 0 ]; then
    , ^9 a* B' n! g3 V! Z: z( j
  1042.     Log "There was an error creating the world database!" 16 A+ h" h+ X/ w$ J
  1043.     return 1. a) M7 r5 c& b% ~! }$ a
  1044.   else
    , u, e# k  f! k& u' Q! {2 }' M) F
  1045.     Log "The world database has been created!" 1
    + d9 [# {1 j+ E
  1046.   fi
    ; Q1 g+ W# i0 P2 {0 \& F. `

  1047. + R3 R2 L: ?1 Y. [+ |5 {. k
  1048.   # Finally, loop through and build the world database database3 O* y6 C8 \) H) ]0 h) Y
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do, E6 J' h- Z3 K1 N1 m$ E; q+ ^. d8 E
  1050.     # Attempt to execute the SQL file
    0 x% c$ Z/ Y5 g+ J" |" H) p" I4 t
  1051.     $DB_COMMAND $DB_WORLD < $fFile
      w5 e1 [) R4 S$ _
  1052. 6 k0 S( p- T$ @; a. G
  1053.     # Check for success
    7 O. h7 G: p1 H7 K) v, Q
  1054.     if [ $? -ne 0 ]; then
    & O( h" j, E  z3 H
  1055.       Log "There was an error processing "$fFile" during database creation!" 1, s+ ?3 y- S( @6 S  M* i2 J
  1056.       return 1
    ; \; T0 q% |7 F5 r2 M
  1057.     else
    ! j) V6 K9 q' b( Z
  1058.       Log "The file "$fFile" was processed properly" 1" R! z3 P% U/ }! D
  1059.     fi; [/ U3 K, ]4 |
  1060.   done/ c7 ~: u, A% W$ I4 l

  1061. " w5 L( L5 u4 ]9 D
  1062.   # Now apply any updates
    * Y6 w2 i; \* n$ A/ t' T
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    7 G# m3 T* K; s( r- f5 i
  1064. }# I! F! ?6 j" d& J1 m

  1065. . M& U- T. c2 c; q7 T
  1066. # Function to install or update the MySQL/MariaDB databases. x) x* [$ ^  D2 v3 H
  1067. function HandleDatabases()6 q9 f$ f( a. o; v' |
  1068. {) z) s4 V, M4 B3 c
  1069.   local DBMODE="0"
    # \. K  V9 [+ O, o# k# G4 ]
  1070.   local DB_TYPE="0"" K+ X7 ]$ {3 u
  1071.   local DB_COMMAND=""
    # B+ x" _% P( r0 U) H; g7 ]) s" h
  1072.   local DB_TMP="0"
    5 C* [: R4 \: B; D6 L
  1073.   local DB_USER="mangos"- Y8 T6 e+ l# q9 J5 w
  1074.   local DB_UPW="mangos"6 \5 u; v+ w9 i( u( j6 D
  1075.   local DB_HOST="localhost"8 n3 r* H3 R6 m- m3 v' G0 a
  1076.   local DB_PORT="3306"
    4 x) Z- G7 m! u3 q- o
  1077.   local DBSEL="3"
    4 f( |, z1 A+ l; H1 P2 ^
  1078.   local DB_REALM="_realm"7 o  o% w% v: V) |* a
  1079.   local DB_WORLD="_world"7 q/ R5 x1 S' g
  1080.   local DB_TOONS="_characters"
    ! {3 {+ A+ g9 x0 E
  1081. 5 k0 F: Q7 F/ W
  1082.   # Ask the user what to do here
    * {5 e4 f! B* Y$ ~5 s3 q( i
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \/ T. K  E) A7 E7 v! }1 y2 w: ~
  1084.     --menu "What would you like to do?" 0 0 3 \: i% O' |/ c4 B1 E
  1085.     0 "Install clean databases" \
    4 M) V! V, l: l) m
  1086.     1 "Update existing databases" \
    * P" o2 Q7 ]$ H$ J5 ~. h4 M
  1087.     2 "Skip database work" \
    ( s: V/ }3 C7 M' P# x+ m
  1088.     3>&2 2>&1 1>&3)
    ) X/ |8 C6 z# w/ {
  1089. 7 g+ f% @; h' J9 K2 q( Q+ H
  1090.   # Exit if cancelled
    : B$ U; C1 S# y; P& z
  1091.   if [ $? -ne 0 ]; then! `: n! B. W$ `% V1 T
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 14 Y+ Q, H( [( u8 f% B8 k
  1093.     return 0, b: q  [% C: e4 h0 j9 v' @0 K
  1094.   fi" ?- b& n7 k# m) W
  1095. 1 m2 M1 O% s/ q8 z
  1096.   # Exit if skipping9 a  P5 a: t. K% a7 Z7 q
  1097.   if [ "$DBMODE" = "2" ]; then) r' n! O, W' R3 A
  1098.     Log "Skipping database work. Nothing has been modified." 1
    : W* {: o' E; i* C5 A
  1099.     return 0. R2 O6 o. }. O1 n
  1100.   fi
    5 X2 R9 H; |! X
  1101. " A, m# B- F# k3 w3 `  @
  1102.   # Ask the user the DB type
    : A7 I6 C: t3 s$ E6 s' p1 }8 b
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \, R( U0 I& [( n2 a! m0 f6 ^5 Q
  1104.     --menu "Which database are you using?" 0 0 3 \
    / ]: U3 P" ]+ G1 W! Q7 `; T6 @
  1105.     0 "MariaDB" \( Q* v6 H1 b( Y1 k2 ^
  1106.     1 "MySQL" \5 s  t: w3 Y2 q4 A: t; P. ?
  1107.     2 "PostgreSQL" \9 V& l5 C% @" ]1 l
  1108.     3>&2 2>&1 1>&3)2 O  X9 q- i0 p' M0 K7 _- E
  1109. % h# N4 w* C& D/ X# b& D
  1110.   # Exit if cancelled
    2 \6 k1 R: z; L# e. G: {9 H
  1111.   if [ $? -ne 0 ]; then
    " u$ D1 L2 T& _$ S2 j. {+ O
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 1
    , w' c( p+ t% N# A
  1113.     return 0
    : ?4 H. {1 z/ m! C
  1114.   fi
    + k, v! F3 i* }& Q. f' N( `

  1115. 2 ]% ~! a- k" R9 N  @0 p6 g$ P
  1116.   # Get the database hostname or IP address
    5 v( h2 f8 N% Y0 V1 Q4 H( v" G
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \( F# i6 o# E0 a
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)
    - ?& M2 L9 H2 w& D- n1 w+ N
  1119. + F* i" U0 X5 i) E: T! t( F3 q4 f
  1120.   # Exit if cancelled
    3 c. ^* i  H, |7 k$ @! w6 o
  1121.   if [ $? -ne 0 ]; then
    ) l0 o2 y3 X. D3 Y
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 1
    - }& b) j! u. u" P: e
  1123.     return 0
    0 q. c% f5 Y: a
  1124.   fi0 p2 Q6 p$ A3 p6 T
  1125. & w5 d3 e' v1 G, w
  1126.   # Set the hostname or IP address if one was specified
    : a# \: ]3 W. v0 b
  1127.   if [ ! -z "$DB_TMP" ]; then
    ) v: D, C; T( i4 u
  1128.     DB_HOST="$DB_TMP"
    + F( T- A" E) u- m
  1129.   fi
    ( o) B. j9 p2 }2 ^  f% Z
  1130. 5 ~4 O2 U; Z' G! Y; j+ d- y( k
  1131.   # Get the database port
    " q, a+ n6 q. x, Y- Z
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \
    # |/ k0 m0 U# a' h  j# S
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)0 z" d( q) i$ x( E' D* f/ ~% C

  1134. % D$ I) S3 A6 I2 P& W
  1135.   # Exit if cancelled
    " q5 D6 E& X' V/ s
  1136.   if [ $? -ne 0 ]; then9 t; B3 {" C' |: u1 q3 k! d
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1
    ) {1 v2 ^( R3 w' H1 N1 y2 h9 J
  1138.     return 0  B, g! c" d  q  `
  1139.   fi" n* G; S8 f9 o2 L6 D" a# g

  1140. + m6 C4 a+ k7 F
  1141.   # Set the port number if one was specified' n& M' a6 S9 h% y  M+ e; O) Y9 _0 @6 W8 H
  1142.   if [ ! -z "$DB_TMP" ]; then
    ' d% C; P' d0 q$ x4 t
  1143.     DB_PORT="$DB_TMP"6 e0 T2 @' x2 {. C
  1144.   fi& R9 G8 ?7 e0 d+ w/ J# O
  1145. " d/ p+ X; Z1 n. A5 f5 l3 b' b
  1146.   # Get the database user username
    " ~1 U0 |8 C: c8 g
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \6 B8 f! K- f. B1 P
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)) G9 J. N1 j: K6 Q, m4 M+ }
  1149. 7 W, ?: k2 o, E7 r
  1150.   # Exit if cancelled6 a! X- E; y  p( C! ?* R
  1151.   if [ $? -ne 0 ]; then& L0 ]% D; j. D( }/ V6 c8 d- w0 ?, w5 `
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1
    + r) F, |# s0 y
  1153.     return 0
    ( ?+ y: s& B9 ^
  1154.   fi
    # T0 i$ Q2 m7 [4 ~

  1155. 7 P. i9 g( p- L( G
  1156.   # Set the user username if one was specified' m% G! L) u( j: l( l, X
  1157.   if [ ! -z "$DB_TMP" ]; then
    % |* X! h3 x' R# a: o
  1158.     DB_USER="$DB_TMP"
    5 L4 V2 U* [) T+ b& Y* e
  1159.   fi
    + {" d% w3 d, J& i; i

  1160. % y5 `/ b0 Z$ S7 d
  1161.   # Get the database user password
    . t: F- O- F' z
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \
    , G1 |) K- y# U" |2 l- u; V! [
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)# y  L# j/ f6 z4 y

  1164. 2 y' Z/ u8 n5 o; P
  1165.   # Exit if cancelled
    6 [* I* b$ Q2 a; l3 n
  1166.   if [ $? -ne 0 ]; then
    : I. v( g- n' @: U, N+ F6 v. r
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 18 r6 ]/ L, j% K: b5 U
  1168.     return 08 }. Y2 Q. G, J1 g
  1169.   fi7 u# t3 I" ]/ X

  1170. " C; ~. S& r( E# e
  1171.   # Set the user password if one was specified
      u7 ~% W6 H7 _4 G6 V1 ^* `
  1172.   if [ ! -z "$DB_TMP" ]; then9 F$ B1 f2 p  p- G5 [
  1173.     DB_UPW="$DB_TMP"+ c- ^3 b6 _' M& ~" R0 [
  1174.   fi
    - r. [1 S1 ~4 I2 ?

  1175. + \% g6 H2 O) \- I5 W: F
  1176.   case "${DB_TYPE}" in
    / |3 y# N, X! k
  1177.     "0")6 T, }4 t( n5 t: m: `6 K
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "
    2 F" T2 s! e9 G1 t* O4 p, b
  1179.         ;;0 {' P- z& q1 E3 s, E0 V
  1180.     "1")
    * l7 o' O; \  q+ H! o7 ?. q/ v( U
  1181.         printf "Confirm your MySQL password\t, ": s6 b! X  B" W3 [" g9 d
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn
    . w6 E3 x3 t9 l- }! M6 }
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    / V4 p2 Y9 K; h/ z
  1184.         ;;
    ) L' Z2 {0 v- t7 {3 H0 t9 o
  1185.     "2")4 Q; I8 m" A  y8 j$ b( w
  1186.         Log "Currently not supported." 11 g: f0 G" m. F/ y8 J3 F
  1187.         return 0
    4 w( I' X  _* ]. m
  1188.         ;;
    6 }. E9 i* g% I& o- i3 ?3 ~
  1189.   esac$ [9 x2 ]; t! C. }4 x" c4 v% `

  1190. 9 S: @+ i0 k/ _9 g
  1191.   # Setup database names based on release
    & b5 J" q( @* P( _: V( I. `6 C8 O( H
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"" i) @5 {  [+ R7 _) F6 X+ A
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"9 y! U5 N+ M7 G1 d' Y8 v# M5 `
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"
    * @* R( g% o2 Q- C
  1195. 5 L8 U: ~( m# C& F
  1196.   # Install fresh databases if requested8 Q. ^' k: U9 E+ R- K6 K
  1197.   if [ "$DBMODE" = "0" ]; then
    # @$ i3 H1 j1 C' n: W: ?* |
  1198.     # Ask which databases to install/reinstall* P# j% g. S2 z* ~& S
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \
    ' ^/ F) t. k5 E! N! K9 r4 Q/ _
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \- m4 l& `5 ^, Y  l. \( i% e
  1201.       0 "(Re)Install Realm Database" On \
    & R$ C" S* k8 h$ H
  1202.       1 "(Re)Install World Database" On \- v8 _" b) l6 L6 i
  1203.       2 "(Re)Install Characters Database" On \7 x( h4 }+ O  Y3 K4 `" S
  1204.       3 "Update the realmlist" On \6 W( e  B7 h% S' `8 t
  1205.       3>&2 2>&1 1>&3)$ d" X+ i5 o$ n  m! z/ P
  1206. & V; E% v; ]* \. ?" O" D& |  i
  1207.     # Exit if cancelled$ d3 t" o0 w4 Y$ t
  1208.     if [ $? -ne 0 ]; then' d& N/ y, F" j& h
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1; `* H8 t) c; k8 `/ k  s
  1210.       return 0
    ( l; Y) f8 C1 E
  1211.     fi
    7 d3 c" ~! l/ m$ `6 J5 Y4 u+ ^. p
  1212. # z6 o  P$ E6 f- u& h$ N) B4 {
  1213.     # Remove and create the realm DB if selected6 T2 a+ s4 D( P1 L7 v) U* X
  1214.     if [[ $DBSEL == *0* ]]; then
    ! W& v. U( z' V; S3 V
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"* ?2 `: \4 Q0 H% n. K4 v$ o
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"- Y1 }& [5 F. {% z  ?$ e
  1217.     fi" q% y/ M/ J1 J( t  w3 n, B
  1218. ' _* j& A6 Y' s5 r9 X  N
  1219.     # Remove and create the world DB if selected
    . W) }% g$ P  p7 s1 L6 d( X
  1220.     if [[ $DBSEL == *1* ]]; then% p0 r& c! @/ y7 ~0 U4 w$ b
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"
    3 a" E- z$ K! r3 j0 a" h, g3 }2 x
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;": U' C( {1 r' ?; E7 @
  1223.     fi
    ! U2 g/ l  d" A) p" Z, @$ X

  1224. / o5 ?2 _5 S' E; k) |- B" b7 K
  1225.     # Remove and create the character DB if selected
    5 y2 y. W9 v, M
  1226.     if [[ $DBSEL == *2* ]]; then0 g9 \. X0 g. l
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"
    / Z  G# v! k0 \% `( X
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;", u# W: X! V/ v& d' T6 d
  1229.     fi
    4 N& b" J, K( A1 ?: X& x

  1230. ' B) E: U/ _' K& N" @8 r* F& I
  1231.     # Validate success
    - p0 i# m+ P* Y) }0 j
  1232.     if [ $? -ne 0 ]; then
    ' J$ f3 a% L0 f" G! j
  1233.       Log "There was an error creating the databases!" 1
    - {* `+ _& n7 P" X" K: A1 Y! D! d
  1234.       return 1
    9 G9 K" J9 S7 m: _
  1235.     fi
    3 [* J4 O. ?3 M+ |/ e/ W- a

  1236. # P# N- w8 m& E  N7 g. A0 E* z
  1237.     # Finally, populate the databases
    + Q& B8 o' C6 x* t
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    - F2 K# I; f5 d
  1239. ( a  ^$ i( s& m  W, E
  1240.     # Updating the realmlist
    * j. C( S; v- O" \
  1241.     if [[ $DBSEL == *3* ]]; then$ H% Q0 P; y- Y
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql" M+ s# R2 p$ ~* h
  1243.     fi' q( p* P3 d0 l( G1 b% n0 e
  1244.   fi
    4 [- g2 L0 Y& H

  1245. ! S+ d: F" s' a
  1246.   # Update the databases if requested
    ' {) z5 F8 G; W
  1247.   if [ "$DBMODE" = "1" ]; then
    4 i5 g  T) V9 _5 E) s
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    ; G4 |5 D, K: X. `- Y; w& u
  1249.   fi
    - [/ a3 n( l& `
  1250. }
    6 D3 {! i* S6 w/ {# M
  1251. , Y2 l. h8 o# Y/ W8 M# _
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game6 ]9 }2 Y% j2 f' @3 W3 i" ~! ^" B6 w
  1253. function ExtractResources
    " m9 Q  x1 s# c& v; x. q' i  r
  1254. {
    7 g; r5 G* X; N6 C6 k
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))
    6 q$ Q( P8 |; B+ j9 R9 c

  1256. 1 y! l1 L2 k# ^0 Y: x- a+ R' e
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \# Q5 q% j% b2 g6 P
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)4 W* Z: n0 G. x

  1259. 6 t  o% g) [& f
  1260.   if [ -z "$GAMEPATH" ]; then
    ( _$ D' }  F% J% \
  1261.     GAMEPATH="$INSTGAMEPATH"
    / c: s- n- R  C' \/ N3 I: }, n+ u) @* I
  1262.   fi/ ~. }. a! x3 t0 t2 M
  1263. : I7 E# `3 \; x* _0 N
  1264.   if [ ! -d "$GAMEPATH" ]; then$ P! p2 ]! c2 J+ ~9 l  x* D
  1265.     Log "There is no game at this location" 1. k+ Y8 a! f% T) i0 j
  1266.     exit 1
    / D6 P4 }$ \: R
  1267.   fi
    $ k, W+ }4 m6 z) _7 G, @. Q/ Y
  1268. + o# Y; E8 A2 s& n, t
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \: D* ], n0 i8 r) m# n  Q
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \5 ]0 Y1 M* q& B
  1271.     1 "DBC and Maps" On \- ?6 y4 ~9 P$ `* D
  1272.     2 "Vmaps" On \
      O" U/ }/ }* ^' |6 r. V$ h
  1273.     3 "Mmaps" On \
    ! ?7 C" H) a6 Y) I
  1274.     3>&2 2>&1 1>&3)/ a2 p4 g0 w( L; F" q* ~3 u- G

  1275. 2 H3 G' @2 U( c( \& b: _* x: o4 D- Z$ [8 e
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then2 ?6 X. w! N6 p+ K, D/ X& M" h
  1277.     Log "The client tools have not been built, cannot extract data" 10 ~2 t( y) y5 w* Y
  1278.     exit 1. j. s% h( D8 C5 j
  1279.   fi7 @" A5 u" h# X9 b' c# e$ f

  1280.   r; r$ G2 l, G. w/ p4 g9 o' t
  1281. #TODO What if DBC are not yet generated ??
    3 o8 a# {7 v2 T4 s  i! q4 a
  1282.   if [[ $ACTIONS == *1* ]]; then8 y; z1 ]  `3 u
  1283.     if [ -d "$GAMEPATH/dbc" ]; then
    ) z# I% W) e3 f9 i# W6 @
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \# F! v* {9 p% I9 O; W7 y
  1285.         --yesno "Do you want to generate them again?" 8 60; a1 K. j! u6 ~4 X

  1286. 7 ?* S: j+ j" }0 f; i
  1287.       # Check the user's answer
    ' S% W4 j& Y6 Q' J; D9 e1 z
  1288.       if [ $? -eq 0 ]; then
    , F, ^" u( I  ^% K7 c0 p- C/ ]
  1289.         Log "Deleting DBC and Maps previously generated." 1
    . |  i  v; V: X. \: Z2 }) q8 F
  1290.         rm -rf "$GAMEPATH/dbc"
    1 a9 B% P# Y' X+ O/ q) F5 B
  1291.         rm -rf "$GAMEPATH/maps"
    ; p4 }. p. I. ^6 g9 g( e0 V8 i
  1292. 6 M" D) h9 J7 F
  1293.         Log "Copying DBC and Maps extractor" 0
    " w" ?! ~: v3 m0 n3 D1 D
  1294.         rm -f "$GAMEPATH/map-extractor"5 e4 f- ?$ E3 V) y1 f' U! B5 e
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"" T: ~$ g" Z2 `3 K5 p7 ^7 |. F

  1296. 2 A/ F6 f0 }/ |2 d, v( H
  1297.         Log "Extracting DBC and Maps" 0" s$ n7 r7 P. c% E
  1298.         cd "$GAMEPATH"3 G  }$ ~% T& k) X/ i3 F
  1299.         ./map-extractor1 m+ l0 m0 F6 f( j$ P2 ?

  1300. 3 i; J& U! L4 d$ Y
  1301.         if [ $? -eq 0 ]; then2 |/ S) J! O  I& A
  1302.           Log "DBC and Maps are extracted" 0. n' u( C0 @  M4 Y
  1303.           Log "Copying DBC and Maps files to installation directory" 0* T( q# B% W0 c" T3 e
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    7 k4 Y# Q* A  H, y" g9 _, L" O0 |
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"' G2 b  ?# x" f$ i, ~/ y
  1306.           rm -rf "$GAMEPATH/map-extractor"
    % Y7 k, c/ K  p
  1307.           Log "Changing ownership of the extracted directories"
    % a$ o& {5 I& i4 D. W5 b
  1308.           chown -R $USER:$USER "$INSTPATH"! \+ x% f, q( x* `8 F) Y
  1309.         else
    9 @) p& i( Y# O5 a: `3 L: g
  1310.           Log "There was an issue while extracting DBC and Maps!" 1
    3 h; M# t7 p/ ], `; Z6 X/ {; P
  1311.           rm -rf "$GAMEPATH/map-extractor"1 y; {# S3 y* x3 D% x+ _; E: E
  1312.           rm -rf "$GAMEPATH/dbc"
    7 M& d: X4 {9 d) C6 x( F
  1313.           rm -rf "$GAMEPATH/maps"
    + E* G+ H& ?2 o: h
  1314.           exit 1) |; p* F6 R$ @8 L
  1315.         fi$ ^' h  n# r9 Z# X: ]( H* j
  1316.       else
    9 y1 O6 }! ]1 K
  1317.         Log "Copying DBC and Maps files to installation directory" 0+ c7 Y# d4 L3 M# Q( W
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"0 G2 G7 f3 ^6 W) T4 F$ C: g  u
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"8 V; [+ P2 w1 S/ u
  1320.       fi
    7 u1 p; v1 e1 r6 o2 e& f* X) Y
  1321.     else8 ^; i: T% I4 |+ d& _
  1322.     rm -rf "$GAMEPATH/map-extractor"( d" D) ?7 G& \5 d
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    9 y1 |  x* A, a4 b' U
  1324. 2 ?5 w& @0 Q# V
  1325.     Log "Extracting DBC and Maps" 0
    , W* f2 n, x  d3 g* u
  1326.     cd "$GAMEPATH"* A; G3 }4 L0 r: \
  1327.     ./map-extractor+ t3 \4 J3 x. f1 X) b" K

  1328. ( H$ ^, C! c# Z* }" F( @5 ~
  1329.     if [ $? -eq 0 ]; then5 |. }; Q# v( L& ?
  1330.       Log "DBC and Maps are extracted" 0) I8 A. D% Z: J6 d
  1331.       Log "Copying DBC and Maps files to installation directory" 0' M2 U$ b" R+ n; \# [2 ~. _
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin") F- o5 U: ?2 {
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"" f/ R! o5 U8 L' A$ J) ]* K. Z/ r
  1334.           rm -rf "$GAMEPATH/map-extractor"# L8 ]& N+ D) [9 k5 I
  1335.           Log "Changing ownership of the extracted directories"
    % Z' Y! ~7 D( d& U* O* X5 C
  1336.           chown -R $USER:$USER "$INSTPATH"
    7 C/ V- l( o5 W; F/ T( ~
  1337.         else
    ' }( s6 l2 L: q- G3 R2 j. w
  1338.           Log "There was an issue while extracting DBC and Maps!" 1# Y9 ]. |/ p+ e1 b6 o2 B/ I, ?7 j  T
  1339.           rm -rf "$GAMEPATH/map-extractor"
    0 o; q# @5 E& g8 g/ r* y6 d, H9 C
  1340.           rm -rf "$GAMEPATH/dbc"
    # b5 G# [$ d0 x& P
  1341.           rm -rf "$GAMEPATH/maps": E, F9 X5 l; T1 U0 C+ u* W
  1342.           exit 1! \* ]& x8 s7 ?$ Y
  1343.         fi
    4 H: v. b' p& q8 X0 _' [( T
  1344.     fi. K% O8 f* K" w/ z+ f  r5 H
  1345.   fi
    , j( Z$ M) C$ _( l5 O9 C

  1346. - i5 C+ F. A9 m; B
  1347.   if [[ $ACTIONS == *2* ]]; then
    + z* K+ J  [2 N7 W- U9 ^- d( J* H
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then4 V% z+ h! e1 n& C
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    ; n  r7 i$ ^0 b
  1350.         --yesno "Do you want to generate them again?" 8 60
    9 o* `: k8 q4 B" E+ f, e

  1351. + O7 H) x7 }; {, i- w) h6 H6 t
  1352.       # Check the user's answer
    : F4 ^/ D- J) a) v
  1353.       if [ $? -eq 0 ]; then- p: B  _) I; x; u9 Q
  1354.         Log "Deleting VMaps previously generated." 1  e' Y  J* H# E9 w" r
  1355.         rm -rf $GAMEPATH/vmaps
    & U2 A* d6 t; @3 M
  1356.         Log "Copying VMaps extractor" 0+ e9 s, J3 S6 W# X3 F. a
  1357.         rm -f "$GAMEPATH/vmap-extractor"4 M" f1 q& A2 D: f
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"2 d0 l9 P- p; s$ H* @$ ~
  1359. ' T8 z# [5 I9 `# j0 T$ J- l9 d
  1360.         Log "Extracting VMaps" 0
    . ~/ k8 ~& G  D$ t& Y% m
  1361.         cd $GAMEPATH
    8 X  o7 e8 q) H# ]2 C
  1362.         # Make sure there is no previous vmaps generation that cause issue.- u4 M/ [: O; u$ W0 r) P5 ]
  1363.         rm -rf Buildings6 H4 }- A; ~' _3 K1 ]3 F! S5 U
  1364.         ./vmap-extractor
    & \* S9 Y4 S* w  a
  1365. 3 ~; |% T7 Y0 e, p
  1366.         if [ $? -eq 0 ]; then2 _5 t/ _. f4 s  G
  1367.           Log "VMaps are extracted" 0
    / v8 a- L6 {% R0 J* x
  1368.           Log "Copying VMaps files to installation directory" 0& U& j% |/ i: O$ N0 B- {! |0 o3 ~
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    1 ^& ?6 W3 b+ z. F# ]& L/ {  _
  1370.           rm -rf "$GAMEPATH/vmap-extractor"" E- C# `" U0 Z/ M- `5 H
  1371.           Log "Changing ownership of the extracted directories"9 E' j, ?# z) ], _1 Q7 @/ ~
  1372.           chown -R $USER:$USER "$INSTPATH"
    2 W/ t- |# N; Y  h: z$ q+ s
  1373.         else* M/ F! D/ J# R, Y) ?# @
  1374.           Log "There was an issue while extracting VMaps!" 1
    8 E3 u! m% ]1 |" Z
  1375.           rm -rf "$GAMEPATH/vmap-extractor"
    2 l: K) M, X* p7 F8 l
  1376.           rm -rf "$GAMEPATH/vmaps"
    ! h6 f  L( \7 @9 P" R' M/ ~: N! z
  1377.           exit 1
    - O, X7 ^" t8 ^- K  d, v7 Y
  1378.         fi2 a' i* A% H5 y3 J
  1379.       else+ p+ W- n! ?0 z$ ~0 e+ [" b' G
  1380.         Log "Copying VMaps files to installation directory" 0( Y1 P' v4 P" h- e1 {& n
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    ! o5 Z; J6 o: Z" r* d
  1382.       fi2 b, A$ K$ Z7 [  h6 X6 d
  1383.     else* P# u( |' J2 L( l. T, x$ x
  1384.      Log "Copying VMaps extractor" 0) D; z% l% `7 t
  1385.      rm -f "$GAMEPATH/vmap-extractor"' v) u; L* r8 J4 w! Y0 Y% r
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    3 w, k4 k* t/ Z, d* W; |" m  h
  1387. & l) Q% e1 t; x  M% x: ~: Y% V7 j
  1388.      Log "Extracting VMaps" 0. L( g% j# U$ g
  1389.      cd $GAMEPATH
    7 X# ~2 L. F; X  R' l, H
  1390.      # Make sure there is no previous vmaps generation that cause issue.6 L0 \0 v, k/ l$ k' o! \
  1391.      rm -rf Buildings0 q6 u, W' N) C* b
  1392.      ./vmap-extractor
    0 |$ N, U1 n: n/ u# w# }  o
  1393. , B$ O0 L1 `8 l! v
  1394.      if [ $? -eq 0 ]; then7 S% w9 @' d- s$ p
  1395.        Log "VMaps are extracted" 0
    3 I  l) S' p9 y7 H6 V
  1396.        Log "Copying VMaps files to installation directory" 0
    0 i4 J) l( T8 O: p) m" D
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"; P/ f# A/ n! y; I( h
  1398.        rm -rf "$GAMEPATH/vmap-extractor"# q) q$ W, c0 W$ o+ w& Z  R
  1399.        Log "Changing ownership of the extracted directories"$ P8 O9 E+ O4 w$ Q! T8 J6 ^
  1400.        chown -R $USER:$USER "$INSTPATH", j" u- f& n3 Z) O
  1401.      else' E7 n$ {% d# A+ G$ S$ n) u! V
  1402.        Log "There was an issue while extracting VMaps!" 1
    9 V0 l  {' |( {* H- x; i
  1403.        rm -rf "$GAMEPATH/vmap-extractor"* \% b( Z  [# i1 |
  1404.        rm -rf "$GAMEPATH/vmaps"
    7 e1 h" J8 w' G; r/ H! q
  1405.        exit 1
    . @0 J# U9 P+ E) a
  1406.      fi. Y* G$ r' K% m/ q1 T# {
  1407.     fi
    ! d# e3 {! u6 `0 D8 c
  1408.   fi2 I9 _& A" l  A' C

  1409.   b6 Z5 n$ Z( L+ {" Y  g
  1410.   if [[ $ACTIONS == *3* ]]; then
    5 B9 e! ?) u% J0 l$ c! o
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then
    ( }5 Q0 J" X- b! f- Q
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1
    7 B  c! d) t3 a6 n7 y' W' ~
  1413.       exit 1- v' b2 y' Z6 S2 A  n! [
  1414.     fi' p8 O" v- d0 u7 r% U9 P

  1415. ( Q, |) t5 b" J$ P; U# s4 o6 D- t
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then' B+ V+ s8 e2 P7 S5 L" G% @
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    ) K" U6 {. W8 x2 N" q" d
  1418.         --yesno "Do you want to generate them again?" 8 60; |6 u  M9 y* L6 t- F
  1419. 7 Z( @. X# O7 z
  1420.       # Check the user's answer
    0 X4 U+ X. A6 g/ b) U2 q& ?
  1421.       if [ $? -eq 0 ]; then
    * O8 j2 q  h+ e- ~9 h
  1422.         Log "Deleting MMaps previously generated." 1
    ) B; \1 p! O- ^# Z2 H# y3 M
  1423.         rm -rf $GAMEPATH/mmaps2 T& b8 H& j' b) ~4 Q+ ^1 c+ z
  1424. 2 s+ i# H1 ?4 C/ z5 Y6 ?4 c. A9 w
  1425.         Log "Copying MMaps extractor" 0
    3 ~& q; }1 P$ R" _# e0 a! J
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"# r* T/ {. |/ J5 D
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"4 Q- h3 b9 m3 p& T* D# u' h3 y$ e
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"
    1 Y1 b; k  ^' c5 l
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"7 b% `- j" s# ~* _
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    7 _/ T; g# A0 _( B; W; T

  1431. 9 q3 O8 d9 e4 G0 Q: A
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \) d% M8 W6 `( S! L  X! {* j. c
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    : W$ M3 t8 R) I; t
  1434. & C: l' G# a! E! D' B6 `/ ^( Y0 W
  1435.         # User cancelled his choice, set default to 1.6 k/ T* `! m2 a2 F; I: K( N
  1436.         if [ $? -ne 0 ]; then
    1 ]) _# r6 W9 t$ c7 k
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1( K5 c6 x. R" @1 a. V! e% U  Y. ^
  1438.           CPU=10 s5 Z7 E2 g( g/ q' g0 q+ _$ |
  1439.         fi" ]2 i1 z# L9 f  x5 H, s' t

  1440. 1 R& `" [: V. r0 m* h4 D
  1441.         if [ -z "$CPU" ]; then
    ) v% t% D- f+ B+ U1 k/ B
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1, q1 |0 ]. Y- h) {% K
  1443.           CPU=1. k( _# i0 @2 B; |) P% I# n
  1444.         fi
    # _1 |# }9 e3 r% ^: n- C' ^2 D! M
  1445. 6 x* Y$ H; l7 t
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    . V, j! w. J* [: u. S9 j
  1447.           Log "User entered invalid value. Max CPU set to 1." 1
    ! Y5 m4 d8 J+ R4 }; \& Z" [
  1448.           CPU=1, u, _4 q9 ~7 h3 L) Z* F4 v
  1449.         fi
    # _3 j6 a  e) p' [

  1450. : M- y- M. L( u  E$ F+ j; Z9 k
  1451.         Log "Extracting MMaps" 0* k: @/ e: o$ ]% N! i3 Y/ V2 i
  1452.         cd $GAMEPATH
    6 y3 e7 [# A  Q/ h( R+ B  Y/ f
  1453.         # Making sure we can execute the script
    $ L6 Y6 F# q5 A9 }- M% z# z
  1454.         chmod 700 MoveMapGen.sh
    . p. f, A! @$ [) R- ], k% H) {; _
  1455.         ./MoveMapGen.sh $CPU
    7 o( X; j' n2 V! ^1 y# R/ d
  1456. % I# B+ y7 r, s1 R6 F& @. a4 ^
  1457.         if [ $? -eq 0 ]; then- b: _5 M2 m; _; u
  1458.           Log "MMaps are extracted" 03 J/ J3 h6 e- n, a3 u
  1459.           Log "Copying MMaps files to installation directory" 0
    7 Z! e7 b! O7 Y: n, J2 e; c$ R
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    9 c$ M+ P1 ~& p
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    & |3 L. s! [6 L/ |( M7 C* J% @
  1462.           rm -rf "$GAMEPATH/offmesh.txt"" f$ Y3 j& Q6 e8 w( U6 s5 s7 i
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ( Y( l% W7 S) h0 J" o+ S
  1464.           rm -rf "$GAMEPATH/mmap-extractor"# A  ^$ z" ?1 d/ c' K
  1465.           Log "Changing ownership of the extracted directories"1 l) X' o- x: D
  1466.           chown -R $USER:$USER "$INSTPATH"7 E# Z1 T  s* I  g) P) X
  1467.         else; \  ^% e1 d8 H, [* _
  1468.           Log "There was an issue while extracting MMaps!" 1' ]+ c" g' {4 B5 `( N% {% f
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    # X  u1 w% m2 p! y5 ~8 Y
  1470.           rm -rf "$GAMEPATH/mmaps"
    # i2 E, V  F2 n. E8 ?: ?/ b6 _
  1471.           rm -rf "$GAMEPATH/offmesh.txt"
    , J2 c$ D* ?+ v& _: w
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt") Q% T7 W+ K0 o' h
  1473.           rm -rf "$GAMEPATH/mmap-extractor"
    $ C/ A7 Y/ \+ T# |7 Y/ |
  1474.           exit 1
    7 }. m  t( m) H8 [! S, d% r3 C
  1475.         fi
    " f7 V5 H1 q! t# w% ^' g( i
  1476.       else
    " [6 g& L$ R8 ?
  1477.         Log "Copying MMaps files to installation directory" 06 x0 z1 H5 O( P) I
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    4 Q' S( P; P% v) v* W2 e! o; ]
  1479.       fi) p1 E& @" @( d% C
  1480.     else5 U  Q3 X( S/ b! s6 f7 E7 L- C4 R
  1481.     Log "Copying MMaps extractor" 0
    / x( Z* I0 Y. R% k: s& y+ s( C
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh") \& a" f' f; n7 T6 Q
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    2 @7 o2 [; }; G( D
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"  w% ]/ \7 c! z8 t7 R; p
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    6 }/ I! f. X9 g& i8 M/ ~
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    5 n  L: p, }  ]% M1 t
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \5 W$ G$ |0 g! \
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    1 y  d. Z$ {, i; d- V! a. f3 o

  1489. & t2 `) D' ~6 a2 h( K
  1490.         # User cancelled his choice, set default to 1.) P" q  I, Q- L; g7 q
  1491.         if [ $? -ne 0 ]; then
    ; Y1 e& Z; o: K
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1% l8 [3 ?; v% M
  1493.           CPU=1# {6 D; B' h! h7 _9 U/ @1 c
  1494.         fi
    - U3 P1 S3 H/ s% [, D* C( Q3 k
  1495. 2 a4 }* p4 u. o  c6 c# }! W: J
  1496.         if [ -z "$CPU" ]; then; @5 \9 m, s- b" ?4 u8 e; p
  1497.           Log "User didn't gave any value. Max CPU set to 1." 16 b/ h  Q9 f! j
  1498.           CPU=12 I6 B+ c( `. J6 ]- j: w2 n
  1499.         fi
    1 ^  U( T/ R9 W; I8 f
  1500. * D) X( L; }/ b4 I$ |
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    : g4 c1 o. Y; M+ f; h* B9 t
  1502.           Log "User entered invalid value. Max CPU set to 1." 1
    0 l- X7 @& @. A) R& P( Q3 k8 F) [
  1503.           CPU=1: v4 V' g  I. \
  1504.         fi
    * n. _( N7 h- p5 B2 g
  1505. - g  G5 o2 m7 q5 S: U8 z! ]8 T/ f8 k
  1506.         Log "Extracting MMaps" 0$ H  m# R3 k, H1 R' h/ x3 ~# u; H( B
  1507.         cd $GAMEPATH
    5 h8 V# |) w6 Q/ G
  1508.         # Making sure we can execute the script* `6 ]+ b1 }& d' l2 N
  1509.         chmod 700 MoveMapGen.sh" F& Y3 A  d1 ~
  1510.         ./MoveMapGen.sh $CPU( w5 w8 R( N. q6 U
  1511. 0 m6 V+ P7 }: o! {
  1512.         if [ $? -eq 0 ]; then
    4 e& D! U' n4 `& v: P" V
  1513.           Log "MMaps are extracted" 0* k8 y8 `& P7 y6 I& O6 k4 _
  1514.           Log "Copying MMaps files to installation directory" 0
    6 X/ _, g1 G& K( T, J
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"4 o' Z* q+ C6 I7 h/ Y' w0 R2 S2 t
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"( c' j( g7 P. A4 G+ @7 s% k
  1517.           rm -rf "$GAMEPATH/offmesh.txt"
    6 }; p4 W* u1 x
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    0 }8 }7 t# W; g+ S, _
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    , }+ [5 f8 q8 E+ ]9 M1 a. |: z
  1520.           Log "Changing ownership of the extracted directories"
    " `- B, ~& Z$ F  f' V1 q) k3 d
  1521.           chown -R $USER:$USER "$INSTPATH". [$ t* K) Y  ^% b8 j
  1522.         else
    * d- Y- \5 u" y3 \, I/ y
  1523.       Log "There was an issue while extracting MMaps!" 1
      u/ d' J# V% f
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ! Z) q) i! r2 O' w- F$ V
  1525.           rm -rf "$GAMEPATH/mmaps"( g+ |! E  Q4 y. }+ w4 x' ~5 m
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    8 ?4 o! _; x* d7 q! c: z
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    4 t  N$ h7 t3 g$ h* Y* D4 ?' n
  1528.           rm -rf "$GAMEPATH/mmap-extractor"5 I3 b9 a$ p, n9 q$ W# }6 z
  1529.           exit 15 G& |: v- y; e
  1530.         fi# w) }) W. c- E& p2 @% {3 v% N; f1 ^7 G
  1531.     fi
    ( u& j9 `, Y" m9 {" W+ F  t
  1532.   fi
    8 q* {/ s* y3 Z8 \0 Z
  1533. }
    $ U0 _9 O- z. X% W1 I9 G, o

  1534. $ E; N* [& N) @) b$ u" I6 Y- A8 O
  1535. # Function to create a Code::Blocks project
    3 d/ m3 ]. ~7 k' C" R
  1536. function CreateCBProject8 G% D9 R/ W' m9 ?0 v# s- P* K
  1537. {# D  C8 b9 t- h& k' ^8 r
  1538.   # Create the dircetory if it does not exist- c2 ^5 c, t/ `
  1539.   if [ ! -d $SRCPATH/server/linux ]; then  r9 }5 g5 P2 W1 o  I) V) q! x
  1540.     mkdir $SRCPATH/server/linux
      E: B- }4 W$ v, v
  1541.   fi
    0 s: P( E4 u4 E5 w1 g* Q+ b/ r& N- q
  1542. 0 E" ?% ~/ w' D" z1 n9 b5 w
  1543.   # Now create the C::B project7 m7 k/ T$ x/ f  k2 a9 V! a
  1544.   cd $SRCPATH/server/linux
    / C+ x# x9 g- J; v
  1545.   # make sure we are using the cmake3
    , g: b2 {1 K9 o  E* B- d
  1546.   UseCmake3" L0 g( l& z3 F! z- I
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"4 f+ C* _# r; I0 q- a, [9 m
  1548. }
      [* ~2 Z( }, Y% u0 r7 Y

  1549. * ~& a% t' L/ ?" u7 k

  1550. * T- n' y' m( ?4 X, G1 l

  1551.   p6 O1 h; c& m2 i3 q# E
  1552. # Prepare the log6 G& S$ a; k& B! u5 \5 R
  1553. Log "+------------------------------------------------------------------------------+" 0% L0 J& d$ O# U! `( J' v: G8 s0 o
  1554. Log "| MaNGOS Configuration Script                                                  |" 09 Z; T" `7 P4 N% Q5 x; d' _
  1555. Log "| Written By: Ryan Ashley                                                      |" 0! n" B7 g8 N* D; @  ]/ `8 ~/ v
  1556. Log "| Updated By: Cedric Servais                                                   |" 0
    , G+ h5 J& ]# J3 J; x+ J
  1557. Log "+------------------------------------------------------------------------------+" 0! H* q2 N# t) h* f% Z. J& }

  1558. " {1 ]' c- e& J+ F! m9 w$ t' F$ l5 K
  1559. # Check if user who is running this is root  I# d9 R( s5 ]8 u7 S3 ]7 Y( d! U
  1560. CheckRoot
    5 p. E7 w/ L# F

  1561.   ~1 @2 p7 E+ D! G
  1562. # Select which dialog to use) f2 B# a, k7 i: }6 p* p8 M8 e
  1563. UseDialog2 H; a, b' R/ d  b* {
  1564. / \! l, @* t1 ^; S2 \
  1565. # Select which activities to do7 Z0 q- d5 _. g: ^8 v. y* H" L
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \3 _2 v' |9 h4 Y, P( J
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \: _7 r" O( \+ x% P0 Z
  1568.   1 "Install Prerequisites" On \0 U- Q2 ^& _6 d8 ~( P9 y' b  e
  1569.   2 "Set Download And Install Paths" On \
    5 T: x2 F& e0 K8 G
  1570.   3 "Clone Source Repositories" On \7 d. J( Q& f2 o* l3 a; H9 e, K
  1571.   4 "Build MaNGOS" On \0 a" x: z% j! _. E" l
  1572.   5 "Install MaNGOS" On \3 n" c: ]% v  C/ D
  1573.   6 "Install Databases" On \
    + M* g  f) ?( g
  1574.   7 "Extract Resources" On \; n3 o' |8 C: e. V/ m8 O
  1575.   8 "Create Code::Blocks Project File" Off \! W" r1 P3 s# g! K
  1576.   3>&2 2>&1 1>&3)
    * S  y) F% [+ h& @4 ^, X3 d1 L
  1577. 4 H9 K" G% t& @: a- `/ D
  1578. # Verify that the options were selected5 O0 J" t- o& q' K% ^* Q3 {
  1579. if [ $? -ne 0 ]; then8 J( d$ [- o" \( |# E! }* Z
  1580.   Log "All operations cancelled. Exiting." 1# `, h0 w4 p  i& ~
  1581.   exit 0
    . j/ a8 T1 l2 E% m; x! n7 i
  1582. fi
    6 D8 ~) `. O/ d( u) I1 D; [' k

  1583. : i" p" |. `- o/ M
  1584. # Install prerequisites?
    : z2 s9 D' p# [+ [
  1585. if [[ $TASKS == *1* ]]; then/ V2 {0 a! {* O( A/ ]
  1586.   GetPrerequisites$ w6 R8 Y, W8 Z+ u& L
  1587. fi7 q# H5 W- E, u7 q7 d0 y8 T+ r! [
  1588. + T2 u+ d' n" G) b
  1589. # Select release and set paths?2 o% c3 L; }5 d. u
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    4 R* }3 ~. X( h' h3 @
  1591.   GetUser5 w# e/ H4 g" K; m
  1592.   GetRelease; W: U9 ~! J5 V( @, g; I
  1593. fi2 p) n' }; y# C/ [4 r

  1594. 0 }" w# d5 J1 `. }' L9 l
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then
    ' w2 P+ ?. _' |- H* y
  1596.   GetPaths
    - b0 C  _  s& M& z) \, {/ y6 [1 F) i- `
  1597. fi" @8 ?8 k' |, ]! W8 g
  1598. # `. p  }, Z0 ?9 I' ]$ G" [% {
  1599. # Clone repos?
    ; P$ i7 G$ g( ?' U" S/ R5 z
  1600. if [[ $TASKS == *3* ]]; then  _! b2 F& G' J( f4 v6 }
  1601.   GetMangos
    ( c" _# D6 D! p. N
  1602. fi: o2 Y; c. b9 A6 l7 R
  1603. ) K. a  p! I/ C  S8 S
  1604. # Build MaNGOS?# `% y" i5 B! ]7 X) x
  1605. if [[ $TASKS == *4* ]]; then, @$ a, {3 T" K* N+ H0 l
  1606.   GetBuildOptions
    7 g  B3 \& E  F: q
  1607.   BuildMaNGOS( O; [: q3 t  s' B
  1608. fi2 O$ b! f7 h0 D3 F6 b
  1609. . h9 T9 ~6 C3 d3 ~( H
  1610. # Install MaNGOS?
    * N+ d" f0 z; r- ]$ {" }8 w
  1611. if [[ $TASKS == *5* ]]; then
    ! ~" `7 G4 ]" F7 z5 y( B- p
  1612.   InstallMaNGOS9 d2 [, ?  ^% y. v/ c3 j& ~
  1613. fi
    5 U8 k) `- `, K" y
  1614. 1 ^0 u9 H- P$ P9 {0 j3 i
  1615. # Install databases?9 Y1 M) f" U  M
  1616. if [[ $TASKS == *6* ]]; then
    . u8 p  V" b) z' }" e0 z1 a1 p# S
  1617.   HandleDatabases4 H' k# _5 ~' h0 n# T4 @
  1618. fi0 K, w0 p! U, j$ r& B
  1619. ' f4 R' m6 r$ K' \+ T/ Z. x
  1620. # Extract resources from the game?
      l8 ~) ]$ m: m5 Q6 `
  1621. if [[ $TASKS == *7* ]]; then
    8 n  `8 ?$ {' C- i1 s- Z+ z7 a
  1622.   ExtractResources3 X. V5 i+ m# F3 W
  1623. fi
    + T' ~% }8 L. Y7 k
  1624. 5 c6 n+ }- t: P* }* l
  1625. # Create C::B project?4 B5 ?  l6 W! `& P" \- ^, ?
  1626. if [[ $TASKS == *8* ]]; then
    $ A  R& Q! x/ D& n7 V5 }
  1627.   CreateCBProject
    5 ?$ c4 W8 j" P, A7 ], g4 S% y
  1628. fi
    3 v* W# N* v  ~& H
  1629. % X/ z( P; ^( k8 o* W3 w8 `0 ]6 t0 n
  1630. # If one of these actions has been performed, then we know the user.
    ) _6 Y6 ^$ ~- s8 L2 w6 G
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    # z$ ?; f# Y9 X  ^/ |
  1632.   Log "Changing ownership of the extracted directories" 1
    * F+ E" S; S, s
  1633.   chown -R $USER:$USER "$INSTPATH"
    ( M  v# C# z+ ~" x; |6 E
  1634. fi7 p5 \7 ]& ]$ c- |

  1635. 4 j; z; z4 \6 M0 i& `
  1636. # Display the end message
    % |$ K) o! d6 O' g
  1637. echo
    # z# N2 S6 C, c+ q
  1638. echo "================================================================================"
    $ h  t4 i& z7 t
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please"" r6 p9 Y3 x3 z! g$ o$ x4 d
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"
    6 p" B& ]9 h& K- q( H
  1641. echo "server. If you have not configured your databases yet, please do so before"6 g8 ?) H2 y: L; L
  1642. echo "starting your server for the first time."
    4 E$ z: N0 R6 q! l; A
  1643. echo "================================================================================"
    0 k# s+ _! t3 f# o, s, _- O7 F
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh
    0 [2 s: t2 A  p5 ~8 f8 O+ n$ L: D
  2. ##############################################################################) b+ y5 z& v' Z$ i% g+ y. d) G" \
  3. # This utility assist you in setting up your mangos database.                #
    * j) Q. |, g, _
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #7 ^  I3 I8 I; N% J2 m/ f: e
  5. #                                                                            #0 V9 `# m8 E( P: i
  6. ##############################################################################
    5 B$ @9 H7 F6 O5 T

  7. ' ^( G- J3 \9 P5 @. ^, J& v2 T7 \
  8. OLDRELEASE="Rel21"
    + m5 B0 g+ B' ^
  9. RELEASE="Rel22"5 {2 n! R/ T. l/ D4 P& v
  10. DUMP="NO"
    5 T2 t' x' q$ D9 C

  11. 0 P" h& y9 Z' b. O* l  o
  12. dbname=""
    * v% a# h, n0 R/ u: K1 u
  13. dbcommand=""
    ) W, W0 _& E2 r4 P" _1 ]  O8 H
  14. 6 n* K6 f6 Q6 \9 d# A( L7 p# u
  15. createcharDB="YES"
    0 ^; U, _( T0 Q+ S5 c6 \6 q/ P
  16. createworldDB="YES"
    # v1 s, c5 p9 ?
  17. createrealmDB="YES"
    - q5 Y! s  ?2 a8 S

  18. ( C- A% l7 ~) T" M! ^. z: h
  19. loadcharDB="YES"3 @7 [# K) `! _
  20. loadworldDB="YES"7 p) D! ]  R+ E
  21. loadrealmDB="YES"" W$ ^* [5 X, m0 [
  22. dbType="POPULATED"" E7 [2 [& i5 m

  23. ; R5 o# Y5 j0 A
  24. updatecharDB="YES"' R& c: G- t$ g+ q! z% F
  25. updateworldDB="YES"4 x4 e3 J, M* V& F; M. c  {
  26. updaterealmDB="YES"
    " r) ~0 x' b/ l$ g; _6 @4 P

  27. 9 l  w$ h( Z6 m- V
  28. addRealmList="YES"# W6 Y0 Y5 q; y1 |
  29. 8 K) a* p4 ~4 b3 A' }* o8 a
  30. svr_def="localhost"
    ) q, h0 y& L" X1 ~/ p, @5 O
  31. user_def="mangos"
    4 E. S' o* B. d8 u+ B. G
  32. pass_def="mangos"
    . d- t1 _. }8 p3 `9 s4 Z
  33. port_def="3306"% \* ?$ G) f! z  ^7 H
  34. wdb_def="mangos2"9 r3 B7 X9 o# v0 N0 J
  35. cdb_def="character2"
    ) U1 K6 k+ S4 @
  36. rdb_def="realmd"( a/ Y; v5 w0 ^( s7 ~3 c
  37. - F* `) L" W1 y+ S
  38. printHelp(); m( _9 R1 g' B$ o8 K: E% |" J
  39. {
    + P$ |! N& h7 I, ]( F
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n") |! y$ \% r, k# @* l
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"  S7 i+ n0 W7 T$ C
  42.         printf "\t-u: Run only the updates of the database\n": T; {+ t# D/ i% W# N7 a
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"9 n5 s/ Z( }% y% y+ c
  44.         printf "\t-h: Display this help\n"4 Q0 y7 o$ f1 P! [3 b2 E7 S
  45. }( _( m4 P1 x1 S( c
  46. * W  s0 t0 H' J8 s9 k
  47. printBanner()
      A' W& d" w4 d& p
  48. {
    7 P9 r6 r" O7 V7 ?8 p) w
  49.         clear, j; M. V# A& X' l
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"
    . \( j" k3 G7 l9 X& Y0 `, }
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"
    . {3 t; c1 V- U5 \
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"9 Q( ^3 u3 ^/ c. h7 P
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n". m% ]* B8 R% P/ e) s! p% M2 W
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"5 C( h9 c. l& E+ x
  55.         printf "\n"$ F) V0 N0 i6 a2 u0 Y
  56.         printf " Database Setup and World Loader v0.03         \n"2 k( g8 h1 K/ T& I2 Q
  57.         printf " ---------------------------------------------- \n"
    " i& l% o+ y! J4 V8 |) E& ?
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"% ]) |# t% V: t9 H0 M  @9 R1 ~$ w
  59.         printf " ---------------------------------------------- \n"
    + Q3 Z% \9 F+ P' p, Q
  60.         printf "\n"
    ' J! B' A  F6 t* N! N: n
  61.         printf "\n"
    4 d  G& z$ l4 [, L. T6 H" {7 n
  62. }
    4 e" b! V. P% G+ E! J
  63. ( {' I9 t  C7 D4 g7 l
  64. printActivities()
    1 U% Y$ H( v. q$ A& v5 s& K
  65. {( L  x, z! ]% H" c( L) P- a
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"7 Y" N; `8 L# w9 s. l
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n"
    7 d) P7 H3 F: _  |, x( }8 V/ I8 X
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"* U" c% V/ f- i/ ]: }
  69.         printf "\n"
    9 l+ j, W. U( }% c1 @: Y/ k' e
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"& U1 M! v' ~# I/ s8 c9 O7 V
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"        ' ^, A  \/ V( S% H
  72.         if [ "${loadworldDB}" = "YES" ]; then, z" r+ f& Z% v: K0 k( `6 H
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"% m: j+ s) P; l, W7 X1 r$ x- Q1 s2 ?
  74.         fi
    5 f) u% {9 o# \; R, f3 s+ l4 H
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"
    - F6 E+ {7 m: ]; m- _) k) B2 Z- K
  76.         printf "\n"
    * a- A2 p% \& ^/ }  }1 j9 z
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"
    ) E4 V9 U+ \- q" N3 k
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n", S: M) b% N/ x$ e9 f
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"
    # x4 y, x# y$ `
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"       
    3 T/ z, b7 W7 s/ I9 [/ V
  81.         printf "\n"8 f/ @- K% [+ ^
  82.         printf "\t\t\t\tN - Next Step\n"9 P# r( c8 p8 X; G+ q
  83.         printf "\t\t\t\tX - Exit\n"
    * o, i' Q6 {' S, `& z
  84. }8 J1 z% T$ x2 l8 r, R3 `

  85. # U  ]) O& @5 D0 y7 s; i
  86. determineDBName()- s( I4 }* Y+ g$ t& ^, K: E
  87. {
    , w& A# @: ~# h8 c; l! a
  88.         if [ $(which mariadb) ]; then- k4 @9 p# u% u7 m9 w
  89.                 printf "MariaDB found.\n"
    % S1 G1 i  n% ]
  90.                 dbname="MariaDB"
    + W  X& [+ ^7 Q5 v) ]
  91.         elif [ $(which mysql) ]; then
    # j  A  ^$ @4 h3 w$ k. j
  92.                 printf "MySQL found.\n"
    $ ]( m! w8 g, j2 r8 q& S& x, v0 O
  93.                 dbname="MySQL"
    # z" [8 K! {, d- k: A) V( l8 z
  94.         else( V2 M- p1 _1 J" v5 v2 S
  95.                 printf "Did not find mariadb or mysql.\n"7 R( i' Q& {: j- K* j3 ?, F3 Q* R
  96.         fi; U9 A3 e/ P, p1 Z
  97. }
    4 p+ s" L( ~3 [8 l" U% U
  98. / |! j, h: w* p- m3 J% t' f
  99. mysqlconfigeditor()
    * _% Z( p: y. \
  100. {
    ( L) k) O) v' ]. w, o- Z
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"0 A' P  N+ I  P, z2 E( q8 Q
  102. }
      r) h/ S7 ~3 Q( T
  103. - O% y5 e8 _! B- s* ]; Z7 R+ ~; N
  104. determineDBCommand()
    ! M$ O4 @6 G+ }  g% \6 I* g
  105. {' K: n1 M( T1 |4 }+ E/ B# P7 _
  106.         if [ $dbname = "MariaDB" ]; then
    ! S# ^! v1 F& i5 \* P+ U
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"
    * H% U8 B# A, ^& l
  108.         elif [ $dbname = "MySQL" ]; then
    7 u4 W+ H1 L6 i, q' A/ _( p
  109.                 dbcommand="mysql --login-path=local -q -s"
    - ^! W( p3 ]5 D: ^2 R7 d
  110.         else
    - i$ |7 K- [2 c. [' h
  111.                 printf "Did not find mariadb or mysql.\n"
    5 [$ E; e' Q) r+ n: j
  112.         fi3 o! T% h! }# T8 }
  113. }
    6 Y! U/ a5 P8 m7 H
  114. : |, L+ p7 ]2 J
  115. createCharDB()2 z; \6 g( G$ s: ^. c
  116. {+ N! @, C: p; R; ~6 N
  117.         printf "Creating Character database ${cdb}\n"5 M5 W; h2 ?2 h: m3 p9 f
  118.         $(${dbcommand} -e "Create database ${cdb}")! S4 `* j0 d# x1 a
  119. 4 _5 w& W: R! Y
  120.         if [ "${loadcharDB}" = "YES" ]; then- X6 I3 v1 I) G) B5 y4 Y# }
  121.                 loadCharDB
    0 `' c8 R7 c  o* |7 {" e' ]
  122.         fi
    + c, }2 ?- o. J) a0 i8 z
  123. }
    $ F3 E, S/ Q) F* P9 s5 E  O
  124. " X0 s! `5 Q+ j# b
  125. loadCharDB()
    0 g" Y7 _4 b0 ]( A4 n  ^2 e
  126. {
    * I' {, l4 W9 f6 a
  127.         printf "Loading data into character database ${cdb}\n"4 N( \0 {' i2 e2 n% i8 ~
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)
    8 [) x% H- }9 l) E

  129. . @( `8 n& E& I4 C9 P2 [( \
  130.         if [ "${updatecharDB}" = "YES" ]; then2 I: o, {) D  @: E4 C
  131.                 updateCharDB
    - N  W( [7 y% D3 @4 O, u
  132.         fi
    4 u; S# k6 [9 e2 r
  133. }
    8 M0 d+ a2 P- b3 @. l9 y
  134. 3 u- z1 Q1 F3 D; G# D' \
  135. updateCharDB()4 R' g5 X9 |9 V
  136. {' ?- Y5 \" ]0 ^6 p- c$ v
  137.         printf "Updating data into the character database ${cdb}\n"
    5 k1 X: e" j* d' [+ c2 G% R
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')1 b; L6 Y$ ^1 p) ^% z* L
  139.         do
      |# l3 h- ~: A$ u3 s1 f* n
  140.                 file=$(echo ${file} | tr '|' ' ')
      A) I# O: @9 ?5 {  t
  141.                 printf "Applying update ${file}\n"
    9 d  b* Y  s; |+ _' B5 D$ e0 O4 }* H
  142.                 ${dbcommand} "${cdb}" < "${file}"# a; D* W- u! ^9 z% y1 [* n, n% m
  143.                 printf "File ${file} imported\n"; l9 U% H3 N7 ^5 U) s6 Z( h& k7 S
  144.         done6 l* x7 r" a7 K
  145. 4 a, N" W5 L# c: J4 P4 i1 ~0 P
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')0 d9 P7 F7 D) N$ m% v9 ^! e# o2 P
  147.         do# H! N# Z) E( B" A
  148.                 file=$(echo ${file} | tr '|' ' ')( Q% E2 l' R( R/ j2 y7 x
  149.                 printf "Applying update ${file}\n"% i, J) L; @% M; \7 {! j+ F( t
  150.                 ${dbcommand} "${cdb}" < "${file}"' f9 n6 Z, d& w/ ?9 J: I
  151.                 printf "File ${file} imported\n"2 s+ u/ l% l) a1 e
  152.         done
    & ]3 H4 r; ]1 F2 U! H! @' d
  153. }- I) A9 }: k. F  s! f! r

  154. " x. F$ x, L: p/ l  A& q* M0 Q3 G
  155. createWorldDB()
    ' z; f2 {& J( ^* A0 j
  156. {
    1 y4 E' u' r; x% J* U
  157.         printf "Creating World database ${wdb}\n"8 U# ]& r9 w4 T* n, P7 m- V
  158.         $(${dbcommand} -e "Create database ${wdb}"); I/ w# D1 I' @: }6 H' j

  159. : P! n: R) K3 I% h
  160.         if [ "${loadworldDB}" = "YES" ]; then
      n% e! l0 z/ Z- G) X$ R
  161.                 loadWorldDB" z0 m6 ?# r4 v: g5 B" j
  162.         fi1 ?% l: t9 k7 q
  163. }
      z! @0 p4 y4 i7 T5 X9 o
  164. / G$ O! v& i% h1 Y* y8 p
  165. loadWorldDB()+ U; a/ A% W5 {' J$ k8 y  U( n  J2 l
  166. {
    % H& @& c+ q6 c3 P; [+ n. K. j. D
  167.         printf "Loading data into world database ${wdb}\n"/ e3 A% s% ?0 T8 m# i, ~! |
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)9 x0 m' {0 W. X7 x7 z0 Y% T& M
  169. ( k6 T7 @. N' G& h+ U
  170.         if [ "${dbType}" = "POPULATED" ]; then
    / A* H, e% A- L0 P: J
  171.                 populateWorldDB/ n, ]/ U2 m. x" x. B8 z  ^2 C1 X
  172.         fi; i8 I0 _. G# W% W! d1 ^
  173. }
    3 A; [$ V" d* j2 M
  174. 5 m+ x; ]5 ^9 m# |
  175. populateWorldDB()
    9 _6 }( L5 ^) c" A
  176. {1 o3 u9 ], i9 i9 E8 c2 ]" u; E- Q
  177.         printf "Importing World database ${wdb}\n": U0 ^" ^# n: Z$ G# [
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ') , E- C& b1 w5 x5 v
  179.         do
    ! G, N$ R2 I% `9 ~) m0 e6 ?" h
  180.                 file=$(echo ${file} | tr '|' ' ')4 [+ Z' s2 s, Y6 F6 B- a) D
  181.                 printf "Importing file ${file}\n"
    " A3 l, n- F9 O( O+ d& t
  182.                 $(${dbcommand} ${wdb} < ${file})7 [; d. h$ s0 {# Q9 b5 I# A
  183.                 printf "File ${file} imported\n"0 M+ c9 v) E8 {
  184.         done. D8 a* ?& z/ ?
  185. / m' g: K" X0 L. G; Z' t4 K& k
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ')
    7 @  Z4 O8 A) j+ A7 V8 s6 A
  187.         do
    . x0 u8 U7 u0 W, Q' N
  188.                 file=$(echo ${file} | tr '|' ' ')
    * E: ^0 }7 E/ H5 L  _/ p
  189.                 printf "Importing file ${file}\n"# V1 U" J$ Y) i8 P) d- p
  190.                 $(${dbcommand} ${wdb} < ${file})8 W: e( v" ^0 ?+ }' m. Z! o
  191.                 printf "File ${file} imported\n"3 {- P# M+ ^& G" T4 J5 x0 E% H5 N; F
  192.         done
    " @* _% R, `5 F8 [1 {
  193. }; H9 m# L7 h2 H

  194. $ m1 R; u- X$ s( N- v) O- x9 M" I8 ]
  195. updateWorldDB(). ^* A* `& b6 l# l
  196. {
    ; ^% m9 i* ^! b" r5 l- V
  197.     printf "Updating data into the World database ${wdb}\n"% F" n2 W; h& Y* i/ n7 s3 n8 a6 I
  198.     for file in World/Updates/${OLDRELEASE}/*.sql- a2 z1 [* j/ c/ ?5 z
  199.     do3 c3 q: F1 D2 `; m  x& L
  200.         printf "Applying update ${file}\n"
    " ?" b: E. P5 q) ]1 }. w
  201.         ${dbcommand} "${wdb}" < "${file}"$ H  p# `* _, `) `7 }
  202.         printf "File ${file} imported\n"
    7 i. V5 L; {: b7 X* k
  203.     done
    $ W2 u/ j8 `, N( w* a3 k* m7 v9 q

  204. 9 g6 i& o8 G! L: g4 M
  205.     for file in World/Updates/${RELEASE}/*.sql
    6 d! a! \1 R- F; w
  206.     do
    8 Z; _" `. K2 s/ }* p. B  E
  207.         printf "Applying update ${file}\n"
    ' F+ e. t4 X. s
  208.         ${dbcommand} "${wdb}" < "${file}"& Z9 g6 ]& o/ t! P3 l( i
  209.         printf "File ${file} imported\n"
    0 K+ Z$ N% }: r
  210.     done  M& S7 I" Q) ?4 l# {6 }
  211. }* c7 C0 j1 X7 X( i

  212. 4 d0 J9 G% O1 K/ X* ]
  213. createRealmDB()7 i+ K- a* e( W4 k3 j9 `6 ]
  214. {. c0 U5 c# P, Q' v) {/ t7 l+ i
  215.         printf "Creating realm database ${rdb}\n"
    7 H, D) V  }7 l( d% M1 n  q' {
  216.         $(${dbcommand} -e "Create database ${rdb}")
    & `8 |0 j8 ^& {  ^3 Y# R$ T
  217. 6 L# \' W& [2 }' r/ \8 I' |* v, w
  218.         if [ "${loadrealmDB}" = "YES" ]; then3 O  c$ m2 f2 w2 V1 D5 d0 \) V
  219.                 loadRealmDB
    , J6 K5 Z! p+ P0 j
  220.         fi  Q8 R) ?& D# f% i  T" F
  221. }7 _6 E- H0 h3 O. z. p

  222.   d' N, P$ V4 i8 L
  223. loadRealmDB()+ ?# h3 {* n$ I1 q# P4 {* w
  224. {  o  Q  w/ f" O
  225.         printf "Loading data into realm database ${rdb}\n"        # Y) A7 }# R' N* c. p. u1 R) t4 e
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)
      }& ]3 R. j( h/ P( g; y/ t
  227. }
    5 j+ u4 N; H# D. b

  228. 7 k, i0 Y" ?4 E7 z) f+ r- p
  229. updateRealmDB()
    7 F/ F7 W7 Z- x
  230. {
    6 H0 v# N5 \# {! y
  231.         printf "Updating data into the Realm database ${rdb}\n"
    & o2 `# Z3 H; P2 s8 q' H3 D
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')& s- {8 z# ^& c( m! }
  233.         do0 t: j* \: V# P! F! W
  234.                 file=$(echo ${file} | tr '|' ' ')
    - I, C8 V) O& V& m2 I6 g
  235.                 printf "Applying update ${file}\n"
    ! l7 O1 b9 s4 q/ c  V
  236.                 $(${dbcommand} ${rdb} < ${file})
    1 _) Z3 Q+ A5 Z6 }
  237.                 printf "File ${file} imported\n"' q3 F; F6 _0 W2 D
  238.         done% N( ]% \% @. a! g' R6 _4 L

  239. / Y% S1 l8 c+ [9 W7 ]
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')/ ~/ W; x% `, r, X- y9 \& f
  241.         do+ M( r% ]3 }6 d9 P- V7 O& w
  242.                 file=$(echo ${file} | tr '|' ' ')
    6 a# Y% n: e% H( R
  243.                 printf "Applying update ${file}\n"+ N; O' P9 w7 t
  244.                 $(${dbcommand} ${rdb} < ${file})9 [6 A. O$ ]3 K# o3 E
  245.                 printf "File ${file} imported\n"
    1 G2 C, l, b8 l2 W' c# ~
  246.         done, D  x  H& h* s5 B
  247. }
    3 m( M% g. S  a. D+ ^/ Q5 w

  248. 8 f9 X% M# q1 l1 C/ |8 F
  249. addRealmList()
    * ~5 O  _: O# Z$ }" G9 N
  250. {
    0 w* X! X) d/ x, \
  251.         printf "Adding realm list entries\n"9 n, o& G/ M# L6 J( k  r- z
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)
    ! M: {! `/ [4 L
  253. }7 j. n, y1 S1 Y; F$ z* H' V

  254. / ?' n0 R, R$ Z- r
  255. activity=""; R$ p. I/ o5 L8 v/ T7 x

  256. - V1 e5 u5 y! E" H! w( G
  257. while getopts "suh" o; do9 |9 R  `' q' d2 u
  258.         case "${o}" in. H: ~- `4 A, C7 |
  259.                 s)
    . ~2 e0 H: p, k% S8 |# q
  260.                         activity="N"
    ' m$ r8 P9 o5 v2 v! ]1 L5 f6 P1 L% P
  261.                         printf "You selected silent mode\n"( t# A& k* X' C% t' ^2 I
  262.                         ;;- i' l( s5 F- w" }, _4 [4 {0 ~
  263.                 u)
      O5 A2 E$ N+ ^6 d
  264.                         createcharDB="NO"
    3 O1 q8 \4 T: g& |2 s/ D3 j7 y
  265.                         createworldDB="NO"
    " e# u/ {8 ^+ F  J
  266.                         createrealmDB="NO"
    7 F- C0 Q$ ~* l' _8 `

  267. 1 J+ y! L, y) ]) k! E4 o" L! k
  268.                         loadcharDB="NO"
    & z. ?1 b' [# O9 F) |( V
  269.                         loadworldDB="NO"
    ! d9 Y' c5 O, a+ |- `- L
  270.                         loadrealmDB="NO"
    ( x4 ?6 k0 z; \* d2 ]
  271.                         dbType="EMPTY"- y+ \3 Y, I3 V: \
  272.                         printf "You selected update only\n"
    $ P$ g: r8 b# R8 k! T' e
  273.                         ;;
    ! y  D8 Y; X; F9 l3 H5 K0 d  v5 K3 M
  274.                 d)4 U+ a0 L" D7 g1 q
  275.                         DUMP="YES"
    % ~! c+ L4 d% C8 n* l' L5 e
  276.                         ;;& g# i9 j! W! ?& \
  277.                 h)
    5 `- o9 V, B2 q9 T# s  }
  278.                         printHelp" x$ H' ]( z7 ~  [1 n  V
  279.                         exit 06 J- @5 S' n  M/ {% n) k. Y
  280.                         ;;/ T  K2 r( F0 }5 o& L/ f# _
  281.         esac5 ^9 F0 y% K( m. o1 s
  282. done3 U0 _, ?7 ]1 ^
  283. ! o0 V9 R, M" l
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]5 {" b) q- v. z- s/ l
  285. do
    " Q$ }3 r" H* G1 z  }. I
  286.         printBanner$ J9 L; j, S2 R
  287.         printActivities
      m2 N0 K6 N- r; ?
  288.         printf "Please select an activity : "6 B0 a# ~( ?) s+ u
  289.         read activity# A0 X% R% `$ w8 n  Y% j& i9 A
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )
    $ P0 ~0 U. D1 E% Q
  291.         case ${activity} in
    ; W7 |! V* O" k* D
  292.                 "V")' R$ f) ]( {' S; ^
  293.                         if [ "${createcharDB}" = "YES" ]; then
    $ U! w/ C5 ~. \, S4 L/ @$ k
  294.                                 createcharDB="NO"
    - T  w2 k' |6 o; U( n
  295.                         else % ]( r& ?, y& A3 ~- y
  296.                                 createcharDB="YES", J# p( F- `* h' N/ T
  297.                         fi
      S2 ]1 G8 F/ U5 n
  298.                         ;;
    ; o! E5 g% I* x! V" R* h
  299.                 "C")
    5 N' `0 r2 g$ o- r
  300.                         if [ "${loadcharDB}" = "YES" ]; then! v9 ]5 |9 o% y
  301.                                 loadcharDB="NO"0 \6 t9 c! U& m. T& U
  302.                         else
    . |) L2 @7 ]' q  E9 z
  303.                                 loadcharDB="YES"
    ) S( V! z# P* u5 q: W& h2 H2 P6 D
  304.                         fi
    " i6 J9 {) r$ z* E! V
  305.                         ;;
    / d2 O5 `* @9 A0 u( q+ @; c  L
  306.                 "B")
    / j$ E' \( E' y- d
  307.                         if [ "${updatecharDB}" = "YES" ]; then
    * Y; A6 h9 v- Q( E% j3 X$ z/ l
  308.                                 updatecharDB="NO"
    $ C# B" I9 Y% o5 W  L+ M$ N
  309.                         else 8 y1 h' l" h( r  Y& T1 o/ \+ j. c' R
  310.                                 updatecharDB="YES"! n: |& x& C1 ~( A: X9 Q& f/ ?
  311.                         fi& e  x  \) _3 ^$ m& x
  312.                         ;;$ I1 ?. a2 e/ D, G. ]
  313.                 "E")
    7 D! m6 c( K2 w* K6 p: R
  314.                         if [ "${createworldDB}" = "YES" ]; then# L6 n4 A* }3 t# f( @7 [
  315.                                 createworldDB="NO"
    3 v+ M3 m9 G+ H/ ~3 q- C$ D: A  @* t* W4 N
  316.                         else
    4 z, ?3 \1 J* p  T# T
  317.                                 createworldDB="YES"
    2 ?, v6 q/ a* x% }/ T1 I2 L
  318.                         fi       
    0 s* p5 z/ S* Y; f  J, a* b
  319.                         ;;
      k) E1 a) ^, T5 w1 k
  320.                 "W"): `3 ], E4 }/ Y: P8 Q& Z1 m) a
  321.                         if [ "${loadworldDB}" = "YES" ]; then
    % {  I8 W5 J5 N8 ?# \* A- _6 j
  322.                                 loadworldDB="NO"6 k" F6 v  f' |- Q) T. n4 `9 q/ ~
  323.                         else * j& f9 F! F) f$ v
  324.                                 loadworldDB="YES"7 O! t1 O" x+ M" j1 Q9 H/ `
  325.                         fi        * x" ]/ o- S3 g: D  y9 a
  326.                         ;;
    $ _- P5 M0 L' g! P  ]
  327.                 "D")5 e2 y4 `* S9 W' T* i8 x
  328.                         if [ "${dbType}" = "POPULATED" ]; then
    : e6 ]* ~7 @1 ^3 W- c! |
  329.                                 dbType="EMPTY"* m# T7 z$ x8 ^$ I
  330.                         else , R0 N* g3 Z5 \( s9 |6 {* M
  331.                                 dbType="POPULATED"8 N& C% E) C5 M4 v$ |) v' b
  332.                         fi                                 ( c& d* C2 T( W- {( o. `) n8 ?
  333.                         ;;
    1 d5 U% \$ v( q, l! H! ~6 ?
  334.                 "U")1 b: i7 z$ b+ v8 E, Q* `
  335.                         if [ "${updateworldDB}" = "YES" ]; then
      U6 Z) M+ t6 k) l9 u9 I
  336.                                 updateworldDB="NO"
    6 @7 [4 |. Z, |: o
  337.                         else 2 R. I2 z( M9 ]# r- S5 o. u
  338.                                 updateworldDB="YES"( O% [  a6 C2 @8 w( O
  339.                         fi6 o$ J% \' {7 e; C
  340.                         ;;
      J' g' e4 q* H  S! o( G4 n
  341.                 "T")
    ' X+ e# l$ M, `. @, r
  342.                         if [ "${createrealmDB}" = "YES" ]; then
    ! L; |, `/ X8 u+ i3 n) c0 f
  343.                                 createrealmDB="NO"
    ' c" G9 E: {, D% t
  344.                         else
    ' r- t* i7 a+ C0 J
  345.                                 createrealmDB="YES"0 V+ e7 x9 o6 M
  346.                         fi                                
    % x- R& L8 c4 h, W, a: I/ O( b
  347.                         ;;
    * ^, F6 G8 m3 B+ b% H$ A$ S$ h
  348.                 "R")8 j  f8 F1 i$ [0 G  m
  349.                         if [ "${loadrealmDB}" = "YES" ]; then
    ' h/ q; R, X- q4 H
  350.                                 loadrealmDB="NO"                          Z# [' X8 M5 O2 M+ X5 t
  351.                         else
    0 Y3 W( r+ ^6 U$ m  E' D0 e
  352.                                 loadrealmDB="YES"7 v% ?1 P$ w8 I" Y! h0 z6 D3 [
  353.                         fi9 y, _3 `/ c, ~
  354.                         ;;8 |/ |+ u5 d0 s0 T+ S
  355.                 "Y")0 B0 j( y& Y7 b; l; U) c9 Z# F
  356.                         if [ "${updaterealmDB}" = "YES" ]; then1 G& y0 D# J( n
  357.                                 updaterealmDB="NO"
    . S* F& R# I: h( m, N2 ?+ ^
  358.                         else   a" n' Q. J7 S, \
  359.                                 updaterealmDB="YES", m; a7 a! z& Z
  360.                         fi1 j+ J2 o/ [' _" R8 r+ f4 r7 J+ K
  361.                         ;;0 P  h( i1 |3 O0 F% p  B
  362.                 "L")
    : n3 S' l. i! z0 R* |4 G) O
  363.                         if [ "${addRealmList}" = "YES" ]; then
      I! h4 {$ w7 p$ d
  364.                                 addRealmList="NO"& V5 \( @% w/ g( w
  365.                         else
    $ r3 P# ?( @' l3 F- I9 Z7 p
  366.                                 addRealmList="YES"# V8 ~0 |* ?# V. |4 b
  367.                         fi4 c9 r( m. k7 L: o
  368.                         ;;+ C: C* N5 u5 s  t5 ~  I2 F
  369.                 "X")
    ( }$ c1 `0 B* D6 Z$ Y
  370.                         exit 0;;
    4 w' Z5 s& P8 R8 j1 d$ d* U' G
  371.                 *)
    ( S. U( x& W. h; ?; q
  372.                         printf "Invalid selection";;
    ) v4 s; }1 W; _
  373.         esac
    $ E( E# [. Z5 C* @% R2 i$ n2 Q, N
  374. done
    # O* J! N5 N; Y$ G5 j
  375. - _: o6 y4 N. n% K
  376. printBanner
    " v6 t0 b  I; H* ^8 i; S1 [2 D1 |
  377. determineDBName/ T# {2 @9 w4 g& B% S2 s6 h
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "
      m) i5 r/ G0 `& h( }  K( ^
  379. read svr2 a! I6 b  R. G# y
  380. svr=${svr:-${svr_def}}
    6 z( d( ]  [; ?
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "0 y1 l% f+ u1 w+ R& \
  382. read user
    " L# G' L7 e/ f! e& p
  383. user=${user:-${user_def}}
    + F# v, A5 }& T4 k) B* m
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    - b) I. L9 O( y0 y
  385. read port1 D8 f' @9 W& E& x0 a$ a
  386. port=${port:-${port_def}}
    0 O* J" Z  [2 ^8 u! M% h: h
  387. if [ $dbname = "MariaDB" ]; then) z3 N2 o5 `9 F: M8 {
  388.         printf "What is your ${dbname} password ?\t []: "
    : {+ d. a3 P" L* w0 k6 m
  389.         read pass" U' X3 g5 w5 l# ~8 W/ S# D
  390.         pass=${pass:-${pass_def}}
    " i; F" u+ d5 n& t
  391. elif [ $dbname = "MySQL" ]; then
    , J; g' E- Q, ^! @9 m1 [
  392.         mysqlconfigeditor' Q9 C4 R" w2 J
  393.         $dbconfig# A, K( l" R8 J) i+ @
  394. fi8 e( a0 w& a3 w4 C5 q
  395. determineDBCommand
    0 ^9 g- d* {! S0 X6 h5 q9 N  }; I: i
  396. + S9 v, n3 [. R  O1 r+ P  B
  397. if [ "${DUMP}" = "YES" ]; then. g9 S# W6 `' g/ X
  398.         printf "Enter it again \t[]: "( v/ E1 T& M. A
  399.         read pass& T( K% K! b; H6 c; y- M' ~
  400. fi5 N# z2 v5 _' s% `, D+ [0 W+ L

  401. ) \& i' ?. l9 f
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then
    0 q' B, ]2 H" x- o3 Z# X( W' P
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "
    ' |" Z1 z, H( L& g2 h* [% D( Q
  404.         read cdb
    0 z0 E0 l- P; ^2 B
  405.         cdb=${cdb:-${cdb_def}}
    : T2 A9 K; k0 V/ Y7 M6 R
  406. fi" M' ?7 }$ d4 ]$ T( w. V
  407. / ]7 K+ |. T% `( I6 w& L0 S1 o
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then* s; c0 d' s6 |" S1 g" c
  409.         printf "What is your World database name ?\t[${wdb_def}]: "+ s# T8 X6 k- d; V6 |5 Z
  410.         read wdb. j& S6 h9 v# j' r3 |
  411.         wdb=${wdb:-${wdb_def}}
      b0 g! s( o% \
  412. fi
    * @2 X9 q+ F1 G& G1 j$ L
  413. 9 H2 R# h, @7 M7 W' ]5 i
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then
    5 I9 z* I* }8 J0 m0 L6 ^6 r* N
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "
    ; f2 |& [# d+ N/ I: q! |, q; i
  416.         read rdb
    , g7 G( F8 Z8 q  V' ^0 g: U
  417.         rdb=${rdb:-${rdb_def}}
    % P: M* E) S' A; d0 M
  418. fi& F; w$ H0 t9 \0 W% ?
  419. " C* ]# B" D: A. D. o- w
  420. if [ "${createcharDB}" = "YES" ]; then0 i6 o- \* W+ E  ]5 p0 j
  421.         createCharDB
    % X- {' N" H$ @) S3 z/ N: b
  422. fi
    ( I  ~3 a* k9 p: X
  423. - D" s$ q1 L, Y
  424. if [ "${createworldDB}" = "YES" ]; then
    ( ~- i% Z' V  X7 U. Z7 ^; V0 ]! r2 S
  425.         createWorldDB5 E3 p" Z& {: h9 a* B
  426. fi7 p) f2 R; Z/ w
  427. - c% R& ?6 e: t" p( P7 D
  428. if [ "${createrealmDB}" = "YES" ]; then, y6 ?- ^4 ~. S% k  j! R! c
  429.         createRealmDB
    3 }9 ?/ @3 s0 |* Z2 }2 t
  430. fi
    6 T% C4 s& Y- e; k/ v2 W2 @

  431. 9 I# Z& U4 y8 i; |6 B- o
  432. if [ "${updateworldDB}" = "YES" ]; then# E2 b* l+ {  I0 ^( [8 `. \8 f
  433.         updateWorldDB0 _3 n8 s+ V  e! E# t/ _  V0 D  R
  434. fi9 h6 W6 |8 G. p3 `) N6 x* j: c3 g+ `3 I

  435. / ]- }( b( X8 ?, L+ ^
  436. if [ "${updaterealmDB}" = "YES" ]; then
    . a8 F; |/ }" g  U2 X) h. N% V7 |
  437.         updateRealmDB) W' l$ f/ _; Z! [! [/ S5 x' t
  438. fi
    ' M  K3 n: f1 d  J0 A& I
  439. 4 j0 q; |/ h& U# t! L
  440. if [ "${addRealmList}" = "YES" ]; then, ~, Z# e' d5 A3 A) M
  441.         addRealmList  ^2 }! ], N9 E9 `: z1 p# _* q* M( V
  442. fi$ z) K5 j- n4 B. ]& }4 E
  443. ) v% V! W6 p2 q6 n! R* t
  444. if [ "${DUMP}" = "YES" ]; then
    2 s4 X- c0 [! S* O# a
  445.         printf "Dumping database information...\n"3 h8 d8 P% N; A$ q/ Q4 N1 ]
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf
    0 N& g% V9 D/ |8 C! q+ F# |
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf
    ( n% z; r1 u: D
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf
    7 j- f: z7 b0 l1 m1 q0 B
  449. fi
    ( T8 X# A) O! f% E; x+ L: @/ y

  450. ) E6 h2 F  r  ]4 @% x/ u
  451. printBanner
    % ?. ~! @& k( S: ]5 W- ?8 Q
  452. printf "Database creation and load complete :-)\n"' Y4 Y% W  ^' w
  453. printf "\n"
复制代码
& o/ B/ @/ z; I0 s
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令: x* k: T2 U. s( `6 ?

4 Z; j( P$ ?7 U2 l+ |& X+ {! O使用 Playerbot 密钥的指南:, w* S! s$ t. u" }9 b) N

) f/ Z2 x0 }' ?  U. \, N2 v标识符说明, n( [# C  @0 `: i# j0 z/ Y
机器人名称    机器人的名称
3 P, v% w" v0 ?$ e2 E0 N: q) k朋友    命名机器人或玩家角色- W7 u, E4 M/ G0 }3 P( O
目标    选择目标玩家、尸体或NPC(非玩家角色)  U# Q1 v4 g8 e
|    逻辑或
0 w- @) G7 N* j% }/ }, V& E2 t* W&    逻辑与
$ a) S7 p) G9 Z/ G! B" H$ g..    多个实例
5 X4 L& i5 }2 r/命令    MARCO 命令  N) T1 I+ A7 ~7 Y+ K# D
/s    聊天:说, X6 p4 }. D' n! z* U  }
/p    聊天派对
/ K6 S1 k- i/ T/t 机器人名称    聊天:TELL BOTNAME
7 a/ O/ N( N, e/ l  p7 x9 l7 b/w 机器人名称    聊天:告诉 BOTNAME
/ Z& h. e3 z4 ]7 j7 c2 ]<名称链接>    名字=
# \) g! \  w; I" j' `(捷径)    为命令或子命令分配快捷方式3 Q) x. N, m: K0 T$ ~9 d& H

3 o- u5 A% C2 F4 A# T可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明
! T" s& h  {+ N" m! [# |.bot 添加 BOTBNAME    为世界添加角色. S8 G5 }1 g& [( j
.bot 删除 BOTNAME    从世界中删除角色
! K: z9 Q1 x$ @0 M9 V! w4 a1 @  ~- L, t# O5 F0 E" e
当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)4 `$ I: F  v; v+ f+ I- ~
.bot < co | 战斗命令 > BOTNAME    分配机器人角色
2 \% {  a% |8 n$ d0 x0 H) g, O0 J+ j; J- S8 |9 W) r3 v* o
宏命令:" f! B. W2 X) I3 l" q+ O7 _
句法    描述$ A0 _9 v/ e) a! ]5 m
/邀请机器人名称    机器人将自动接受聚会邀请2 h5 F& t. {& m8 F0 n
/uninvite BOTNAME    机器人将自动接受派对不邀请
2 a( A9 j: u' ?: }
9 N2 E$ Q9 |1 [) A) m; q( FTELL/PARTY 命令:(某些命令可能不适用于某些内核), e& w3 v- r1 R4 Y" z
句法    描述4 ~5 G# D0 W3 ]2 n- ]4 f
协助目标    机器人协助列出的角色,在他们攻击时进行攻击。
( y7 F/ d9 k9 W8 b& J攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式
- x( x; K5 Y3 [' O0 y拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..
- q, n5 l. V! V8 p% m$ n/ H拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..0 \. {  B7 I) e( r3 d3 a4 }
拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..0 v1 i. [  F/ j7 F( l
银行    命令机器人寻找附近的银行家并列出机器人的银行余额
! B$ E$ b% S* A$ ]2 X3 T银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
; R8 r& S. c8 u& d% \! ]银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >../ M6 R" c) Z1 {& F0 k5 G
(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..
! @, l6 Z+ L' l) `©ast SPELL    拼写 = >, M8 F# [3 _  O6 C0 w
搜集    显示收集对象选项和当前收集状态4 B; T4 C* ]$ U& T5 b* l( j; U6 a
收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
/ ~. @( `9 @& y* ?5 d工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
/ L  F) k$ J/ N" a工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例3 G: J3 T' ^2 I4 K: I
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
/ u+ c  \% y7 i! e% u工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习! z$ R+ q8 e; d* [" r0 c) {+ F
工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习
& I: ?! W. u& @) G" y! b工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习3 H% ?/ \  e/ q5 L7 l
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习
. Z) k8 n2 C# C6 d# j0 [1 a6 F工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
5 O" c0 V7 H$ G# X' w1 X工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习0 ]$ k9 |7 b* X& S$ D4 @$ r
手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习+ \/ a8 ?# J7 K' l1 N3 \2 x
工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习/ N/ ^' Z* d  b9 [8 @/ }
工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习/ D5 R9 G- I- ^. t7 Z6 w
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习* L, |, l% L- u' n4 T" h
掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..
* {+ ]# m: [. `  w' H$ D" J全部放弃    当机器人库存变满时,丢弃所有低级物品。
% m9 i: O+ y8 r+ W$ T$ e: ^) G附魔    列出机器人学习的所有结界 1< Spell LINK >7 ?2 ~6 v8 Q- r3 v/ f' b5 t% [2 y
附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中9 o( j* ?2 d& _8 g
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品, P% L  F1 ?6 y1 k' n2 X6 }4 p
(e)quip auto on    打开自动装备,也立即检查' y: n( L- o+ h( c7 i: Y2 b
(e) 装备自动关闭    关闭自动装备。
3 ?1 W. s0 E+ x' Y7 b% w(e)quip auto 一次    运行一次自动装备,然后将其关闭。* Q% ?! Q" c4 l3 z/ W
(e)quip 信息    显示装备自动切换状态(开/关)。, U/ D5 K6 ~+ _
(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用
+ P! t3 R7 U& U5 j跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人
- M* d# |6 D! K2 j8 i9 w跟随汽车    切换自动跟随距离(开/关)
6 T. f3 Y* l3 c+ A% X+ p, e关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)
2 G0 l+ j! ~2 i; _, d跟着远    机器人跟随,远离主人。8 e0 ?5 B2 A+ a, ^8 t
跟随附近    机器人跟随,更接近主人
" ?1 Q/ U7 ^3 |跟随重置    机器人跟随距离重置为原始默认值
& a# a1 z. Q+ G# x  O4 S(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家: g- t8 K) U( ?) |: e* v
订单    显示机器人的战斗命令
: g# j3 {5 s' k) O% I订单延迟<0-10>    在机器人开始战斗之前激活延迟。7 g- b& c0 \, U0 c
命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
6 P3 t# k5 h5 [4 C命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。
5 c, J" z' e: I1 K* C命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。/ p2 }2 }* C- C* b% L5 c$ S$ Z
命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。5 ~7 V2 H3 ]' x5 a$ ^
命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。8 ?/ \5 r/ W+ ?& Y. x
订单恢复    将战斗命令恢复到注销前的状态。
! Z' F! r& J7 g( }& a/ j邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。3 V+ J1 r' @5 N! N
mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..$ G' @4 o, O/ ?: D
邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..
  B8 u0 M1 @$ {; c$ T邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
' U- n% A& @  ?, f5 I9 a, L. ]宠物遗弃    放弃活跃的猎人宠物。( h8 n( N7 z$ p( C* U. q
宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术
- ]5 Z$ b, p; k. Q; G7 _宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色
1 A) j7 s& r5 `5 s宠物施放法术    拼写 = >0 n. k9 r# c+ K9 z; x2 Q7 G
宠物切换法术    SPELL = >为给定的法术切换自动施法
  e- Z! g: @0 d宠物状态    显示机器人宠物的当前反应模式+ l/ a* ?& D6 K% V
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>- y! [  g0 }' C/ e: A* t
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
3 |- d: h: ]8 f7 X处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素
. x. y8 @, O/ D/ }6 M! U$ @. Y  c! G过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
- h5 I* F4 ]. S: K- P; H- L( {拉目标    以协调的队伍/袭击方式拉动目标。
/ p( D. H* L1 F! S: Q拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。% L; |1 c8 I. w4 j3 R' [
准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。+ ]2 j% P' N! H% r
寻求    列出机器人当前的任务
, o, M; {* ~* }: X) N) Cquest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..% N1 S! Q& G6 E' z
quest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >
6 o0 Q* F0 w( B# K' ]% o追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务
% n) r2 P8 |: ^# d& O寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象
+ P0 v# T# r% V. a; i- Z任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
5 I7 @. B+ |4 l, D; M' Q; squest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到
4 k4 m) Q1 Q# E! V% J修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..& D* Q7 I# a4 p/ j
全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品
& Q! r$ i4 }" o, E0 B. x8 |# i重置    重置状态、命令和战利品清单
+ o7 j( g. s2 A4 _+ h4 h, ](s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..1 v2 T' \, M( P3 y5 s- O: B9 V. r
(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。
. D/ b/ Q/ c5 W. ^( o! O技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能
1 E- i* u5 g% s& ]% ^/ ]技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..
; `3 |6 q) p4 h. |技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..
$ _- C& _7 E" l% B! e技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术% t; q+ B. a% e
咒语    显示机器人已知的所有法术
) V+ k; [, k  `, X4 [! X4 t统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本. n; ]+ W% o- o3 S2 u
停留    命令机器人站立而不跟随玩家
& z4 ^6 l3 W" e% A" {, d, L- U* n6 o' O召唤    玩家附近的传送机器人
7 f& k. I0 H+ V  W. y民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..  z' R1 {, C2 R. Q( K$ i6 P
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)
! w8 {) \5 q; E9 k# `  `/ _0 d使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)0 x: G" {% D% _% J
句法    描述/ _& ?9 g) Y* X4 {
天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用$ j( o+ C( k4 R  ]6 |
人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋7 v! t* z3 ^; n8 p& Z4 O
天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2
5 r( B6 E% |( R& x* d. W+ a* H% G人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
; W# h& l% m# S2 g( \- T天赋规格#    机器人将遵循此天赋规范。. |; P" E8 y1 H/ x; \; h
) h( F. N7 Q7 K8 _
1 要选择 , 。; G" O" K$ ?6 ^' v+ I# E! ^
2 每个机器人的税收增加,每次重置天赋。
6 h3 r9 I9 Z( X+ r' A' m2 ~1 _3 L
8 a( k0 p; ]) e+ g9 m' }2 b" C) C. l0 n& f# Y
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 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)
1 {  S- q" V, |! J1 e. ^9 H/ P* y) m' _  l
1. Make a folder for ACE in your preferred location ( I use /opt)4 V( u  a9 o' h6 D* R
) t3 J# D7 w( H
mkdir /opt/ace && cd /opt/ace
6 a$ Q+ |( O: }, K1 J" S
; v0 X+ E% \, z/ c2. Download and unpack ACE! P$ u7 E8 n8 M$ k
& L( Q5 b, {; q, X% z/ k2 w# f/ n
wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz
2 B& Z9 B3 B- [  ?" j! f& Ntar -xvf ACE-6.4.7.tar.gz$ f3 r, N% y: q, k3 i

$ @. T8 c- ?: ^7 A3. Add needed environment variables
: h: ~! P) u3 O4 s
# _8 \* I2 x+ }" Q, [2 j1 M1 N8 C9 Ucat >> /etc/profile <<EOF- }1 a3 q# A- b2 ?! R
export ACE_ROOT=/opt/ace/ACE_wrappers
! z' _: ]$ ^+ O( R! a% X/ i& QEOF
  i: `( F# T* H, r8 s! x0 Wsource /etc/profile
- w: N  r1 x' G/ o! B7 J. {" G

" _( h! S; \7 e6 b* N: L$ R" Q& M4. Add the desired headers7 f1 w: R1 L( }, H5 i8 l" K

; D7 }& d0 v8 j0 v; S  l5 y6 Ecat > /opt/ace/ACE_wrappers/ace/config.h <<EOF
6 B3 _! g5 I# z' C#include "ace/config-linux.h") J! H  W6 z4 F& j% Y
EOF* C& s" j1 ^* w+ R) O: }
cat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF
) B' K$ f! h5 U+ Q5 AINSTALL_PREFIX = /usr/local0 b$ j* A+ z6 R
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU4 R; G8 |8 t% J) }4 ~, X1 @1 e. S
EOF
: }8 `6 P* Z2 A, i

6 C2 F+ f% d. k+ i* k6 q) V& ]% h5. Build ACE
( Z5 _7 E# _& A; v" H  d
' U! l9 T* m" L# N  }4 J; `cd /opt/ace/ACE_wrappers
# @5 H6 N$ e3 K6 imake
  v: ^/ b+ q) g/ qmake install
6 b+ ~- I' O8 h2 ~

$ t) l. f& ~& G6. Add the library to the public path: H% @( N, B9 H. l2 D7 l

* n+ N) z0 W0 e, n. lcat > /etc/ld.so.conf.d/ace.conf <<EOF% D3 _! Y  X$ o5 T: }' O
/opt/ace/ACE_wrappers/lib
: g' m' {% ?- KEOF5 Q" [' U. ^5 }: D- y; h* X9 {$ T
ldconfig -v

% ]  T. A: c1 @+ \6 t2 ]/ t5 x
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client
+ B8 i- U, E) X' u( cTorrent Download
6 o+ S2 T1 H' a- |8 t' l* i8 R7 b# L3 ~- T$ @% n9 f
These are clients that can get downloaded through a Torrent. We always recommend using a VPN, when you download the World of Warcraft – Wrath of the Lich King Game Client of 3.3.5. The reason is to avoid copyright infrightments from your ISP
5 I5 F- Z* N% e/ i2 P9 J: u4 P2 E; L' m4 R  A
    Torrent – Client from Dalaran WoW (Recommended)( Y! u* T6 {: M) [
    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)
& ~" Q+ J9 G) k: j" J    Magnet – Client from TrueWoW; y$ Q( c6 L- `

- x' M8 R# f+ t  r! `6 E6 [1 R; mDirect Download
/ |  C$ O' O$ b: p; O8 O7 k( |$ Z5 v8 O4 B5 _+ W$ ?
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.
7 Q+ f8 g/ s# n  B4 |  o3 F7 T. j, K5 g$ B6 u1 j7 v2 A
    Direct – English Windows client) v% v. m7 {. l5 |/ o# x, R/ B& _! B

" v: T8 n' t; R: o* R5 u3.3.5 Wotlk MacOS Client/ k" K& ~7 V/ T+ `3 p

0 T2 B! K, i, r# \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.8 K, h+ G4 U( y. E) l0 v

3 Z% F0 z" _  [) Y    Direct 3.3.5 MacOS Download – Client from Sunwell
/ u7 N) Y* P0 @: u6 X5 C- ?    Direct – Client from Paragon-Servers (French)(Mac)( U( B( \/ u* ?2 Y0 @3 f

6 W: Z! J$ _1 p( B2 TModified Clients, LegionRemaster:7 S' U3 n9 s3 L

8 Y) W! B& a2 y  H3 _8 z( k, J$ T    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis% D+ g8 D$ _  }# c1 S
    LegionRemaster Patch (modified)
+ L3 o/ U* H3 S$ B+ l- p& W    LegionRemaster ReadMe (Custom)
( m* d( g, M4 ^/ ^6 r% X+ N$ Phttps://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos
/ c. H% ?& M! _
6 G' B9 J, v% f; q: T- V在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
: h' A' H  P% G- O" ~- r# H# c# q" Y5 P- \" a6 t* E" N: _7 M
本文 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。
2 M( I) Z7 _7 T  T  ~. [' w. n2 C( ]2 A( n
正文如下:
0 ?* `& V3 ?' Y2 j
/ V5 |! V7 _( S& E) y开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。
6 L3 c/ @" ]: i7 Q. V: m1 W9 q% j9 ]9 E& v% C. ?( D
暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。8 a! W3 l( s: u

+ H' Z1 j. T! _, d& `: m而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。
. t; @/ W5 A, J8 N# M7 b. {+ [3 w# i8 S$ n' q
  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。/ d% U3 ]. T' K' z* W2 r

+ d- T/ O6 ~: z) L* R7 F开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。
* H: o& f! ?* A9 E/ W; d
; R) z( G3 S; Y% U6 fmangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。
$ ~: e- }8 A7 `. a
; S1 F8 i2 Q" t! B3 e; t
- a4 U( v9 p9 v2 R为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。
' G& O8 C* y+ B( I7 W7 C1 z: D
# z" T( `9 p% a9 F一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:
    : f7 ?8 f- ]' y
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:% a6 X2 k, t5 H/ p5 q$ t* k' z
    Brien
  • 开源数据库软件MySql8 E) M* o! x  a) ?  }
    官网:MySQL
    ! O  `/ k& @; Y/ `. W2 i' G& ~9 s
    或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库  ^9 O: _+ M" h0 z9 {) p8 `
    官网:

    3 L; n) C, z. f+ g/ |$ J# ?$ Y9 G我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。
    4 r  _- M1 l2 o! y文件名:CompleteSDB156-Mangos3462.rar! m+ H$ P. Y! R; A
    下载地址:2 X1 g* L- W6 d/ J) M
    4 O. g. ]  ~" I5 w6 z- u
二、安装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"
      5 A+ s: w8 K4 H- s2 \: r: U
    ; t: _6 ~  @! f: H0 B
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径7 o; p' D8 A/ [+ l: h
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。
    ( a- L& \$ R1 p% O0 f
四、解压安装地图文件
  S/ f' \. `- x6 ?9 }  O* g
  • 把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子目录了。
    & g$ B% U& T8 f4 d2 l
五、解压安装提取的*.dbc文件& ~' d# k7 ~% c# {7 E3 e5 s
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:- I* }( ]; ]: ~
    mpqe /p dbc.MPQ DBFilesClient\*.dbc
  • mpqe工具将魔兽的游戏信息提取到了\MPQOUT\DBFilesClient目录下,整个结构为:("C:\World of Warcraft\data\MPQOUT\DBFilesClient")
  • 当mpqe运行结束后,可以将所有的*.dbc拷贝到你的mangos的dbc目录下:("C:\MaNGOS\dbc"),你大概有158个*.dbc文件。
  • 你可以安全删除魔兽世界下的dbc文件目录:("C:\World of Warcraft\data\MPQOUT")了。+ \0 h3 U9 z- X( z/ ?
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.9 B7 {  M* y! `. j7 [4 ^3 B
  • 将下载的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”,导入数据库文件。1 ~- B5 M! p1 t3 V0 O' ^, o4 y" D& H
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。
- T7 s9 p$ q( U8 G9 E
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到
    # t( ^0 ^, O7 G" A6 o; n"LoginDatabaseInfo ="
    2 G1 M1 D5 D. f改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"
    , A* M/ A! a( B. V/ y+ p这里的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"- \! ^7 x) u, z

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

4 K6 p% B1 Y: D% V' F& i5.安装数据库  Q  g/ r' a" n1 A; P' I
使用mysql建立 mangos 数据库
+ C9 F) I+ s$ p2 k7 P: W' l  Z! _" k! d8 K2 Y0 l  {4 U
a1)使用官方最小数据库,mysql用户名及数据权限等请自行设置/ l# O/ S: F8 U. u  q# G
mysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据, _5 L" e% r$ T2 k7 c; \
6 f. ?' B* g- E. x! O$ l- O& I
a2)使用sdb数据库,mysql用户名及数据权限等请自行设置2 i! L- _! L+ t* h* X8 r/ p* _
假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
7 I/ m9 V4 X/ [0 M/ R2 |5 W2 imysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据  o0 {7 P, {: o$ g4 ?1 I
3 e- x  |6 L( ^0 B" x
b)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1; E; ^0 ^2 _, \( l! x& H9 T
5 u. b3 H4 o; n8 I' Q% `3 N
6.编辑配置文件
" P9 ?6 b: C* `1 T6 k4 V, d编辑 /usr/local/mangos/etc/mangosd.conf+ |) s( |7 K$ {4 \
; S' _% I/ A; A( n
a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"
5 d! w4 A; a4 l! |" p$ X为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"% b2 ?' B9 ?: l7 X
4 g- Y' ~+ r# g
b)找到 Host = localhost4 ]0 B3 h$ z- p4 O- {' K
为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1; `* j( C, R2 B5 _
& s9 Z; |- w/ g
回复

使用道具 举报

986

主题

92

回帖

5万

积分

管理员

积分
55255
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。/ \+ F; E5 b0 j$ B" _

" u% a' ?5 n% {6 b% V2 v: _本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。6 q0 x* J* B1 }6 \/ K3 s' I

. u. k# k! k* m. i# V3 Y( M我们走吧..8 c9 }. ^1 C6 V% w- F7 O, r9 u
9 u+ w) ]5 ^1 \
设置数据库:/ v+ q" T; P8 i7 z& y9 w4 ?
) {- S+ e2 [, V0 o8 R
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。+ Y9 N" t% c0 b- o8 ~5 z4 a) ?3 g
( N$ S" O0 U. d. [9 e; C
启动一个终端,如果还没有,您需要成为“root”用户:
* {% u, {, c8 u! i# V
6 H: ?; k5 d1 c2 S须藤苏 - 根
4 o8 g! P+ B: r; v然后,安装 MariaDB:
# ^" A2 h+ d, t+ m) b2 i- P$ z, L% D( E8 I% d) D$ H8 o1 v# A
yum -y 安装 mariadb-server
1 u! x7 Y$ S* L1 p7 @+ t9 [     安装 MariaDB 后,启动它:) ^; e) I7 ]" I7 p7 P
( P, l' z( Q# T5 J& F- s: q
systemctl 启动 mariadb
# J; j4 @" H% }& f- S8 A7 e我建议您在启动时添加 mariadb 服务以自动执行它:
( p$ ]- u. e3 n2 t) ]. k0 V$ {9 \7 S7 @7 H
systemctl 启用 mariadb1 t3 ]  M% ]: y7 j
让我们保护您的 mariadb 安装,执行以下命令:- l$ S- ~$ l# n" j

) ~" L4 S4 Y" N1 e/ ?mysql_secure_installation& v1 v' \) b$ k7 G
我建议您设置以下参数:
. R. T5 I' q+ B% O& X5 }8 Y% u' p7 e8 r- z/ f7 v9 q% q& Q4 g' R6 h7 g
设置 Root 密码. L3 e; A# V$ l& x5 U. o
删除匿名访问; {: w9 I6 o' `
禁用 root 用户的远程访问
# v8 Z9 ^) P/ X删除测试数据库
/ X; t, R& U4 |# a8 N. c重新加载权限
% m( ]) U1 l, w  m# J$ f验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:
/ J" [: w+ ~8 x4 {- w( q( F) J7 \) z4 }
mysqladmin -u root -p 版本' o2 d2 r. H5 z6 }' w
如果一切正常,您应该有如下输出:
+ W$ U4 E/ R) P
' P- w2 w" y( f, u/ ^/ F+ p/ K1 \- B服务器版本 5.5.52-MariaDB
' T7 @& a+ ^! P0 ~$ j# f. s协议版本 10
+ S2 D$ [7 b3 g- v; f, O, _4 j  L通过 UNIX 套接字连接本地主机& s6 ?6 r& Y$ e+ D/ d
UNIX 套接字 /var/lib/mysql/mysql.sock$ C* o) c$ @/ p1 d) }
正常运行时间 x 秒9 S; Z3 T$ G# _
9 ]: o8 x: Z5 @8 m3 Q
5 E: v* `  g* N8 R  ]
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:
( M( D' b7 U; L- b$ D& a2 i8 F6 M5 B! |9 @, V- q( x$ D
mysql -u 根目录 -p. T% I+ }7 w" \
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):+ n5 e9 y) i2 \  w5 M

9 N- K: T1 w5 n; \# v创建用户“芒果” @ “本地主机”由“密码”识别;- D) i2 B$ P2 h  a7 O" M
然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):7 l# \( b2 u- y# y9 H8 n6 m+ j/ n
2 S4 m0 w2 V2 }' D, u& ^( [4 ]
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
) w6 F* h; J2 J" ?3 o) J/ y退出终端:
; x% a# S+ e1 t0 _8 C+ U
  N1 c3 h/ @) s7 b退出
+ c1 ]7 g7 ]7 x. z& S. c( w恭喜,您已经在 CentOS 上设置了数据库的先决条件!
( K$ I3 N7 I( ?8 |) x6 V1 V3 Q# x( L& j# K& m8 N
. Z. A/ Y1 \+ R% |! F" ~7 ~: r

& I2 g4 P/ k/ T4 i1 K4 H- A- l安装芒果:
" v9 `% C4 R3 }. H6 g  S5 d1 z" e4 c0 h  @6 z) {& E+ R1 l
我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:) I8 h+ E% T0 ^5 s+ d
, J  D  j4 L, f. c; E6 P- y
光盘~
% }' e: R  i3 Y2 M让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:  l( F4 G5 I+ A

6 H* j) k6 \  B  \: A: Ayum -y 安装 wget
6 v! L/ l; ^1 P+ Y+ g; }现在,我们可以下载我们的安装程序:
2 T1 r' `( b  p
5 L1 C8 w  M% ]wget https://raw.githubusercontent.co ... /linux/getmangos.sh, e: E/ G, K- H
设置允许执行它的权限:
- D: I* P0 c, w1 u8 J6 m8 Z% I2 Q1 d2 y
chmod 700 getmangos.sh
9 r9 K, p9 ?" @$ E- N. x并执行它:3 K  F8 s2 ?7 i8 q6 d( k4 B
- M  x  t3 {, L0 O$ _0 J, U* Y
./getmangos.sh- y7 T' z) P) x4 s9 b# \3 j; p
在我们进一步讨论之前,对可用活动进行一些解释:. N- s1 Y5 S2 i% U/ H: w" s% w
# D1 e! i% P5 Q. W( J& n# P  y% p
安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。
% A' r  P3 a  D  l( A. h设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。  P  J+ e3 p& v4 V: L  s% l  r
克隆源存储库将帮助您克隆Mangos源。默认切换。
* r4 \& C+ d; B; h$ |6 h' y0 ?Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。
$ }3 }5 g( ]9 v" e, X2 k. J# X安装MaNGOS将帮助您安装MaNGOS。默认切换。0 C. Y5 t3 [8 M4 f  y2 Z  ]5 `
安装数据库将帮助您创建数据库模式。默认切换。
5 b: O0 w2 @& y! n" y提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。9 d2 G% N6 ~, {2 \: U
创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。
3 y3 _1 e$ G  w, c4 Z7 S现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。6 m6 O- Q5 ^& Q  D8 b8 b" s- a
6 Y$ P1 v1 N: q% U9 o* L
用户选择:
* x) D8 g) z) r  O, y. ]3 t; C
' f5 {3 m4 s! P# ]- g0 K5 TMangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。# |) E9 ^0 f# \& k0 ~
( G5 E2 i+ X' u% z, |( b
如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。7 I/ B- i/ c; R: s2 b

  Z* f+ s! Z. H1 t选择魔兽版本:
3 B$ a1 g6 f9 N, V6 s6 g) q0 W. s! K$ \1 {% N" b- B1 b$ Q
下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。
) b9 h, Y& J$ Z2 x; e: Q0 b( _+ y
源代码路径:) f; g7 ^, ^# A
* P$ K: q& k4 X/ g8 k
下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:9 Q  a1 l( @0 ^

7 b; s6 P4 W* {7 L; ]0 ?: ?7 c! ^/home/芒果/zero/src
# C% ~, d  T5 `3 ?3 l  u  u" X如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。
# b/ K, x6 z6 q0 {
+ i6 Y! S& M& ], f; L6 N! n9 L8 n安装路径:
! Z) w/ D' o5 y/ s, w" x) N5 F# }- ~% N8 Y9 r
下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
) q$ u) d8 w. c6 u% Q. p7 H- P
+ C, a+ B+ B% b' Y5 e8 ?/home/芒果/零* ]: ^; K* e: }+ x9 }" f
如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。% e+ O) o7 j  B7 G3 U: x; x

/ k0 c, c* |$ j' p7 G克隆或更新MaNGOS:
# E/ M% D7 p8 W: K2 ?
8 u1 J; s( Y- L6 K; }脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。' I  p/ H6 `  k$ l0 ?

( t  E) x! l; c  L: Z, B3 w$ @# W. y6 ~安装程序现在正在克隆服务器和数据库存储库。
0 v3 y7 Z" ?( E9 k+ h+ I# A
2 q) o9 v; D8 I% z/ j构建选项:
6 U5 l' N$ G+ o
# F  m5 x6 ?% u$ G* Z3 i7 K: Q您现在处于构建步骤。此屏幕上的一些解释:/ i, g6 o, Y4 i3 h  g. O" E6 f

# B( _0 Q- n- Y! T! ]" A. z* PEnable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。
" `; C! L" I% L  e- M使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。/ l& {- Y. C: N! G. N
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。
0 K4 e0 I  M& S# f# D使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-3-21 10:23 PM , Processed in 0.115225 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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