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

MangOs搭建魔兽世界私服

[复制链接]
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!2 l, ]$ H* T: g  \2 N. ?
考虑再三,我选择了CentOs来做游戏的服务端操作系统。
3 A3 A9 j/ X/ o7 R通过Git获得Mangos的源码之后自行编译搭建服务器。9 r2 q9 O# X: [" J# z
这么做处于几方面的考虑。
6 H0 N, o7 ~9 d3 K7 f& t
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。
    % R5 K# B: ]8 w3 g8 E9 h3 J' i
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。/ Y: h$ g& j1 i
把该打的补丁都给打了(yum update)
( d  ~: w; D3 B+ F4 |完了之后,咱们安装一些基础的组件和环境。
# e8 j# R, r# J! fYum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel
" C; H; z+ n; ^+ t: K7 L7 t1 i如果有些组件提示没找到,无所谓。继续往下。' K1 G6 j3 A( |! w0 e: I: `
我编译安装的第一个版本是cmangos。( J+ |( W0 _" |7 T5 A6 q
这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。
3 R: u; t% j  ?5 o/ U! |cmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
) O: w/ h; N! Y" @4 C7 L编译参数中:3 I) m: b' Y$ C
DCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。1 s" X; A! t. |/ C/ h, Q+ G
DBUILD_EXTRACTORS是指是否安装地图提取工具% `6 N) y% W$ V4 m2 B9 _" ]
DBUILD_PLAYERBOT是指是否打开机器人# Z7 y" L) K3 w. M# F
这里我做科普2:
1 D& D2 n  r) m' p* [/ }首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。
- p% @9 f! A1 s. P) k" p$ F$ U既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。
) F" m+ |6 H' ^; p+ A至于那个机器人吗?那是个笑话,请自行忽略。  M; l8 F" a& L, v" v
我们继续,我把整理好的搭建步骤列一个明细:
1 w, v0 Z9 U7 h' C% j
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。
    " H$ j5 O" I+ s' x
这中间,我把一些别人不会告诉你的关键步骤做科普3:+ m) l4 K0 k8 j' V/ Q6 W1 Q
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)8 Y0 t: i! F) r& c) W3 j% {
放几个链接仅做Mark:
- A9 f: P6 q% A, n1 R# J( R8 X: KCmake3 安装0 W1 z0 f5 k/ ]' Q3 j( ]6 a
https://blog.csdn.net/weixin_38883338/article/details/864087496 m8 x' i# z5 v
Gcc 6
# P; ~- b" f% A/ p/ ~https://blog.csdn.net/Al_xin/article/details/92438055
9 V: T% s8 U( J" o5 y% o8 jACE6.3.3% Q( B; _# C; l/ g" x; h
https://blog.csdn.net/u010587274/article/details/50965369/ Y9 U3 [1 L! s& p" l! {3 Q
Git源码和数据库编译安装服务器  @) P# Z4 u) {+ P4 {
git clone git://github.com/cmangos/mangos-classic.git mangos' M5 n+ G( ^; Y% [
git clone git://github.com/cmangos/classic-db.git
1 x& |+ _& R. D9 J/ bACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。7 k2 ~' S1 }/ D2 E
我们来说一下服务器的配置。( x0 R2 e* E# z" X$ P) o4 Z, ]
在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:
# ~1 E% ?+ ^; e! }- h  \' }+ G
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)
    - H6 S# o* X; @# A+ ^+ [! @7 n1 a
有几个关键点,我整理如下:
3 ]1 m2 T+ R1 C8 `) e5 A
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。
    / p7 f7 ~$ J$ m$ S
参数名称:
8 h( T  ?" q- ?1 v9 ~2 ]地图目录6 d5 O( G  Y/ R9 ]: L
DataDir = “../data” $ w6 a, L) r' [! u
日志目录
4 d0 r9 p! D' `LogsDir = “../logs”9 a5 c# A/ s, E' K
游戏欢迎语
" {$ e# }: T  Y, a2 i6 x# v& d. u' LMotd= “游戏欢迎语”
9 X6 N2 \0 J) b! j5 z. n出生等级
4 D/ n% B, Q  D) M/ b/ FStartPlayerLevel = 1
: w3 ~# b' b/ R( M3 d8 H出生携带金钱1000G
' o( X* `0 ~2 VStartPlayerMoney = 100000005 b! t; h2 i3 t' L# A" n
杀怪经验5倍
* |( J5 ~( H" e2 t# ^5 LRate.XP.Kill    = 5
0 V) f5 h: j2 k" f任务经验15倍! d* l+ C% g" x8 X( r
Rate.XP.Quest   = 15
+ F. O6 b: U0 [0 Q8 R% N探索地图10倍) [- g# r- @6 z+ w# U+ F- |
Rate.XP.Explore = 10
1 ?6 s! n% X! @3 u! S0 U数据库连接(应该有3-4条之多,按下面格式修改即可)9 G- {* o" c+ v4 h- y
LoginDatabase.Info              = “地址;端口;用户名;密码;数据库”
1 W8 _) I. }; I配置结束,就是启动。
& n0 A" b( \6 i因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。8 X6 P7 e" Y5 x! F( o
我们需要开启如下端口:
) E8 w# s) R- l( \8085,9600,3724
4 X9 Q4 H2 O' @' n9 H. p# q$ Y. h5 I把他们添加到你防火墙的白名单即可。
. J* S  T( v4 W- \, E. @! i(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了)" W! w; {9 I. V% G
一些收尾工作:6 M! t6 Q# P5 I+ W3 j
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。
    + y+ k! v+ i2 C+ N0 _& a( V

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

server.zip

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

database.zip

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

ACE-6.4.7.tar.gz

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

ACE-6.3.3.tar.gz

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

cmake-3.0.0.tar.gz

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

rarlinux-x64-5.0.0.tar.gz

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

 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
3 O; m0 ]  r- ]; ]5 k  c! pgit clone https://github.com/mangostwo/server.git
3 T1 ?8 @9 h# lgit clone https://github.com/mangostwo/database.git
; x2 L0 N+ o' o5 D& A  W6 r5 w% k" C) R# c
$ ^- H! z4 x# L0 R3 T8 p1 n; p
  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-scl4 P# M( U9 c0 I5 X. p/ {
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils! a# j/ M$ ?0 `1 y3 \, e/ T
  3. scl enable devtoolset-7 bash
    ! B7 G+ \2 v& ]0 y6 G- y
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile
    2 y! Q8 J* f! R' H' A* n8 C2 J- T
  5. # 查看安装的包
    4 X+ F) [/ Y8 q* K: l
  6. scl -l
    5 N2 j: ^2 c* }+ d; |/ H( A+ B
  7. yum -y install rh-python351 J3 c- }4 }3 R5 t
  8. scl enable rh-python35 bash
      J1 F" {, j- ^
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    * j  I) h; k9 C7 `& Y/ t) l1 ^

  10. 5 u6 {  _/ a* `9 X0 W, b" }
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz
    , @  R& L, U; L2 R% u/ U
  2. tar -xvf ACE-6.3.3.tar.gz
    - R0 ?. E% j7 {3 Q" [
  3. vi /etc/profile
    : s+ c* b2 o3 G$ Q( K# v
  4. #在文本尾部添加:: y+ ~6 P+ k% ?" E- R  {' C; u
  5. export ACE_ROOT=/root/ACE_wrappers) @1 G% M( D& f$ i  b$ \
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH  |8 C  Y/ ~* g$ T. @2 w9 B
  7. vi /root/ACE_wrappers/ace/config.h; g- W' p# _" O& v5 k
  8. #写入如下内容:( n7 r; Y- y% b7 }7 x& t
  9. <code>#include "ace/config-linux.h"8 l, m% [; G) X
  10. </code>
    / L  ]# j6 B+ G
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU2 p3 e( Q, N4 e
  12. 写入如下内容:
    - B- C( l( b- Y1 W# c- V8 B
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>
    8 _" I# }8 P, F9 Y# j1 h( H- R
  14. <code>INSTALL_PREFIX = /usr/local</code>
    4 ^6 M4 w6 t1 Q
  15. ) V0 H* x; U* ~' I
  16. chmod 775 -R /root/ACE_wrappers4 l5 j5 r: H5 Q# P) g- E/ l% J
  17. cd /root/ACE_wrappers/, Y# h7 W( Z8 Y/ d- N2 Y
  18. make3 `1 t3 ~8 U5 Y4 m& ]4 k! `0 H
  19. make install
    6 N% y% h2 d2 N
复制代码
回复

使用道具 举报

 楼主| 发表于 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
    , F' \5 ^9 d: t9 W4 S& q7 c/ `
  2. ###############################################################################
    3 q8 F+ z2 u" M( o' w. C. @
  3. # MaNGOS Build Automation Script                                              #' G6 W: q. I- o. C8 A9 w6 n+ a
  4. # Written By: Ryan Ashley                                                     #) @1 o. q: n) {9 \( L4 |
  5. # Updated By: Cedric Servais                                                  #
    ; c6 d! r2 _4 J$ d
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #% _0 q. z! w. `) \( {) z% `8 g
  7. #                                                                             #
    & x4 Y. L' |. [- F% o
  8. # This program is free software; you can redistribute it and/or modify        #1 A  k4 _9 J" u2 L; e/ @6 L5 ?, x. L5 Q
  9. # it under the terms of the GNU General Public License as published by        #
    0 ]2 S, T) x/ g/ L+ Y& C
  10. # the Free Software Foundation; either version 2 of the License, or           #* W6 b- t* a" Z& Q
  11. # (at your option) any later version.                                         #
    / ]. w0 W+ T1 E" [1 c* o8 Y! Y
  12. #                                                                             #" X1 `5 i. D" M$ k; t9 x5 s+ C" E
  13. # This program is distributed in the hope that it will be useful,             #" V& j( y. W% T: K: d
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
    4 m5 w( {' n" D# D2 T! M
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #+ T( J5 X+ s* u" h& a6 f
  16. # GNU General Public License for more details.                                #8 W9 O" `9 H! F5 r, z
  17. #                                                                             #) r( \$ _3 Y6 O; o  T/ l* z# f* n7 G
  18. # You should have received a copy of the GNU General Public License           #
    5 C+ Q% R' t5 I) a
  19. # along with this program; if not, write to the Free Software                 #( i3 h0 m4 n3 S3 B$ Q
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #
    ) \/ C8 V# m1 C
  21. ###############################################################################
    ! t1 ?1 c1 G# n! ~! D( p
  22. 2 y' M5 V6 c0 s  I% f0 s( K  |
  23. # Global variables
    ! B9 _/ K- I5 T6 S
  24. DLGAPP="whiptail"
    1 Z3 Z; C/ n! [( u$ q; ~8 G+ N
  25. VERSION="2"
    + o1 B  H# J8 C, p( D
  26. ROOTPATH="$HOME"
    7 H' W) B9 `7 e+ y
  27. SRCPATH="$HOME/mangos/src"
    ! M. r- N. r1 N" P! g
  28. INSTPATH="$HOME/mangos"
    . j6 Z5 i5 Z% Z& G2 x4 i
  29. DB_PREFIX="two"/ ^0 Y- Q+ E& x
  30. USER="mangos"$ J) e( `8 b1 I% i6 o. @( k: S
  31. P_SOAP="0"
    5 r0 k8 E4 G( L4 ^  B- o
  32. P_DEBUG="0"1 E: A% O  h. `1 D$ i5 X4 M
  33. P_STD_MALLOC="1"7 U3 P+ n7 T% L6 O2 A; a) r
  34. P_ACE_EXTERNAL="1"4 R6 p: a3 ~7 U3 S9 Y
  35. P_PGRESQL="0"
    " T, a* E( [" t/ K% d3 I
  36. P_TOOLS="0"
    : y0 Y; i- @1 @. G/ v' D6 k3 P
  37. P_SD3="1"* Z( l6 ^3 r+ [
  38. P_ELUNA="1"
    ; Q3 M3 K  W& |8 O/ B0 E
  39. P_BOTS="0"
    6 D, K6 J: ]+ P# {: t
  40. CMAKE_CMD="cmake"! l1 P. `2 p" F* v

  41. 6 P* J2 p& R6 z) y7 L8 L0 Z3 w$ n
  42. 5 O9 ~' {6 d: h: B: ^/ P; R
  43. function UseCmake3()
    ! j4 `0 d9 j. ^
  44. {
    . A0 r$ Y9 a1 p* \6 ?6 z/ D8 c
  45.     # set the command to cmake3 if its there3 ]# H- x' D6 R( X  m0 t% F
  46.     which cmake3# f7 n% t3 w0 r/ {! z7 o3 i! ?+ U! P+ n+ l" \
  47.     if [ $? -eq 0 ]; then
    3 u- n% R3 S' }" \1 q" R
  48.         CMAKE_CMD="cmake3"7 Z) Q: x: g1 M# D0 t  l' R
  49.     fi' Z1 W3 G) N8 e% m! _0 s  ~
  50. }
    ' v8 \& u0 [$ k
  51. : i: w+ \: r, k3 D8 w/ P
  52. # Function to test for dialog$ f) f" Q0 C! ~
  53. function UseDialog(). n/ h: v2 a' g0 Y8 n" @5 T; ~
  54. {* R+ j  Y% B) _6 }
  55.   # Search for dialog: c. h( Q( R6 ^- p5 D. A3 L
  56.   which dialog& N# _+ a& C* Y' H4 U
  57. 2 d1 q" d5 |+ p0 Y! A  B1 u) O
  58.   # See if dialog was found. h$ p  D. a* o8 C
  59.   if [ $? -eq 0 ]; then3 R2 \+ T: c  V$ D
  60.     DLGAPP="dialog"( I  v. m3 u7 c+ Y
  61.   fi
    ; ]/ y; S4 z% v$ p( f9 T  g* G
  62. }
    ' w/ [: N0 ?( C  P: k

  63. 2 j1 d' r- L! z
  64. # Function to test if the user is root or not+ Z% a" P6 e4 j
  65. function CheckRoot(). f: z- C6 H" ?# k0 N+ t/ k9 G
  66. {
    ' M3 V& b. Y0 a5 r# @) G9 T
  67.   if [ "$(id -u)" != "0" ]; then/ G% C5 w6 I- h1 O8 g( q
  68.       Log "This script can only be used as root!" 1
    / ]( w! b2 m( v# M" \0 b! J" m
  69.       exit 11 {4 ]. f. T" n3 @6 G# j3 F, Z5 K
  70.   else
    5 x, D! r+ T, s; l) q; T3 l
  71.       Log "User is root, check passed" 0
    4 O0 v! `  @; E1 f3 d8 [
  72.   fi1 V$ A! P$ X) n. C  _% y/ P
  73. }' C. u0 R1 T0 l) M6 x/ d
  74. 5 J/ T, h0 K8 D: s  n  {
  75. # Function to detect the repos
    9 K& ^# t; _$ m
  76. function DetectLocalRepo()
    ! l& u% F2 M) T; J; {/ O. O* F2 q
  77. {) D; P2 V5 d- K, P. ]$ P
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    $ r3 t8 Q8 X1 V7 G$ ~2 ~7 O: l
  79. 5 x' ?4 Q) D( ^' P+ V: s8 V
  80.   # First see if the Windows stuff is in place
    8 k3 R7 E2 t- W0 T
  81.   if [ ! -d ../win ]; then% z+ E2 x0 [! Q( r% `% i. N
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0
    ; D' K9 ^: j9 o( e+ S
  83.     return 0* b/ k" m. S! s8 `: X
  84.   fi
    2 v! U/ ?6 F, H: l4 _2 {
  85. # K% f- h+ w' M8 k: w  }/ v# }
  86.   # See if the sources dircetory exists! ?5 E# R% ~7 ~, ]; ?6 p2 S! v7 N
  87.   if [ ! -d ../src ]; then2 B1 E, w4 n& f; A8 \
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 0
    # s' ]- G9 h3 Q! P
  89.     return 0
    $ L$ K& E3 Z5 d$ F% C4 C: Z
  90.   fi
    # [) |" v* f- o7 A# C+ x4 y$ q8 _3 H

  91. / l4 K$ `/ |/ n/ }/ y; n
  92.   # Check for the CMake directory
    4 [; n2 d! H& ?, W7 L
  93.   if [ ! -d ../cmake ]; then
    ( q1 c( ?! a: Z6 t$ l+ K6 e8 u
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 0
    * N3 x1 E+ J. X% g" @
  95.     return 0
    ) n- B# x1 M) ?
  96.   fi
    ; U4 u5 c% O5 H: d, l

  97. " d/ r0 @. H9 v, k4 f* y
  98.   # Set the default paths based on the current location7 G' n2 Y; @6 G
  99.   SRCPATH=$( dirname $CUR_DIR )
    1 s- U9 _* i$ p+ V$ J; ?8 x% R. T
  100.   SRCPATH=$( dirname $SRCPATH )
    / c& n- W& O8 n5 _
  101. 8 u. Y; P, x, \5 k* Y
  102.   # Log the detected path
    % X1 }5 ]9 v! M- O+ e1 I% I, @
  103.   Log "Detected cloned repository in $SRCPATH" 0* ?; o4 N8 R. j, r
  104. }5 H7 e" h; V1 `% ]1 \

  105. * L9 T7 v: [" p! Y& f1 d' c
  106. % h/ V2 i: `6 A: {7 B* r
  107. + W' v+ u# N8 }0 U
  108. # Function to log results8 x& Q! }" D5 \+ R
  109. function Log()
    - j8 {( p# [& ?2 j* y1 Z0 ^' q; t
  110. {
    9 Q$ C9 `# @# L
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )
    9 g5 X7 w( Z, Q. O2 _$ f2 \$ q9 m6 J

  112. 3 [8 K' `' x& ]! V5 a2 f8 u/ V
  113.   # Check the number of parameters  w, G* k$ X) d0 V" t
  114.   if [ $# -ne 2 ]; then/ b; Y) R: M; j- z# n$ X% q
  115.     echo "Logging usage: Log <message> <echo flag>"
    8 z- m; B7 I. d, w3 l
  116.     return 1: d. U4 t0 K! ~
  117.   fi9 L: w; l( U, K* i

  118. - G3 ^  e, H# K* A# G) ~& e1 t
  119.   # Echo to the console if requested
    : T2 e* y! n6 o% J2 v: {8 P# p( N- \# {
  120.   if [ $2 -eq 1 ]; then
    ) a0 e# l  u; }6 R3 w+ R' [
  121.     echo "$1"
    & i/ [* x: N' R8 h7 a: t
  122.   fi
    " u0 H3 |+ Z% g9 ~, x
  123. 1 n. Y) |6 w" o  X% o* L7 \. P
  124.   # Append the string to the log
    . \  A7 A6 R2 N  M) p
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log
    4 S1 w+ C' y- _# F4 t% h: D
  126. }
    ! _, D6 t9 U% ^, }4 k6 i, `' r; W

  127. 0 J5 |) m& j4 K( R! |0 v$ j4 w

  128. 1 _, E3 Y  L: z# O" e7 I  c& b

  129. . u8 L. m1 B+ I( c
  130. # Function to install prerequisite libraries+ R. O4 Q+ w6 }1 q7 K) ?$ l6 O. m# ~
  131. function GetPrerequisites()3 E( ?5 L& E$ u: s" E
  132. {+ o& z% K- g4 Z) V# y4 G
  133.   # First, we need to check the installer.
    . }# e# Q! P* {. F: N/ ~2 ]2 ~
  134.   installer=0" _2 I$ A" X: U
  135. 7 W/ I0 Z+ O0 Q% \* n8 I7 f
  136.   which apt-get3 y( V8 d3 Z- p0 D
  137.   o3 F. o4 V; Y  s( C! w
  138.   if [ $? -ne 0 ]; then
    " U. x' _- a* _& Z( I. f9 A5 V
  139.     Log "apt-get isn't the installer by default" 1
    - S& u. `4 ~; \! P3 p' q
  140.   else
    9 m4 z1 c0 Y( ]1 P7 V( r' I
  141.     installer=1
    , A4 i/ r% X1 L  F0 `8 V$ _
  142.   # On a fresh OS boot (EC2) libace was not found without first updating
    ' E; I  V! L# N" L
  143.     apt-get update -y && apt-get -y install git lsb-release curl
    0 c2 o/ _% D/ C0 ~9 p
  144.   fi, A1 W% q' {, f# C! u. Q  u: P
  145. ! W" B+ E* O, r" B
  146.   which yum
    * }1 {- a6 [7 `/ L7 T/ J* o) G
  147. , E( E& `- X7 m
  148.   if [ $? -ne 0 ]; then  L2 Y6 ?' m, q! |) ^& ]: N6 `* X7 Z
  149.     Log "yum isn't the installer by default" 18 _# U/ j6 v7 i4 p# D) e& o: ?
  150.   else: ]* C: j" V9 b  o: j2 t. h
  151.     installer=1
    3 B9 O, E! c& p$ k, r% e  i
  152.     yum -y install git redhat-lsb curl% B4 p/ P, ^+ H% n3 k
  153.   fi" C+ K" ]. w2 L2 O  R
  154. 5 A  S4 l" v; I: T0 l& r
  155.   which aptitude( R$ U; c. q7 J7 h; i" z" _
  156.   if [ $? -ne 0 ]; then. J- `7 N, ?& z
  157.     Log "aptitude isn't the installer by default" 1/ b! B+ |1 }0 N( w6 `- N% X) w% n
  158.   else
    4 i0 @  t; P0 l7 A  {* l4 m
  159.     installer=1
    ! V2 a3 p3 [8 _3 E" w3 r) \
  160.     aptitude -y install git lsb-release curl9 _3 r3 a- V% k3 r2 L
  161.   fi" C  c% Y9 u9 E2 ~2 L' ~
  162.   i# |0 k' J) o, P3 Q; t: K- b
  163.   # Then, let's check that we have the necessary tools to define the OS version.
    8 f3 @6 y% b% d  y5 s2 B- C
  164.   which lsb_release$ W8 Q4 b" i% q" ?3 l
  165. ; i% z9 w' u; J+ k
  166.   if [ $? -ne 0 ]; then
    - v1 s( O' \% T1 {8 W6 M# j! w- F: D
  167.     Log "Cannot define your OS distribution and version." 1
    + `; \/ x6 H2 ^9 K" _1 [
  168.     return 0
    2 F5 H9 o3 l# x0 u1 r2 i5 h
  169.   fi
    % R: e# I9 N3 Q; x8 a; n/ u# D
  170. ; m4 x1 H* A+ r  t- h' m& ~0 E& U
  171.   local OS=$(lsb_release -si)
    8 i$ P7 Y5 v: k' J/ G8 P$ Z
  172.   local VER=$(lsb_release -sc)
    . @5 A  ^& U  h5 S* Q6 I1 j! I
  173.   local OS_VER=1
    2 P8 a5 X( h5 z2 {! @& j
  174. & ?; {4 ?( U0 |$ i: M
  175.   # Ask the user to continue$ L2 U) u. p; N9 N
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \: x* T' q% d5 K% l- c
  177.     --yesno "Would you like to install the required build and development packages?" 8 60
    - q5 y  i  W4 R6 ~5 C

  178. ( n3 P( v7 T+ E0 ?) V; j
  179.   # Check the user's response
    9 D# q( M5 N/ k7 N
  180.   if [ $? -ne 0 ]; then
      w$ m3 c0 n3 ]! p, ], t) V  N) o( R
  181.     Log "User declined to install required tools and development libraries." 1
    : m8 v9 I1 \, n0 U3 ~- n# g8 E3 r
  182.     return 0
    - Q4 {3 a6 o/ t* q8 @( E0 H
  183.   fi- f6 a  [" k: E! a

  184. 2 j; z  k. B$ E- W+ i* ^- A' e$ V% r
  185.   # Inform the user of the need for root access
    2 I1 N* O, k' E/ ]' c
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \: ]$ N2 _( Z$ v1 {1 D
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    9 |1 U1 v" g: M1 m6 n9 o. J; ], t) y# P

  188. 6 b, r( H) ]6 ]) c7 h
  189.   # Check the user's response# a# f$ V% y. a- ]" R. V
  190.   if [ $? -ne 0 ]; then
    , ?1 X9 q. c# E( O: i+ F
  191.     Log "User declined to proved root access for package installation." 1
    6 e2 l5 g. p( ?3 Q/ _' O9 S
  192.     return 0
    7 z. h+ |7 T  u% T, h
  193.   fi
    5 H/ [7 Q4 S. D7 \' B' h& e- Z
  194.   U* ~* z5 U2 k# \6 I; z( G& G  }
  195.   # Handle OS
    0 D% }4 X$ A- O1 x% b
  196.   case ${OS} in" L. q$ A/ }$ j2 d
  197.     "LinuxMint")
    . j, A( c+ g1 F7 a: `
  198.       case ${VER} in
    0 R7 j3 l; d: s2 y7 }# s$ B8 G5 ^
  199.         "sarah")
    4 V' l, f* y( i1 j
  200.           # Linux Mint 18 - Ubuntu Xenial based
    & I4 F$ T' h1 ?. z: g6 \: O) H5 Y4 o( u; f
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    1 z3 Z5 b6 V% @/ }
  202.           ;;
    ) X) ?, E. P3 ^: [) B, x) j
  203.         "rosa")
    0 F/ W- K" L! E3 x/ k) T/ g, o4 W9 K
  204.           # Linux Mint 17.3 - Ubuntu Trusty based3 e+ S, _  T2 i3 M2 I9 }2 N
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    & O1 G' c: U, h' d' A, Z
  206.           ;;6 d; e8 u* q0 l
  207.         "rafaela")! Q4 R3 P7 `. X) Q! H: l
  208.           # Linux Mint 17.2 - Ubuntu Trusty based& H, C/ U) c% j4 v) p% Y* h
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root% ?# l6 h# Z, ]" p- ]- K
  210.           ;;  b1 P' g9 I. P5 ?5 i1 R6 T) h* a/ J
  211.         "rebecca")
    ! {) Y+ U0 H: l$ \9 s8 e
  212.           # Linux Mint 17.1 - Ubuntu Trusty based
    ! B6 ]( I& {  D& p( C/ h4 f: K
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    % U7 K& F- @* R
  214.           ;;0 E5 Y$ x' c9 Y& T
  215.         "qiana"). B; B. c) W8 Q5 Y& [- C! H
  216.           # Linux Mint 17 - Ubuntu Trusty based- u9 f' Q, U& e4 I3 x5 }  `
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    + O/ o( N$ }- E1 D% @1 Q; R: h8 s
  218.           ;;
    ' [- E  e& D6 |6 w" M3 D+ F
  219.         "maya")
    & u, {8 E$ j* s, f% h8 [
  220.           # Linux Mint 13 - Ubuntu Precise based0 w1 A; o- }8 w  X9 b) K2 J5 q
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    - E5 G5 I7 L5 |% a# W
  222.           ;;) j' J$ F+ O: I7 x: l& Q7 S
  223.         "betsy")2 r1 e6 {% U* E0 \
  224.           # LMDE 2 - Debian Jessie based
    4 N7 m$ o" S) g5 x/ S( x) F
  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
    ( B  Y5 {* q) L& s0 T# j
  226.           ;;2 U; K/ d& z2 [
  227.         *)
    " A/ F8 u1 D9 m. Y8 \. c8 |$ ^
  228.           OS_VER=0
    + K' B# N; b" U4 }' ~+ O
  229.           ;;
    0 w4 X/ X. |5 @
  230.       esac, Y5 A2 U3 U0 S1 B0 J! O( H4 Z
  231.       ;;
    4 a3 u( ~, Y. L) J! R' G+ K0 N. l
  232.     "Ubuntu")
    - }5 v& {! Q1 `4 l+ P
  233.       case ${VER} in
    ; N  o* H6 e1 e1 j2 S: i9 r
  234.         "precise"). S  x6 ^0 T; ?; E# H
  235.           # Ubuntu 12.04 LTS
    + @2 ^8 R( i( h$ z6 I6 f* O" ^
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root! C. Q+ V, _9 ^- x' {
  237.           ;;: `: p7 v, r, f
  238.         "trusty")( l2 Z% c; \) X( r
  239.           # Ubuntu 14.04 LTS# j3 B, [9 N0 g- {
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    3 ?: c4 W7 A/ ^7 j3 r! k( F
  241.           ;;
    2 [" y* E* T4 C$ b) F' z
  242.         "xenial"): i4 ~: Y2 X. n/ C1 R- c, @
  243.           # Ubuntu 16.04 LTS& q/ S) A. ^8 C
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    ) B9 D3 [* l; \+ G7 V
  245.           ;;
    : t' z* K( v( _, H2 X
  246.         "yakkety")5 p, @  ~8 J7 [3 Q
  247.           # Ubuntu 16.10( ?* v9 P) \8 v4 g0 O0 M
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    3 Y/ a: S9 D- n$ c4 x& R% T! b
  249.           ;;3 ]" ^  c& w# r. y) Z1 F! G
  250.     "zesty")
    3 P( F8 S7 s1 v9 d
  251.       # Ubuntu 17.04
    6 m6 S# b# g2 _5 Y0 g. A4 k
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    . X; A: i% x1 P" i7 g4 e1 `- I: p
  253.       ;;' C4 m9 H6 X2 {; T8 }" R
  254.     "artful")
    ! S, m7 c5 e: d2 X
  255.       # Ubuntu 17.10
    ' ~/ T6 J2 F  z5 S& l* x+ D
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root6 k1 n; ^0 b8 o6 B6 R7 h6 s
  257.       ;;
    5 W* u5 W& D) G+ y+ p7 s6 g+ e* `
  258.     "bionic")
      z- i/ u) A6 O9 H& s- P- Q
  259.       # Ubuntu 18.04 LTS
    - c+ L- z* Z+ a  Q& B+ q
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root1 N9 G; Z7 a, U, t5 S: E$ w
  261.       ;;
    ) `, x& W4 c; f+ h9 m# g# E
  262.     "disco")
    5 n8 G  e8 A% w
  263.       # Ubuntu 19.04
    : p$ z% d; u: C- f2 D+ V2 `- O2 `
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root% ^9 f. z1 E* s+ ?4 t# j
  265.       ;;
    / h5 Q( p2 E, L+ T8 b: k6 U
  266.     "focal")  r; V/ J! O7 x0 o5 B/ o, k1 i
  267.       # Ubuntu 20.04. {4 D. }# m: Q$ M
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    " u; m% ~. q. H; D9 K
  269.       ;;7 X6 z# r8 {0 O& h
  270.         *)1 W2 @: A: f' Z- w- |: o* S
  271.           OS_VER=05 Y7 k7 M. t8 A- X
  272.           ;;& B- x# O* v/ B% F4 ~- T6 C
  273.       esac
    9 O( b* r& D! S, }) E& R+ c- [6 P/ K" K
  274.       ;;
    8 u1 V4 s, G9 F% \; q9 U
  275.     "Debian")0 w6 v2 [$ L( S* u9 {/ f9 v2 K( R8 n
  276.       case ${VER} in4 ^5 y1 e4 N- d' C0 a1 a: [: [
  277.         "jessie")
    , n# S1 m" l' Y0 @% y
  278.           # Debian 8.0 "current", y: {$ R; ?3 y
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root! \0 G5 |6 w% u& i
  280.           ;;; F: y8 l" K  W' d
  281.         "stretch")1 S$ o4 b! f$ ~# s1 x: ~" p/ ]
  282.           # Debian Next
    6 D, c& c. J7 B
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    + c" v5 i+ k  d7 j* {! G
  284.           ;;
    9 q) @1 i7 i. K: S
  285.         *)
    / D( Z0 p2 a- d' ^& w! K
  286.           OS_VER=0
    ! {+ C1 l) u( o; d$ h, ?9 O! z
  287.           ;;' `5 Q. S4 M3 z4 `' q0 \  R
  288.       esac* J: _0 J3 W4 M: i/ S' G0 G! S
  289.       ;;
    5 f5 p$ z/ J% v7 H: }+ M
  290.     "RedHatEntrepriseServer")
    $ }9 O" L$ U3 g. o+ T2 F
  291.       case ${VER} in
    + i4 e) h  F0 }. [6 ^8 d7 \/ F, ]$ X
  292.         "santiago")6 l/ K8 q; D. r8 @, {* ~
  293.           # Red Hat 6.x6 X1 s4 u1 C& h" C. E9 {+ F/ J
  294.           su -c "yum -y install curl build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev ace-6.3.3 libssl-dev libmysqlclient-dev libtool zliblg-dev" root
    4 c5 L% H: ]5 l: C4 v
  295.           ;;
    4 w# d' Y& D8 h+ T9 O, N
  296.         "maipo")
    . A; r  n7 I- c( J, P# n  p
  297.           # Red Hat 7.x
    : \1 m; f% H1 X% p
  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) m# S% c! H( H3 y: k
  299.           ;;
    0 t. D/ [# ~. i% w$ T
  300.         *)
    1 V! ~" V0 i- x+ Q
  301.           OS_VER=0* A$ v0 Y0 q8 U4 U1 b; k* X* P
  302.           ;;2 m  Q- A0 n7 L
  303.       esac
    - X$ Q; {6 o) \) t
  304.       ;;. b! M! x7 f! U+ v: M( S* @
  305.     "CentOS")4 b! b0 V2 I& v7 [( t1 p0 f2 n0 q' O
  306.       case ${VER} in9 x$ b% U1 A1 B
  307.         "Core")
    ( W% {  j& A# F* Y( N5 }. h4 ~7 {
  308.           # Default CentOS - Adding necessary RPM third-party.
    / Y# V4 p4 ]+ C
  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.rpm5 Y4 ?& k6 a$ |% a) |& k: y
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm3 g3 q/ I. P( o  ?
  311.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro:/versioned/CentOS_7/x86_64/mpc-6.3.3-42.1.x86_64.rpm) ^' s( Q- F; K* b# N# R* F
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm
    # p% }) ^6 `7 B& \" J1 d
  313.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro/CentOS_7/x86_64/ace-devel-6.3.3-55.1.x86_64.rpm
    3 O' t, Q  v! r; h7 g! y
  314.           su -c "yum -y install epel-release"
    ) N/ ~$ P. s0 L& i9 Q! T8 t$ v5 a) w
  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" root5 C% t; Z: `8 m' R$ `, Z, A; \, l& @6 g
  316.           ;;
    - I3 y. `, L( z! L, v
  317.         *)
    6 m6 D( _1 n" M- c8 ?2 F% n
  318.           OS_VER=0
    5 O/ a- y" D8 V' W# [7 m. d" q9 o
  319.           ;;
    . w% n0 p% x/ v$ B$ E
  320.       esac
    ' h; H' p8 S% o- C- l  _5 T
  321.       ;;* S! B9 J/ e2 y& ]3 y
  322.     "Fedora")9 T* u5 X, i1 t+ ]# u, n
  323.       case ${VER} in
    * {. V/ C3 m' R$ G/ ?6 f# g$ o7 j
  324.         "TwentyFive")) @+ m8 y" m# x1 p3 o
  325.           # Fedora 25 - Adding necessary RPM third-party.2 P/ Z; F- S5 M. L! l6 D6 ?" o% j
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root# S% [$ F. a" o1 n& d$ a' L' w7 l
  327.           # Getting and building ACE. Not provided in RPM for Fedora...% h2 `% ^. Q0 v( D! W1 e
  328.           rm -rf ACE-6.3.3.tar.bz2
    & C* j; C( ~) x0 A5 e
  329.           rm -rf ACE_wrappers
    ) ?; Z2 w: A  V- o
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2' x, v0 u9 t8 n6 r! y
  331.           tar xjvf ACE-6.3.3.tar.bz2* o- q( N4 `% D7 ~/ ^' D
  332.           export ACE_ROOT=/root/ACE_wrappers* S' J" u& m' q: k& i$ D
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h- C2 o) M7 K% e
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    7 @# \( I/ N  j0 N* Y0 d/ U2 B6 A2 O, H
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU& e0 W+ S3 Q' d
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH* l) n* C2 S! z# ]1 i
  337.           CD $ACE_ROOT
    8 b+ @3 _  G7 e" B6 D6 t
  338.           make
    8 Y0 P! H: }' a" z
  339.           make install9 d- `% @! c/ q# S; l7 |
  340.           cd ~
    8 `. }8 [( n0 E, b1 v5 r
  341.           # Installing remaining dependencies..5 u' `' G) K) v: E* o0 A) v& m
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    + y5 |' R9 R$ K, x
  343.           ;;+ o) i" ~2 q$ i' b
  344.         *)( C- U* k- ]2 t
  345.           OS_VER=0
    3 }8 d  p* H' ~
  346.           ;;
    6 e& |9 k* `6 R
  347.       esac
      G- |$ I+ X- D' t% T: }
  348.       ;;
    3 u" i1 i' n0 F* ]
  349.     *)
    ; P( W0 E0 v# ^8 {: {; {8 W
  350.       OS_VER=09 m' G8 k7 E8 A# i. v
  351.       ;;/ p$ ?. u: |: q3 ^9 i1 w7 [" }- L
  352.   esac
    0 j; F$ z: W: @4 c8 w+ R9 m6 \( N  a
  353. 9 |; Y  d; l7 t; \' e
  354.   # See if a supported OS was detected# X$ A* a1 e8 W8 H+ S
  355.   if [ ${OS_VER} -ne 0 ]; then! T" x+ E! n( y* B+ ?$ Q6 m
  356.     # Log success
    # ~! D7 E- e( W/ {: }
  357.     Log "The development tools and libraries have been installed!" 1
    1 ]7 J( Z) D7 k. l* W
  358.   else1 \9 n% A- x6 j# e0 ], q
  359.     # Note the error+ j, Y$ }# ~8 c6 Y% d  K+ x
  360.     Log "Could not identify the current OS. Nothing was installed." 1
    1 c) t% y% }; Z% h9 X, {
  361.   fi
    " e$ W, ^, L  C; L! o3 H
  362. }/ ]5 m1 \0 ~6 l5 c  ]- C

  363. ) X7 o4 H. K: w# d8 G

  364.   B- I# ^7 [2 X, E! k, D" `; W% _8 [
  365. , h+ ^. }7 q0 n8 i/ C. K6 C
  366. # Function to get the WoW version
    % t. U7 i) f- Y9 r) A4 c) u
  367. function GetRelease(); j, r4 m3 r+ I' ^& h
  368. {
    ) S, \4 M# V5 i, C
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    ( X# W& `! E. G, B  c$ F& Z
  370.     --menu "Select a version of WoW" 0 0 5 \
    " U) O+ M! D4 Q* \
  371.     0 "Original Release (Vanilla)" \
    2 k! \3 P6 s! n8 p+ {; \5 q
  372.     1 "The Burning Crusade" \1 g- V* w0 x, [( ]: P
  373.     2 "Wrath of The Lich King" \* B1 S: `( u7 Q
  374.     3 "Cataclysm" \- j8 C9 _4 ]4 X7 U
  375.     4 "Mists of Pandaria" \- b& x0 w3 }! S
  376.     5 "Warlords of Draenor" \7 I  a# f8 c6 \9 A- t* s
  377.     3>&2 2>&1 1>&3)$ J0 L' y9 Y# X
  378. , K; A9 j/ A+ a& N% `7 P* ~3 J
  379.   # Exit if cancelled5 r8 F8 Y& q" Q( m% t+ n
  380.   if [ $? -ne 0 ]; then3 X1 R, t7 h2 d5 f$ [& ?, s
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1
    & ?& l  Y9 t3 S' P' s! Z
  382.     exit 0
    0 r8 ]; T$ n+ q, H$ e: ~- h- ]* r
  383.   fi
    1 |8 }1 N0 O( e# _9 _3 r0 ~

  384. ; L- I: S6 E/ d* N) f) W* ?& v
  385.   # Set some defaults based on the release0 a0 M- {4 i, _; u
  386.   case "$VERSION" in
    , L4 a- Y0 ]3 i0 y1 ]4 u& \
  387.     0). Q! s% v: d& E+ U3 N
  388.       SRCPATH="$ROOTPATH/zero/src"
    # @' g. J* z3 k) |/ K+ R
  389.       INSTPATH="$ROOTPATH/zero"( W( S' O; Z9 _! Z- y2 o8 ~
  390.       DB_PREFIX="zero"
    1 O) S/ m6 T2 @' L5 {
  391.       ;;9 [2 Y/ X$ L( S! _9 k

  392. ) m# u8 K3 v$ k6 w) T
  393.     1)
    " J$ h/ D2 M6 E0 R" M: n" F3 V$ K
  394.       SRCPATH="$ROOTPATH/one/src"5 p; a' A+ f- [6 {* W
  395.       INSTPATH="$ROOTPATH/one"7 M" A% L) H: u7 m. s8 |  P( M
  396.       DB_PREFIX="one"
    " t% O0 i' ]" o
  397.       ;;
    ! ^2 ]# U: J0 c9 c; [2 h
  398. ) A: d# R/ E+ l
  399.     2)/ o* P  W3 j+ E! a1 b/ F
  400.       SRCPATH="$ROOTPATH/two/src"% p2 f; v0 w  u, H, ]
  401.       INSTPATH="$ROOTPATH/two"
    % m/ X/ \5 A, n+ {( {. ?
  402.       DB_PREFIX="two"
    ( m0 ]8 z$ k; `, ~
  403.       ;;% _( x1 v7 j* z, [' D

  404. - C! a6 [* [5 H) N5 ~% z6 ]
  405.     3)% J6 m7 i) F/ w2 V! v) y
  406.       SRCPATH="$ROOTPATH/three/src"0 M$ P0 o6 }0 ^8 g
  407.       INSTPATH="$ROOTPATH/three"5 ~0 E9 t4 Y# I: ]
  408.       DB_PREFIX="three"
    5 d5 P0 T) v" u. g, o5 N0 z7 H+ M
  409.       ;;" z0 o' w- }" G6 F
  410. % [  B- t) e, O* q9 I$ a# @
  411.     4)
    6 g3 }- F3 e$ ]/ B8 P( R
  412.       SRCPATH="$ROOTPATH/four/src"
    9 q" T0 N) P! P0 @0 k- D
  413.       INSTPATH="$ROOTPATH/four"1 x2 h: C+ V. ]$ y# s
  414.       DB_PREFIX="four"
    8 Y5 M8 G! V/ ~" W
  415.       ;;
    $ U3 a& T7 u; O3 J
  416.     5)2 f9 `# g7 n: ~$ v; D
  417.       SRCPATH="$ROOTPATH/five/src"
    ' v, g# A% [1 [2 Y
  418.       INSTPATH="$ROOTPATH/five"
    . T  T& z: u2 w1 o8 U
  419.       DB_PREFIX="five"( f  v! y; X3 y
  420.       ;;# O4 E. A2 j: @( H- g7 b% E
  421.     *)7 G& ?2 c% K8 j+ @# b+ G
  422.       Log "Error: Unknown version selected!" 1
    8 w; @; A' O* B8 G- T5 E, k) c
  423.       exit 1" H& ^6 \2 `8 R  T
  424.       ;;9 K3 \1 G- K. J% N* y# V* M
  425.   esac% G4 a+ G! n# F* D2 Y! R0 q. ~# q
  426. 1 Y8 H9 k; Y, ?3 C$ s; R$ t
  427.   # Now set the correct source path if the repo has been cloned already
    : }" c! H1 b* K% C* Y" y/ x% [
  428.   DetectLocalRepo& Y2 B. s- ]. I, k0 \. E
  429. }5 q4 I9 `* `5 l& L2 R( N- X
  430. & _  O: D3 b# ?
  431. # Function to setup the technical user
    5 h: s5 Q& y1 x$ \( {1 R
  432. function GetUser()
    ; N3 y  p, H! h: a: N
  433. {
    ) C( \1 p( \1 t/ }: k! P
  434.   local TMPUSER="$USER"& h5 I: @7 x+ C2 J
  435. 2 S: a* ]2 E6 A$ @3 U* C
  436.   # Set the user; E3 n) W& P$ `1 ~9 T/ _6 |' K; w4 O
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \
    " Z$ H6 z; K# G5 G, Z9 Q
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)/ Y0 W2 ?- J  v2 X: V+ e

  439. ) \5 `# x. c0 ?5 `
  440.   # Exit if cancelled
    ( O9 w6 k+ A' I+ n/ Q( `, \
  441.   if [ $? -ne 0 ]; then
    3 A- E+ T" b* L0 M
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    6 x; [7 T+ t" s; n
  443.     exit 0; i- `$ I- n" S3 O1 g9 b- _
  444.   fi' \( n# _$ o! Q& z; B: s) O

  445. ) t" B, G* \0 v" C6 r6 F7 U- c
  446.   # Change the user only if it was modified& H/ p# T0 X$ p8 G9 q7 L* M8 ]
  447.   if [ ! -z "$TMPUSER" ]; then
    6 J0 ^3 R9 \  _6 X
  448.     USER="$TMPUSER"
    : M) c, G- v2 J) I
  449.   fi- J( q( b% J3 A1 A! Q
  450. + a8 A! t5 y* s
  451.   # Validate user
    7 A2 d5 M8 c+ \/ D: L- B- X
  452.   id $USER > /dev/null 2>&17 o* b2 J3 M) }; Q
  453.   if [ $? -ne 0 ]; then
    ! e% p/ c! \! b; b+ t
  454.     Log "Creating user: $USER" 1
    $ m! q4 M% G/ s  u# v& m, f
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    % a8 ?' z1 ?6 S1 B* G8 R1 x. v4 y

  456. ! h( _1 J% v3 ^& Y8 f! K$ r1 u
  457.     if [ $? -ne 0 ]; then# C5 J8 ?. F' @( [7 B
  458.       Log "Error: Failed to create the specified user!" 1% Y) P/ c# ^9 ^6 C! s/ u7 J4 V& V$ E
  459.       exit 14 ~  l6 ]8 t, B# f
  460.     fi( O+ N" H1 q+ V1 u: h/ Y
  461. 9 G/ b4 ~. X6 P
  462.         usermod -L $USER > /dev/null 2>&1
    $ j6 r  `+ F  ], e+ a7 z1 ]
  463.   else6 @& x- A: |& u# l* k* g* \2 u
  464.     # User already exist, asking to keep the user
    6 p1 d4 A1 X- ^8 }3 t. r
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \
    8 Q" T5 G/ h  W$ f4 j7 m, h% O
  466.       --yesno "Would you like to keep the user "$USER"?" 8 601 [9 o9 a* F3 z0 ?7 a$ @+ K* K6 \6 ~2 e$ E
  467. 4 Y+ J; `( }' @. [5 d4 \  a
  468.     if [ $? -ne 0 ]; then8 k$ d( }" `% \1 ]0 r1 i, s: p
  469.       Log "Removing user: $USER" 1% k. m( m- O1 A
  470.       userdel -r $USER > /dev/null 2>&18 A$ [5 Z. j' M3 H
  471. 9 h. W8 k4 M1 u0 r0 _
  472.       Log "Creating user: $USER" 1( @: o, ?/ T7 S; b+ Y
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1; ~8 N+ K+ @( s: `7 O6 ?

  474. $ X1 J2 x0 M3 s- g+ W( \# g( z( k& m
  475.       if [ $? -ne 0 ]; then8 ?1 O; j  J" b1 _& q0 r
  476.         Log "Error: Failed to create the specified user!" 1
    0 r! |/ u7 j+ A5 f3 }- U( ?
  477.         exit 1
    ) Z+ ~0 h* b& F7 C7 ]( ]
  478.       fi
    ' S' F8 h$ U$ ^  L& m

  479.   a. L5 w5 R; n5 Q, W3 ?+ t9 o
  480.           usermod -L $USER > /dev/null 2>&1
    2 ]( @8 l& T/ `
  481.     fi
    0 l4 ~, k* `% ]4 x
  482.   fi' e" H6 ~% X& _" n/ b! ], h
  483. $ T5 c1 ~" L' k- [  p0 w
  484.   ROOTPATH="/home/"$USER
    " a4 S2 @2 i# t; i5 c
  485.   Log "User: $USER" 0
    & S, r+ Q2 _( x, Y
  486. }
    5 M' N( A  Q; M# L
  487. : r7 c, Q: A; c" E# d% a
  488. # Function to get the source and installation paths8 ?# ]( l$ S7 ^8 Q
  489. function GetPaths()
    6 S& Z0 r' \5 o% v
  490. {. P/ M9 B. {7 u7 X5 j! b
  491.   local TMPPATH="$HOME". ]3 \+ u6 K; r( d- _( {

  492.   f0 b3 G3 p. s7 D0 ?( D4 ?
  493.   # Set the source path
    7 |" K. T5 _2 Q7 b( q. r1 I: u6 q
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \
    7 _$ ^8 V/ d* d$ ?! z  P+ z
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)7 _1 F$ E) F- e% ]

  496. 7 C" f! t0 u; v& a. T3 }( {
  497.   # Exit if cancelled2 h  W! j5 u4 Q; E5 i
  498.   if [ $? -ne 0 ]; then3 z! k4 h9 V! y$ J4 ~! `9 U/ V5 ]
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 1
    ) B$ f) a  r4 B1 A" ^: y. A2 Y
  500.     exit 06 J0 y. |6 A7 U
  501.   fi" E+ n- V8 d5 u' d  [
  502. . u( T: i  ]4 t
  503.   # Change the path only if it was modified
    % h% h6 a% b" v* Q
  504.   if [ ! -z "$TMPPATH" ]; then8 ]; ~2 s0 ^2 X7 Z6 N  I. N
  505.     SRCPATH="$TMPPATH"/ q: V; {" H% `. e" v# A
  506.   fi
    " n" q) q5 e. `$ X+ X4 v2 s: K
  507. 9 ~% m1 U0 d1 p  E* c4 d
  508.   # Validate source path5 T9 e9 e% d5 s8 O8 c* L" U
  509.   if [ ! -d "$SRCPATH" ]; then
    " {6 ~% [* c9 {+ ]( R
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \: Y$ ~8 r7 H; i7 w7 v
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60- ?( r9 l5 U$ K/ }; ], n6 c
  512. - N. Q3 |5 N; H! M& h) {4 h
  513.     if [ $? -eq 0 ]; then
      {/ u- O, F% a; D5 ^+ v
  514.       Log "Creating source path: $SRCPATH" 1
    7 t! E& V! X8 j# X2 g
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    ) v) i' A  u6 w6 l+ K" s: T8 ]

  516. 3 a# u4 a/ ^* C( G& V( L* k4 j
  517.       # Check to see if the directory was created
    ; a3 D. H" L6 ?8 z
  518.       if [ $? -ne 0 ]; then
    % w7 @& Y/ o8 J& A0 q4 T0 f
  519.         Log "Error: Failed to create the specified source-code directory!" 14 J- E7 z, e6 t, {7 D
  520.         exit 1
    7 _3 A( }" z0 w; {. N. ~$ C
  521.       fi4 e3 K  m" H$ D; e: D# w
  522.     else
    2 Z* F) z7 Y$ g/ u- y6 t2 _
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1% X; g9 h8 j& o1 I
  524.       exit 0
    ) E2 S# W4 k/ a* _  L- ]4 B
  525.     fi- Q4 G2 Q% y4 R+ X
  526.   else
    6 ]/ a- A- j2 y
  527.     # Check for old sources
    3 C9 Y4 n4 k, \$ g- L: d
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then
    2 W# a  I0 g( I- {* U
  529.       # Ask to remove the old sources
    - K5 M( V7 M" i
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    $ S, X' v5 i. F( P
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 60% M1 ~# m) l, e5 n

  532. ) Z# x7 X6 b; Y' V! T* b1 F
  533.       # Remove the old sources if requested
    ) a3 _- o: v) k* H
  534.       if [ $? -eq 0 ]; then3 r/ B+ m4 b! n$ N: ]
  535.         Log "Removing old sources from: $SRCPATH/*" 1$ A; G6 {4 l( n4 b
  536.         rm -rf $SRCPATH/*$ B; }' ^  f) h% X! N

  537. 9 s2 y* v( {, R) H6 ~* L  }' g
  538.         # Check for removal failure
    - a5 r/ ~; D& h; |
  539.         if [ $? -ne 0 ]; then  w3 B6 `, O4 L9 `
  540.           Log "Error: Failed to remove old sources!" 14 H5 k6 o. z- ?: K, t$ o, d
  541.           exit 1
    . A: W$ L+ K8 i' Q6 d
  542.         fi
    2 L) ]+ D/ N8 ~$ D1 }
  543.       fi
    8 b8 d' k# w4 M$ F' a* p2 s# M
  544.     fi$ ~' H- N$ [  |0 [! k( D2 j' g
  545.   fi
    & V9 p, c5 Z: i  }, S+ V$ C
  546. # w8 @- E! M; r1 Z6 K
  547.   # Set the installation path
    . `  H, A  _3 z) K( `: v  V
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \
    ! t, `3 e. [, J0 j' h
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)4 J0 U: ?( q7 c7 K

  550. 1 ^- k! J; S6 H- Q8 _5 t8 L
  551.   # Exit if cancelled: {: @7 |8 r% u* [2 `
  552.   if [ $? -ne 0 ]; then% V6 |, c$ |$ u) O$ F  n
  553.     Log "Install path selection cancelled. Only the source path has been created." 1+ V, l6 a( }# C0 C
  554.     exit 0/ @3 W) m. K8 P: v6 {7 p8 l" u
  555.   fi8 |# Z8 W) j, `6 \. z. C0 T
  556. + r2 O2 s) o: Y6 U$ h
  557.   # Change the path only if it was modified% L& K3 j% w& B1 H5 P
  558.   if [ ! -z "$TMPPATH" ]; then
    6 x% ~' W% Z. [( F
  559.     INSTPATH="$TMPPATH"" k2 }* V9 E: P& ~, `- ?
  560.   fi
    " V  X! J( R$ J. _& @5 N

  561. * U$ `. O0 `' X; Z: I3 m& T
  562.   # Validate install path: ?4 l) g4 \% J0 e, s
  563.   if [ ! -d "$INSTPATH" ]; then
    + z& C9 y" A& t' V. n& L
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \
    # n- i0 z- v2 X2 u; y! @* g5 F! k5 a
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    / G0 x& }& Y0 g3 k' P+ i

  566. " @: O; g- O0 O3 a" L3 K, l! ^; |
  567.     if [ $? -eq 0 ];then4 @) ^' I0 n! [/ h8 T4 Z6 ~
  568.       Log "Creating install path: $INSTPATH" 1
    , d  @! c8 W$ n9 G
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&14 Q% ^' R$ m  u

  570. 9 e- {: c" s5 h7 O0 T. q
  571.       # Check to see if the directory was created6 `" T' E* l! v& M
  572.       if [ $? -ne 0 ]; then
    8 m7 X, H. X$ D* [1 N9 |$ l
  573.         Log "Error: Failed to create the specified installation directory!" 11 P9 s* f, u# Q8 ~
  574.         exit 1- x' f8 o( }; a/ p* e
  575.       fi2 M* l( w: u: Z! K- o! T4 M
  576.     else
    5 o, o. y: p5 `) i. F! Q' _
  577.       Log "Install path creation cancelled. Only the source path has been created."
    7 C/ w$ }. t5 M$ H' k  {; i8 a
  578.       exit 0
    2 @! ~2 C' c) E# w$ p- W
  579.     fi5 Z- x1 I+ U" m2 j
  580.   else
    ' j- E8 `! M4 J3 Y' A6 X  {% t
  581.     # Check for an old installation
    - m( a! ~2 s9 q8 M
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then3 s$ N' V( W( I0 Y1 H6 [
  583. 1 q  e9 p' o( l$ b" J
  584.       # Ask to remove the old installation
    9 @3 m5 J8 V6 s" O% n/ a
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    ' N; ~$ g* N0 `# z4 M+ L! }
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 0
    " C# o: z+ m- l! }% V  F# U! _

  587. : Q7 N9 P7 c* ~! ^/ ]2 ~3 A$ L
  588.       # Check the user's response& K* x0 Q6 A9 T/ d! R7 i
  589.       if [ $? -eq 0 ]; then
    + K  }/ I# w: [! \( @! H
  590.         Log "Removing old MaNGOS installation..." 1
    - i1 g4 g, U* k4 b3 ^3 g% _
  591. * |0 z: D8 x* y+ u, R
  592.         # Clean up the binaries, G% F# {. z4 j9 s+ Y6 Y
  593.         if [ -d "$INSTPATH/bin" ]; then
    & q, O/ v- L; D, o
  594.           rm -rf $INSTPATH/bin. B* o4 w* R" Y2 w: H  r/ y
  595.         fi: [0 z4 ~; \+ M# d- L7 a

  596. & o  T% H1 ]8 w8 Y/ C
  597.         # Clean up the old includes8 E* X/ Z# U6 u! D( h" u
  598.         if [ -d "$INSTPATH/include" ]; then
    ! j0 `* F: O* _; [; F2 {* X
  599.           rm -rf $INSTPATH/include5 Z2 e! D* H8 L% o" v4 ^/ [2 y
  600.         fi
    & V8 g9 c  Y" |

  601. . K% `" ?1 c9 E1 C
  602.         # Clean up the library files" B4 O" m. [8 t* r) O# U- {" y
  603.         if [ -d "$INSTPATH/lib" ]; then
    % G# ^6 g: @4 N$ i; o4 @5 y
  604.           rm -rf $INSTPATH/lib
    9 f8 O. x6 J0 C: ^, b( R1 _
  605.         fi
    , g, r) m. o. l, L2 \3 b, @
  606. 6 W7 L1 g8 ~- A' v1 {  ~
  607.         # Clean up the old logs
    / e- d, l4 L: b$ M* E: R
  608.         if [ -d "$INSTPATH/logs" ]; then
    ' h1 |7 B) l. M6 @+ F' `0 c
  609.           rm -rf $INSTPATH/logs/*
    . ~( Z" s1 l% B' P) c4 i# ?5 D
  610.         fi9 _, c4 I* q7 A; \
  611.       fi
    / G+ D! [, h. f9 ~: M
  612.     fi
    " y! @# }. j3 m) V
  613.   fi4 ^  _$ F3 D4 k& O8 B9 }

  614. % N$ {- ]+ V# h7 ^7 U
  615.   # Log the settings: J( B+ w( J8 B  {% d% c
  616.   Log "Install path: $INSTPATH" 0
    , g. e. V% g& B: Z* a  t, [3 Y
  617.   Log "Source path: $SRCPATH" 0
      ~1 P  X' A3 R7 e8 R
  618. }
    9 s7 k9 d" H6 g7 A, l' ?
  619. * O/ |+ U) K9 d$ D0 z* h

  620. ( F  q) G8 o7 a! N

  621. 4 T5 G; L+ k8 S% t
  622. # Function to clone or update sources
    & R+ Z9 e. V+ \; I
  623. function GetMangos()+ m. m# i  d9 ?
  624. {
    " F0 f& H7 ]& [+ U5 q
  625.   local CLONE="0"$ s6 ~8 t0 ~: y- I! s( Y8 O
  626.   local BRANCH=""# C' ?+ q/ }+ ~  o4 e8 `

  627. 6 H6 L# B) v+ d+ r! l+ Y' {
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \$ }9 ~3 I9 ]  [9 V6 ^
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \
    1 X" A& j( g% [0 U) M* u4 R
  630.     0 "Clone a fresh copy of MaNGOS" \
    ; b1 j, `0 F' K4 w0 m, _
  631.     1 "Update your existing copy of MaNGOS" \
    ! E2 x9 F! _- d6 {) w0 ?' C
  632.     2 "Use existing copy" \0 c, X1 n0 K8 ^4 y. w5 I
  633.     3>&2 2>&1 1>&3)
    / `0 W" A* U: }( f  s

  634. 3 x# {) ], B2 Q. ?
  635.   # Exit if cancelled
    % }( Y& e+ Q* r3 t+ N
  636.   if [ $? -ne 0 ]; then- |! o, {/ O' }/ |1 `( l# G
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1+ a; N1 Q' M( o) L
  638.     exit 0# [0 @4 r9 ?  v2 A
  639.   fi& J8 y7 N- f( o4 u, Y& _

  640. ' \$ o7 f  n0 \+ a. K( x
  641.   # Clone from scratch if selected( e8 G0 |& I& D/ [
  642.   if [[ $CLONE = *0* ]]; then( v6 @& {, `# ?7 E, a/ J
  643.     # Pull a different branch?
    3 ]/ g! ~# V$ o, |- i( K' h
  644.     case "$VERSION" in* a% O7 Z$ W) B7 ]( F
  645.       0)
    ) N& ]3 f+ b3 M/ ~6 [' H. z
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    + ~- \! a  I( @' ]7 r  L6 u. r
  647.         ;;- ~. k9 b0 ]% @/ @; [6 T
  648.       1)
    9 H& C5 H9 x' Z1 k( q8 M
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    4 r$ G) Q9 C0 D7 Y/ {; j
  650.         ;;, O  G8 a: D4 H0 Z1 o
  651.       2)
    8 w+ v, C/ W" W. o, }$ b
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')* R- n4 Q) c1 A; v  d( z/ v, m2 J
  653.         ;;
    6 X  Z( E: ]9 b, |
  654.       3)
    9 F- j/ D; {! u9 B8 x( C9 p
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    + P9 I5 j! W3 t: H& X0 [) J
  656.         ;;
    . m/ N3 f& ?+ p# q
  657.       4)+ Q7 B  r7 x5 n$ I, m; E5 P
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    8 Z6 ^- d' R- f& v- `$ w; K
  659.         ;;8 V- Y, C' y3 c+ `+ c
  660.       *)
    5 u4 _* D$ b! j( `& _& E. L2 }2 R) f
  661.         Log "Error: Unknown version to select branch" 1( \; y+ [+ o- V! l$ Q
  662.         ;;, g" z& Z' A/ o, e7 S
  663.     esac# `# \7 c. c6 Z+ b4 h

  664. 1 R3 L; x, d9 b' |6 K$ _
  665.     COUNTER=1
    : U4 a( A# H: i/ U
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog
    2 ]. M1 L. e( A3 W7 A
  667.     for i in $releases; do
      E1 u+ p. F: ?; q1 K7 F
  668.       if [ $COUNTER -eq 1 ]; then
    ' n' D9 `3 ?( c$ B
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "
      ]8 e' ~1 s1 T+ e2 u, z
  670.         BRANCH=$i0 D8 Z5 Z" n" h1 S
  671.       else" Y+ v, U( V3 F
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "
    , B8 C  r: T9 x! d* k6 S: ^
  673.       fi
    ; x- C$ g4 L) ~( a& n# g8 H1 `( W5 I
  674.       let COUNTER=COUNTER+10 e. z) N( V+ N/ e& |
  675.     done* Y, }0 M2 z! V9 E& Z- p

  676. ; S, |1 u! v5 ~; S- c0 X
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \
    ; j6 s4 b, ^% f8 Y. z- }
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    3 O; i2 g$ N$ Y# h" n! b+ A. _- m2 n+ R
  679.       $RADIOLIST \* A2 T8 T8 S8 c) y9 u4 x
  680.       3>&2 2>&1 1>&3)
    ( c2 G6 B4 _$ y

  681. , H7 {- D3 v( j# ~6 p* F
  682.     # Exit if cancelled
    7 c2 N% ?9 y. Y( w+ p0 s, q
  683.     if [ $? -ne 0 ]; then
    . G8 w  q9 V2 K4 K
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1
    , E9 D( m% q: g& a
  685.       exit 02 v4 Y5 l- g# ~6 W
  686.     fi
    / L2 \1 }' q4 u3 p3 t

  687. " C7 o9 d" E6 x- ?0 N
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}'). U9 m  |. p0 w$ t$ f* ~
  689. 0 [( i( M2 _( K
  690.     # Set the branch
    # y; m$ H# @! O* W1 q9 H: M
  691.     if [ -z "$BRANCH" ]; then& }0 y' r% z/ K/ |+ d2 [
  692.       BRANCH="$releases | awk '{print $1}'"4 C; l7 c) I2 ~0 Z0 u- J4 ?
  693.     fi
    7 W* y5 m1 s. W" }
  694. 9 Q2 ~) \1 i1 Q& @+ f! c5 M
  695.     # Clone the selected version* q( F. n; F1 G
  696.     case "$VERSION" in
    ' k5 |" n2 U/ h! c( h& A7 x
  697.       0)
    0 p2 C4 I; k* C& I/ Y
  698.         Log "Cloning Zero branch: $BRANCH" 1) l3 b% V( _3 |9 s) X
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive) x$ ?0 p& @: Q" l, s
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive' l, T" ^- m% ~- A" j$ ~% }5 o
  701.         ;;
    ! m  X, L; V8 N4 p6 c7 G" q* {

  702. 2 {- _3 H7 {% N7 ^' |$ k
  703.       1)
    * \# T) \& B+ F- A, i
  704.         Log "Cloning One branch: $BRANCH" 1
    : O1 }$ T! ?( P$ E. o: r+ ?2 H9 f
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive. x# q6 j% N/ V- m
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive  m5 L* H+ K+ N& [' m0 p
  707.         ;;) V5 w- T" z2 L. I/ a: e. {
  708. # Z, T% y) v' v! M! S6 c
  709.       2)) ?( b  x8 D. C. m' Z, a; v- a
  710.         Log "Cloning Two branch: $BRANCH" 1' @: c  c: t) R
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive
    . Z' P7 P. n8 q) z( V; T& J
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive
    3 ?2 h& i2 j9 y0 f& m6 u
  713.         ;;
    * m8 M/ r9 X# ^; T0 @8 a
  714. 6 d$ k( ?4 j, n" x) G0 f) ?3 w4 Y
  715.       3)  D3 c6 c: h$ I  _9 d
  716.         Log "Cloning Three branch: $BRANCH" 19 L0 g7 e- Q% z. M
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    # G$ u; z0 M; i% @8 w- G! L5 t
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
      B& Y! b+ n- X4 j! `
  719.         ;;0 y) @* {' h2 k; F6 ]

  720. - t% `; u" i% `4 j4 p/ m) j7 g
  721.       4)1 X' G; @8 o7 `5 r; H. ?( t& ~
  722.         Log "Cloning Four branch: $BRANCH" 1
    7 `4 e, m( v" }1 b- G
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive# S) z9 g3 O5 a2 [# C8 ~2 S
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive" b+ @1 z+ z. O
  725.         ;;
    ' B7 k- a  F8 R1 Q; O0 Z

  726. - F6 V4 j: t1 x9 i) d& ~
  727.       *)
    * ^2 k* x. {) e
  728.         Log "Error: Unknown release selected for cloning!" 19 ]/ S, ?( f  G! @+ P
  729.         exit 1
    1 n3 |) ?: ~+ m: J6 b& F+ s
  730.         ;;
    . w+ m3 l6 I* g* l9 X
  731.     esac
    : x* }; t9 |9 T8 r% I% \. M
  732. 9 Z: O& N2 I+ O+ h2 s( H  m4 I
  733.     # Log success
    ; i0 G$ _4 }" m: ]! B
  734.     Log "Cloned the selected repository!" 1
    2 A) I5 w# w' a5 i
  735.   fi
    0 z8 O, @3 Z6 }5 f- v
  736. 6 V, R: {5 L9 J5 L" K! {% l" E. m; l
  737.   # Update the local repositories if selected! W8 p3 [& t  W
  738.   if [[ $CLONE = *1* ]]; then" C. J- h6 a5 Y+ x
  739.     Log "Updating your local repository..." 1. g/ I; u8 n* v4 i; O& y8 Q( w

  740. % z* q) K! J" l# f+ [
  741.     # Update the core sources1 a( A( V( S, }9 ~
  742.     cd "$SRCPATH/server"& P  `( b" ]& V8 R* O: X
  743.     git pull
    5 o; ~, l! v% ?' `( `" u, D

  744. " c: b/ y0 T- a" G" i0 y! T& E  S: c/ u
  745.     # Now update the database sources
    2 J3 _2 O* P7 o# Z9 d+ U$ h
  746.     cd "$SRCPATH/database"- d) J3 m6 ]$ k' `! D
  747.     git pull
    ( [* O2 Y3 D, @* }+ G

  748. % Y+ ^7 z4 h0 Y
  749.     # Log success  H3 c* \0 W$ Y* o! m. F
  750.     Log "Updated the local respository!" 1
    , y7 ~9 |! `/ T+ |/ C) n: U$ X
  751.   fi
    - w" e$ J( f5 R& Z; n6 v! [
  752. ( ~' e2 u  {6 x9 j
  753.   # use existing repository8 m5 z& F% R. J# z/ ?9 r  w
  754.   if [[ $CLONE = *2* ]]; then# ?5 s9 p2 y7 o2 ~' K: d
  755.     Log "Using existing local repository" 1" l/ B0 _7 V7 F8 ~) N% G
  756.   fi+ |+ G  T) w9 c9 \
  757. }1 U! K. C6 W! Q) X! G0 d" F
  758. + X% j& a* B6 ?- l# s0 J

  759. ) l3 E; e6 R. d
  760. 5 f) L  t0 W) T8 \" Z5 D
  761. # Function to set the build options
    $ e$ B- ^! t4 X: N9 n. B; M) u0 ^
  762. function GetBuildOptions()
    - n* I: x7 Y8 @, ]
  763. {( W9 I, t& Y% s- D
  764.   # Select build options
    / |4 a: |, i/ v
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \( }. s8 [) [# d/ P/ H  P
  766.     --title "Build Options" \1 m# E9 ], `+ k* }( A; {- k
  767.     --checklist "Please select your build options" 0 56 7 \
      U( }+ }' J. \3 _$ x" e3 o5 i
  768.     1 "Enable Debug" Off \
    4 R5 a/ |) c) [$ C* }  r
  769.     2 "Use Standard Malloc" On \1 O8 C( ~( S3 ^
  770.     3 "Use External ACE Libraries" On \6 Q8 m1 c' V0 W  [: V) w6 |5 V
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    $ _2 l5 s, L4 a/ m
  772.     5 "Build Client Tools" On \/ L. V9 b, N. U/ E1 R# \. x4 [+ j/ D
  773.     6 "Use SD3" On \
    " V5 n7 ]  r; O5 @# e4 j2 K8 E
  774.     7 "Use Eluna" On \4 |% @, S/ K9 \& E4 s7 n" J
  775.     8 "Use SOAP" Off \8 p! U2 v7 y3 u5 O! c, A/ S
  776.     9 "Use Player Bots AI" Off \
    6 y( t  U( R/ O( j
  777.     3>&2 2>&1 1>&3); r- F1 o; S# u4 k5 G
  778. ( u& O, e6 [; S: g* Z4 C6 y
  779.   if [ $? -ne 0 ]; then8 _3 y) |+ K3 G& W" ~2 k3 K7 l1 `5 w
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    5 P6 x# \$ E) M1 f1 e: c
  781.     return 0
    " y+ w* _2 B1 U
  782.   fi" g! y, r( k2 c/ c
  783. " l1 H; g# k* u. Q$ g# X
  784.   # See if debug was selected  r/ k. S- O0 h1 x
  785.   if [[ $OPTIONS == *1* ]]; then  j" H4 s- P+ a1 v1 {' p5 ?/ r
  786.     P_DEBUG="1"8 ]9 V9 k3 }6 d; g) ?8 P
  787.   else
    ! w) t: b! \' E* p8 B
  788.     P_DEBUG="0"# n. X) ?$ m! F, t0 c: t
  789.   fi+ N5 G1 y7 t& K7 r9 s7 q, Y

  790. : c# G  d5 N( K+ L
  791.   # See if standard malloc was selected
    # i# C8 l" i0 @5 s$ G; [
  792.   if [[ $OPTIONS == *2* ]]; then8 `6 l9 \/ U, Y' ^4 r1 G* J
  793.     P_STD_MALLOC="1"
    ; ]5 {1 c+ b8 N5 s, P0 p
  794.   else5 A- t# X' F8 S9 d8 R1 O
  795.     P_STD_MALLOC="0"2 J- Q) J: w8 {& J1 d! N
  796.   fi# I: F. P8 C1 x/ i$ `# ?
  797. 3 X  \8 Z+ L4 ]5 {' s
  798.   # See if external ACE was selected
    2 w* M, k/ i  _/ ~/ K2 T/ M+ l
  799.   if [[ $OPTIONS == *3* ]]; then
    - L! b# u& O/ J- D5 F. p& y% P
  800.     P_ACE_EXTERNAL="1"
    + C. {" x& c1 m/ o+ E6 m8 a
  801.   else. b* y! c8 d* i/ w+ e; O
  802.     P_ACE_EXTERNAL="0"  q( Y0 T. T/ b$ b9 a4 `- L* T
  803.   fi
    % _# W& }% Y) G

  804. - U1 }; o% j, I
  805.   # See if PostgreSQL was selected0 T+ b* Z) e' B; t1 z
  806.   if [[ $OPTIONS == *4* ]]; then+ ~/ {+ `* ?( o& v
  807.     P_PGRESQL="1"
    + Z* E; l1 k: C) X! J, N7 X
  808.   else
    : r0 r' M& {9 i$ m2 A
  809.     P_PGRESQL="0"
    - ~' U2 J4 e; p2 C- h
  810.   fi9 O9 o5 `  m5 ], s/ x" h: A0 l

  811. 6 @  g  Z6 `+ N3 h$ J& t" M
  812.   # See if the client tools were selected
    $ W! W- G) Y; @1 v' X
  813.   if [[ $OPTIONS == *5* ]]; then
    1 p2 J& ?, y1 f! y) J; W
  814.     P_TOOLS="1", _/ S" h* u5 b- Z8 P
  815.   else
    , D. N; b  J2 `3 B/ E! u. ^
  816.     P_TOOLS="0"
    7 O: d  |+ F1 o) ~* k
  817.   fi
    . T9 A4 |, |1 r# w# a/ ~
  818. 3 @1 x- O9 X: L- P* y2 I, o
  819.   # See if SD3 will be used% w. o8 Z! s- Y5 n. [9 D
  820.   if [[ $OPTIONS == *6* ]]; then
    $ T6 i  V; r1 t! A, O+ q
  821.     P_SD3="1"% s+ `6 x2 v* q* J: U# `
  822.   else' C. ~" H6 p% o
  823.     P_SD3="0"+ w; o: Q6 c2 ]# @3 v1 W2 G: B
  824.   fi( L5 }: m( _+ B: ^
  825. ' O$ V1 ~( h0 ?4 C( H: D
  826.   # See if Eluna will be used
    ( O8 T0 D* o1 Y/ S; S
  827.   if [[ $OPTIONS == *7* ]]; then
    0 V+ u- M4 A  K6 Z6 ^* }; i
  828.     P_ELUNA="1"
    ! f) Q7 K( \+ p+ w& S, @. a: D
  829.   else9 Y& Q) I. x: k4 b- o
  830.     P_ELUNA="0"
    - u  L9 H& }& L) X/ M/ u  C* x
  831.   fi
    ' Z; o; c( x9 ^1 r1 g6 u

  832. - z3 }; X% }4 W
  833.   # See if SOAP will be used
    1 |9 O) Q  c8 S  f
  834.   if [[ $OPTIONS == *8* ]]; then  J2 C8 B! `+ i
  835.     P_SOAP="1"9 c) P; R; _* ?5 d; Q3 @
  836.   else
    % D( m3 r3 Z, K' H
  837.     P_SOAP="0"
    ( ]3 T- K4 y$ j2 w
  838.   fi
    " C+ x/ R: Y' f
  839. : E  G7 z3 [6 d, o5 B7 D9 m) A( C
  840.   if [[ $OPTIONS == *9* ]]; then: m$ N% @4 ~+ G$ Y
  841.     P_BOTS="1"- `4 X5 R4 Y( c' Z/ O
  842.   else0 F+ h* n1 r, D
  843.     P_BOTS="0"4 N5 v) Z2 s5 p. G' f. q
  844.   fi' B/ S2 R9 z$ Z3 \9 T

  845. 1 a9 G' M) f3 U( W. W5 @0 z) \
  846.   # Verify that at least one scripting library is enabled
    0 E/ }8 {8 P  i6 A1 Z
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then
    ; e' p& K% Q; H8 m1 p+ d
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1
    2 a; J4 }# g; M; o# u0 i
  849.     exit 1
    0 P) _; G: r& m2 |, [3 @  ^
  850.   fi9 W; c  t. L3 b) o% O/ {$ B
  851. }
    ( k8 R; @4 C7 Z' x+ X6 R" G

  852. 2 i& y0 ~, x" D

  853. 6 |( p% R7 X; u, _, z8 ^  P5 P

  854. 8 Y" z2 ^6 R& ?3 J( i7 O. A' T
  855. # Function to build MaNGOS3 B  t% D  A; ~; {* h$ _
  856. function BuildMaNGOS()/ A. K  `$ x- h7 V5 R8 a9 ]7 h
  857. {
    , P* H. b0 M5 o. \/ ?% a3 M$ }% Y
  858.   # Last chance to cancel building
    : G1 z. K$ ]1 q+ B/ M- L# U
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \
    8 x% @" r3 N2 B
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60
    / O7 E+ ^+ `* d5 Z2 b9 c
  861. $ o8 U1 b$ P" \( E: A: [! d2 n8 a
  862.   # Check the user's answer& E3 X; O. K& n
  863.   if [ $? -ne 0 ]; then- P; ?, w2 b; O2 x* i# v+ }
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1
    5 Z" g. i% ~/ c1 e2 V) ?& s9 \0 Z8 i- w
  865.     exit 0
      p, Y+ ]+ d& M6 N% v
  866.   fi" \5 ]' J" e% o) \4 U: v

  867. , ~0 k$ E/ E: e9 g. ~$ {4 @
  868.   # See if the build directory exists and clean up if possible7 ]+ B6 H2 ~9 x2 q" T
  869.   if [ -d "$SRCPATH/server/linux" ]; then: S4 `' X* @: s3 _4 M
  870.     # See if a makefile exists and clean up9 B, @/ A" j9 N6 ?2 @: @
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then9 l# ?( i8 B/ G; Z' V
  872.       Log "Cleaning the old build..." 1$ E+ @$ o/ W1 b( R/ f9 c1 |
  873.       cd "$SRCPATH/server/linux"( ~5 Q+ d9 K! h6 x6 N# l9 [
  874.       make clean0 `6 U2 D7 N+ b1 }* P3 q
  875.     fi
    $ q2 i3 N& l1 W1 S( ?" u
  876.   fi8 L) S  _; U: o- l' |

  877. 0 t3 h: N6 f- g. m- \/ w5 T
  878.   # Attempt to create the build directory if it doesn't exist
    ; j7 b* ~- H; g3 v3 P# `
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    7 s% y7 d2 N: ^3 y% b
  880.     mkdir "$SRCPATH/server/linux"5 U3 t. {0 g3 S/ A, |
  881. ) }  _5 g, C. ?' T) b( V
  882.     # See if creation was successful- A: `9 V7 s4 D0 @3 g
  883.     if [ $? -ne 0 ]; then
    6 y+ T  r) E) V5 }/ c" p' `9 D
  884.       Log "Error: Failed to create the build directory!" 17 s8 n3 O3 L' J2 ]3 [
  885.       exit 1
    ) ?+ l, M7 s* c: ^2 h$ w. `
  886.     fi
    : A  s% B4 r+ M3 k( M
  887.   fi
    ' W' ~. B/ e9 U- z
  888. ; _. l2 y' e, X% G7 n3 p
  889.   # Attempt to configure and build MaNGOS  ^% H* Z& Q5 U$ ^$ @7 H
  890.   Log "Building MaNGOS..." 05 B. K5 }  ~/ M# J: }
  891.   cd "$SRCPATH/server/linux"
    # m* L  ^  Z  d+ j% x, ?
  892.   # make sure we are using the cmake3
    ' A! G4 O% D8 w# g  S. _6 {1 |$ U
  893.   UseCmake3
    ' c- Y# L( q3 `# \# u2 g
  894.   $CMAKE_CMD .. -DDEBUG=$P_DEBUG -DUSE_STD_MALLOC=$P_STD_MALLOC -DACE_USE_EXTERNAL=$P_ACE_EXTERNAL -DPOSTGRESQL=$P_PGRESQL -DBUILD_TOOLS=$P_TOOLS -DSCRIPT_LIB_ELUNA=$P_ELUNA -DSCRIPT_LIB_SD3=$P_SD3 -DSOAP=$P_SOAP -DPLAYERBOTS=$P_BOTS -DCMAKE_INSTALL_PREFIX="$INSTPATH"' ?3 s! T4 V5 Y4 ~  W5 k2 j
  895.   make- Z3 i1 e, S" h9 y% n& j

  896. 8 R1 Q& X' i9 G
  897.   # Check for an error; m; I) g- y& i% r& I
  898.   if [ $? -ne 0 ]; then+ @0 u: S# H/ h- Y0 f# _
  899.     Log "There was an error building MaNGOS!" 1
    1 Y: W3 W% K# O0 F; B" H
  900.     exit 1
    7 H) |4 N+ o9 O* L9 \! o, M( D8 b
  901.   fi
    / s# ^2 R# {' J9 n: i* ~. V
  902. $ @3 W' O( a. M* q, m- U  R
  903.   # Log success
    & J; y8 k/ |1 e8 H1 W
  904.   Log "MaNGOS has been built!" 0
    ! y% b. \7 u: ~4 K' z3 @
  905. }0 T6 N, ~) Z. u9 b% o
  906. ; i4 Z- U/ P% Q

  907. - _) ]: I5 ?, h% M4 T4 Y0 w2 D, I

  908. 0 p$ S( D3 `* U. Y* p9 U- K
  909. # Function to install MaNGOS
    , ]0 c+ u6 X% K  O9 L1 ^& H6 j
  910. function InstallMaNGOS()" y$ K% @- \3 h% b2 c
  911. {0 P: t3 e9 R5 _
  912.   # Ask to install now/ M4 ^* Q) c# A7 v2 m$ c# @
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    ) c5 n7 O/ d* P1 c3 U1 N
  914.     --yesno "Do you want to install MaNGOS now?" 8 05 _- }% J- U9 B/ S

  915. ( v- [' c( ]9 u6 @8 y+ @8 W
  916.   # Return if no8 v! C( [% r5 ^% R& p
  917.   if [ $? -ne 0 ]; then
    - K7 Y- D  s  P. ~& b  I
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    " Y+ C! {/ T3 `2 u8 D& `
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60! u, a' \! N% C% D

  920.   \0 p& K- a4 W4 Q5 Q) _
  921.     Log "MaNGOS has not been installed after being built." 1! _" u* \2 S& I$ b
  922.     exit 0
    3 \; Y' S2 V7 L/ Z& r
  923.   fi
    + g7 t) A, E; B1 r
  924. 6 a/ X' V4 {3 E
  925.   # Install MaNGOS, E/ u# m; R  s: I
  926.   cd "$SRCPATH/server/linux"
    ! K$ [2 ]- l% s8 j" g
  927.   make install" b0 a& {" `/ i

  928. 0 J3 g3 x2 L! T- t7 n8 w, L
  929.   # Make sure the install succeeded
    & y  l6 Z# `& D& ^( B! C
  930.   if [ $? -ne 0 ]; then% H! ^5 l* R& h6 B& h
  931.     Log "There was an error installing MaNGOS!" 11 t3 s! K' D4 ?7 q
  932.     exit 1+ ?  Y  V' z. {3 {3 B) E% \
  933.   fi4 w* E# J; C; K3 N+ S, M+ N: K: E6 j
  934. }
    + T. L3 c2 H% n( P4 i) B

  935. 7 ?3 w  N. {9 c0 Y! c8 c; G
  936. # Function to apply database updates
    8 H* s. q4 |5 a# _* K
  937. function UpdateDatabases()& W5 g2 n3 e& q# o# {
  938. {- u7 g% m: R' U; Q- T
  939.   local DB_HOST="$1"6 U9 E2 _2 w$ X( `
  940.   local DB_TYPE="$2"& V' ?8 |7 B* D2 g# `9 Q
  941.   local DB_COMMAND="$3"( G) N6 e! U8 }% T  x2 y, J
  942.   local DB_USER="$4"
    2 B3 a4 Y& y. S3 y. y: C1 o
  943.   local DB_UPW="$5"
    3 z  N. b3 ]! f# e0 k2 z
  944.   local DB_REALM="$6"
    0 j# c( ?( F1 S" m9 n9 J3 y8 f& v
  945.   local DB_WORLD="$7"
    " y, M( [6 F: R7 K. G, S. ]" O
  946.   local DB_TOONS="$8"- s- V5 w0 H# H

  947. 0 H1 E; `  E6 _9 r4 {
  948.   # Loop through the character files$ ?+ ]/ M# X/ @0 v+ P* G0 X4 S
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do6 l: P$ X! `# ]+ l. K- x
  950.     if [ ! -f "$pFile" ]; then4 R! R4 l) ^+ i$ g' u6 z. K
  951.       continue/ ^& w" s" i+ x* l! X
  952.     fi
    1 t# ~( R2 t: z- _2 t, U7 l3 G7 z
  953.     # Attempt to apply the update2 B6 D0 Z5 r1 z
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1
    , Y% f; W. a$ n  x

  955. ! {; x6 P6 t! n; d
  956.     # Notify the user of which updates were and were not applied
    % T% \/ F7 i3 E/ X* S& \! s% t
  957.     if [ $? -ne 0 ]; then& k# k7 l: \& z) J
  958.        Log "Database update "$pFile" was not applied!" 0
    0 ]2 N' d9 D6 a, V+ n
  959.        Log "Database update "$pFile" was not applied!" 1
    + Z# ^- N% o8 l1 S8 I
  960.     else
    5 a) h2 G( I2 C& a# K
  961.        Log "Database update "$pFile" was successfully applied!" 0
    3 P1 n8 x  d% O' ~& v% t  A! C
  962.        Log "Database update "$pFile" was successfully applied!" 1
    1 C( \. _. x. S! y0 n: p
  963.     fi! Y, F- S4 c5 \& W; J& x, F
  964.   done- Y5 _% d/ R# H/ h; _% p+ ]

  965. " c" v; k8 K. v0 ]( m! B
  966.   # Loop through the realm files2 e/ U5 T$ x; l& v! B1 I
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do9 u; t9 a, v. Y5 s: s2 k) t
  968.     if [ ! -f "$pFile" ]; then
    & x* s8 ]9 i  [+ K% W
  969.       continue# l3 k7 {2 I. o  W4 f! u; X
  970.     fi
    8 Q: A9 m; f7 O0 T8 y+ X/ X
  971.     # Attempt to apply the update
    . p0 W! q8 K- o
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1
    0 d; r) k* K2 N# {1 k: h

  973. 7 K8 N* d8 _* L, d/ x  s2 z5 u9 k
  974.     # Notify the user of which updates were and were not applied
    ) e3 t7 J0 F  g3 L: ]% o
  975.     if [ $? -ne 0 ]; then
    , b1 Y; a; N& |, L2 X- S1 `
  976.       Log "Database update "$pFile" was not applied!" 0
    & H0 V# p% a6 r9 i1 n+ N
  977.       Log "Database update "$pFile" was not applied!" 1$ b4 z6 {+ y0 C2 @, r  C% j
  978.     else
    ( {) H( @4 k* O- U, p5 F. \
  979.       Log "Database update "$pFile" was successfully applied!" 0
    ) C  u$ P/ E2 D" f4 E) _6 T
  980.       Log "Database update "$pFile" was successfully applied!" 1- T) a' g, w* U) b0 c# p5 x
  981.     fi* Q- M: r6 x: B& u6 B
  982.   done
    + @7 v+ R* u, N- z% d4 l# ~$ @
  983. ) O7 d7 p, m, g! O
  984.   # Loop through the world files9 W6 Q- F, C# C8 ?8 p( l8 Z: P
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    0 Y2 b7 \( z- B% ?- ^
  986.     if [ ! -f "$pFile" ]; then
    : W+ u' g! ^9 Q, Y4 R
  987.       continue- s' r/ T: o: I- N
  988.     fi
    ' {$ x; a# T" r) n* w: N6 x9 R
  989.     # Attempt to apply the update
    * ?; D  J  [! C8 G0 j
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
    & c% e1 u  m% C  ?  D+ |, k, z
  991. 4 {! M9 e# Y" S* F" o  P
  992.     # Notify the user of which updates were and were not applied
    " B% X. Q( g' s1 A  y' _, Z
  993.     if [ $? -ne 0 ]; then4 T# i. E, X5 g! R) f
  994.       Log "Database update "$pFile" was not applied!" 0
    " v3 E, E' T6 [7 I$ C
  995.       Log "Database update "$pFile" was not applied!" 1
    ; p6 U: X* }; o( f
  996.     else
    % X6 U7 Z) e  l1 b2 H5 t/ f1 D5 D
  997.       Log "Database update "$pFile" was successfully applied!" 08 ~1 @" q3 w& q1 }4 y
  998.       Log "Database update "$pFile" was successfully applied!" 1/ ?: Z. e. x0 M
  999.     fi' p+ \1 Z1 c1 h7 L' j
  1000.   done
    / o: h; z5 x) }: H% p
  1001. }2 W' q: o8 m* J3 }2 s# N

  1002. + z3 p' t& i) ]1 _# x, g" e
  1003. # Function to install or reinstall the databases( G0 R  ~# x9 {0 A
  1004. function InstallDatabases()
    1 m5 u: y0 g2 q( j
  1005. {* @4 K$ D3 M/ l. ?' l3 {. }8 T
  1006.   local DB_HOST="$1"
    % ]: k/ }! U  R+ O0 S; _' S
  1007.   local DB_TYPE="$2"
    & x4 R! F' W" F. g9 s# d: `; G
  1008.   local DB_COMMAND="$3"
    9 X. b7 h1 a* C: q# ^* d4 f0 }
  1009.   local DB_USER="$4"+ m* |4 B* o1 k+ n  _# o% G/ z
  1010.   local DB_UPW="$5"1 [% g# C, n9 s* y# X( }$ G
  1011.   local DB_REALM="$6"
    8 O. u, G, O; z& J& o3 F8 D
  1012.   local DB_WORLD="$7"( a' y3 J# f; J5 r" O
  1013.   local DB_TOONS="$8"% o4 {. w, U5 ]# O; R

  1014. 0 z' [7 o$ E: \
  1015.   # First create the realm database structure
    ! A* ~/ b7 r6 L5 W8 J  ?- ~
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql' s; M. U- k7 c& \& a; j
  1017. 7 k7 ?. o, v, D- Q( C+ G5 {& q
  1018.   # Check for success) s6 W5 d1 G/ }9 o2 r
  1019.   if [ $? -ne 0 ]; then
    ; s4 \2 ~1 A" x/ e
  1020.     Log "There was an error creating the realm database!" 1
    , U$ J/ ?' G3 a  ^; u
  1021.     return 1
    9 q4 Y2 q- ^" a0 B% m+ i6 o# {
  1022.   else, k; Z# e" H* I4 g- q1 W! E
  1023.     Log "The realm database has been created!" 15 x0 ~! e4 Y0 w' b9 i) W4 M& [- B  f& s
  1024.   fi
    6 B- a' o' V4 ?! {4 o8 H
  1025. . {- v% h! G- i) r
  1026.   # Now create the characters database structure
    # J# s0 f0 L0 g- x4 F' U8 a
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql
    8 R7 T9 Z, r* A% O
  1028.   ]7 t% ]* Q0 c, \5 ~8 U
  1029.   # Check for success1 O! ?9 N5 H; w
  1030.   if [ $? -ne 0 ]; then
    $ T9 W5 {( m: \! t+ U
  1031.     Log "There was an error creating the characters database!" 1# A3 p7 Z$ V/ {% I, {
  1032.     return 1
    - o4 m. d1 c+ D0 L2 i
  1033.   else
      H4 o3 u) ^3 P1 X& P- A
  1034.     Log "The characters database has been created!" 10 T% S2 x' |& b) J) U; S/ r
  1035.   fi
    ) P3 B+ q) D3 [" y0 l5 }) |
  1036. " f7 s  H  J6 A2 p3 d2 N& N
  1037.   # Next create the world database structure
    + Z6 M: I5 t3 G) A3 d: _3 K! n* m
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql
    0 h7 M: e# y6 b# p0 `& H- B

  1039. 1 ^* B/ Q% _0 _
  1040.   # Check for success, `8 I6 z8 M* P3 @
  1041.   if [ $? -ne 0 ]; then
    + D+ P$ Q3 w( T; U
  1042.     Log "There was an error creating the world database!" 1
    " W( n- ^  r; I0 L6 x
  1043.     return 1
      ^" K8 Z: F" |2 `
  1044.   else3 Y9 O  a- P7 t6 g. S/ q& N
  1045.     Log "The world database has been created!" 1( `+ V; [- z, j. M5 i* m- F
  1046.   fi9 x- Q. C5 G/ V9 C8 w

  1047. " f) m, `5 o7 s
  1048.   # Finally, loop through and build the world database database
    & i* e. k, C1 x, m, z; X' }  k
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    ; q/ O( z. J4 {/ f2 w
  1050.     # Attempt to execute the SQL file* b( P$ _! C9 j" `) \
  1051.     $DB_COMMAND $DB_WORLD < $fFile
    ) `- R* i4 e) `) z! o# F
  1052. % A; Z0 e. S9 `2 ~
  1053.     # Check for success( a5 w3 I8 D& f: h- d
  1054.     if [ $? -ne 0 ]; then' t, C5 S( P# v" D
  1055.       Log "There was an error processing "$fFile" during database creation!" 1
    2 F9 n* M, y  J9 x8 H& ^( v
  1056.       return 1. _& Q, M3 v( ~0 k$ P; j6 f9 l' P
  1057.     else
    % x: L) D0 z3 q+ X5 ~
  1058.       Log "The file "$fFile" was processed properly" 1
    / R* U4 m" X" K1 D2 Q( U; W( ^# ~
  1059.     fi* _* s. h: h) @2 l. \& U
  1060.   done. j% z4 \3 x& k" Q, q1 r
  1061. 5 ^. x4 N* M7 f8 W, l: T! L/ m
  1062.   # Now apply any updates* i5 z) T! ?% T  ]. Q; R* {; [
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    % A4 M2 e( l+ S0 |/ N7 I
  1064. }  e, k6 O: U7 f/ d7 `
  1065. + {2 \7 u/ W$ b! K
  1066. # Function to install or update the MySQL/MariaDB databases- o' f' d$ s+ j" @5 e
  1067. function HandleDatabases()) |" X. @- A1 F: \4 G; x
  1068. {
    + Y8 c( Y3 L" A; C7 Y' @
  1069.   local DBMODE="0"" C3 n9 h$ A1 l# R2 m
  1070.   local DB_TYPE="0"
    5 L4 r, L; \" T% c) i" A; b
  1071.   local DB_COMMAND=""
    7 z  M2 ^% ^6 v! I+ [# I/ p
  1072.   local DB_TMP="0"
    6 }: X+ }; ~' t/ _! \/ F
  1073.   local DB_USER="mangos"
    - u+ e1 d* U- v+ q! I
  1074.   local DB_UPW="mangos"1 Z* j8 }" L+ R; q9 Y/ e9 H5 E
  1075.   local DB_HOST="localhost"
    : E$ [" Q; T& R* [
  1076.   local DB_PORT="3306"
    # b" [; a/ a6 \3 j" x( A& F
  1077.   local DBSEL="3"/ s; N2 s4 g; j
  1078.   local DB_REALM="_realm"
    ( R1 n( [3 g! |" n
  1079.   local DB_WORLD="_world"
    # T) N. m" ]) V9 r! P- t
  1080.   local DB_TOONS="_characters"+ R9 H2 I: B, ^) ~' R7 C, B3 o4 T/ X

  1081. 8 S! [9 c5 L, t6 e! ?
  1082.   # Ask the user what to do here
    $ f3 g- \6 B' W/ s: v: _5 F1 V) F
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \/ W+ g6 _. _# U6 \1 y7 j
  1084.     --menu "What would you like to do?" 0 0 3 \
    $ W+ a9 R- M; E6 E9 s
  1085.     0 "Install clean databases" \: J3 f$ C5 a2 S5 b' B5 X
  1086.     1 "Update existing databases" \
    8 ?3 P, f# z/ z0 O  I- \2 q
  1087.     2 "Skip database work" \% q, N( g5 c3 O2 S& U8 b3 w
  1088.     3>&2 2>&1 1>&3); O# H* M# y5 @7 K& Q# p

  1089. 0 B* h2 B- j$ T7 R% I+ O% j* N
  1090.   # Exit if cancelled& g- b8 X3 J8 t" p  \
  1091.   if [ $? -ne 0 ]; then
    % b5 ~6 a8 G* k
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1% b5 J' K4 a6 g$ _2 X- H' Q
  1093.     return 0
    ' J: A) e* \2 v# P5 T& R# r
  1094.   fi
    $ A$ c: U) O/ e" U) W' n- i
  1095. ' S! T& t! Q+ g, s2 |
  1096.   # Exit if skipping
    2 m( W  B, m9 a% R
  1097.   if [ "$DBMODE" = "2" ]; then
    $ \  J& W' l/ \/ A, u. \; \$ q
  1098.     Log "Skipping database work. Nothing has been modified." 1
    9 I! |% ~' n2 O) H( q
  1099.     return 08 ?- ^5 C* J; b  e4 H! c* P
  1100.   fi
    # T8 s4 ^" I, E. V9 M' A

  1101. ( l( F5 P. U/ F! H3 H' o. w  @
  1102.   # Ask the user the DB type/ y; j$ G0 |1 h+ {
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \/ f0 z; b5 S' `% P6 U3 M" l! @+ G, ]0 y
  1104.     --menu "Which database are you using?" 0 0 3 \& H& r8 r6 q$ h8 j2 `  j
  1105.     0 "MariaDB" \. c' {  S$ m$ c0 X; U0 Q
  1106.     1 "MySQL" \8 f4 L9 b- u5 X) Z5 r
  1107.     2 "PostgreSQL" \
    4 R3 x2 I4 Q; Q
  1108.     3>&2 2>&1 1>&3)( l9 ^3 y5 f; ]1 Y% p
  1109. % P1 O0 x: w2 D" _$ y( A; O! e
  1110.   # Exit if cancelled
    0 \, S( G: V: [; I  p/ a- J
  1111.   if [ $? -ne 0 ]; then% y4 E$ u7 t4 M0 m. t/ M; g
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 18 }+ S/ J" ]+ H) E
  1113.     return 0# F' h5 U" P. g- h
  1114.   fi  v- e  b4 P( @$ p
  1115. 0 M% E/ z2 ]6 \
  1116.   # Get the database hostname or IP address. _# Y# ]; q) T1 F7 i# T: S8 }$ w! I1 p
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \
    " d4 K5 Q2 j/ j
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3), l$ }! m$ Y3 s9 E& G9 A8 \& y

  1119. " k9 Z4 K; R# f7 A& s- s3 }  @' \
  1120.   # Exit if cancelled; O6 ^& z6 H0 d7 b1 z. y" Z% H
  1121.   if [ $? -ne 0 ]; then
    2 M  N) U* B5 j' x# L! z
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 17 j+ ?, V6 \+ j( n
  1123.     return 0& d! w. {5 h3 D* z5 l& e2 w
  1124.   fi" \- [$ {2 c6 }' o3 H6 D2 O
  1125. ' T9 C" I6 s% T% w) d+ u8 b5 j
  1126.   # Set the hostname or IP address if one was specified! e- j2 M/ P9 s6 a* C
  1127.   if [ ! -z "$DB_TMP" ]; then2 ~9 i, y  r0 p) A) |5 O6 Y
  1128.     DB_HOST="$DB_TMP"
    # F# F  b4 u3 i  j8 |+ r! a
  1129.   fi- o7 ~( h' u7 \2 h; d! \5 x5 n

  1130. * x7 h3 F2 Q" F, |* [: w6 h
  1131.   # Get the database port% a, J* v  D8 A; R
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \
    * m$ I# P! p7 C, x7 |0 B
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)
    0 i5 Q5 _. \1 l
  1134. . G- l7 ]- X! T0 s6 U$ T- k: [- B! l
  1135.   # Exit if cancelled
    ' r0 q3 D6 X/ S% u- {1 _0 E. Q" k
  1136.   if [ $? -ne 0 ]; then  c: N; ?$ i2 U' d1 K* W
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1
    " _( L7 ?8 F. s9 L5 O
  1138.     return 05 L* p) X+ R' V1 g1 Q% j
  1139.   fi
    8 \6 v6 \$ E# y, O) S: _

  1140. ) A! B1 v8 H; k) s0 s: h
  1141.   # Set the port number if one was specified
    9 P- b. P& ?2 u( n- i0 I
  1142.   if [ ! -z "$DB_TMP" ]; then7 }; ]+ }( M" G9 ]
  1143.     DB_PORT="$DB_TMP"1 m* O( ~* K( c0 B6 l7 Y& a; B
  1144.   fi% D% p& i( g" i' j* p4 h& R
  1145. $ ^) H. t. a5 e1 W
  1146.   # Get the database user username
    ' h( g5 }! f& x3 u5 K
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \5 G7 ]% Y( E3 N# ?
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)" |* w6 Z2 j& }$ T

  1149.   G+ ?1 t2 b9 o# }1 F* T( Y
  1150.   # Exit if cancelled
    0 |4 u. u; U: r/ U* _
  1151.   if [ $? -ne 0 ]; then
      h$ m  x( [6 g, Y' T6 K
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1: ^) w1 l" m+ J7 N2 C( ~) r. X1 y
  1153.     return 0
    0 u- D/ B7 V# ^8 b! _% U- `
  1154.   fi
    9 h4 T+ ?3 T% A7 A

  1155. 7 |/ \$ [' ]& H, e& m5 E" Z
  1156.   # Set the user username if one was specified
    ' _$ v* \  X. [; u
  1157.   if [ ! -z "$DB_TMP" ]; then) `4 N( {8 F1 e$ T3 s* d* X4 \
  1158.     DB_USER="$DB_TMP"
    ; E7 Q, x. K+ H( k: j
  1159.   fi
    : C  b5 h0 w6 [# y# }/ Q

  1160. 4 Z! f' K$ X7 {  d) J
  1161.   # Get the database user password
    7 U1 i; h+ K( T
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \1 q, k: Q" U) F' W5 m
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)
    ) x& @8 l) O9 q7 [; W; k5 z

  1164. 7 V( C, k2 W* v' g$ l
  1165.   # Exit if cancelled! ?' G1 @6 M/ J/ i
  1166.   if [ $? -ne 0 ]; then( N. N5 x1 ~0 E* N0 N
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1
    % M( i6 {  r: y7 r- g
  1168.     return 0$ b% W5 ]& `: a4 b
  1169.   fi2 [5 H, u1 Z  |- w. B# J

  1170. 5 D8 G% @, X' \; x" y
  1171.   # Set the user password if one was specified* w& ~) C; }" P" N# ?6 b
  1172.   if [ ! -z "$DB_TMP" ]; then2 ^8 ?, y9 l4 x- h
  1173.     DB_UPW="$DB_TMP"9 K* Z# Q( n+ E, [5 ~* ]7 e
  1174.   fi
    ; t5 }$ u& w" M7 g

  1175. ) a# u- o" Z; G# r7 J) \% H" I
  1176.   case "${DB_TYPE}" in: n9 S( N# q1 s* M2 b
  1177.     "0")
    8 a7 x$ F5 v* `- B) d7 A) q
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "8 n  |' y1 r$ X+ l+ }( g9 i
  1179.         ;;
    9 m9 f* Q. M9 i3 Y# \. M' G
  1180.     "1")! @4 S( D) t4 x  a
  1181.         printf "Confirm your MySQL password\t, "
    , s3 P" V- O9 i( R# n
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn2 W: D6 E8 ]  D+ ^
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    , u2 G/ n) ?. z5 B0 ?
  1184.         ;;; ~& ~# g  e% S, Q! u( O2 {
  1185.     "2")$ D# e* D$ c# P% T- d) n
  1186.         Log "Currently not supported." 1
    % J. _! ~: `* l
  1187.         return 0' g( `% A2 Q3 O1 {$ V- g
  1188.         ;;- ^6 }. i! _3 n* V. h  v7 |5 F
  1189.   esac
    ( e/ E5 B3 B% ]+ M4 C4 F
  1190. 7 d3 v3 B  d' f( R# s4 `
  1191.   # Setup database names based on release
    0 {( m  {% U" I. _( h3 y  w3 E9 c
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"" s8 G* p& i, s% b+ l+ A
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"
    ) n! \+ m6 n" R# ~
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"' B* l6 v! r8 n" @, [* z
  1195. 1 p9 h3 n/ Y. U# s2 i3 O- O
  1196.   # Install fresh databases if requested" _. j5 W4 {0 V2 ~! {
  1197.   if [ "$DBMODE" = "0" ]; then
    . z& a( M9 c, @0 D3 a
  1198.     # Ask which databases to install/reinstall
    7 S& s" t" d' M7 m
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \
    : c" _# ?8 {! ?6 E; @" P
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \
    6 t" J+ N3 J3 |3 S& b
  1201.       0 "(Re)Install Realm Database" On \
    4 w- D4 h* o+ E% _* V0 u
  1202.       1 "(Re)Install World Database" On \+ F* l$ T" w' [) B# x, O8 K8 T
  1203.       2 "(Re)Install Characters Database" On \
    % j. T9 b' r' R( Z+ H0 `6 ]- H* p  v
  1204.       3 "Update the realmlist" On \5 X8 F5 A3 y/ b0 n- ?4 C' u
  1205.       3>&2 2>&1 1>&3)
    9 j- l  G5 ?1 y; l
  1206. : _' Z$ n" N* b7 k9 \& B) ~
  1207.     # Exit if cancelled
    7 B% @7 Z4 R3 w! k: J3 i+ A/ t
  1208.     if [ $? -ne 0 ]; then
    % l0 c0 k& f- R# A; r
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1
    . H2 j" ]7 m" U% S3 a
  1210.       return 09 B0 F2 P( I: n# L" z
  1211.     fi
    0 Q$ E4 \8 W6 r# h
  1212. + g* k1 j' P+ `7 ~4 V/ x
  1213.     # Remove and create the realm DB if selected
    3 M& L# k+ C3 s! m, n4 m
  1214.     if [[ $DBSEL == *0* ]]; then
    ' a3 X, L" H4 _
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;", p! ?7 u0 E' w
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;": _$ m% F3 l5 R" [) C2 I
  1217.     fi* }, k9 l2 e0 I  C; D* i
  1218. % B5 m! z+ f- L% ~
  1219.     # Remove and create the world DB if selected
    9 n* O0 t. T1 H0 G
  1220.     if [[ $DBSEL == *1* ]]; then  h- `4 p2 D9 x% X& `% u
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"
    . s" m' R9 W. g9 u% T/ e. D9 k
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"
    # Y  e; `! u. }6 P+ {
  1223.     fi- u+ S) T5 R  A! x! E- p. A- g
  1224. / y3 S$ b) N" F) z5 m
  1225.     # Remove and create the character DB if selected
    % d" T, C: I& M1 I: o' h
  1226.     if [[ $DBSEL == *2* ]]; then
    : p8 l( j# u; S( G
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"2 m0 A$ M, i5 P& S: r; _4 x5 x4 y; S
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"
    # d; l8 E9 a1 \+ T
  1229.     fi  M& X0 r. x+ A/ D8 S" V

  1230. 2 h( V; q8 z9 V2 Q& H
  1231.     # Validate success
    % ]' P! j$ j' T+ A
  1232.     if [ $? -ne 0 ]; then0 X+ j9 d' K  P
  1233.       Log "There was an error creating the databases!" 1
    " D3 _& K$ i  D% `* J: `1 X* i6 R7 ]
  1234.       return 1& M- T; G# a0 V* i
  1235.     fi
    & Z: J3 U! O5 s) O
  1236. . G" I, `( w2 l5 }
  1237.     # Finally, populate the databases! c* {. B* s' b' u
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    8 ?' l8 D+ v0 @( H0 `$ |7 U2 R# `
  1239. + k# V/ s8 l0 J
  1240.     # Updating the realmlist
    7 D/ Q: c& N; N' \
  1241.     if [[ $DBSEL == *3* ]]; then5 p# y) k8 V9 i3 b' Q
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql# W, o* U% W7 j/ h! Q
  1243.     fi- h5 W& Q7 T- B5 Q5 H
  1244.   fi
    $ I+ I5 b+ J0 |4 }; _" U
  1245. 9 ?/ H5 b9 k2 h! ?4 u+ y
  1246.   # Update the databases if requested
    / Z3 e" o; L9 K& }3 O
  1247.   if [ "$DBMODE" = "1" ]; then; a0 ~3 d/ {/ A+ f
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    : _% Y* E" @2 F: J- P! S  ?; H
  1249.   fi, }5 J  }# d# h' h& W$ b9 I) ^; N8 h* E
  1250. }
    1 [; u8 Q0 t) r3 o
  1251. * [9 R6 j' q. K' K% `
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
    ) ~3 k6 i% c* h
  1253. function ExtractResources3 v7 B% K* y7 U. ?: d
  1254. {
    ; o8 }. K6 y8 V) ^9 ]6 q% R
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))
    6 _) G, w2 a5 F& i' h) v
  1256. # Y4 ^9 a$ Z; f7 o- l
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \
    ' o4 S3 Q, G1 ?. W
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)
    + s8 ^4 u0 f  Q7 }6 S' \
  1259. # a. C2 B; x/ o0 [4 s/ u) {
  1260.   if [ -z "$GAMEPATH" ]; then
    / J2 j/ H1 n5 k+ z7 j& g, u
  1261.     GAMEPATH="$INSTGAMEPATH"' ~9 P; L- x1 N# e9 d- l  K
  1262.   fi! k" `+ _3 [$ [" L& G4 f
  1263. ; C: f( c) P$ W3 J
  1264.   if [ ! -d "$GAMEPATH" ]; then
    ( V2 C0 @. Q, I' Q+ M7 e) h
  1265.     Log "There is no game at this location" 1
    ' b3 J( T0 ]% j
  1266.     exit 1
    3 o/ \- D. V5 P4 P& m
  1267.   fi
    ; y7 C6 m9 t* q  ]' S1 |7 G

  1268. 0 S4 o) Z0 X# w4 o$ o2 Z
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \: D/ m: {7 @. f
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \' [$ I$ Y& D# _% S7 C) I
  1271.     1 "DBC and Maps" On \
    & d# H! I& v5 L! W- }5 ]* C
  1272.     2 "Vmaps" On \
    ) E$ |3 e* ]# F( b+ L$ @, l0 F
  1273.     3 "Mmaps" On \
    ( f: C8 D( Z5 Z4 ^
  1274.     3>&2 2>&1 1>&3)2 w+ v2 ^' v% Q

  1275. : D7 {& J# \7 |1 e
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    # {" R! ~' R2 j/ q
  1277.     Log "The client tools have not been built, cannot extract data" 1
    " |4 B+ [  C+ v# F  p
  1278.     exit 1/ t1 M7 U4 Y/ v. Z* S4 M
  1279.   fi
    * a$ L+ A7 q: d0 i! a

  1280. 2 c* g# u3 N" H, H
  1281. #TODO What if DBC are not yet generated ??
    6 L, C5 {! B+ ~  H7 n2 b
  1282.   if [[ $ACTIONS == *1* ]]; then
    & Y+ D' h& Z; f8 N6 D# A( b7 b
  1283.     if [ -d "$GAMEPATH/dbc" ]; then' z4 {, m& l1 ?7 E2 I
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \6 U+ z5 G( F3 {2 I4 h. |# @
  1285.         --yesno "Do you want to generate them again?" 8 60* i6 r/ Y1 V1 e8 P: @7 v
  1286. 5 n# m9 X( S2 {! x: W- x
  1287.       # Check the user's answer
    / D5 R/ f: J# d% X
  1288.       if [ $? -eq 0 ]; then1 d2 G+ L5 G: A  b  }3 L
  1289.         Log "Deleting DBC and Maps previously generated." 1' J( i4 d# b/ a
  1290.         rm -rf "$GAMEPATH/dbc"
    2 `) n) Q, y' m! N6 U
  1291.         rm -rf "$GAMEPATH/maps"4 u7 z( q% F8 @1 m
  1292. " `8 ~/ ^: e3 W9 E
  1293.         Log "Copying DBC and Maps extractor" 0  M6 J3 T1 r! K5 @* I7 M# J
  1294.         rm -f "$GAMEPATH/map-extractor"- c6 u3 w! M% u* g( W
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    + Q8 c2 I5 u& x" ?3 g# R

  1296. ( n7 X/ @. _; Y' b% L3 q
  1297.         Log "Extracting DBC and Maps" 0
    ! _# {% F% @# R  z' R: q7 U5 u" a9 _
  1298.         cd "$GAMEPATH"
    7 s1 Q& j' w0 ~. b# j. _
  1299.         ./map-extractor  Y! m8 Y9 w- h# ?
  1300. 2 {9 i+ g& X! o5 b
  1301.         if [ $? -eq 0 ]; then
    9 Z1 e) j1 |; \' U0 u
  1302.           Log "DBC and Maps are extracted" 0
    / g7 F# X! m) G: A; j& I
  1303.           Log "Copying DBC and Maps files to installation directory" 0
    - F! m( h" i1 o8 @
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    * G9 @4 K  [" N  i- |' ]" P9 H3 c
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    , z/ E$ [$ {( a" q2 \) O7 {2 o
  1306.           rm -rf "$GAMEPATH/map-extractor"
    # g# [: i1 ~' [% E/ W% ]. B
  1307.           Log "Changing ownership of the extracted directories"
    7 n3 H, Y  s% }; O6 w
  1308.           chown -R $USER:$USER "$INSTPATH"+ d6 q& `$ V: m$ L
  1309.         else0 l5 r' f4 N! o3 {# T
  1310.           Log "There was an issue while extracting DBC and Maps!" 1
    : A" k/ ~0 [: ^& y
  1311.           rm -rf "$GAMEPATH/map-extractor"
    3 ]6 o( o3 N+ E
  1312.           rm -rf "$GAMEPATH/dbc"5 p. g" `5 k! t
  1313.           rm -rf "$GAMEPATH/maps"
    4 S4 _/ I, [$ @5 b4 s
  1314.           exit 1
    9 y4 Y2 W7 A0 U1 ~9 _7 _% D
  1315.         fi
    2 F5 c4 R/ r4 B
  1316.       else
    / f4 a, U0 K, T: ^. n1 h4 Y2 Z8 p
  1317.         Log "Copying DBC and Maps files to installation directory" 0" o* ^& o: M2 ^5 s+ y  u1 J/ y
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"- ^. E% d( |" h
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin". ]# h% P( n: N' d( S; U
  1320.       fi
    9 J7 Z8 Q% {7 k& }2 f( z
  1321.     else( |7 s. S, P" f
  1322.     rm -rf "$GAMEPATH/map-extractor"# b' ~  ?- o3 b5 X8 }# @( N
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"1 p* u, s! L* Y' {! t' L# M: o
  1324. 2 E+ ~( B$ N$ o- u
  1325.     Log "Extracting DBC and Maps" 0
    4 {! @8 V; c% H: z
  1326.     cd "$GAMEPATH"+ u+ F4 t9 Y. O
  1327.     ./map-extractor5 s& W3 w/ B+ [; b: P

  1328. ) X+ M9 ^& ~& e6 R5 r5 f/ Y  n% X5 p: Q
  1329.     if [ $? -eq 0 ]; then
    - L) x" E* K# n# h4 G
  1330.       Log "DBC and Maps are extracted" 0
    ( ^6 E( q! n& y% |: P6 v, Y" g6 e
  1331.       Log "Copying DBC and Maps files to installation directory" 0' Z$ F5 Q! W; |/ u' J4 k' c
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    & z. [$ i3 o, z3 W; O
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"9 w: Y8 h+ M  m3 s0 a6 c/ }
  1334.           rm -rf "$GAMEPATH/map-extractor"8 ?( y, D9 f; s- u, s: e; ~$ t
  1335.           Log "Changing ownership of the extracted directories"2 [& T! ^& u* n# l. F- |
  1336.           chown -R $USER:$USER "$INSTPATH": G  k7 g3 ~2 o1 n7 c' k  l9 \
  1337.         else
    ( l& `) o' d$ _1 y5 ?( M  \; V  L8 V/ f
  1338.           Log "There was an issue while extracting DBC and Maps!" 1
    & p7 q4 V. {" J, F, ~
  1339.           rm -rf "$GAMEPATH/map-extractor"  L1 I% C! i* {' O3 S8 L1 ]
  1340.           rm -rf "$GAMEPATH/dbc"9 i4 K" t: a; W1 l, y! p
  1341.           rm -rf "$GAMEPATH/maps"
    " H* r8 Z% W6 w, V1 R/ j
  1342.           exit 17 R$ K  s8 j' }8 J) W; f% H
  1343.         fi. Z1 M. {4 {, i: X. k  x2 e9 A
  1344.     fi* D+ M  ~- g* n& j, ^
  1345.   fi
    1 N6 r4 h+ h; I' m
  1346. 2 m' t' p8 m* z) y: Y7 w0 K2 _+ ^
  1347.   if [[ $ACTIONS == *2* ]]; then& f  g1 e" \" k, e
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then6 T6 R1 K) K( w) k
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \
    + C5 ]; h; c0 r- n' _
  1350.         --yesno "Do you want to generate them again?" 8 60; W: J, I  D6 o; N

  1351. 5 `. z4 ?& A1 I! t( [5 p5 U3 Y, D
  1352.       # Check the user's answer+ U( w+ x7 Q% |& G& G0 M/ S0 i& f1 L
  1353.       if [ $? -eq 0 ]; then+ U: b# M' A2 T! I& d4 P
  1354.         Log "Deleting VMaps previously generated." 1
    ) [, \8 _/ ^- y" r
  1355.         rm -rf $GAMEPATH/vmaps
    # w$ s+ f  L: |' a' L1 u
  1356.         Log "Copying VMaps extractor" 0
    / N) a: h7 G% S$ R: ~8 _  m
  1357.         rm -f "$GAMEPATH/vmap-extractor"2 P( ~! d0 Z; I5 P- o6 H
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"2 ^: p0 H+ F3 e' @( [

  1359. & e+ S) p- V% U! x
  1360.         Log "Extracting VMaps" 0; o3 a0 o" f& k( _
  1361.         cd $GAMEPATH: I* x. n2 X, E4 v$ p6 C
  1362.         # Make sure there is no previous vmaps generation that cause issue.
    % ~4 a; h4 x, S) L) r
  1363.         rm -rf Buildings4 }5 n; N  }8 J* f: g; ]
  1364.         ./vmap-extractor
    $ I* v- W% I& Y+ ?& N. T* b

  1365. & Z7 z/ \( ~+ |6 c% @! L
  1366.         if [ $? -eq 0 ]; then
    4 t, J5 ?0 P# S. h4 D' ~& I
  1367.           Log "VMaps are extracted" 0
      Q  D; n- b# j: x
  1368.           Log "Copying VMaps files to installation directory" 05 [2 D0 C7 a' r4 O  G8 c
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"5 m  b1 I( ^0 V
  1370.           rm -rf "$GAMEPATH/vmap-extractor"
    " O3 t; P/ i7 u5 }$ y
  1371.           Log "Changing ownership of the extracted directories"* T5 T- y4 {5 [% p& y( [3 ]9 @' W
  1372.           chown -R $USER:$USER "$INSTPATH"
      x+ p1 \/ p* Z- p5 M9 B' _
  1373.         else
    0 D" _* ?5 v+ T  K9 i% I
  1374.           Log "There was an issue while extracting VMaps!" 10 I0 ]) |- e9 h6 O% {+ t- ]- T
  1375.           rm -rf "$GAMEPATH/vmap-extractor"
    , O3 F2 U) y) I+ n8 D
  1376.           rm -rf "$GAMEPATH/vmaps"
    - u- Z: ]1 e$ A
  1377.           exit 1
    5 \4 s, H7 ^6 A: u8 G( s2 ^
  1378.         fi' y0 V3 ?' d$ V; C$ y9 T: p0 J
  1379.       else0 b, I" Z, a7 `6 W9 h2 p( g
  1380.         Log "Copying VMaps files to installation directory" 08 m' }' r+ S2 ?: d- r- O
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"5 N& w. a6 i' F- x; u( T$ P
  1382.       fi
    ) i/ }# `* N* N  T
  1383.     else
    6 y) ?7 `5 f; s) ^. s* X
  1384.      Log "Copying VMaps extractor" 0
    6 f2 k) a4 V7 P
  1385.      rm -f "$GAMEPATH/vmap-extractor"
    0 P- @( |+ @$ K# I! y2 |2 g
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"; F6 @! j( u& @; b  b" |' @
  1387. . K2 t+ {  F* E
  1388.      Log "Extracting VMaps" 0
    / a' D  z# J+ d4 w# u
  1389.      cd $GAMEPATH  M8 B! d' G- ]& X1 @7 T
  1390.      # Make sure there is no previous vmaps generation that cause issue.
    % c+ u; \( }. v. M: L& r
  1391.      rm -rf Buildings
    % j) |$ x) l# o* r. C9 l9 t
  1392.      ./vmap-extractor& L6 G4 ~- c" }& `! z4 b" r
  1393. 6 ]  m( t  K1 J+ `8 r
  1394.      if [ $? -eq 0 ]; then. k" O) b  u5 W% w5 L" M& Z
  1395.        Log "VMaps are extracted" 0
    & p5 d. }& |7 B  d9 {& J9 p6 Z
  1396.        Log "Copying VMaps files to installation directory" 0. }( B) ^5 j# Y7 r# @) r% V
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    8 X9 ?# g% K. N) N! D. A* t' T0 l
  1398.        rm -rf "$GAMEPATH/vmap-extractor"
    & z- X/ y5 G; |% q
  1399.        Log "Changing ownership of the extracted directories"/ Q( Q8 d6 l3 F4 m4 Z
  1400.        chown -R $USER:$USER "$INSTPATH"4 j1 r3 _. [+ c! D
  1401.      else
    - b' S8 J" W1 |) Y- }
  1402.        Log "There was an issue while extracting VMaps!" 1
    # D* ~8 d! _5 g5 H* u; u" q# N
  1403.        rm -rf "$GAMEPATH/vmap-extractor"
    4 B9 M9 C! M& v
  1404.        rm -rf "$GAMEPATH/vmaps"
    % s1 `, [( M" V) p5 O4 h
  1405.        exit 1$ {7 c& _, z  J) D% K/ E6 B$ M
  1406.      fi+ x: c; g3 ^7 a- i
  1407.     fi
    + C1 U! g3 X' R1 v5 S) d% b
  1408.   fi
    % @, `. A; j; j5 ]$ [& j
  1409. 1 z. X9 z8 u3 B- _. X
  1410.   if [[ $ACTIONS == *3* ]]; then
    9 N: H0 K. D2 `; u* Z1 u# E* R, [
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then
    $ @3 x( ~$ M# R; z9 {' M1 f
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1
    8 B. O  ]+ i" t! U. A; D
  1413.       exit 1
    2 J3 h  M: t& p; [+ K
  1414.     fi7 P9 D2 W9 f; v  L
  1415.   @4 C# T3 L; h, u8 m, }, t# I
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then
    # _' Z6 Q) A) P- \' P
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \0 J6 \4 |& u8 g; o; ^
  1418.         --yesno "Do you want to generate them again?" 8 60! @: a6 ~% E5 I' b5 o/ f' e

  1419. 1 j% y' G# ]4 U" G
  1420.       # Check the user's answer5 Q5 g2 M3 O) f+ R: I
  1421.       if [ $? -eq 0 ]; then
    $ Y( j4 g: |# K4 z) z' s
  1422.         Log "Deleting MMaps previously generated." 17 d1 p+ @  `4 I/ R. h) q
  1423.         rm -rf $GAMEPATH/mmaps8 Y' V" r4 }6 j; I7 @' Q

  1424. - C, |, W; v' a1 @) |$ k( @
  1425.         Log "Copying MMaps extractor" 0
    " o* ^3 y/ v+ J) U+ o: ~' T
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    / H4 I2 k% \( Y$ Q* m6 ^" H
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    7 ]2 }$ ?# H% E/ i% a# _
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"$ m+ R" A3 }$ g& R
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"2 K: u% y+ W' m! e7 f' J; |3 I3 c2 G
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    $ g. \  q6 R- H9 x9 [

  1431. & W! Q7 x/ r$ u3 `
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \* ~4 M5 |0 X) e# {) v( X
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    " N) N% l) u/ D7 \0 P! O: X* C

  1434. . k7 [( S1 s; V& @/ S
  1435.         # User cancelled his choice, set default to 1.
    2 U; u+ X5 l0 i' M  i4 D, z3 M( F
  1436.         if [ $? -ne 0 ]; then1 a5 f5 p& C, a/ }6 _
  1437.           Log "User selection was cancelled. Max CPU set to 1." 1
    8 m$ A8 z3 R! b# q
  1438.           CPU=1
    1 u  Y) c: n9 i; _4 r  R
  1439.         fi
    " H; X0 y0 i$ F: X" N1 R) k
  1440. % d7 _5 H, B7 U0 g7 [
  1441.         if [ -z "$CPU" ]; then8 K) P, N  u$ d, W
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1
    : j& w* u* P% }8 v- M
  1443.           CPU=1
    ( p6 [( |# B. A& w4 ~5 _4 d0 p
  1444.         fi
    7 X8 \0 y2 @5 \, B; ]1 L  A" R
  1445. / q' E: A# ], S6 I$ g3 P0 L
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then! h  T- I' z# h0 W  k
  1447.           Log "User entered invalid value. Max CPU set to 1." 1& q% D9 Z$ z! G/ T- _
  1448.           CPU=17 o- q3 b4 y4 _$ D& N* T3 ]5 \
  1449.         fi2 j9 ?. K2 v5 p/ G# }" k
  1450. 9 e3 g: ?7 f' [2 I+ c( e7 I* ~
  1451.         Log "Extracting MMaps" 0) M- `( m& E. q+ n, e
  1452.         cd $GAMEPATH
    ! m% H9 i1 }* ]9 n9 H, B- G
  1453.         # Making sure we can execute the script. j5 U( [6 a  ?' x
  1454.         chmod 700 MoveMapGen.sh4 O' G9 D' }  l' |, ?( a" k+ ~
  1455.         ./MoveMapGen.sh $CPU$ y* Y9 P7 y- @+ E2 B

  1456. 6 M3 d, X( x+ n
  1457.         if [ $? -eq 0 ]; then4 w- E& O2 l: E6 r8 X3 A6 B
  1458.           Log "MMaps are extracted" 0
    % i  S2 j4 o1 ]" n4 V6 w
  1459.           Log "Copying MMaps files to installation directory" 09 h# ^. o6 T8 e: ?0 ^3 _
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"9 S2 E0 s  d/ g& |) }! @* ~
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"' d& w( r! e4 _" V' @
  1462.           rm -rf "$GAMEPATH/offmesh.txt"
    ! \8 z( J1 I6 }# a0 G
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"% Q0 Q. U0 e$ L- F1 v
  1464.           rm -rf "$GAMEPATH/mmap-extractor"# C& h$ U8 T& P- p9 V/ P7 }) k2 l
  1465.           Log "Changing ownership of the extracted directories"+ k2 J% L' P  Z6 G
  1466.           chown -R $USER:$USER "$INSTPATH"9 ?9 |0 j: m' g( m& @
  1467.         else
    ' }. D9 F4 U# `: E/ ?" V' V
  1468.           Log "There was an issue while extracting MMaps!" 1. z4 O0 F' _5 k0 E( K
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    ) M. h7 M* b$ s, s5 v+ C
  1470.           rm -rf "$GAMEPATH/mmaps"& y8 B) I2 O# |0 g: F6 k; p
  1471.           rm -rf "$GAMEPATH/offmesh.txt"/ ?6 x. W! i! K. Z9 R# v
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"  z5 X( `9 G# l( N
  1473.           rm -rf "$GAMEPATH/mmap-extractor"2 p; [+ a3 i; \; K; C* j% X8 R
  1474.           exit 1
    / h& k6 V' K$ n1 c  h3 O" Z+ Z
  1475.         fi
    $ U$ e$ r" I- e) q3 Y
  1476.       else
    & p; w) L: T- m6 t9 X9 [5 L
  1477.         Log "Copying MMaps files to installation directory" 0
    " z* N9 r' o+ ~8 D2 b, X# O1 A
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin": A3 P! O" ~  t( r! F
  1479.       fi
    $ \& l" L: K4 K3 p0 G" Q
  1480.     else% f% \9 V" x' ^! T$ _; u
  1481.     Log "Copying MMaps extractor" 0
    3 s, ?' X3 g, N8 f, M
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"$ _/ v" J$ p: d& W: u
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    # H) M, ~1 ]; m: l/ \/ R7 H" w
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"4 z7 d: X! h# Z- Y- F* n4 @9 n* p
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    2 m5 |' O% _" m5 Y
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    8 e9 t; f% L, L. q6 H5 q
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \) C  M% ~* S! K, ]3 `3 ~
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)" r1 K$ Y$ i3 {4 s/ h
  1489. 0 s4 M8 A0 ^$ Y1 y
  1490.         # User cancelled his choice, set default to 1.9 u' ~! Z& Z- m, O6 |$ E/ T! I
  1491.         if [ $? -ne 0 ]; then
    7 p5 y8 i' q0 @; M5 O' Z
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1, w( \8 @" b  m# c8 c9 ]! j
  1493.           CPU=1
    9 ?" T  z0 T1 l* _" a" u  H8 s
  1494.         fi/ C. x/ z& b' i1 t& G4 @: h" f

  1495. & `, ~) t* N4 T. C
  1496.         if [ -z "$CPU" ]; then9 T# g1 b8 u9 {4 D/ H+ k* q  D
  1497.           Log "User didn't gave any value. Max CPU set to 1." 1# @, _5 r) B: P4 x, N6 R
  1498.           CPU=1  [, K1 [( Z/ `! Q* U2 n
  1499.         fi
    5 x. n8 u* l. m9 x9 h

  1500.   p3 j) H- _) a5 J
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    & M- A% e/ R, a' }  m
  1502.           Log "User entered invalid value. Max CPU set to 1." 1
    $ N& Z! e8 F7 o7 U( Z
  1503.           CPU=1
    9 A* }2 l/ O/ b; q- }5 \7 N
  1504.         fi
    7 L$ D! Z( j3 x5 Y; l% {
  1505.   H; }, v) s8 T* m: g. J- Q, u
  1506.         Log "Extracting MMaps" 0
    8 g& U9 H/ R+ P! _* F, Q' Y8 q7 g
  1507.         cd $GAMEPATH
    ; f4 t  _- F: \; v- |) O. V/ Y" E
  1508.         # Making sure we can execute the script
    & W7 N, q. |7 k9 [
  1509.         chmod 700 MoveMapGen.sh
    # g0 J' B) U! N  `+ P
  1510.         ./MoveMapGen.sh $CPU% {0 q* G3 V8 ~9 o$ ?% ]1 a
  1511. 2 F4 Y. _7 \5 g
  1512.         if [ $? -eq 0 ]; then
    * v) b- T6 A! U
  1513.           Log "MMaps are extracted" 0  v; H2 t1 K3 u9 O) c
  1514.           Log "Copying MMaps files to installation directory" 0- I) H% D) O/ R& \0 A5 e8 n# q% u" u
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"' o4 p: \, o: W
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh"5 X( `' X0 R3 ~9 l! g1 b
  1517.           rm -rf "$GAMEPATH/offmesh.txt"
    / h2 l. X; Y5 f; \$ k4 U# P' d
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    $ r" b, O+ W- M8 m& G/ T. m  b5 J3 s
  1519.           rm -rf "$GAMEPATH/mmap-extractor"' O  X: |) d8 z# ?2 k& h$ ?
  1520.           Log "Changing ownership of the extracted directories"! F7 u4 p1 E4 p2 _  D
  1521.           chown -R $USER:$USER "$INSTPATH"- Y- o4 Z3 _6 C0 B& J
  1522.         else
    9 |' |) V7 b! O( i. f9 F
  1523.       Log "There was an issue while extracting MMaps!" 1$ c" [5 G" I! H6 n; ]: P" b
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    8 f( P1 u; G4 d( s4 W
  1525.           rm -rf "$GAMEPATH/mmaps"
    + @1 w- W9 \7 Q, ~) u7 _
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    , \2 V/ G" n" n/ y2 n2 O; y
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    8 k2 A+ i3 I5 Y4 W9 C# V2 ?1 u3 @4 {
  1528.           rm -rf "$GAMEPATH/mmap-extractor"
    . \/ U5 O; t" h
  1529.           exit 1, q$ F7 m* K# E  d7 F! B" ^8 _
  1530.         fi
    " X$ ]# f0 p, S  Y: d0 P% z
  1531.     fi
    ) ~7 [3 B5 M/ K3 l! f1 ]
  1532.   fi, R5 p7 }# s' C  y
  1533. }
    ) y5 a- \+ `' f/ C- _2 Y* V$ n

  1534. : _- X) O6 o% z  A
  1535. # Function to create a Code::Blocks project% g6 Y; v- W2 `, Y/ \) U- R
  1536. function CreateCBProject+ u" o7 V2 k* @/ I
  1537. {9 t# \) V, N* G0 E4 k
  1538.   # Create the dircetory if it does not exist
    $ h0 @% y6 K. ]5 G
  1539.   if [ ! -d $SRCPATH/server/linux ]; then" V1 {  p3 ~' t% e8 l/ x
  1540.     mkdir $SRCPATH/server/linux
    # p8 l! U7 P( X
  1541.   fi2 s" E; u8 x& e" Q) F+ u: k

  1542. & i4 {8 g4 k/ D$ R  W7 @7 D  f
  1543.   # Now create the C::B project: R* P5 e5 |/ z/ H: ?
  1544.   cd $SRCPATH/server/linux
    7 U5 |* Q7 S& X" _
  1545.   # make sure we are using the cmake3) v, S: g  W8 d  S  k. Z# i
  1546.   UseCmake3% ~0 L  t' r8 C* @! a/ p, E
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    / x8 t' P* v( _$ a9 c/ O
  1548. }
    # Y8 `7 N; r5 w( \

  1549. - p1 O/ I% ?9 A; [& H7 w4 o; Y+ ]! t
  1550. ; t- e) Q4 B; E4 x; i: g, X  V; O3 w
  1551. * H; h$ Y  D7 I( Y0 S, C
  1552. # Prepare the log
    3 i' \0 `; ?8 n, Q) d( G3 M
  1553. Log "+------------------------------------------------------------------------------+" 0* i  T" {3 _; j
  1554. Log "| MaNGOS Configuration Script                                                  |" 0
    ( A* C) w6 Q1 j- w* ~% D) s$ U
  1555. Log "| Written By: Ryan Ashley                                                      |" 0; a7 a# F6 R' Q7 ^
  1556. Log "| Updated By: Cedric Servais                                                   |" 05 U2 w, L$ M& p# V
  1557. Log "+------------------------------------------------------------------------------+" 0$ K. {" G5 W! ?

  1558. 6 v+ G0 g: i$ ^. Z( |. n3 `+ z
  1559. # Check if user who is running this is root" R+ w4 V& b, a! g$ [) j: V( Q
  1560. CheckRoot
    $ B$ x6 F% |6 \8 P7 ^2 h

  1561. * _7 h+ j6 B+ Q8 ~% l
  1562. # Select which dialog to use: h, {9 h* e8 ^
  1563. UseDialog
    0 f: p% p% {" @2 _) x8 f
  1564. + F. x) R5 _& `
  1565. # Select which activities to do
    ) s0 u( {  D9 W" ^6 |
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    ( [0 P4 r: `4 d3 ~
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \
    3 u) \3 t7 k3 n" |( n
  1568.   1 "Install Prerequisites" On \
    , Z3 i& u* L7 Q7 |; a" B9 O$ F
  1569.   2 "Set Download And Install Paths" On \
    1 C/ f! {6 d4 H3 V
  1570.   3 "Clone Source Repositories" On \
    9 t' k, `: F& K
  1571.   4 "Build MaNGOS" On \
    : x, o" k4 R5 q1 n" t/ Q, M) K
  1572.   5 "Install MaNGOS" On \
    9 q7 g! D% c( D8 C. j' E4 D
  1573.   6 "Install Databases" On \* |- S" P% T3 n5 P
  1574.   7 "Extract Resources" On \9 j, A; q/ q. \9 a
  1575.   8 "Create Code::Blocks Project File" Off \
    # z, ]% ]+ g! g" y) \. O2 j
  1576.   3>&2 2>&1 1>&3)9 h: z/ n0 i& M

  1577. , W4 g* t; G( N2 |- p' x; _0 ^$ K2 @
  1578. # Verify that the options were selected
    9 Z, j2 @9 z* ~: S
  1579. if [ $? -ne 0 ]; then
    ! T' `2 J2 o( o' x
  1580.   Log "All operations cancelled. Exiting." 1
    2 \/ G: m$ _- {0 f7 q) H
  1581.   exit 0
    2 `. b$ E+ \7 g
  1582. fi
    % |1 e% }/ ?6 p! O) _$ y

  1583. ' F) J' u: v$ I4 r
  1584. # Install prerequisites?
    7 p: Q7 u% M, j: y" B
  1585. if [[ $TASKS == *1* ]]; then
    ' x; m. s+ w0 L# f2 o
  1586.   GetPrerequisites! b+ E3 y) d; o$ ~, s6 x
  1587. fi3 b( z5 F% T* G- l/ C, c: @. o3 P' I! o

  1588. ; Z6 Z- y0 |; ?% G+ S8 ~0 {! E# ?) G+ q
  1589. # Select release and set paths?
      Q" l% g3 U5 h! o2 h' o
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    ' r9 n- U3 r& H3 I8 V& j  G7 }
  1591.   GetUser
    ) v5 G* K/ `0 `; [* t5 k
  1592.   GetRelease! n+ @7 y7 \% L, s- G# h2 |; a! M
  1593. fi6 J' _7 ?) W# Y% w/ s, L# J
  1594. & c# r% l: i& Y* S$ S7 S
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then
    ' `- L+ f3 @, {+ i% D4 b) n
  1596.   GetPaths0 J$ e+ ~+ I4 ]' z; L2 b
  1597. fi
    ( l" D7 X1 f: F) `
  1598. 5 M2 l0 {& V' t  }) f& h
  1599. # Clone repos?
    3 o! _# L: m* R% {
  1600. if [[ $TASKS == *3* ]]; then
    1 }' ^- z: A! [6 b5 {$ b
  1601.   GetMangos
    9 X0 k8 {5 p: S' B0 D' }7 `; q
  1602. fi) c/ x6 b3 J1 [+ A6 q

  1603. 3 v2 q- D" e; n; A3 M/ e1 b
  1604. # Build MaNGOS?
    8 L% V' Z  a! E% l! V1 B( _7 z. r+ a2 H
  1605. if [[ $TASKS == *4* ]]; then  A" `3 _3 t1 P9 x; e! Y+ y' Y
  1606.   GetBuildOptions
    9 E. m( P/ G% U$ x
  1607.   BuildMaNGOS
    : u" z' |0 s  |% ^
  1608. fi7 x5 A; j# r: d& w; S  @2 c! |8 ]+ d

  1609. 2 u0 U2 T, R8 ~. R
  1610. # Install MaNGOS?1 o$ D" ^- r# X, L6 j5 M( X5 k
  1611. if [[ $TASKS == *5* ]]; then
    - u0 k# }$ P1 H
  1612.   InstallMaNGOS9 W- P7 k+ t0 W! E3 v2 }
  1613. fi5 ?; p2 g$ j7 q! [; e8 a7 d& o8 J
  1614. : H$ _9 u, u" z& L8 Z  R
  1615. # Install databases?
    ) g8 i3 |$ u; H1 N5 F, o4 Q" x4 q% b
  1616. if [[ $TASKS == *6* ]]; then
    # K" h7 C4 z0 Y; ?
  1617.   HandleDatabases7 R, N- `( q/ [3 P3 `. V4 Y2 d
  1618. fi0 a* n- I$ I" Y% ~) h: w

  1619. $ ~; Y' H4 Y+ A
  1620. # Extract resources from the game?* @/ x- Z8 I1 M; i: N5 k" h) u
  1621. if [[ $TASKS == *7* ]]; then
    : U( ?1 _" ?( }9 O8 e2 h
  1622.   ExtractResources' |- m" W4 D1 A: a0 |+ L
  1623. fi6 G# l' z; J4 t4 X" t. q

  1624. ( r0 o( B, n1 Q0 ]) b% O
  1625. # Create C::B project?
    - ~* `' A5 _  r% X' a1 H& ^
  1626. if [[ $TASKS == *8* ]]; then
    % }9 t7 i1 d. k+ y1 z/ v
  1627.   CreateCBProject
    * p2 s' D+ i0 e, t( y! G+ `  k# @" i
  1628. fi
    $ q. g. P2 H" K0 X& ]1 T- g

  1629. , J9 w) a6 n! P
  1630. # If one of these actions has been performed, then we know the user.# m! D5 A1 D* Z! U( @
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then0 [) [9 q+ f, r& F
  1632.   Log "Changing ownership of the extracted directories" 1# t$ {2 ~8 t3 J' w& a
  1633.   chown -R $USER:$USER "$INSTPATH"
      n# U5 ]7 ~' t2 D) F
  1634. fi1 A9 `2 _6 g) t) r* S3 w5 q
  1635. 1 P. F1 K9 y2 F% R  g5 u
  1636. # Display the end message
    . S/ q6 _3 S$ z& e+ \% K
  1637. echo% V* i5 X* z8 I# J$ c% A% }* H
  1638. echo "================================================================================"
    % C2 V( M# Z! K
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please". s. y& j/ c8 d' A
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS"2 s7 t# o2 V+ [/ x/ I& @* r
  1641. echo "server. If you have not configured your databases yet, please do so before"
    4 j7 x: R4 u  H" \6 P; D
  1642. echo "starting your server for the first time."
    % v$ T" x; [+ c8 \
  1643. echo "================================================================================"
    . u) t- Z+ T8 o
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh4 q8 ~4 O- z+ E' `
  2. ##############################################################################
    * z  v- b8 X( V' X6 V
  3. # This utility assist you in setting up your mangos database.                #, P2 V; b" R; T4 o1 t
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #3 Z3 `- o7 E. [% t& {: E
  5. #                                                                            #1 T6 \8 ?; j8 R5 `! e% v1 J" j
  6. ##############################################################################" b+ O) \' M. A9 Y

  7. 0 J2 ^8 M: C! l5 [9 p" ?; S9 j9 p
  8. OLDRELEASE="Rel21"7 W' k+ g' O- x
  9. RELEASE="Rel22"
    ( O% @- h  ]* E9 s* f2 \6 h2 v) _9 x) l# x8 S
  10. DUMP="NO"
    2 ]& u+ y; O8 `8 h) W9 ?* W! \
  11. / w& v- ]2 C5 y( S; W
  12. dbname=""2 n( S" p% X0 j3 y9 N) y
  13. dbcommand=""( ~5 d) _' K, j
  14. / V' O2 R- K/ |; i& N
  15. createcharDB="YES"/ H9 t8 m* V& E% g
  16. createworldDB="YES"( E4 P. l. W& Z# Q$ N
  17. createrealmDB="YES", \8 Y) ^$ `% W
  18. 4 s- N4 ^0 z: P6 _; |" V# m
  19. loadcharDB="YES", m+ Z( `" P! H& S
  20. loadworldDB="YES"
    % ~$ _! t; R# I' \+ Y
  21. loadrealmDB="YES"
    7 i6 ~; p. P4 M. z
  22. dbType="POPULATED"4 L6 C. G7 p; p9 M8 V1 q. F

  23. 4 t% g) H2 A0 A% P$ ^
  24. updatecharDB="YES"
    : b- X5 c3 [+ d: o; p0 N9 x* P
  25. updateworldDB="YES"0 B; ~. D- v# F3 n3 A8 E) z
  26. updaterealmDB="YES"8 o5 b# H7 B/ q1 z6 n' P0 i2 A* e- q

  27. " f" q/ N' E; r+ }" j
  28. addRealmList="YES"! N: x+ V# v9 D6 U* i6 x2 J: S; [0 c

  29. 4 r) t- ]! F: W" x0 a
  30. svr_def="localhost"+ W, T) n0 K' M+ ~$ ~4 J0 G
  31. user_def="mangos"
    5 i# ~3 e7 M5 H0 q  b; u! G  @
  32. pass_def="mangos"
    & k/ L0 o2 H* @; I- D# v( k0 o) \
  33. port_def="3306"
    6 o) h. q  q) Q! S0 O  }
  34. wdb_def="mangos2"3 o0 _; M4 M6 x. t6 R1 [
  35. cdb_def="character2"/ \2 i4 @2 J6 C$ u, D! s4 O- g3 a
  36. rdb_def="realmd"
    9 ]+ C2 t* u, ^* u4 _

  37. 8 Q7 W" I6 ~8 K
  38. printHelp()
    . q; ?' T# W; e$ d9 n# B
  39. {
    5 A6 J/ d, ]* ?2 b% J& e
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"! \7 s3 p" c4 l
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"; k! u4 Q! p, Z! d6 P
  42.         printf "\t-u: Run only the updates of the database\n"
    " [6 q# m: {$ [) D/ G% J
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"! s$ G0 Q4 a: [( _
  44.         printf "\t-h: Display this help\n"7 U, K6 A  ^4 p9 j; t
  45. }
    . X6 Y- h6 y5 @: F$ j3 n

  46. % o/ y/ L& f& T* }! D& l
  47. printBanner()
    , x) k$ w+ C: a6 y, A$ D6 @
  48. {
    - F& {9 F5 s7 ?+ Y
  49.         clear
    % i+ u  f; u  O9 x( Y7 b5 D" V
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"
    $ a  a) \$ A' y' @! [" \
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"8 ]# ?8 V$ M7 ?. S2 s& \( I) b1 u2 Z
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"* W! @' T4 s9 K# p) M$ N: L
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"- l  ^. ~' q0 b" r
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"
    5 x  W, U: R" f2 y, w7 T8 d
  55.         printf "\n"% `) {0 d5 {5 k8 x
  56.         printf " Database Setup and World Loader v0.03         \n"1 ~+ j) R6 {" {0 }& r
  57.         printf " ---------------------------------------------- \n"0 ]* O, X2 |# F) K% R0 _8 _
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"6 m6 B0 w- H" u7 i, E( A: L
  59.         printf " ---------------------------------------------- \n"
    ! w# S1 d# i) q9 G% f
  60.         printf "\n"9 @1 H8 ^$ b) t' q6 }4 h
  61.         printf "\n"5 y3 H3 t- B% a! u/ \
  62. }8 ~4 I5 f" A; l" X: O  _9 g1 G
  63. " z* L& E* s. i$ A; S7 C0 a3 l5 z
  64. printActivities()
    ( o0 w9 V( ~; K3 S% q
  65. {, B6 h3 i1 L7 x  ~" d8 v) U; y
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"' S: T2 K( ]. S; s; m* p7 b
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n". q* X3 i3 N/ z8 x4 v5 x( ?1 D
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"# g& g7 e1 x2 t' q6 e
  69.         printf "\n"
    # x$ K) }/ j6 [" m5 v8 J) @1 h0 g
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"% r( x# G8 d7 q4 `2 Z5 i
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"        : M; o! n) S/ ~. \% x
  72.         if [ "${loadworldDB}" = "YES" ]; then# b% O' O, J! _- w6 Z
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"
    % `; F" k0 M1 I
  74.         fi8 P! O9 O, H$ U3 j
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"
    $ d& `; A; ?+ ^: }% I, i
  76.         printf "\n"4 ]+ H) u6 I4 F4 f  j. i
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n") x4 _/ }  `1 {0 w1 d! F
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"
    8 r; f* S3 i; s
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"3 A& j& J1 P! i
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"       
    ; ?* A5 U) t) t6 z+ h
  81.         printf "\n". e0 ^- m  Y" _2 w
  82.         printf "\t\t\t\tN - Next Step\n"# W3 S' c' O. {$ q5 F
  83.         printf "\t\t\t\tX - Exit\n"
    + s7 m- C4 N9 f+ ~7 C
  84. }
    + `5 N& i2 X' S

  85. " ~+ F; e4 H3 k6 _1 Z2 {% }
  86. determineDBName()
    ' `8 ^& G3 |  Q4 J. r
  87. {
    / N' }4 W3 }; N# j/ b" P
  88.         if [ $(which mariadb) ]; then  c; ]( ^  f$ ^$ @
  89.                 printf "MariaDB found.\n"# W- ]/ ?# c0 y& }8 e
  90.                 dbname="MariaDB"
    " C) j6 i% I, T1 u
  91.         elif [ $(which mysql) ]; then
    ) R, e4 ~8 `3 _9 ~$ [
  92.                 printf "MySQL found.\n"$ u# @" }' W2 B. p  T" j
  93.                 dbname="MySQL"
    % ~% X  W; D% ]
  94.         else
    - @  }! f9 W5 d, t" k
  95.                 printf "Did not find mariadb or mysql.\n"
    " W( T! C: S9 u: }; R- Z3 c
  96.         fi) Z: @' R' U1 k" H7 Z+ D4 s
  97. }
    + ?3 x: i7 L- W
  98. " G" M0 @1 @' b3 @& m
  99. mysqlconfigeditor()
    , a* S/ `: }/ V# b$ V" Y& r( b
  100. {
    + U# P& A' w4 Q* K. Z
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"
    2 u" l! k/ E  K% @* ]
  102. }
    . {# R9 r5 \: Q( d  E* b

  103. 9 G  q! @) b" G, k, T) Q/ _$ r8 k
  104. determineDBCommand()
    ! i# u0 K# ]' J3 H% t, R1 p, j. o
  105. {, r5 W0 i) ^# e, V/ u& S  G8 X3 Q2 E
  106.         if [ $dbname = "MariaDB" ]; then
    ' h% N8 c; ?3 m; E1 d$ @& Q3 J
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"  a6 R7 ]& \- B7 d
  108.         elif [ $dbname = "MySQL" ]; then/ a9 r1 D. T. ~) o1 R+ g3 Q
  109.                 dbcommand="mysql --login-path=local -q -s"$ m) O1 z/ M' O( D
  110.         else
    . M* e) {! _( T0 c
  111.                 printf "Did not find mariadb or mysql.\n"
    5 [4 _# @0 q3 }0 N' ~. M) u+ \( l
  112.         fi
    ; N0 ^6 q8 w" d% U& G+ i  h
  113. }
    * _: X( m9 m* O4 d' p

  114. 5 w. D3 C+ U% o7 Y  ^7 y: b6 }( e
  115. createCharDB(); f- |7 v' N" o+ u& W
  116. {
    0 r4 i9 l- R0 z
  117.         printf "Creating Character database ${cdb}\n"& {; w8 u, Q/ \. B  q+ ?0 v
  118.         $(${dbcommand} -e "Create database ${cdb}")
    / X& y8 c7 j% b9 p

  119. 1 {7 y* I& Q5 D* G1 X" L
  120.         if [ "${loadcharDB}" = "YES" ]; then. u9 c$ P$ U, g* Y9 w
  121.                 loadCharDB
    ; T4 O  J  h* v5 G1 R& k' X, W
  122.         fi
    % d3 J$ [1 @  s
  123. }
    / s  Y% d( g0 t

  124. & ~" r8 m6 d* ], ]/ y" m
  125. loadCharDB()6 Z) g5 X& }. g
  126. {$ i; @; v# k5 b8 }! i6 t
  127.         printf "Loading data into character database ${cdb}\n"" I% S3 Q% d( \$ ]! z/ V
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)# m9 u9 E1 t; c
  129. 7 {1 L0 c# g! N/ j4 y7 ^
  130.         if [ "${updatecharDB}" = "YES" ]; then
    1 G5 P, U( W+ u
  131.                 updateCharDB6 P! A3 A1 i3 F; }) G" p
  132.         fi
    / o5 T" n0 W+ x* P# y8 K
  133. }
    , q- J/ u5 O: S" q* V: n9 m

  134. 5 y% @8 a- b! H' Q
  135. updateCharDB()5 e; z' B2 `, \7 ]
  136. {
    & x, {" h) J0 v4 b1 Q6 d0 R
  137.         printf "Updating data into the character database ${cdb}\n") C$ d) [  X  G" N. A
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    ' _: c0 b  b. [6 }5 K( G2 f
  139.         do
    + X( E, B# r; {3 `2 ?
  140.                 file=$(echo ${file} | tr '|' ' ')
    9 C; l1 S% k1 p. g  E' A1 f
  141.                 printf "Applying update ${file}\n"* @1 Y& }4 d+ _' \
  142.                 ${dbcommand} "${cdb}" < "${file}"
    ) ~) J5 B* l, A7 Z1 u' Y
  143.                 printf "File ${file} imported\n"8 q" J0 r0 y! R; S3 R) c
  144.         done
    ! L4 C! X. Y0 \

  145. - r3 ?2 K4 |0 d9 N: u- w: Z
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    9 U; ^, [8 x* X( M0 F2 g5 I
  147.         do2 T% t: O: U/ w8 H4 L
  148.                 file=$(echo ${file} | tr '|' ' ')1 t- t; ]( \5 z+ F
  149.                 printf "Applying update ${file}\n"- J% ^, [& a% l: `
  150.                 ${dbcommand} "${cdb}" < "${file}"+ f* ~' b7 q% Y8 S2 U
  151.                 printf "File ${file} imported\n"
    # R2 x; u+ G6 D. o( Y
  152.         done
    ) Q& G7 t' `7 ~4 N  D9 _. U
  153. }! ?$ |/ X6 }8 A8 D5 n& d: i- V

  154. " a  t1 k: d4 Z( ]7 G6 X
  155. createWorldDB()& W6 n2 l$ f9 Y5 L) p
  156. {3 E' L9 k# p( Y, @. |
  157.         printf "Creating World database ${wdb}\n"- `" d" H% Z6 V
  158.         $(${dbcommand} -e "Create database ${wdb}")8 |5 G: J% H5 i
  159. ( ~' ?8 E2 o+ u) c7 S1 y, w
  160.         if [ "${loadworldDB}" = "YES" ]; then
    * y5 |; ^. F& v, c3 c  i$ I1 B4 z
  161.                 loadWorldDB
    ! w  ]; U$ g$ ~% m/ o* ?! \
  162.         fi. {4 n, I" Q" X% \& Q- V
  163. }
    , j# ?& b. d( O, Y6 J; k
  164. , G7 t: D' h" S) N  i
  165. loadWorldDB()
    ( O) R3 ~% q8 T3 z; ^2 ]5 X8 I; I
  166. {3 T4 A2 h1 w  }5 S: m3 l
  167.         printf "Loading data into world database ${wdb}\n"
    9 j; g  N1 c: Y- U, R
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)
    ) E) M0 [1 y; B! k, P4 Y2 c
  169. 9 \7 S! i# K4 g4 v% t" v2 t* E
  170.         if [ "${dbType}" = "POPULATED" ]; then
    5 t$ z+ x! x- Y0 X
  171.                 populateWorldDB( v9 y; g5 q) ]' ]$ |0 ^
  172.         fi1 P* L0 c4 ^& }9 K' F' M
  173. }) i9 }) k( |5 ]
  174. : Y2 A& f9 N# }. i* b* S
  175. populateWorldDB()# O" ~' d# K3 N4 M# `
  176. {1 Z1 S0 h4 O; R# l( x2 y
  177.         printf "Importing World database ${wdb}\n"4 ]% Z0 [1 ]- \: W
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')
    8 |  h# L" _# F" ~
  179.         do
    ; I# C) K% p9 W2 z# R5 F4 E/ x
  180.                 file=$(echo ${file} | tr '|' ' ')
    6 r0 X5 l; T# O/ f2 Y0 P+ m7 V
  181.                 printf "Importing file ${file}\n"$ r% v( C" T; O6 G3 _
  182.                 $(${dbcommand} ${wdb} < ${file})9 U# H, ~9 x- e2 m& `) v* s
  183.                 printf "File ${file} imported\n"2 m: ]6 I1 j) M# i# u
  184.         done
    $ G) w+ p. N- |

  185. . g7 y0 O0 l' W5 w. c
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ')
    ; x) Q8 Z+ L" p8 W: H, d6 Z
  187.         do- y/ k7 X' r$ ~, Z+ C
  188.                 file=$(echo ${file} | tr '|' ' ')
    4 N/ p2 B7 W- M+ M9 ]  R% _
  189.                 printf "Importing file ${file}\n"! \: k* E; B- ~. n7 f  J2 B
  190.                 $(${dbcommand} ${wdb} < ${file})% H. x+ P! V- E8 z3 f6 @
  191.                 printf "File ${file} imported\n"3 L& h& b! v& r2 k) H! e
  192.         done2 @  y0 R5 x$ a
  193. }
    3 S# \  V3 t1 l' Z/ b+ N5 Q" l7 Z( b
  194. 4 X; P2 [8 y* q' L; R; t+ Q5 t
  195. updateWorldDB()
    ) a7 H3 T; `) C9 h* ~% a7 D4 a
  196. {$ r& H/ s- |8 g9 }* o; ?
  197.     printf "Updating data into the World database ${wdb}\n"
    - ]3 L& `2 h& B, ~5 T, q2 w
  198.     for file in World/Updates/${OLDRELEASE}/*.sql8 P  |( u5 [) B$ @* j$ k# M- }
  199.     do
    9 J" ^, x' X( R; h7 i, x9 S4 J
  200.         printf "Applying update ${file}\n"
    7 f& q+ d3 U- l. R
  201.         ${dbcommand} "${wdb}" < "${file}"9 A1 n# k4 U* O. l; e
  202.         printf "File ${file} imported\n"
    ) T1 h+ e7 x; |9 P; ]) w6 S
  203.     done1 `8 ]+ }  Y1 ^6 B& u0 b
  204. 0 @  H9 d7 P  ]- O2 I8 `( a
  205.     for file in World/Updates/${RELEASE}/*.sql
    ' s: E" B( R$ o$ _. M: W4 s
  206.     do+ r  b! D, l, w3 L. Q6 y
  207.         printf "Applying update ${file}\n"& E# r2 r; ?4 ~4 S
  208.         ${dbcommand} "${wdb}" < "${file}") I, L8 ?, C+ m; \  B+ d: m1 ^
  209.         printf "File ${file} imported\n"
    ' f( P2 o. \( i
  210.     done
    , I. g. {) c3 T* k, q* `
  211. }
    * O2 h# R( M6 o# e: k* u8 L
  212. + S/ Q! G: h& ]7 \
  213. createRealmDB()
    : f" s  c; I( @1 b- ]: v
  214. {; g3 Z" ?# u+ {5 s
  215.         printf "Creating realm database ${rdb}\n"5 p' x+ ^: I! F# r# g9 V7 p
  216.         $(${dbcommand} -e "Create database ${rdb}")6 H# \9 a: L* g# `

  217. # [- y# l3 o7 |! ~
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    4 \" p1 a  P" x3 x% B0 u
  219.                 loadRealmDB
    , X% Y. q* {8 v
  220.         fi& z" X9 q  A  Y: }9 ^; `: r4 h6 `
  221. }
    & C7 m" G) a0 P  v8 G
  222. * n8 S/ [0 L0 L; g
  223. loadRealmDB()2 |2 _- e* D8 ~+ ^; E  L
  224. {3 Q& ?$ r/ |8 \! E+ h" @; Q
  225.         printf "Loading data into realm database ${rdb}\n"        ) U3 Q/ z' d! P4 T2 F' h- {. v4 x
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)
    . G/ J  w" \/ m
  227. }
    8 E: F% I# m' B$ i, {
  228. ; o! p; i* j8 z! [
  229. updateRealmDB(). N" \5 Y9 y( `" l
  230. {3 A( x' D8 _0 N1 u
  231.         printf "Updating data into the Realm database ${rdb}\n"/ Z" v1 }; X1 S  ^3 o7 ^
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')! I& a, T% X8 T2 [* S
  233.         do
    ) E2 P0 P( @) B2 {: K
  234.                 file=$(echo ${file} | tr '|' ' ')
    - B  X! w2 F' a! J  U, G. R/ \; c4 P9 Y
  235.                 printf "Applying update ${file}\n"
    + `" X7 B: {3 y! i3 [) [6 l" G
  236.                 $(${dbcommand} ${rdb} < ${file})# d3 L6 Q! @# i. y0 }9 M
  237.                 printf "File ${file} imported\n"
    ) o/ k. B8 q  H3 b! D
  238.         done5 P3 V4 `" t7 U- ]+ Y- C) T  N
  239. 7 P7 w* t2 @9 a3 M! q/ _
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')3 S0 K: a0 q* D, D2 f$ V3 _
  241.         do- L  A, v2 f' S
  242.                 file=$(echo ${file} | tr '|' ' ')1 b3 w! J9 }2 j# @+ X$ }% @! w
  243.                 printf "Applying update ${file}\n"/ q/ F( P$ U8 O# X; w$ p) X5 S& K- S
  244.                 $(${dbcommand} ${rdb} < ${file})! K" I8 q; a: C2 _- |1 c1 n5 d# e
  245.                 printf "File ${file} imported\n"6 a5 p4 @; P8 J
  246.         done1 s4 u' {# @) X- }! C7 V
  247. }
    2 p2 l0 f" U) d% [5 t+ S' k
  248. ( g, A9 B% Y0 w3 W9 O
  249. addRealmList()
    + m- }* K$ C7 C8 u) R$ Y
  250. {
    4 w* ]9 E1 C6 U! u
  251.         printf "Adding realm list entries\n"
    3 V9 D* y7 g1 N2 o$ V
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)! Z/ E, A  ?# H& V
  253. }/ {' S% U+ N- G$ t3 r

  254. + b/ _4 _. o3 z/ J. ?7 A) f
  255. activity=""9 D; S) C9 d. t* q6 l0 O' k6 ^
  256. $ ^' ?. C$ t) V9 d3 f; F
  257. while getopts "suh" o; do
    $ i7 v6 s( \8 q) \1 P
  258.         case "${o}" in$ R* A0 b+ {# w1 |
  259.                 s)' L) \: W9 L: o; z9 @' ^9 f+ O" M
  260.                         activity="N"
    / c2 K+ e2 f( j8 R
  261.                         printf "You selected silent mode\n"
    9 |+ c/ v" f5 K7 y: s& d4 H
  262.                         ;;
    - G% n# M, q' J; f! _
  263.                 u)
    + ^9 W1 ]$ W7 b* C! ]: \
  264.                         createcharDB="NO"
    # y/ T0 F9 j9 E" ~) C2 {
  265.                         createworldDB="NO"& R( l4 ~3 ]; _3 C1 q
  266.                         createrealmDB="NO"* _- L1 C/ {/ u1 J& S3 P( _4 w6 [

  267. % `) G& c2 O3 |' I% K5 m/ i
  268.                         loadcharDB="NO"
    5 O: y$ P+ U1 ~7 ]8 L8 B
  269.                         loadworldDB="NO", c/ X' B' ?- S9 ^- E" ^# B
  270.                         loadrealmDB="NO"
    & z  l! _& U3 z; Y6 D5 z+ B
  271.                         dbType="EMPTY"
    9 ^5 E( \. e* F; P
  272.                         printf "You selected update only\n"' m' F" b6 u! F, c: ]# v" [$ [" e. g
  273.                         ;;" M1 S: |  ~% v: G  i/ {/ E
  274.                 d)7 p2 L- A& e, u- _% P! p% z. w9 k
  275.                         DUMP="YES"# u3 b7 h# {& k3 R
  276.                         ;;8 m% U! A/ X( P5 q( Z/ @+ D- H0 q$ X
  277.                 h)$ \( k1 `) @9 y9 S# j) T* @% L
  278.                         printHelp$ E% z( y/ B+ G3 Z' k
  279.                         exit 0" M+ z  U7 e. Z9 T: I
  280.                         ;;8 L  G2 Y8 O, \: K. t
  281.         esac
    7 V% v1 U: @% J0 E) S& J
  282. done9 D& f0 x: F+ u0 {4 ?
  283. + H' Q* H" r$ R
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]
    ) }/ D; a/ U" A9 n  N! x& D7 O
  285. do; ?, y! x; a* G  x
  286.         printBanner
    & H! g. L' E9 O! Q" U: a# s
  287.         printActivities
    6 C1 F9 o+ }6 ~$ f* ~. i, p) W' l  _
  288.         printf "Please select an activity : "0 ^% ~. u! N* ^# E& O
  289.         read activity2 m6 \/ ~: i4 Y) \6 w0 I
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )8 E: P8 S: a4 ]" e, T) F% i
  291.         case ${activity} in
    ) v( F( ?0 |% V
  292.                 "V")2 D" F3 a' N% U, z" \- {6 L
  293.                         if [ "${createcharDB}" = "YES" ]; then
    0 a. Z0 H+ t! [0 c$ M$ ?( u3 H3 P
  294.                                 createcharDB="NO", d) U% v' F+ o' b1 W( R
  295.                         else
    # @* e) S2 _) V
  296.                                 createcharDB="YES"1 A9 F  X# I, C9 b* K1 ^: |
  297.                         fi: |, l( N5 d! D" v
  298.                         ;;
    . M( P$ o& }5 S/ E$ i( V* L
  299.                 "C")
    4 X8 W% ?9 ~, n' L# A
  300.                         if [ "${loadcharDB}" = "YES" ]; then+ D3 [' h$ U  R' B/ Y. b
  301.                                 loadcharDB="NO"& t; A) n9 c# |
  302.                         else ' S1 y: p# x( l8 s2 M0 J3 d
  303.                                 loadcharDB="YES"
    . `# W+ X' N! F
  304.                         fi3 ]; f: z3 e9 z6 y1 b  P( F$ U
  305.                         ;;
    6 j! v5 O0 p. j. U
  306.                 "B")
      H9 J! m/ K; _8 X1 F6 I7 o
  307.                         if [ "${updatecharDB}" = "YES" ]; then4 M4 _8 I, N8 I% _
  308.                                 updatecharDB="NO"1 z% Y2 V; j% c! v  g/ {8 k
  309.                         else % c+ G5 S, F. e. K! j
  310.                                 updatecharDB="YES"2 I# U  N% u' p: U4 v: ~
  311.                         fi
    6 u6 N' U" L& @* X
  312.                         ;;6 x- \" y( P8 B+ u: k0 g
  313.                 "E")
    ( ~+ T* k/ ?, _, s
  314.                         if [ "${createworldDB}" = "YES" ]; then6 S* v" u1 c% _9 J; [
  315.                                 createworldDB="NO"* }5 a+ e! G2 c  b, ?5 Z
  316.                         else ( C* Q/ i1 J) Z6 }& X
  317.                                 createworldDB="YES"7 R* j- V8 t6 Q$ A+ B
  318.                         fi       
    - J# B" k. V. |. a" w. d
  319.                         ;;- ]& v3 p- b6 l1 x4 ~1 j
  320.                 "W")" D1 J2 e  n( N% S4 U7 H
  321.                         if [ "${loadworldDB}" = "YES" ]; then
    2 C( ~% |' h/ U. ]2 i( y8 `4 ?
  322.                                 loadworldDB="NO"4 m$ ~" c0 d" I* g' _* t
  323.                         else
      a/ O( E4 O% [5 F0 l! @
  324.                                 loadworldDB="YES"
    * \% P* L/ ^0 H* G
  325.                         fi       
    0 }: @8 ^5 x: ~  D
  326.                         ;;0 E$ c! o0 o/ r+ ]; G, u
  327.                 "D")
    # z0 f  h, Z! W
  328.                         if [ "${dbType}" = "POPULATED" ]; then
    6 s2 I2 p: u# ?, n! H2 K  O6 q
  329.                                 dbType="EMPTY"
    % D- r- M# o! ?8 ]9 w$ V
  330.                         else & ^7 g* R$ I6 Q, O3 e$ @" t6 v9 z
  331.                                 dbType="POPULATED"
    , w, y8 b9 ~& i3 c
  332.                         fi                                
    * z# z. Y$ y5 L3 n9 E/ V3 ]& X
  333.                         ;;/ O' {) |0 Y' Z8 T7 J) Y) f' y
  334.                 "U")8 O7 H. ~: j5 r* @' |# Y% z
  335.                         if [ "${updateworldDB}" = "YES" ]; then5 g8 ?  B& w; B2 a
  336.                                 updateworldDB="NO"5 X. N) P( M9 J7 X6 T
  337.                         else
    $ q* p2 S- e& P2 F5 V, }; P! y
  338.                                 updateworldDB="YES"
    7 \  S0 e% B% c& X/ @! G1 j# w
  339.                         fi4 s& S: o5 d4 o* g/ a$ k
  340.                         ;;
    " q1 M9 @1 z5 L% p" i. g! f
  341.                 "T")8 K; U" t3 y& ]% S
  342.                         if [ "${createrealmDB}" = "YES" ]; then8 U/ N2 g% j6 i% {
  343.                                 createrealmDB="NO"
    ! P) u4 T8 `6 |7 F/ I: K2 a
  344.                         else
    ( I. g  O$ [8 r/ @
  345.                                 createrealmDB="YES"
    0 z' t% Y+ ~/ L
  346.                         fi                                 ) Z% C4 P# W+ C  ]! u/ x+ x
  347.                         ;;  d; X5 w, ~3 D
  348.                 "R")
    ( I$ B# Q1 y( W. E
  349.                         if [ "${loadrealmDB}" = "YES" ]; then+ D4 @* m- G! Q2 v; x
  350.                                 loadrealmDB="NO"                        ' g3 o* k" v0 \+ P
  351.                         else + N4 U1 D' ]. G+ f; ]. u
  352.                                 loadrealmDB="YES"
    7 d2 Z! ~: G& Q- q: `  Z% d
  353.                         fi' A0 D; K* R, f+ c1 z2 h: Y. L
  354.                         ;;( \- X5 A& O% |- c% ^8 |- g
  355.                 "Y")( }8 X5 k; N0 ~
  356.                         if [ "${updaterealmDB}" = "YES" ]; then8 |9 |5 W+ a! W' F* ~! d" P
  357.                                 updaterealmDB="NO"
    + {8 S8 A' g- y1 ]
  358.                         else # l' F5 y8 y* W5 Z% I0 ^. [
  359.                                 updaterealmDB="YES"
    / H" k4 m1 @: I) b- Z7 Y
  360.                         fi# N  U6 `8 k" L6 b( B, H
  361.                         ;;+ b! U0 u, `' s; W
  362.                 "L")
    ; G( e4 U# x% ~2 y; q& J1 u( A/ D
  363.                         if [ "${addRealmList}" = "YES" ]; then
    * x9 c. A; h% W/ \, \$ a8 r
  364.                                 addRealmList="NO"
    6 Q/ i8 W' M4 t% x" m; |* R
  365.                         else
    % E$ v2 H# A9 p: g: T8 }: W
  366.                                 addRealmList="YES"
    ) u$ l9 H7 ^) H/ _/ r% y% P
  367.                         fi9 k9 G$ R6 T, V+ [
  368.                         ;;% H3 D1 y- C, f" g1 \- J6 G5 N
  369.                 "X")  U/ q' p2 l9 L. v
  370.                         exit 0;;
    1 N: U7 H/ |9 X7 z$ U
  371.                 *)
    # v- k0 @4 o- p3 ^
  372.                         printf "Invalid selection";;# L* E! @2 U+ Y/ d
  373.         esac/ D: }; {: Q2 \3 O  X( q) f
  374. done4 ?1 H6 l" j3 M& x3 B% G* d- R
  375. 3 S. E! t! n) C$ Z% F, v
  376. printBanner
    ) Y' {  e% @3 L! ^0 l# ?9 c; E
  377. determineDBName
    - X5 p7 d" M  S/ K; Y  u
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "+ @3 v. n/ W, X& Q* }3 o
  379. read svr
    7 C0 a4 M1 [; C7 w& M* N
  380. svr=${svr:-${svr_def}}/ B' _$ m7 n; l) X3 g6 |
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: ": z, L1 E& e; c
  382. read user
    . o, l9 @0 u0 k! P& e& R
  383. user=${user:-${user_def}}1 o' O' t* U2 n' t# [- c" V. i+ M
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    ; [; z) V/ y" T3 Z; R) R
  385. read port
    9 e& T: g. |/ j2 g. E3 h( O. }1 k
  386. port=${port:-${port_def}}) c6 L/ y2 D/ r7 X
  387. if [ $dbname = "MariaDB" ]; then, q4 u6 Y' V! t# W9 w  o
  388.         printf "What is your ${dbname} password ?\t []: "8 `$ R1 X. w" \
  389.         read pass3 Z# X! N) [6 A) L: q; d
  390.         pass=${pass:-${pass_def}}
    * o0 }' Z, p' M: |3 f8 `' A9 x
  391. elif [ $dbname = "MySQL" ]; then8 V; K( y- K# D, B6 I5 L6 E1 \
  392.         mysqlconfigeditor
    1 R$ H- n8 d" Q6 k1 D; k) b
  393.         $dbconfig& d2 Z' l' s9 ^* }! S# d
  394. fi
    8 [) i# ]+ W* V; F5 s& T/ I
  395. determineDBCommand. k4 n; K* J4 y  }0 l1 Y. W
  396. ! X# H# {* v2 P' F, r& ]' P
  397. if [ "${DUMP}" = "YES" ]; then
    % M  `* ^! L, P& ?. k0 X: C
  398.         printf "Enter it again \t[]: "! ]. l7 F4 n9 A6 [& V
  399.         read pass& B0 @$ _6 p. P+ j) c/ m0 I3 t
  400. fi
    $ }) }% D! f: @  {$ b* f) s( b

  401. 7 k* [) O; Z1 i# [" i
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then3 a! V) b6 b5 k& g7 D! P# g: r
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "
    . w# H* v5 B/ m2 {  E" n2 L
  404.         read cdb* M- ?2 g% u( H. q4 o
  405.         cdb=${cdb:-${cdb_def}}
    5 S! D" B! h& T) Z7 y8 _
  406. fi
    9 b. r$ y. r7 @; p* v
  407. 0 _7 Q8 V% V; t3 F/ ?5 d! F
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then% s# _8 f7 H# ~) O. i; V1 R
  409.         printf "What is your World database name ?\t[${wdb_def}]: "
    % @) f. K1 z( B3 ~3 n
  410.         read wdb
    1 F  s# J% g& p$ h. d. Z
  411.         wdb=${wdb:-${wdb_def}}
    ; F! i# \- T1 p
  412. fi
    ; I( Y) Q- ?$ z
  413. ) C+ J) b: U/ e* l1 N
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then! _2 k' @, B0 z' Y2 ]
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "
    & N9 b5 S+ d( s2 C
  416.         read rdb
    ! s# |7 ~4 i$ B6 }8 \/ a
  417.         rdb=${rdb:-${rdb_def}}
    6 G7 r, R$ f% u& |; k. e
  418. fi
    ) \/ o1 l2 M$ H/ \; I5 d) ]

  419. 9 K7 a3 n8 x  _2 c- @. H
  420. if [ "${createcharDB}" = "YES" ]; then7 g- O9 q7 p1 C- P6 ^
  421.         createCharDB3 k' r1 ^% K2 R. E  N6 g* [$ X6 i
  422. fi6 i" y4 ?2 Y5 B# p, V* j

  423. 1 C/ ^' |% |5 J) \% W
  424. if [ "${createworldDB}" = "YES" ]; then! J$ ~  @1 T5 ~* }- r$ _* _1 M# A
  425.         createWorldDB! F4 d! C1 Z( k% @; J, B# l
  426. fi
    , h) W( _8 M1 |9 u$ Q9 H/ y8 ?
  427. 8 m! K6 |6 C# c2 y- q/ n
  428. if [ "${createrealmDB}" = "YES" ]; then/ K7 j  r7 ~6 T% y% n& R
  429.         createRealmDB% c" G0 X* W9 t+ V8 b) }! ?4 H
  430. fi
      P  v. A$ K9 b+ P5 O

  431. ; O8 @; f& J7 }/ b
  432. if [ "${updateworldDB}" = "YES" ]; then/ Z/ I6 Y1 e! ?( M: U
  433.         updateWorldDB* a* X. B3 M: ?+ H! `# C; ]  _
  434. fi- X6 Y1 g. h# _; }% C

  435. ( ]8 F& G% [4 e
  436. if [ "${updaterealmDB}" = "YES" ]; then" D( }4 Q; f% H! ?8 A$ P$ m
  437.         updateRealmDB9 j8 h( t5 B6 h$ L/ A, z
  438. fi" x9 @* S, T: s& d9 E* y* @
  439. ; V" B, d- m  U
  440. if [ "${addRealmList}" = "YES" ]; then' Z* U/ y5 W7 A' k' N( b
  441.         addRealmList' K9 S1 t" K# d8 U
  442. fi( _8 B9 \8 ^. G
  443. ! @- i, y# U4 h
  444. if [ "${DUMP}" = "YES" ]; then
    1 b+ @- B( Q+ m" X$ M7 F0 S$ `% t
  445.         printf "Dumping database information...\n"
    * H' d5 Z9 w( \" g- ]
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf: R# U% b# ?+ U9 n3 D
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf
    . k# T& Q) C- s
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf. ~4 @% `& s6 Y2 v; q  R
  449. fi
    : z/ e: c" ]" ~9 U, c( t8 y

  450. 5 Z( k2 D# ?% i# x  z/ u
  451. printBanner
    5 c2 y4 t2 J) ~4 C: e# X  g
  452. printf "Database creation and load complete :-)\n"
    + W# t" E0 u) S
  453. printf "\n"
复制代码
! H* |$ }. H$ Y1 k- C
回复

使用道具 举报

 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令
( F- J( y1 Y/ W8 F3 z8 ~/ V* I: Z1 c3 c+ m& t( r5 d
使用 Playerbot 密钥的指南:
8 h& a1 ~/ a3 y% f; M4 V. g
$ I; j3 |# M. W8 n& k标识符说明; E; i9 v# T- M
机器人名称    机器人的名称% b$ N2 M. J: U0 v5 c
朋友    命名机器人或玩家角色
! x8 \& i/ t) f& R. Z$ \目标    选择目标玩家、尸体或NPC(非玩家角色): ?: U' D8 Z$ B1 s
|    逻辑或6 G/ @* f; c* R) [5 A9 \
&    逻辑与
9 {. l5 B2 {0 w0 i4 ?1 u2 ?8 V6 v..    多个实例8 e( \$ c  `: U1 y
/命令    MARCO 命令
  A+ B6 I) |4 f: i/s    聊天:说7 u- y/ W- H  _/ e
/p    聊天派对) w* T2 d, m# F9 ^
/t 机器人名称    聊天:TELL BOTNAME
: G$ J- ]' V1 j" z/w 机器人名称    聊天:告诉 BOTNAME
& k4 F) p( k5 M8 I<名称链接>    名字=8 l5 W/ l& X8 j9 c
(捷径)    为命令或子命令分配快捷方式
" S/ y7 n6 x( }2 h& }
) T% q& p$ v+ K可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明- k& Y7 B: M% h) }2 z
.bot 添加 BOTBNAME    为世界添加角色
, J# R+ [6 G& `6 u( t" }" Y( w.bot 删除 BOTNAME    从世界中删除角色. r+ ]. d4 g& u* U9 X4 Y

( [% j& Z8 J1 O/ l% ~' R: i- ?当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)+ `3 N3 |7 W5 y5 {" @  I9 }
.bot < co | 战斗命令 > BOTNAME    分配机器人角色- L' S8 C% c: S. B

* m% n0 b; Q' r# Q: B宏命令:1 y* l! [: W$ C4 F$ }
句法    描述
# i# L( o& M5 h+ {8 ~6 y/邀请机器人名称    机器人将自动接受聚会邀请
$ `4 h6 h- [6 ^6 w0 }3 F/uninvite BOTNAME    机器人将自动接受派对不邀请
0 g: v" f. q& H; g' \
. z. f3 o  M; R  g) U2 v7 N! rTELL/PARTY 命令:(某些命令可能不适用于某些内核)
) q' ]4 {5 H: A9 B( e% F句法    描述9 A1 i  j# d( `- P& c
协助目标    机器人协助列出的角色,在他们攻击时进行攻击。
2 N/ I, \: u8 g+ ^$ m' q+ w4 e攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式
9 h! ?# f" m$ `( d' s% ~拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..  C0 {1 c; g  [( ]
拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..
5 [# o! x: N) R% ~' h( l1 j拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..
: _! j, V, @) Y/ z( r# a5 A银行    命令机器人寻找附近的银行家并列出机器人的银行余额
: C1 r6 L0 M; A# N+ m银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
) l- Y$ [# a0 `1 M; _银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..
/ U) R; T% ?+ s6 V0 s: H- S(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..1 b0 C$ P5 S1 q  q
©ast SPELL    拼写 = >
+ {) ^! \" Q7 u2 h搜集    显示收集对象选项和当前收集状态6 k) |; e7 p2 u- N3 }# ~
收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
8 y! l% b+ G- E- k$ F工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
$ H9 t5 @' H, g3 s7 B7 Z) z工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例  r4 U0 O6 n% u  b4 K$ u! X
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
( \" y3 o$ j1 [工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习
8 L% X* f+ [: I/ U/ b5 D! O工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习
5 ?0 [* ?' @" g( R5 L工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习% p5 ^& ]" b  m1 z: a
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习
1 f5 S& g; c( U+ m4 }  d1 U& D/ B8 [) D工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习
" X0 y5 x" E& D# q* S6 x  w  G工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习8 C, R% K9 B3 |
手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习$ z5 J0 f- s# c( a
工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习
6 z  f8 j7 `3 H工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习9 h3 t# R9 b* x8 E; S/ w5 D. R
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习% O5 k9 h" B* K4 l5 j+ x. H+ I
掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>..
( p% |' P0 y- g全部放弃    当机器人库存变满时,丢弃所有低级物品。
- o# D4 T3 t# D* }! w9 ~附魔    列出机器人学习的所有结界 1< Spell LINK >
- V  L# v% m' D& L9 ]5 v附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中# \" S9 p% [" J: ?7 p1 }" J- H6 U
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品
) H' S6 w! D% W1 P' ?$ h6 m( S(e)quip auto on    打开自动装备,也立即检查& i3 g# _: a- o. ]
(e) 装备自动关闭    关闭自动装备。
* a2 [0 u, o( ~$ J(e)quip auto 一次    运行一次自动装备,然后将其关闭。
1 N1 W+ k3 J: `. y8 w4 n) t+ S(e)quip 信息    显示装备自动切换状态(开/关)。
6 g: P8 ~6 I1 d- x(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用' L$ \5 ?. ^  W& ^4 b
跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人; B( s* R% \1 o+ O6 P3 q
跟随汽车    切换自动跟随距离(开/关)  r$ H/ g: I1 H8 T
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)) [, m# u  w8 r( u3 m- t
跟着远    机器人跟随,远离主人。5 H( H- L  I/ n
跟随附近    机器人跟随,更接近主人
' B0 u  _$ M7 M跟随重置    机器人跟随距离重置为原始默认值
# m  I$ L8 `" t7 X/ q(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家. _6 \( d; n  Z/ i
订单    显示机器人的战斗命令; [. D3 O6 T- g: t- F
订单延迟<0-10>    在机器人开始战斗之前激活延迟。
: q: Y* Y3 F4 z4 l- h4 S) T命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。
! j0 |6 L0 |  S* Q6 Q命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。
$ _1 v/ p/ F$ U, I/ d; Q. R命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
* R5 s5 X/ g6 ?- {命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。
7 W* c9 g9 _6 s8 D: ~" j! j- Z命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。
8 x- ^$ h# I0 H9 P7 x订单恢复    将战斗命令恢复到注销前的状态。6 h4 N' h: {1 P* B' r( b
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。5 s) m. |9 X( k0 v3 @4 J/ Q# ^
mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..
6 ~! B- I8 ^2 P" V( a/ K) I5 X3 L邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..( C! @4 L9 Y. z
邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..
" z! j) t) U. g+ I0 J7 e: d! `宠物遗弃    放弃活跃的猎人宠物。
- I/ N# q. e' M' J9 L; C宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术
, n  }' t% E( @宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色/ [& C6 h2 H  }0 E/ Q' }* d5 g
宠物施放法术    拼写 = >$ L5 ]3 t( W, r. L% N+ Y
宠物切换法术    SPELL = >为给定的法术切换自动施法
: G9 }$ \+ ]7 o* t4 s: E' m- e3 J宠物状态    显示机器人宠物的当前反应模式: P2 D& k0 R7 b3 P, P7 ]
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>0 O0 W8 c, v+ S) E& e3 ?- P
过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
% [/ A7 L6 C% L( G* }5 L) F处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素& ^2 ]7 j+ F  Z
过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石8 o+ Y/ v9 U7 w4 h1 e$ P$ W" w
拉目标    以协调的队伍/袭击方式拉动目标。: @; F0 i& N6 @2 E. K! }
拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。
5 K8 w( m+ J4 W$ a+ Q$ C( [准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。" E$ e3 J  D; d0 d0 `% u
寻求    列出机器人当前的任务
6 E8 `1 i9 k8 q0 k, xquest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..
. y7 a' e, ?  j+ Squest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >
8 Z4 ^- M1 |" A追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务1 Y1 F- s# W1 T
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象
8 ^/ S+ `* z* I7 Y& v4 F; ^任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
. E7 J( G  z6 t3 P+ g5 d; Nquest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到0 Y; [/ Y: y: L
修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
  X9 o4 s7 v4 _( C. T6 I$ _3 C( x9 Z全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品
  u8 x! K4 @  U重置    重置状态、命令和战利品清单9 O- ^4 E: n; y3 f* r
(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..
: f- a2 L" \3 c(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。2 e6 R0 P" h( z0 |" x" \) Y
技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能$ I) S) @2 v0 F" k/ p
技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..8 Q. c: S9 {: _5 ^, N# {6 z" r" N  y
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..' V9 Z% R9 v0 y
技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术
) r. |+ G# o0 X0 J4 q* }) y咒语    显示机器人已知的所有法术
+ ~% N, q* s8 j% [统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本
6 O3 W- {8 y; c3 t, Z4 O6 L停留    命令机器人站立而不跟随玩家# ~  T9 E: |* d4 W( \$ o
召唤    玩家附近的传送机器人
) X8 J" t* }. g- @' h1 A# S' c民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >..' b3 U( \0 N$ N9 x8 Q! D+ u5 O$ Y
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)
" g2 }* Q! c, K' b. v使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)$ \0 n$ S& S* j. ]
句法    描述
! I8 \9 u! ^: `  G7 x% ]天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用, T1 n0 _) i3 s% ]* i# U8 R
人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋
; U* J2 H8 F" [! [( a( y天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2. \3 m% P/ I- w+ K
人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
1 |( B" b% t) A0 Y天赋规格#    机器人将遵循此天赋规范。6 u5 Y* Y" b: c' A; A2 ~$ A
9 L$ Q* Q: F: F
1 要选择 , 。) b  c6 L* Y8 y" J  @$ D
2 每个机器人的税收增加,每次重置天赋。
% |& m* O+ B- d6 n* x( A( D0 E$ w* d6 R& h! e* K8 X

/ F4 t" J# y# Y$ o! c, j% H
回复

使用道具 举报

 楼主| 发表于 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). Q% Y. ?  P/ `7 ?6 T) ]) {* A, ]6 C
+ {  ?% i. k0 `. E. Z$ _! ^6 Z
1. Make a folder for ACE in your preferred location ( I use /opt)4 X" |( J$ O7 n
3 f& g4 n2 c( [* W" S+ S# H, G
mkdir /opt/ace && cd /opt/ace% K) M- J" d6 y8 x7 w8 Q4 `
, ~' Z7 Q- D% G: i; m, _
2. Download and unpack ACE2 W+ V, T: Q/ U% ?2 F

& v' ~- U. T# [  D) {wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz5 a* F4 X# r1 F8 W5 C; Z. R
tar -xvf ACE-6.4.7.tar.gz
* v3 U" }$ \7 g0 B& y# n9 X9 j2 `' _' L. m+ p8 j9 G6 @
3. Add needed environment variables
# o/ x, R  ^: ~! O' n. o: F; |
# v) V4 l4 t; ]8 [; m6 ecat >> /etc/profile <<EOF3 F& `' u" G8 d3 K5 V; i3 E
export ACE_ROOT=/opt/ace/ACE_wrappers7 w4 K( v3 H* i
EOF! [$ z/ G$ h+ ]2 q( M) j
source /etc/profile
6 h2 Q9 c# e$ H4 v
; w5 u/ B* G/ z# n. O# Y3 v
4. Add the desired headers7 A' n& e- J% Y. F' w/ Z
* v% q0 G5 L# ]' E$ c8 f7 @
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF
# k1 }6 N) Q# }' q! k#include "ace/config-linux.h"  U) h  v+ {4 {" X" O
EOF1 Q" P3 |  _3 q+ p3 |
cat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF* Q: L- [& t- _9 ?  z
INSTALL_PREFIX = /usr/local2 [/ N  ~1 H' ?7 W- g2 ~8 C
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU! c( R( }# a8 F; a, }& Z% S
EOF
! C" J9 n5 K! J, M5 _
4 t, J( R8 w" w" q- Q( E! G
5. Build ACE
5 X6 G! M3 n3 D$ M4 \
( L7 B0 R% r7 D6 y) ccd /opt/ace/ACE_wrappers
9 `  N5 v" b  F$ `; c( Smake2 G* K0 z! E. T8 ~% y/ m0 o/ b
make install

2 Q$ |# i9 ^/ s: t1 @; C5 X/ m7 M3 n" f
6. Add the library to the public path0 U* t- q' Z  c& q

" x6 b. O  P  ccat > /etc/ld.so.conf.d/ace.conf <<EOF1 x7 f& O- z% u/ T* ~8 D5 R5 u
/opt/ace/ACE_wrappers/lib
, }1 S7 [+ F. q0 k( V; _0 p4 d8 LEOF8 {$ f7 V* M3 @+ u7 f( t
ldconfig -v
4 ~. c: l2 x' L, C8 p" \9 L
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client1 G$ B) v5 L  _% X% m
Torrent Download
' I7 o" ~6 b; F* Z" q! q7 w4 c: @+ ~8 e. Z% l
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. Y5 F3 S9 h" t7 X& z
3 t9 Q8 H+ @6 K" o
    Torrent – Client from Dalaran WoW (Recommended). Z; l9 {# Z6 c4 ?! P( L
    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)3 s8 ^3 c4 c/ s. L! o) ]
    Magnet – Client from TrueWoW
0 q" p. j- Z& Y9 B  E
" j2 S6 a) c4 L" a" oDirect Download
7 F2 |7 R# P7 y: s8 ^
1 N) O" h" W; h2 aBelow, 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.
0 M8 a1 s6 g) ~8 |8 S. V
" }$ Y: U9 q* L    Direct – English Windows client
; J2 x. ?5 u5 O6 v, W
0 E5 @1 F  W0 X4 R3.3.5 Wotlk MacOS Client
1 D3 K1 J( Z+ H/ r, j7 d  h. ^  _( F$ p
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.
% J) `$ E0 M# M7 y% z4 \/ Z. D
( W# ]! Y( |- ?1 K8 H. J' u! r    Direct 3.3.5 MacOS Download – Client from Sunwell. E/ V4 ]2 D& ~; Z4 F
    Direct – Client from Paragon-Servers (French)(Mac)
$ `6 B5 y- e  z2 m8 s6 Z3 z. n3 o# k7 Z3 O  O2 d! @2 r
Modified Clients, LegionRemaster:
, t' O/ V0 {+ q5 Q) }8 o9 J& N$ U  Y# H# V6 x  a
    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis1 h8 }: }# C3 T' v
    LegionRemaster Patch (modified)  `& W0 f* Z/ p9 d5 B1 [$ p, ~
    LegionRemaster ReadMe (Custom)
4 }  _! q- ^+ e9 d" ?. Mhttps://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos) {* ]" O/ f- W+ t" T2 ]1 B

. U$ @0 ]# d9 [, g) L在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
9 H  {  P1 X4 L9 K
: F8 t( Y( u7 U$ O5 J! @* h本文 章 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。
9 d+ i9 D1 ^. v1 J0 {2 `: }* l7 C' s* R; f( \' \) W9 I
正文如下:( B1 G3 O, y8 b7 q6 ~
2 ^* ~. M* ~& ?
开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。
& L+ A* q% g" d' \! O  W1 n: A* Z+ T- R3 y: [/ ^! w* Z
暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。4 ]$ u: _7 A$ }* h* s

7 W- k/ ~; K5 b+ {9 x. J而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。" I  D1 R9 y! I

+ o: Z0 Z4 c* y8 t' ^- v  S1 G2 @  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。
  z; w  a; X! J+ Q: T% e. n  \
) Y/ k1 k; g& y9 f* m5 q开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。/ X2 W  b2 J  T4 X: w
; j+ D7 [3 e5 [9 P6 p4 `! q
mangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。6 Z8 u; s8 n6 a0 v3 }& x
# _% o; m( Y" f7 y
% ?8 Y2 I, F5 b* v
为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。' R# ]$ y0 {1 y& ]0 v2 P

( x% _3 J- }3 h) t5 q9 {一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:
    + C" n9 h, s$ g
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:$ m# l0 w6 P$ \& @$ G
    Brien
  • 开源数据库软件MySql
    7 b/ l; ?4 y- Z/ N: ]官网:MySQL
    , [( _5 T! H: q9 I) d
    或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库
    & P2 E8 }3 D# k/ A) y官网:
    , g* O% S/ A& L2 [" B  H( W
    我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。
    $ }8 Q  S6 B3 I- f& V文件名:CompleteSDB156-Mangos3462.rar
    ) c9 N) X3 Q6 }下载地址:
    2 v5 r: q& r  o6 v6 M

    3 v6 f' h! E+ O# V- _
二、安装MySQL数据库,以及SQLyog客户端
  • 点击安装文件选择典型安装(Typical)
  • 配置数据库服务器"Configure the MySQL Server Now",选择标准配置"Standard Configuration"。
  • 确认安装成windows的服务程序和自动启动服务"Install as Windows Service"、"Launch the MySQL Server Automatically"。
  • 输入你的root用户的密码。可以打开的使用root远程管理数据库的选项,便于远程管理,和链接。
  • 应用你的设置。
  • 点击安装SQLyog的安装文件,安装到缺省路径,运行SQLyog。
  • 当SQLyog运行后,需要输入以下信息:
    • MySQL主机地址:可以输入你的本机IP地址或者"localhost"。
    • 用户名(UserName):root
    • 密码(Password):在第4步里面你配置的密码。
    • 数据库(database(s))输入:"realmd;mangos"
      8 M4 W5 j- o4 X& i7 _
    3 ?( j5 M/ v6 A, r
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径
6 s1 h* L+ \" x/ E
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。3 n( u  S' T" S8 E; X
四、解压安装地图文件# M- C4 ?7 J# N
  • 把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子目录了。0 ]3 p! f2 |! I$ F: T9 J( J
五、解压安装提取的*.dbc文件
: x: A& `- M1 y% U; t
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:+ A; M& g, ]- N- W" P5 m  K
    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")了。
    1 ?4 @- V) s0 ]) ?% p! w
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.
8 |& b' x4 T8 }/ o; B% g0 x; H5 ~  y  G
  • 将下载的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”,导入数据库文件。/ x  r" x* E  t) U/ d
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。( K5 e' T/ t. m4 [; ]9 P
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到9 t" Z2 w9 R5 h9 R0 q, Q$ z
    "LoginDatabaseInfo ="
    6 }3 B! o/ i$ e& W, ~改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"
    ( j  c3 `9 y* e3 }! `( m这里的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"
      4 g. H* J6 _5 f( I" u2 ]

    - k6 N, H) `) D7 p( t; W8 w, W; s
同样,这里的IP地址可以是你的IP,[password ]是你的密码。存盘。到这里基本就大功告成了。先运行realmd.exe文件,稍等,运行mangosd .exe,魔兽服务器就已经运行了。连接到你的魔兽服务器,修改你的魔兽世界客户端的realmlist.wtf 的文件,将127.0.0.1 ,或者你的IP地址填在里面,例如:"set realmlist 127.0.0.1"   到此为止,开源的魔兽服务器就架设成功了,我给朋友建立了几个gm帐号,他们测试了一下,觉得这个版本的做的很不错了,开源的宗旨是知识的分享,开源 社区黑客们的探索精神页不得不让人佩服。

0 X  X# O; T& F/ U; R4 q
& {3 q3 m% F' g" m
4 y+ O5 S, L' X5.安装数据库& Z% S5 v6 B" J
使用mysql建立 mangos 数据库) h6 J: d. g9 |

3 V: a+ K% C8 I  `  A2 ya1)使用官方最小数据库,mysql用户名及数据权限等请自行设置. a0 ?7 T' i. P& @& w* z. i' \
mysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据
9 y* @/ N9 F* \- Y3 N$ `+ C
' C0 {/ u2 F! _  \- v3 Za2)使用sdb数据库,mysql用户名及数据权限等请自行设置
: j% v" l7 y0 l6 z6 w. S假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql
0 }4 _$ v$ V( v6 I! ?mysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据' b, G8 i% u4 r* r) S! ~

, z% n3 C$ b9 A1 \& pb)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1$ X# R1 ~' j# @9 k! ~9 ~
! ?2 R8 b' X- ?/ {6 g
6.编辑配置文件
# l6 z  d5 ]+ z: g) y编辑 /usr/local/mangos/etc/mangosd.conf
% e9 r8 H: i- M6 E0 K- O$ W3 ?" [7 ^& U  F" [& p
a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"" D2 U4 z6 v( e# k: ^+ ~
为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"
8 r) \: G5 }2 @& I- D
: o# S7 ?& A5 `$ Fb)找到 Host = localhost9 H0 ^4 W% |5 Y+ c3 x: ]* ~
为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1
4 b# D0 w% h' b$ M
$ A$ e# R( `! y
回复

使用道具 举报

 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。- G$ F- |1 V' b6 R
( w$ @8 d) ?0 |) Z
本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。6 J7 |2 U" A6 E. @7 k3 w

/ E( m8 q8 K* u1 g6 _我们走吧..: ~6 f* M1 m$ r" z" p! _
, q% P; A& Z( L3 q! U! o
设置数据库:
4 x6 R+ _) m2 h6 ?1 G+ j' \# p* P$ {0 z9 H7 b
CentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。/ p% H4 @, ~, |7 ~3 e4 x+ ?0 f
  }; \, q& O( O9 r# F( S! x2 |
启动一个终端,如果还没有,您需要成为“root”用户:
* }! y) P7 `/ Z. x+ T9 a9 T& @+ K5 |  B3 j: a3 \- |7 N7 {" t
须藤苏 - 根
. ]1 D. H; k1 d( N$ Q然后,安装 MariaDB:
8 b- H; h) g2 e% V. X6 t, B3 a! e8 X
yum -y 安装 mariadb-server1 E/ i( |8 @- s" u. f/ ~( C) S/ x8 w
     安装 MariaDB 后,启动它:4 \) X) i3 ~- T( l% a' r
& l9 e7 N: \9 ]* z8 B8 N
systemctl 启动 mariadb
' w# P/ Z/ Y9 y我建议您在启动时添加 mariadb 服务以自动执行它:4 T) s) `& L# z1 R
1 v  P9 l7 y/ z( ^9 g* }$ `$ o
systemctl 启用 mariadb
0 ~2 [2 }; a. k  x3 P1 r7 M! E让我们保护您的 mariadb 安装,执行以下命令:
, d$ z/ T2 {5 [8 [. Q2 L' }: ]0 `! s# V4 U1 K8 C, _
mysql_secure_installation
: _, j7 S8 U8 P' o0 {1 Z我建议您设置以下参数:
: y/ O: f2 B/ B% @2 w
0 ?0 c; ^" F6 c  u' S' a& k9 q, Y设置 Root 密码5 n" |9 m$ n# I" ^: Q" }% [- \! X
删除匿名访问
! r2 u  r5 ]# r: S3 \禁用 root 用户的远程访问
5 E7 f7 p2 E- n  U1 |0 d0 F删除测试数据库; P$ Z: r7 O% S3 N
重新加载权限
+ x  P  h9 p9 G6 Y1 a. X验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:
( G8 G% k4 _8 A2 ~' O) n& o* ?7 e6 {$ C2 |* A
mysqladmin -u root -p 版本
- }1 M( U3 u8 `; @* |如果一切正常,您应该有如下输出:
5 ]5 M3 j5 C. B4 r
7 E7 |  J; I+ z& R- f7 X) J服务器版本 5.5.52-MariaDB. w- E2 \2 r/ P: C- ~
协议版本 100 `- a3 v5 ?: ?. G& p
通过 UNIX 套接字连接本地主机
' M1 ]0 |5 e; O5 l1 }' i- ]6 ?UNIX 套接字 /var/lib/mysql/mysql.sock
) ?$ ]& ?$ {- Q- w, j正常运行时间 x 秒
. b5 o& q9 ?: [/ c( T7 \6 g ) c! ^$ S9 y- X% ?* ^

/ N- _) _- D! R  f/ f现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:; z' g* @. ]! D; s5 {

2 M$ [/ {/ V$ z5 _5 f! V3 u$ \mysql -u 根目录 -p" k4 p& k% y0 J
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):
& [2 I9 R: I* N, R1 E
4 {4 B+ `2 r% P# ]' D1 \6 f, @  O创建用户“芒果” @ “本地主机”由“密码”识别;. f7 y' o; c; V5 f
然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):
/ ^" R& W" }" Q" B" l8 O% t# I" ]: m5 H# h: n+ v2 s
将*.* 上的所有特权授予“芒果” @ “本地主机” ;
' X6 Q. |7 H, J退出终端:
( p% O/ U6 H: C
, o0 P: h" Y1 Z' b退出
0 [6 c; ~7 J% f0 ?! `+ K* _恭喜,您已经在 CentOS 上设置了数据库的先决条件!
8 q) i! s+ }$ [, s8 V* i
* _8 p/ ?+ r! L" E# Z( E 1 i6 G0 o$ W) g& l7 E2 u. K

" l: D: c2 C8 H) r; S安装芒果:5 I9 p4 W5 q0 I$ C

" W. j; Z( i8 _2 H1 h+ r+ C我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:* v5 W$ @+ H. d) ^, M! F* |
, X7 }# a9 |6 x
光盘~
( O9 E% p6 C1 o) N! ?2 y& j让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:" d: A/ v; c' E* C+ g( N% e, c

4 V, G: l" {+ {8 [6 Tyum -y 安装 wget0 V; [2 W: i+ G$ A
现在,我们可以下载我们的安装程序:- X. T8 l1 z' J5 m. s. k  m, k

3 O  z) d" }/ `6 R$ W1 H4 Q8 Y: bwget https://raw.githubusercontent.co ... /linux/getmangos.sh2 t& x* L6 z& t, f) Q6 P
设置允许执行它的权限:
6 H6 Y1 I; v5 z! X& T3 A9 f- w& h- f! G& W, _
chmod 700 getmangos.sh  [9 x" N- H- c. P( U" L' k
并执行它:: M1 h$ x/ U- c# {$ Z3 p
: ?) n3 t8 j+ Q( o
./getmangos.sh
+ g: I! S3 x& A" E3 @+ r( y在我们进一步讨论之前,对可用活动进行一些解释:
8 A* L0 h; d2 S
3 {2 {6 t" V, e5 @7 o' P& s& I3 z安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。8 x0 [3 q, H7 O0 z, G
设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。
1 P7 ~; ~% U5 G# R$ k* ~克隆源存储库将帮助您克隆Mangos源。默认切换。. ?3 T2 ~+ E2 ?" n0 \5 y
Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。
/ Y0 Z9 D$ l! R: q/ u" l安装MaNGOS将帮助您安装MaNGOS。默认切换。
8 a4 b- r0 L' h  b安装数据库将帮助您创建数据库模式。默认切换。
4 X+ R8 k) w4 ]+ X! t* Y* G) c提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。
. \# S  b% ]7 z7 T$ m' D1 N- s创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。& ^% X" C. m$ U
现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。, X1 k  O. w' l4 H) j2 j

. s( D2 n4 y' P, f0 b6 Z1 i, ~用户选择:8 G) p% k0 o5 P
0 J+ n( |0 v( I7 |# M
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。; I$ q4 u+ G1 ^6 ?4 `, n
& \! D- B  k/ m' u0 {
如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。
  \6 }$ |% z/ P5 L' k
3 f# l3 Z7 P0 `+ U1 W! {3 X% z5 f0 w选择魔兽版本:
8 ~% l$ a; z2 e5 [+ D; r4 W. A: M' A
下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。5 z$ i% t8 u" B9 i; e$ {
! x/ ]' X2 D& a, R2 O
源代码路径:5 L( Y" Q5 C( g' u" e+ s+ }

6 x" v1 j4 h) e( v下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:) u9 r; S- L' a/ @; k* |  A& [

( x, M: C. x! B4 T/home/芒果/zero/src+ ?* N+ l3 ~/ M8 o2 a& g
如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。' \# I. X; ^0 }, }/ W# g
( n$ Y6 q$ U' H! e/ B7 `
安装路径:/ u% ^5 X- b) t# R" w
" }8 i# }& M6 f+ b$ O! y, C
下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:
& y+ J8 c5 t' X, ~9 e+ X2 ]6 d  V% t! k/ J( V' L  a  `0 `
/home/芒果/零" c7 O( b7 R3 @6 e0 P
如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。
6 \' U% d  u2 K  {# O  l' C1 w: r- R; \, a* e
克隆或更新MaNGOS:
/ y3 w6 Z; K; a" b. g, T0 w9 J! E$ S5 X
脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。
  G% {! i* O- B) Q7 X" o/ V8 x% w! C- d+ F1 G1 {
安装程序现在正在克隆服务器和数据库存储库。# G6 z: \% g5 F; l: U

: \6 G8 v' s- n: u构建选项:
; \  j0 K% F0 n: Z" L* d2 _4 ^  l
% \  ]9 Q( p6 u( m您现在处于构建步骤。此屏幕上的一些解释:
* ]: @, v9 w. e7 ~: b; m; q) C2 s! M+ C- R) A8 C* B
Enable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。
9 F- n( |' u: v6 \/ w2 x' l使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。
* A2 k; J# o. O. V! F, A. G使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。5 `. N4 o4 a( `& D. j6 f
使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-11-2 10:52 PM , Processed in 0.107348 second(s), 25 queries .

Powered by xyh-moon X3.5

© 2001-2026 Discuz! Team.

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