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

MangOs搭建魔兽世界私服

[复制链接]

989

主题

92

回帖

5万

积分

管理员

积分
55361
发表于 2022-7-29 09:16:01 | 显示全部楼层 |阅读模式
话不多说,开整!) @! Y- Z  V' A" \2 y3 p1 l+ O
考虑再三,我选择了CentOs来做游戏的服务端操作系统。
; L( q7 I$ l! Q" |4 A( ^* L( }4 S通过Git获得Mangos的源码之后自行编译搭建服务器。$ n( t0 U9 z2 F# M, H" {
这么做处于几方面的考虑。( l. I0 q4 M, Z8 p& T* X. o
  • 我看不起Windows操作系统。
  • 我更看不起那些Win系列一键安装包。
  • 考虑的可持续运行的服务器,Centos肯定是不二之选。
  • 不自己编译安装,怎么能进步呢?
  • 万一后期自己想修改游戏,设计任务,添加物品呢?
  • 没错,我就喜欢开手动挡。自动挡,那是给残疾人开的。2 U' J$ }+ K- c" b, H7 `. s: v/ F- g; l" d
首先在本地安装虚拟机,虚拟一台纯净的Centos7操作系统。8 R" a. ~* N3 S" E
把该打的补丁都给打了(yum update)
' C: _; `: S" A) i完了之后,咱们安装一些基础的组件和环境。6 ?- c/ ~% T  T) y8 {& ]4 O# a- G
Yum install git cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel
% h) O3 X4 g8 D7 n# |. @  F* N如果有些组件提示没找到,无所谓。继续往下。8 w0 H6 y/ [: J: W: N" B
我编译安装的第一个版本是cmangos。
. M! R5 J/ o! j1 j: {这个版本支持机器人,地图提取工具。在编译的时候可以添加参数。
& c4 z% P% r; X$ _4 Bcmake -DCMAKE_INSTALL_PREFIX= -DBUILD_EXTRACTORS=ON -DPCH=1 -DDEBUG=0 -DBUILD_PLAYERBOT=ON
4 @4 Z' ~6 u% `+ _/ P2 F0 f9 \编译参数中:
/ p# a9 E# s4 BDCMAKE_INSTALL_PREFIX是指你的服务端安装目录,可以自定义。
! p7 E) O. H! `: V+ qDBUILD_EXTRACTORS是指是否安装地图提取工具# a2 M' e0 p4 y" U0 h$ [8 Q, d
DBUILD_PLAYERBOT是指是否打开机器人5 Z- H( q2 }$ T( N  D  u0 r
这里我做科普2:' j/ T* A" Z$ G, s# D: m3 L
首先是科普1我们提到过,MangOs是一个大型多人在线角色扮演的游戏服务器程序框架。理论上他是可以模拟所有的络游戏的。' D$ h1 {- w* T& x0 K' R# c
既然,现在我们用它来模拟魔兽世界。那么肯定要对魔兽世界进行独立的一些补充(数据补充)。这就是上边地图提取工具那个参数的作用。我们需要上传一个魔兽客户端(你想要搭建的版本)的地图文件。然后我们使用地图提取工具,对客户端进行分析和提取。配上专用的数据库来模拟暴雪的游戏服务端。9 q9 F. k( o1 Z$ I3 |/ U& V! M
至于那个机器人吗?那是个笑话,请自行忽略。& k0 S) Y! |# ?, d! K2 ~, O
我们继续,我把整理好的搭建步骤列一个明细:
" m3 C$ s$ ^- I$ Z
  • 首先使用git选择一个自己喜欢的版本git到本地服务器。
  • 然后设置编译参数开始编译。
  • 提取地图放到服务端(下载别人编译好的可以不用自己提取)。
  • 下载安装导入数据库(感谢Mangos使用了mysql数据库)
  • 对服务器进行配置。
  • 启动服务器。
  • 配置客户端的服务器链接地址。
  • 开始游戏。
    : }( ~8 @3 J) k" X3 s0 h# K) o
这中间,我把一些别人不会告诉你的关键步骤做科普3:
' @6 j$ p6 p/ M2 a1 Q% [! f
  • 在编译的时候需要用到gcc、cmake3、ace等几个核心支持。
  • 某些特殊的服务器版本,不支持地图提取工具的参数。只能曲线救国去找,下载别人提取好的地图文件(我这里去找了个别人制作的win一键安装包,借用了他们的地图文件)。
  • 数据库汉化是个细致的活儿。没有编程数据库基础的,建议曲线救国。
  • 有些魔兽客户端版本,并没有太好的大脚插件支持。(反正我玩怀旧感觉大脚怀旧服专用版就做得很好,可惜不兼容我的1.12.1)
    ; M! ?2 D* Q, z
放几个链接仅做Mark:4 Z- F- y: r' E  g' {+ @' I
Cmake3 安装
  p$ e5 m: u  l9 k" ^6 Vhttps://blog.csdn.net/weixin_38883338/article/details/86408749
' H, R' Q; ?/ NGcc 6
( G  u2 @0 E1 _% thttps://blog.csdn.net/Al_xin/article/details/92438055  C0 k& A! x- h; o6 Y( Y" U
ACE6.3.36 `+ q/ c" W6 I; n( u8 t2 Q
https://blog.csdn.net/u010587274/article/details/50965369
9 s! H2 `) t) @) SGit源码和数据库编译安装服务器7 @% z) v* h3 d% S2 Q) V! y4 ^% t) R
git clone git://github.com/cmangos/mangos-classic.git mangos
) ]8 C! I& y! l% C1 {git clone git://github.com/cmangos/classic-db.git
1 Y6 u! e6 A1 P3 C4 ~ACE的编译安装和地图提取,确实有点耗费性能和时间,不过地图和数据库后期你熟悉了可以越过,而上述三个环境的安装是铁定要做的。
5 A# b3 Y& \6 w- w我们来说一下服务器的配置。
4 }: i4 y6 p2 F4 M  X在编译好服务端,上传提取好的地图后。我们要设置两个文件来启动服务器。分别是etc目录下的:2 V, K. p, G! E% i" F7 q
  • mangosd.conf(服务器参数配置)
  • realmd.conf(账户认证服务配置)
    / T) E, `+ E: G1 }# \0 r* a- L7 P+ T
有几个关键点,我整理如下:5 o1 ^. {( n- [, h2 R1 ]
  • 首先是地图目录的配置,你可以写绝对路径,或者相对路径。只要写不正确,服务器启动不起来。会提示xxx.map exits之类的。意思就是找不到地图文件。
  • 你要配置数据库的链接地址这里可以连接远程,本地都ok。只要连接地址、数据库用户名、密码、数据库名字正确就ok。
  • 我们一般会配置一下进入游戏的欢迎语,人物出生的携带金钱和出生等级,还有打怪升级的经验倍数这些参数。
  • 如果你需要做一些有特色的的东西。可能就涉及到修改数据库了。比如说人物出生送T3套装。这个就需要去数据库中进行配置。
  • 如果你是为了让朋友一起来玩。就吧那个BindIP给注释掉。否则可能引起一些无法连上服务器的奇怪现象。! G% E" O/ Q! F& Y! l" c  B
参数名称:
1 \3 V7 P5 @9 T9 Q9 f. V地图目录
. |7 v7 B; D2 V4 a7 M4 {DataDir = “../data”
% n  P( r8 I0 B4 Z0 J3 M4 H日志目录; z" Z! D6 {; q& v- y$ ?7 g5 D
LogsDir = “../logs”$ W3 G( p$ {3 u, Y$ T, B
游戏欢迎语
: h) \, I0 }# t% |" fMotd= “游戏欢迎语”2 `5 y/ z" l1 H* r/ q
出生等级
: o; _$ y9 {6 pStartPlayerLevel = 1; [8 U$ U- p  w4 D. f/ W
出生携带金钱1000G( N( `( [/ ^4 l
StartPlayerMoney = 10000000
+ o. m3 _- |5 M+ H0 I$ ]7 d" G; {杀怪经验5倍1 v7 w/ E5 M- A; S
Rate.XP.Kill    = 50 A; a6 N7 f: m9 K# O
任务经验15倍- {& R  c8 z) V& V# n8 K
Rate.XP.Quest   = 15# K( ~' B# f& m, j2 k' @8 e
探索地图10倍% e7 a0 n* B% N, d+ Q  d0 P
Rate.XP.Explore = 108 Y. r3 [5 b( W9 x0 H
数据库连接(应该有3-4条之多,按下面格式修改即可)
+ R) Z( e4 ^5 qLoginDatabase.Info              = “地址;端口;用户名;密码;数据库”
3 d& m3 T! d6 B! \: y, S配置结束,就是启动。
$ ]# O( T5 x) ~6 R8 x/ o1 Z8 `因为,我们搭建的服务器属于广域网,可以让朋友一起来玩的。那么肯定要对防火墙这些进行配置。否则防火墙会阻断服务端提供服务。2 A0 M7 m4 \; p/ s
我们需要开启如下端口:
; Z* x) Q( z1 _7 ]* B  \  p  i; k8085,9600,3724* ]4 O5 L* e# D6 b1 R# w
把他们添加到你防火墙的白名单即可。/ `. L# [: e1 e9 d$ {
(当然,考虑安全呢你可以修改一下端口号。这我就不多费口舌了); H! K: O8 U5 }5 ~. d* ?) n- F+ C
一些收尾工作:
& v) I5 B8 s' a. O- S
  • 主要是对服务器进行安全加固,例如修改ssh登录端口,禁止root登录。开启防火墙等等。
  • 对游戏数据进行定时备份。毕竟是自己家的服务器,有时候可能会来做一些测试。数据备份显得就非常重要了。我反正是1小时已备份。这个用shell脚本去备份mysql数据库即可(注意清理)。
  • 可以要制作一个网页,开放给新用户去注册、修改密码、下载客户端等等。这个就是另一项技术了。有机会我们再聊。
    9 {8 ~) ?* ?- u5 _1 g6 i2 I( d

游戏登录界面

游戏登录界面

成功进入游戏

成功进入游戏

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

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 2022-7-29 16:13:58 | 显示全部楼层
yum install git
: O9 G: ?9 \7 c  Ngit clone https://github.com/mangostwo/server.git4 n+ h6 n+ m5 `; u8 }- {6 P
git clone https://github.com/mangostwo/database.git
. W6 l$ Q; M9 k, Y6 |
; P* A5 ]+ n, }+ _3 H* }; N
  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-scl3 C- t2 ]) v* w& j! P% r9 Q, _
  2. yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils
    3 S3 F/ z) H4 j* r8 w
  3. scl enable devtoolset-7 bash
    0 R- u5 ^1 ]0 x) }! R' j; h
  4. echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile
    $ V* [  Z; e8 F- X& w
  5. # 查看安装的包6 L* }3 j9 H4 W$ L& I
  6. scl -l + n4 J5 G& f- {; @3 e
  7. yum -y install rh-python35
    5 f  w3 \' a$ D1 O% w; c5 U6 e
  8. scl enable rh-python35 bash4 l9 }: P1 j  r' p& D
  9. echo "source /opt/rh/rh-python35/enable" >>/etc/profile
    6 }9 E& @4 B& q! p9 j6 P
  10. 8 L$ ]8 [% a& {: V8 X- ?" Y5 f) E1 A
复制代码
  1. wget -c https://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.gz
    : z8 K) I; R6 Y2 h: r. l/ Y; |
  2. tar -xvf ACE-6.3.3.tar.gz
    * U  }0 e  b* A0 @5 o' ?! F- E. |
  3. vi /etc/profile
    ) [, Q  q: R7 L) S4 L
  4. #在文本尾部添加:* m7 ~, W8 U- ]
  5. export ACE_ROOT=/root/ACE_wrappers
    7 }' ]. y& t* d/ j) C- d( _
  6. export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH# ^  b  S3 `. x1 b! x( B& H
  7. vi /root/ACE_wrappers/ace/config.h. K  a0 M: F' `2 e- c% ]
  8. #写入如下内容:
    0 E5 o. \" E5 U0 B; t, F) @
  9. <code>#include "ace/config-linux.h"8 @/ P$ b% ^# R/ B& \
  10. </code>
    ) D6 R, `* S, [, w& o5 U4 b
  11. vi /root/ACE_wrappers/include/makeinclude/platform_macros.GNU! O8 Z: J2 w) k' m
  12. 写入如下内容:
    ; G# q$ n) o! X8 V6 h
  13. <code>include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU</code>" u  T; F5 K, B, }* X
  14. <code>INSTALL_PREFIX = /usr/local</code>
    8 s* Z8 d5 A: F# ^2 q
  15. ! Y' A9 A# C7 s4 J# F/ H; [
  16. chmod 775 -R /root/ACE_wrappers
    - [6 p% ~. L- W9 ~
  17. cd /root/ACE_wrappers/, {) g5 Q& h$ M: J
  18. make
    0 U4 F' P, U( t( [$ a
  19. make install
    5 N! I& c8 K3 z% ^: f& ~
复制代码
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 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; R' `/ j9 w3 [3 y
  2. ###############################################################################
    - a( |6 J8 I' Y9 C3 m
  3. # MaNGOS Build Automation Script                                              #; e4 y: k3 M8 O# a  l3 d2 g1 M
  4. # Written By: Ryan Ashley                                                     #
    , m8 W6 ?( O% Y! y1 N
  5. # Updated By: Cedric Servais                                                  #
    ! a. B/ B3 t3 c9 B0 h
  6. # Copyright (C) 2014-2022 MaNGOS https://getmangos.eu/                        #
    5 y. G1 x- j* ^$ f+ ~. {
  7. #                                                                             #% y5 d0 ~4 }$ ^9 O
  8. # This program is free software; you can redistribute it and/or modify        #% ^# U; ^1 |  E3 {2 R+ V7 t0 p- G2 z
  9. # it under the terms of the GNU General Public License as published by        #
    " b; i. C- l+ `& T
  10. # the Free Software Foundation; either version 2 of the License, or           #" y- |! x. ^' W% G
  11. # (at your option) any later version.                                         #
    1 D; J0 i5 Y. |& A+ u* z
  12. #                                                                             #
    . r; p" N( U! W9 X) j/ x
  13. # This program is distributed in the hope that it will be useful,             #0 R! ?9 D: q* C% q$ }1 u. \
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of              #9 C  h  j5 t) J1 P/ c
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                #
    2 X! k6 v! x- N, U7 t/ _1 \5 c
  16. # GNU General Public License for more details.                                #
    4 l) h. d& g; w  q
  17. #                                                                             #
    ( J0 ^# I% {" \2 u! n( h
  18. # You should have received a copy of the GNU General Public License           #
    3 z/ W8 g& a$ i' _
  19. # along with this program; if not, write to the Free Software                 #. u- f, [0 ~1 n" z
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA     #
    8 i% S, P* _2 L" ?# Q  q
  21. ###############################################################################
    ( C2 T' U% ^* j" y

  22. . D/ N) t, c) u$ p  r& n
  23. # Global variables& Q1 X, d' |+ p* [. a: \3 P
  24. DLGAPP="whiptail"
      R+ p( @8 ^+ S( L) Y$ Z% M
  25. VERSION="2"
    * s7 Q6 z( _/ _, E
  26. ROOTPATH="$HOME"
      ?0 f. O% e( J) n8 A* w
  27. SRCPATH="$HOME/mangos/src"6 `" C* N! ]* l) t$ S! d& P1 e- v
  28. INSTPATH="$HOME/mangos"  p) P. U# I6 w0 k% ^+ p" E9 \% ~
  29. DB_PREFIX="two"
    + u5 f6 F% U8 F+ b# C
  30. USER="mangos"
    4 V' v0 o  t; i
  31. P_SOAP="0"# \& g+ s. Y' \, \
  32. P_DEBUG="0"  h7 m$ k. D) ~' l( a
  33. P_STD_MALLOC="1"5 ~9 h0 s% \. I0 Z: D" s. Z/ c8 D
  34. P_ACE_EXTERNAL="1"  c  S, ^9 m' ]/ f
  35. P_PGRESQL="0"
    7 A- F, m4 U% {
  36. P_TOOLS="0"  p) `* t7 F( K, R1 q
  37. P_SD3="1"$ {: h4 U8 X0 o7 a/ T
  38. P_ELUNA="1"( S! g' m8 Y9 L
  39. P_BOTS="0"3 U% W! C0 b6 @6 E5 L3 m" R
  40. CMAKE_CMD="cmake"
    ! D. ~, ?! s  D1 p0 x) ?4 E- h" C7 c
  41. + l3 @# ^3 D6 I3 U/ o+ g( I
  42. * V  B! z/ [; ]" M; k9 b
  43. function UseCmake3()% {9 c7 ~0 A% q5 ]- z3 |! p9 |
  44. {
    $ Q# E2 u! M/ ~, s* _" r' m
  45.     # set the command to cmake3 if its there" [: O6 d8 ^! T% V+ M% w6 N1 F, {3 J6 S. F
  46.     which cmake3
    2 F4 b1 [7 o0 M- z
  47.     if [ $? -eq 0 ]; then
    & W6 L# h- [$ c3 G
  48.         CMAKE_CMD="cmake3"2 k# X( k! m$ @( l: p3 ~0 q% Q' O
  49.     fi4 |) N# _0 {- h9 q
  50. }. K5 z$ W% G4 h: Z$ o) g! B

  51. # n7 i5 N+ Y9 F6 Q; r
  52. # Function to test for dialog
    7 h/ |2 X1 e5 }
  53. function UseDialog()/ v' T! P: T$ B3 Y$ `! C2 V; o0 Z3 ?5 m
  54. {
    7 U7 ~6 O* }7 P. B
  55.   # Search for dialog7 `2 H: E, Q* c  p  @
  56.   which dialog! `2 @; `4 D+ ~0 m4 T

  57. ! r2 d: Z8 e8 h; [5 ^1 h- B
  58.   # See if dialog was found
    . e! o  h+ j& n2 K- D
  59.   if [ $? -eq 0 ]; then1 a: i, P1 K2 }6 R
  60.     DLGAPP="dialog"
    " h1 n% L9 C# Y6 Z' h5 I
  61.   fi
    & \2 f8 H. V8 G7 j
  62. }
    0 v/ W; ~# ~' H8 V& o
  63. - [; q. F0 L% Z8 P/ j
  64. # Function to test if the user is root or not2 E: p0 |2 `' j3 G9 G3 l
  65. function CheckRoot()
    2 |1 K8 d9 p7 c& h2 `7 P! w3 i
  66. {+ A3 L% ~8 h3 n3 Q$ L
  67.   if [ "$(id -u)" != "0" ]; then
    - x1 j6 ^3 B7 w+ c" }0 |0 X1 K
  68.       Log "This script can only be used as root!" 1* f/ r9 k* B$ @
  69.       exit 13 t2 R- t, g: J3 d& Z" @- e
  70.   else! y. n1 B# j4 q8 _
  71.       Log "User is root, check passed" 0: ~2 c! A0 X7 `+ U" L
  72.   fi3 {4 m6 T4 }* `2 v. k1 s+ j
  73. }3 {- V) Y; E2 T- o0 \
  74.   i; t; E  x+ n2 T! g/ {& [
  75. # Function to detect the repos
    7 u+ G$ n4 T5 h' q, t$ I; C
  76. function DetectLocalRepo()1 Q/ V) w* D) b2 N1 M# V
  77. {; L) |- _. s  o
  78.   local CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"  e5 ~! ?( X8 B, C6 j7 W: E% m% s& r

  79. % P1 Z% c+ Q. w: a4 I
  80.   # First see if the Windows stuff is in place% O/ i+ N9 @' P+ v
  81.   if [ ! -d ../win ]; then+ M5 `  r5 y' Z2 O  K
  82.     Log "Windows files directory does not exist, assuming repo has not been cloned." 0
    + ^4 c# f5 b) X5 \) p. _
  83.     return 0" L4 l8 ^; x+ I' q/ K
  84.   fi# O& V" G- ^) |( E  ]' k
  85. % j, [2 {) q( L1 S
  86.   # See if the sources dircetory exists4 w$ y; s6 Q  ]5 g9 R# h! h- z
  87.   if [ ! -d ../src ]; then( s% {0 S5 Z9 |7 @2 A% v1 z& J/ q' _0 m
  88.     Log "Source files directory does not exist, assuming repo has not been cloned." 0
    ( i2 ], X. `" \9 `4 b
  89.     return 04 F% E# d$ ]0 d8 }( K5 l
  90.   fi7 Q$ ~4 ^5 g# I; i

  91. 2 t: Q+ x% S( h! J% l
  92.   # Check for the CMake directory' E! H# M- Y0 u6 z! B% H/ s% S
  93.   if [ ! -d ../cmake ]; then
    . ^, _- W# A  s4 M
  94.     Log "CMake directory does not exist, assuming repo has not been cloned." 07 X9 \- U  Y9 V3 T! v3 m% W, ~
  95.     return 0
    $ i4 D$ v; a) a
  96.   fi' ?6 c/ p+ h: L9 b
  97. : c8 o  e( m! Q( M
  98.   # Set the default paths based on the current location
    # S! i7 I* p8 x8 B  H- j! K
  99.   SRCPATH=$( dirname $CUR_DIR )9 h( q/ B+ M' G& m1 B6 @  p
  100.   SRCPATH=$( dirname $SRCPATH )
    5 V# d' Y) `9 I" Z8 z: M/ z
  101. ' w+ e# _. [) k
  102.   # Log the detected path
    . e2 {" d3 T; i( b/ p) @$ U( ?
  103.   Log "Detected cloned repository in $SRCPATH" 0" g, r& P* d- A7 w) k' `4 m7 N9 o
  104. }
    6 t- n- r# r* q$ Z- y$ D, s" G. W
  105. ( v# P2 K7 @  Q! H" I
  106. ' _  ^" }- N8 Z* N7 H

  107. / u; h! D; i- M6 i0 ~
  108. # Function to log results0 i( t7 F. Q  z- ~" t9 G
  109. function Log()
    $ N/ A+ k8 X' F8 H$ [
  110. {4 m6 I- ^& j& [  O- D* C$ w
  111.   local TIMESTAMP=$( date +%Y-%m-%d:%H:%M:%S )5 b* }. t- D6 b
  112. 7 E3 ~3 C5 o, C6 y9 {! m* S
  113.   # Check the number of parameters6 a6 h5 r# E( s. A
  114.   if [ $# -ne 2 ]; then
    ' K2 F! l' n+ \1 e/ o( ]# y2 e
  115.     echo "Logging usage: Log <message> <echo flag>"$ _! {, G1 `4 ^% p5 W
  116.     return 1* G: I& v0 Q! E8 \
  117.   fi
    # n+ g$ t0 q) H  U/ v
  118. . a* v2 M/ \: c# c8 u& s" g# H
  119.   # Echo to the console if requested
    & Y& _; x2 h, M" W; Y& [# Y
  120.   if [ $2 -eq 1 ]; then/ V1 Z# O- E* {2 @+ m
  121.     echo "$1"
    1 _& R& V, R4 f
  122.   fi
    * T* b$ W& m1 N& `2 _

  123. ) W# f1 _, e5 J; L0 ?
  124.   # Append the string to the log
    ! C# M  ^$ q+ n
  125.   echo "$TIMESTAMP $1" >> ~/getmangos.log+ c: k  |4 a# b+ @; c
  126. }
    0 ], u1 [0 f5 ?+ {  ?; a# X

  127. 5 {5 F3 y% \) r% P
  128. : Y3 |) D( i4 H6 `8 i5 F7 _4 r/ i) P, w

  129. ! K+ i7 N3 k7 `3 d  s
  130. # Function to install prerequisite libraries
    ; m- _. D9 u7 M2 M
  131. function GetPrerequisites()1 U5 a$ e" T$ i0 B, k" l7 O
  132. {
    6 @9 B; V, f) M, j% G
  133.   # First, we need to check the installer.
    : ], ?" z2 G+ a9 S
  134.   installer=0
    ; e+ b4 O$ t' X) Y5 U( ?& Y4 E$ W  ^
  135. $ t/ H0 c# }/ a* o- x; q
  136.   which apt-get
    2 ^4 l- X8 d# p) A5 v
  137. + u4 V' F4 Q! B
  138.   if [ $? -ne 0 ]; then
    2 X0 M, h! g' n6 i. ?* _$ c
  139.     Log "apt-get isn't the installer by default" 1
    $ q1 M1 e% f+ ?) [" C
  140.   else% H1 g7 W9 L2 V+ {; L: ?, |
  141.     installer=1
    9 |. E( N0 ]# C6 d, @' ^# I' K
  142.   # On a fresh OS boot (EC2) libace was not found without first updating
    * z  @/ Z  b7 F; H) H. \& ]
  143.     apt-get update -y && apt-get -y install git lsb-release curl  a6 ~8 l0 m  _, a+ s) r
  144.   fi  J& m: {, Q  C# {' d) e# ?4 |' h
  145. $ k4 \! [3 J$ }" {5 l2 f, A
  146.   which yum
    : a8 {- h$ i" r# G

  147. 7 F* {0 N% f3 O2 T6 I' R. B- g' ?& T
  148.   if [ $? -ne 0 ]; then. ]( y# H  C8 K% ~% |
  149.     Log "yum isn't the installer by default" 1# l3 F" ~( k1 {  K: z, t
  150.   else
    0 Q5 z0 ^$ e1 Q7 Q: C. c* h7 Q
  151.     installer=1
    " P  Y# f( W6 r0 a
  152.     yum -y install git redhat-lsb curl
    4 [  X, j4 w) z/ L" J5 N
  153.   fi1 \+ {. o2 M1 R; R% A+ P6 a
  154. ' p! H+ ^% p( ]: {9 X8 b
  155.   which aptitude, x* s$ V& X% y8 y
  156.   if [ $? -ne 0 ]; then4 _  I9 |) `7 c6 r: _
  157.     Log "aptitude isn't the installer by default" 1# b. N' |/ }" F+ n2 l, a- a0 m+ p
  158.   else/ |7 c$ M0 T& E0 k
  159.     installer=19 t- B; d+ L3 p1 x' T
  160.     aptitude -y install git lsb-release curl! a* k, s6 J5 o! y  i
  161.   fi: F0 h9 S) u: H  ]

  162. ( X. B% ~3 n" K
  163.   # Then, let's check that we have the necessary tools to define the OS version.+ a8 W" U) R2 n; i# m2 ?
  164.   which lsb_release% |: ^) x  @  `, R' _9 K' c

  165. ! O9 E0 X1 |% p+ P5 J3 @6 \
  166.   if [ $? -ne 0 ]; then  c. t6 E. q/ u4 F) n2 v
  167.     Log "Cannot define your OS distribution and version." 1" E2 L( b0 h+ P% X
  168.     return 03 Y- v* P& W- C
  169.   fi& u1 ~" e, t' {% e! W1 c
  170. , r( N1 o0 T: h  f3 I' M1 ]0 B
  171.   local OS=$(lsb_release -si), u* g4 T# {0 j0 _( c8 Z
  172.   local VER=$(lsb_release -sc)
    + t# s0 T- h9 h1 }
  173.   local OS_VER=12 p( @7 f2 n/ V5 V
  174. ( s1 B" S$ F- Z: J9 P2 x- v
  175.   # Ask the user to continue
    ; k# n& V) D; c( |* e9 o" R
  176.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \6 Y* m! Z& x3 h6 e
  177.     --yesno "Would you like to install the required build and development packages?" 8 60
    ; x" K" |5 w' \
  178. 9 v6 H3 t) b& x, U0 U
  179.   # Check the user's response+ N1 ~4 t$ l/ F
  180.   if [ $? -ne 0 ]; then
    $ h! k. \: s5 B( H) h/ l
  181.     Log "User declined to install required tools and development libraries." 1% e* [$ q' D8 O" k7 D  i1 S
  182.     return 08 a+ I, Q; ?% m- p0 Z. E9 R# Z
  183.   fi
    7 w+ ~4 }" G8 ?, b$ h' d+ L
  184. ( n& @1 c3 n7 E) z: U
  185.   # Inform the user of the need for root access
    * e, m5 t5 o$ s; N, M
  186.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install Required Dependencies" \
    6 R. ~" N: `8 y; U
  187.     --yesno "Installing packages requires root access, which you will be prompted for.\nDo you want to proceed?" 8 60
    9 q# X; w" e4 c) t% f" |- i8 f3 t, c
  188. , _) }8 n/ j% M. `: N8 ~  R+ R" C
  189.   # Check the user's response' |- Y+ ~: b8 X. F0 d( M
  190.   if [ $? -ne 0 ]; then, N+ t1 y9 J3 k. y* Y/ g% H
  191.     Log "User declined to proved root access for package installation." 1
    . O7 e$ m3 L; P& F/ p
  192.     return 0+ t1 U- t, @. F  Y8 i5 @; Y- t
  193.   fi
    % h( g& _" s  A6 ^
  194. ( F0 o% G, C' m5 l/ L7 l
  195.   # Handle OS
    + _( T4 ^0 r# {; S
  196.   case ${OS} in
    " R5 X# b" J# A; x2 Y0 a. R
  197.     "LinuxMint")5 F  R9 h% a5 N& \0 o; _
  198.       case ${VER} in
      D# Y) h: c3 u2 i& Q
  199.         "sarah")# p' i1 j0 d% o- l7 U: A
  200.           # Linux Mint 18 - Ubuntu Xenial based
    & C5 X' U4 l3 P/ X& V) H( L# C! W
  201.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    ' P2 `7 g& o( a. L
  202.           ;;
    - B; Q3 R) o5 {1 ~) I/ f
  203.         "rosa")
    2 L8 m1 \8 C9 e0 N& B% E
  204.           # Linux Mint 17.3 - Ubuntu Trusty based/ v5 J, `* j% ]' h  d; u
  205.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    " L# G% Q0 Y1 A5 X+ c
  206.           ;;
    0 N8 h0 B% n) I
  207.         "rafaela")
    0 p& ^. _9 @! a8 S7 Q, o
  208.           # Linux Mint 17.2 - Ubuntu Trusty based
    0 L. i8 l: y( i
  209.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root. a6 R8 I7 x: }) R: A8 g- G
  210.           ;;
    7 Y# E% F6 M* {1 a7 a+ n  `
  211.         "rebecca")* {. J6 f4 ]  I' e
  212.           # Linux Mint 17.1 - Ubuntu Trusty based$ m8 }& d2 v1 o6 G
  213.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root8 y) ]: m7 L! P, ?% o: [. J
  214.           ;;
    6 ^& J2 w' v, K, i0 l- x( p
  215.         "qiana")- d1 y( N$ w0 @# e1 y$ _
  216.           # Linux Mint 17 - Ubuntu Trusty based
    ( i" m" q, D7 ?/ {/ ]& \4 ^
  217.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    ( z. I( y/ B3 u1 L
  218.           ;;- `* x1 P2 c0 T+ j+ l8 h, ]
  219.         "maya"). M7 q( e3 u4 |6 |# N" ~
  220.           # Linux Mint 13 - Ubuntu Precise based6 j, b2 Z, B- l  I* A- }
  221.           su -c "aptitude -y install build-essential cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev" root
    ( H  B/ w( O) Z0 t+ X
  222.           ;;4 A  g" B6 G, E  R8 `
  223.         "betsy")( y! k4 B) U5 f, Q4 [2 w
  224.           # LMDE 2 - Debian Jessie based
    9 ~9 s6 ~( M0 n
  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" root1 D2 Y/ ~  V; [8 Y% P$ x  z8 y/ B$ P
  226.           ;;: F. H9 F7 j- @8 v/ j6 }
  227.         *)
    9 e- Q7 o! P' n& ], c
  228.           OS_VER=0/ R2 L% V& T  N5 c2 o8 Z3 {
  229.           ;;
    - d  f& R1 }) W* h& L0 T
  230.       esac7 u6 J" c/ a" o) W) r
  231.       ;;
      v4 W9 j0 p- J: i; ]1 ?6 U
  232.     "Ubuntu")+ F: J& \) h. i" J' q
  233.       case ${VER} in
    3 p& O! v; m: M, N* o
  234.         "precise")
    ' n+ A1 ]- m9 o1 ?
  235.           # Ubuntu 12.04 LTS5 z9 G/ a4 s6 K+ q  B' N
  236.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    6 Y$ h- _: b+ A/ d7 z
  237.           ;;
    9 I7 j' R1 \) n  X" g5 v
  238.         "trusty")
      o* s; d8 O) y/ G- B4 z
  239.           # Ubuntu 14.04 LTS
    * a8 f1 ]4 u9 B8 x* m
  240.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    $ R. ]: a; J, x
  241.           ;;. W5 E9 G% H+ w; X7 t+ Q
  242.         "xenial")0 y7 q- R1 D+ F# F" p
  243.           # Ubuntu 16.04 LTS
    - l( P0 `  L4 ~7 Y. z
  244.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root4 Q6 x  i# v! @. h, p; S6 E
  245.           ;;% r9 g* \" _! g7 i: \2 d- ]2 F% k0 D
  246.         "yakkety")
    ! y) t" e  j4 K! r3 Y; }4 O. h
  247.           # Ubuntu 16.10
      `) _, e, Z( O
  248.           su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    2 s, @3 H8 h) o6 i
  249.           ;;
    2 }" i8 k8 v: S
  250.     "zesty")" _4 Z2 f+ ~' \' L: a
  251.       # Ubuntu 17.04- S" a  y6 O$ \
  252.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root4 I& Y( Q  c! C# g) C) f
  253.       ;;7 ], v; V0 B' g% h' U- e9 V* P
  254.     "artful")
    4 C7 a2 U. t% @6 m, L
  255.       # Ubuntu 17.10
    ) `  k7 f2 Z) S# r0 ?/ P
  256.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root" c; F2 o5 T/ m2 R5 Y& p' \
  257.       ;;
    0 i- d" h# |. Q% K
  258.     "bionic")9 @$ }! z5 P. U; E4 S8 u
  259.       # Ubuntu 18.04 LTS
    6 O& p2 G1 d, ]& ~3 D* ?$ J
  260.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root8 o+ `1 H5 @6 w1 z
  261.       ;;, a& z# Z/ |$ [, q% P4 ~
  262.     "disco")+ ~% w$ q( F9 o8 u1 a6 e3 m
  263.       # Ubuntu 19.04
    ! J  K. y9 t$ t' U
  264.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root, b+ }9 Z  m8 C% V9 e! W
  265.       ;;" x8 j5 u; x" S  j+ ^1 D% ]
  266.     "focal")+ r/ r; r9 ~9 t& u8 @
  267.       # Ubuntu 20.04
    1 A+ J# M7 m+ H- I1 M: a
  268.       su -c "apt-get -y install build-essential curl autoconf automake cmake libbz2-dev libace-dev libssl-dev libmysqlclient-dev libtool" root
    / }- D) q: |" T* O5 N
  269.       ;;" j& P7 R: W- Y8 D3 H$ h
  270.         *)9 C8 w+ ]# i# M
  271.           OS_VER=0/ c! L$ l  }9 C) Z) r# I- q
  272.           ;;
    ; q! h8 ^& B4 C( v( y& C! A  x& s# L
  273.       esac
    # r6 w  j9 h  r' |1 C
  274.       ;;
    4 T' }2 Q6 b  _( l  U. W
  275.     "Debian")
    6 x4 v( R+ R8 P+ i
  276.       case ${VER} in5 q' ?+ A; E$ g2 o
  277.         "jessie")# Z0 e" W$ w+ n; [- x  _* ]
  278.           # Debian 8.0 "current"
    / g* p- Z) [; }  Z0 R/ O
  279.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root
    6 {  c* }8 F  b0 J) d+ X/ N+ x
  280.           ;;
    # o- X5 ?/ [% k: E0 E: \* s
  281.         "stretch")
    3 D' c( e5 z# q" O; O
  282.           # Debian Next
    / ]6 O. S8 e' c/ K
  283.           su -c "aptitude -y install curl build-essential autoconf automake cmake libbz2-dev libace-dev libssl-dev default-libmysqlclient-dev libtool" root( C% S; u8 k% A2 D6 C4 Y6 F% E2 S9 _0 V
  284.           ;;2 l4 L  O6 ^8 E7 j
  285.         *); P* y4 U8 G6 L% c
  286.           OS_VER=09 ?, q8 X4 z% h3 a; h
  287.           ;;
    * s2 _! c1 I( c6 F$ W
  288.       esac
    * J5 R6 e4 C9 e+ i) `8 E0 Q
  289.       ;;" u2 m' x6 I) g1 \7 }
  290.     "RedHatEntrepriseServer")
    ! I  Y; V: y0 A4 B
  291.       case ${VER} in
    0 k$ T8 U, q# s; ]0 t! m2 ]
  292.         "santiago")
    " m) \4 D( B* _+ @
  293.           # Red Hat 6.x
    : Y& O8 t6 r" G
  294.           su -c "yum -y install curl build-essential linux-headers-$(uname -r) autoconf automake cmake libbz2-dev libace-dev ace-6.3.3 libssl-dev libmysqlclient-dev libtool zliblg-dev" root
    ; Z; z: p0 c; p% F  L# D& ?
  295.           ;;# v/ P3 C' _6 y) C' k
  296.         "maipo")
    % B0 O# |5 u/ z6 k; L3 `* z/ G! m
  297.           # Red Hat 7.x  c# m2 s; C; O
  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
    * A" G' d, @! N, U/ b$ ?# L$ m* i
  299.           ;;, }+ g) Q' l8 p8 [" K( I: {
  300.         *)
    ( x' ~: A" s. m1 ]
  301.           OS_VER=0
    ) s2 A4 U7 I  F( A3 H7 C
  302.           ;;0 \8 v1 H8 C) D, u! |
  303.       esac6 `- i7 O, F' Q' M7 u
  304.       ;;% X. O' v! }# G# |2 O
  305.     "CentOS")& O: I. w% `9 `9 }  ?( d
  306.       case ${VER} in
    8 `1 C% G* P0 B( p
  307.         "Core")
      v& T) \- T+ w5 U9 m$ {
  308.           # Default CentOS - Adding necessary RPM third-party.% m( M4 y+ g' h
  309.           rpm -Uv ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/devel:/libraries:/ACE:/micro/CentOS_7/x86_64/ace-6.3.3-55.1.x86_64.rpm
    " ~  _6 K" A' T( ?" D5 [
  310.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/perl-Net-Telnet-3.03-19.el7.noarch.rpm) Z) [/ ^% C6 O/ k
  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
    1 q: w0 X( k: [0 w- S8 b, v! N8 A
  312.           rpm -Uv ftp://rpmfind.net/linux/centos/7/os/x86_64/Packages/libtool-2.4.2-22.el7_3.x86_64.rpm
    ; ?! g! B0 B1 V; p1 R8 b' m
  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
    8 n& E6 b$ D  I
  314.           su -c "yum -y install epel-release"3 N0 V4 o! z$ D4 Z' J
  315.           su -c "yum -y install curl autoconf automake cmake3 ace-devel ace-6.3.3 openssl-devel mysql-devel libtool gcc-c++ bzip2-devel" root
    ; p2 w+ s- G( h; j; h
  316.           ;;( T! \9 T; ]% ?: J6 W
  317.         *). a. P; c6 {. G) E8 m% T
  318.           OS_VER=0& I. V" Y* V8 B; J
  319.           ;;" \5 H5 H, Q% g
  320.       esac
    8 |" d/ o2 v  ]# p6 n0 K1 g2 F
  321.       ;;1 k9 Z" T' j0 q
  322.     "Fedora")
    0 _& J! W% W& N8 V" W9 U
  323.       case ${VER} in3 Q$ X& _2 D3 I
  324.         "TwentyFive")$ d0 z4 m  P. b# O  b& H4 Y; f5 B
  325.           # Fedora 25 - Adding necessary RPM third-party.
    + F5 k4 R5 \' X/ h9 o+ p
  326.           su -c "yum -y install autoconf automake libtool gcc-c++" root* B4 B% a; q# i  n; F
  327.           # Getting and building ACE. Not provided in RPM for Fedora...# G6 B& ?7 ^" g5 j8 n1 M% k$ N  Z. l
  328.           rm -rf ACE-6.3.3.tar.bz2
    4 }. `* F5 f% U( v3 r# }, P( `
  329.           rm -rf ACE_wrappers
    9 s4 _  C2 K; v1 W* {* p
  330.           wget ftp://download.dre.vanderbilt.edu/previous_versions/ACE-6.3.3.tar.bz2! n/ Y7 j* x  d4 N
  331.           tar xjvf ACE-6.3.3.tar.bz2% n$ m0 e- r( l, C* O
  332.           export ACE_ROOT=/root/ACE_wrappers
    . R% ]$ O4 K" N8 g5 E
  333.           echo '#include "ace/config-linux.h"' >> $ACE_ROOT/ace/config.h6 M2 ?- y# y( F
  334.           echo 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU* J+ k" F9 g/ Z$ S" S
  335.           echo 'INSTALL_PREFIX=/usr/local' >> $ACE_ROOT/include/makeinclude/platform_macros.GNU
    , p5 \: w/ u( G  L4 a5 }
  336.           export LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH
    5 a2 j( f3 B! p+ _, I7 q
  337.           CD $ACE_ROOT
    % L7 O! X$ O* E+ w1 \2 m
  338.           make: R4 Q. {2 H9 S% T& A
  339.           make install
    0 `0 G* Z4 T, }: c
  340.           cd ~, I; l) @2 P# [0 k3 [' X
  341.           # Installing remaining dependencies..
    6 |# T( }8 T/ B
  342.           su -c "yum -y install cmake openssl-devel mariadb-devel" root
    : r$ c# J6 Z& \3 o* M
  343.           ;;
    : `! }5 s3 J8 D/ G0 H: a
  344.         *)* F$ _) M) {1 D! ~5 Z8 S
  345.           OS_VER=0/ b. F) c% D" x
  346.           ;;$ n1 |" [. f+ m& w2 e
  347.       esac
    ' U/ ~- g! v! j& G
  348.       ;;
    ' T0 i% _  T. Y% Y& b
  349.     *)2 }# U, M* D! o
  350.       OS_VER=0
    & e; A- n7 i8 A6 D" o" B
  351.       ;;
    2 s: l: \3 H9 y  k# }/ c
  352.   esac; }$ w- r; }+ `) ?& j! O$ M

  353. 4 [0 n( v# b. y6 s9 f7 H
  354.   # See if a supported OS was detected6 `( ?: S  t5 u
  355.   if [ ${OS_VER} -ne 0 ]; then
    7 ~7 G# p9 Y( ?" `: K
  356.     # Log success: B- y( O. x) r+ U/ A/ n" I4 t
  357.     Log "The development tools and libraries have been installed!" 1
    6 h3 t& n5 v2 x0 c1 N2 z( R/ ~
  358.   else$ w! t& f+ |, B8 y" X; k5 u& x. m8 v
  359.     # Note the error, S" _5 n- }4 x$ e. }
  360.     Log "Could not identify the current OS. Nothing was installed." 1
    : ?( k4 G# u) @
  361.   fi
    + n, c" W  P  P: C  D
  362. }
    ( h0 W/ T; C8 _1 ^# w+ `3 K+ S
  363. ' [3 V+ t# B- @* m0 Q* B9 i- }

  364. : ]0 I% h' p9 w  I0 G7 [8 V
  365. 5 D7 u0 v, O' O7 S
  366. # Function to get the WoW version
      h7 I% W# D4 c0 k4 k/ s' _% G
  367. function GetRelease()" d$ e* H5 R% D: s, E/ S: M
  368. {( ^( i" ]* I$ n0 G1 E& z
  369.   VERSION=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Choose WoW Release" \
    , n4 a5 f$ r( B# w7 ]4 K6 K
  370.     --menu "Select a version of WoW" 0 0 5 \) G* }% x9 O7 R1 g/ n
  371.     0 "Original Release (Vanilla)" \; x* k+ y& v6 a: Z8 K1 C' E. D  \
  372.     1 "The Burning Crusade" \
      N) E: n- u( p& R' u+ _
  373.     2 "Wrath of The Lich King" \
    1 m' ~3 B4 }% ]$ K+ ^% ~; [7 K- D
  374.     3 "Cataclysm" \7 E& y" W1 A4 _8 j, L6 u
  375.     4 "Mists of Pandaria" \
    9 r6 i% u1 Y' Z
  376.     5 "Warlords of Draenor" \6 [7 I% b0 |0 J! G, b9 G5 e, k& M3 g% c" O
  377.     3>&2 2>&1 1>&3)
    ! m: e3 p9 a$ }' D
  378. % e' H% Y6 S- o; x) O
  379.   # Exit if cancelled
    ( a. N( I. h( d" p$ }( S& H/ {8 `
  380.   if [ $? -ne 0 ]; then; d! l- H% W6 U0 |) k
  381.     Log "Version selection cancelled by user. No changes have been made to your system." 1& q" S* K: |, m/ E. N3 h
  382.     exit 0& a8 E" B, h; D
  383.   fi
    $ Z6 ?9 r; ?5 C: N) i
  384. % V: b* W' l) g" y" |
  385.   # Set some defaults based on the release' J8 m/ J* p' Q& |3 [* e
  386.   case "$VERSION" in
    2 G+ F7 d- n; q. e9 k9 M+ @
  387.     0)5 ~0 [1 D5 L5 x3 C, J% X
  388.       SRCPATH="$ROOTPATH/zero/src", D8 K: V6 F1 f% p! b: \
  389.       INSTPATH="$ROOTPATH/zero"" G7 a* h! @2 s$ m6 C0 @; G
  390.       DB_PREFIX="zero"! C- L- Q: f: j( h' m4 ^+ D% ?
  391.       ;;
    6 Y8 e; `7 ?1 j3 q: Q

  392. + }0 Z! C3 o9 ?4 `9 F
  393.     1)
    & z' D% w7 R0 |0 ?( A& H6 m
  394.       SRCPATH="$ROOTPATH/one/src"
    " i' C& \7 u3 z3 T- i) {& P
  395.       INSTPATH="$ROOTPATH/one"
    3 T4 g8 i9 }' G1 D5 t
  396.       DB_PREFIX="one"
    ( D2 q1 ?6 G/ R8 P. ^6 Z8 J
  397.       ;;! J, {* n1 c. o, [4 T
  398. + V( g9 y3 n- a- t9 f% ]  ^
  399.     2)" A- @7 `, h2 G
  400.       SRCPATH="$ROOTPATH/two/src"
    ; S: T1 @% h6 `7 D# p5 W
  401.       INSTPATH="$ROOTPATH/two"
    - t7 H, ^! D% \# x/ u5 d) ^! }" V
  402.       DB_PREFIX="two"
    ( i2 _8 E" O; l# j
  403.       ;;
    9 W* A9 f* i' B; c

  404. 8 ]: t  X$ k, I8 i# M) p
  405.     3)8 E7 j! r" p) V. d/ r) S
  406.       SRCPATH="$ROOTPATH/three/src"# {2 }) Y. Z2 a* h$ d! t* H
  407.       INSTPATH="$ROOTPATH/three"/ q( @7 W0 B2 ^5 L
  408.       DB_PREFIX="three"
    3 U, H1 p" I$ Q9 _
  409.       ;;" G2 x5 e$ }$ u
  410. % `) S5 ~3 t3 N2 Y
  411.     4)8 M3 P' W7 X& F
  412.       SRCPATH="$ROOTPATH/four/src"( W' y8 t) k5 `) r, @2 q9 S
  413.       INSTPATH="$ROOTPATH/four"1 `* i$ t! Q- K
  414.       DB_PREFIX="four"8 }5 h( A7 g# k
  415.       ;;5 l/ d  q. m" M  k& S
  416.     5)! p5 E! f# w8 }2 w% a5 L4 L2 H
  417.       SRCPATH="$ROOTPATH/five/src"
    8 a. W$ Q! \1 ]6 G
  418.       INSTPATH="$ROOTPATH/five"/ z9 k& E. n. u8 C& h6 |. L
  419.       DB_PREFIX="five"- A: v' k" @  t$ i, s
  420.       ;;
    * m  R% n9 k% O  @; p/ p
  421.     *)
    6 o0 h# I6 ^! A/ N# l1 W
  422.       Log "Error: Unknown version selected!" 1: \+ A' a' E2 G" y
  423.       exit 1: S7 h; ?$ Z3 N( e6 P; g
  424.       ;;+ c% _4 S8 L) W" O8 F1 p# @1 |
  425.   esac
    ' d) l# h5 |( q0 d2 C: k- p# @( ?

  426. # l0 Y6 V" v8 `# U/ U
  427.   # Now set the correct source path if the repo has been cloned already
    # F% j  `3 e  [; w6 S. L' b: c
  428.   DetectLocalRepo
    + B  E4 H8 \$ t* K! B- ~
  429. }
    9 N1 `# x- W' L6 M9 ?
  430. 1 }" q( a6 _5 G5 R( ~
  431. # Function to setup the technical user- }9 g* t% k; M1 s
  432. function GetUser()8 `0 {5 W. P0 v! Z3 {4 y1 j
  433. {
    - M* I1 T# t( I5 }0 |1 j
  434.   local TMPUSER="$USER"
    - P1 J" n. K0 ~# z& U" ?/ I. Q

  435. 1 i" C! v! b4 y9 U; B1 H0 g9 G
  436.   # Set the user
    / ~0 D9 m% X7 X- Y6 ^- d
  437.   TMPUSER=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User to run Mangos" \. x- Z% f& L( A; g* N- L
  438.      --inputbox "Default: $USER" 8 60 3>&2 2>&1 1>&3)3 J3 m. q& A2 N& W0 U* F

  439. % J9 W" a; f0 L, o0 z
  440.   # Exit if cancelled
    0 \& [, x) ~: U3 n6 w9 n& b
  441.   if [ $? -ne 0 ]; then/ r. ?$ y4 L' W/ K( C1 |
  442.     Log "User selection was cancelled. No changes have been made to your system." 1
    8 E5 g" @/ v5 w8 p+ B3 B
  443.     exit 0
    . g5 V* m/ U) Z3 U; \5 m
  444.   fi) Y- F  p6 k9 b' P7 q( }  Z+ I
  445. ; x; k5 r  C+ q4 f3 O
  446.   # Change the user only if it was modified
    . I* B% W! s) J
  447.   if [ ! -z "$TMPUSER" ]; then* ^5 }5 P: M0 [5 _, `
  448.     USER="$TMPUSER"
    # ?3 S- u9 B# w" c
  449.   fi
    ! {2 B: s" ^6 e, }* V- q
  450.   d- n  R5 C+ E1 E  ]. U
  451.   # Validate user
    # O( j2 E* g! _6 X: e
  452.   id $USER > /dev/null 2>&12 U. o4 ^: X  ^' j6 }1 ?
  453.   if [ $? -ne 0 ]; then
    , ]7 M" l" f6 e
  454.     Log "Creating user: $USER" 15 z* k/ G+ Z  \$ e% L# g5 k
  455.     useradd -m -d /home/$USER $USER > /dev/null 2>&1
    7 d' K/ v; y# O7 }2 l8 m
  456. " l/ o8 G6 h6 E
  457.     if [ $? -ne 0 ]; then
    ; N7 Q, C. I2 g; |6 a
  458.       Log "Error: Failed to create the specified user!" 19 h) w( \: N$ C5 X( y* p' n2 L
  459.       exit 1
    ! P% q( {1 p# ]* M4 ^
  460.     fi& [6 {' |$ B' q* U5 ]& {/ g' L9 c' n

  461. 7 Y& ~6 b* }/ b, v) P! J
  462.         usermod -L $USER > /dev/null 2>&1
    - `$ |9 ]: ]/ o6 ]6 K$ ^
  463.   else
    & o5 y6 U  d! q( \. p. X
  464.     # User already exist, asking to keep the user
    + I; b, l% S* T+ C+ `( X
  465.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "User already exist" \( d; b; e6 k2 F3 N+ q6 Y+ \
  466.       --yesno "Would you like to keep the user "$USER"?" 8 60
    ( n' m4 K* i0 M+ d: P) q" x1 D
  467. 4 S( M$ s2 c, H- T9 Z
  468.     if [ $? -ne 0 ]; then
    - v" W( s) A* w3 y  S) ?- `3 }
  469.       Log "Removing user: $USER" 1+ P; X* Y2 y8 G  E- ~( B) ?& l+ M  u$ _
  470.       userdel -r $USER > /dev/null 2>&14 V" g  U# Y/ I) l5 U  ^4 r

  471. # ^' }4 n$ w; I! b" ~
  472.       Log "Creating user: $USER" 1$ o% \) k  P0 z, `+ o* d0 O# a. N
  473.       useradd -m -d /home/$USER $USER > /dev/null 2>&1
    * S# B6 Y4 A7 x* I
  474. ' y& N" x; k. Q4 @$ ]
  475.       if [ $? -ne 0 ]; then
    * N1 I5 n; X) j4 }
  476.         Log "Error: Failed to create the specified user!" 1! W; @# H& a  j  _# `- q
  477.         exit 15 @* d4 x6 q( F- F# x' w7 N% \
  478.       fi
    6 o* D7 j6 y0 U( H* R6 X5 A' V
  479. ' |! ?; y1 T4 `
  480.           usermod -L $USER > /dev/null 2>&1
    ; C0 D# _# Z' }# M
  481.     fi
    2 Z: l- ]8 V( w
  482.   fi
    % [8 [% T+ B' j7 u7 ^8 T* W: v6 U

  483. 9 v3 R$ n9 a3 |! v! V2 ^/ ?0 |
  484.   ROOTPATH="/home/"$USER" g/ h& ^8 i7 v6 [/ y% K6 U
  485.   Log "User: $USER" 0" f, ~, R8 k: s
  486. }
    2 J& r3 X/ h: Z; ?$ h

  487. 5 K$ Y- O, O; E6 P
  488. # Function to get the source and installation paths0 q/ q( O: B8 D5 {; u
  489. function GetPaths()" k$ K  b0 d: j+ s8 y
  490. {
    9 Y% _3 ]6 x& W9 E+ n; X
  491.   local TMPPATH="$HOME"3 d$ x: ?8 |8 P' t1 L- v
  492. , s  H* x9 i7 p/ X1 h
  493.   # Set the source path8 x7 t. L6 ~8 {. f3 x' F" k: S. ^" l
  494.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Source-Code Path" \" h2 c' [% h: _0 Q* B. g. w0 P
  495.     --inputbox "Default: $SRCPATH" 8 60 3>&2 2>&1 1>&3)( i% ^0 I  W; l: `- P+ U1 _9 ?
  496. : B2 Y) o5 }; o3 v- T2 O
  497.   # Exit if cancelled; [: n6 |( c2 A' p: N  R  [4 ?
  498.   if [ $? -ne 0 ]; then5 R/ `2 `7 S. l  j. N; n4 M% l
  499.     Log "Source path selection was cancelled. No changes have been made to your system." 10 g3 F# O4 b$ Q4 N  ]( ~/ |
  500.     exit 0, z- M9 [% P) S5 K% q9 f$ L1 m
  501.   fi: s% K" M2 O$ J6 G. l8 e( s  O
  502. ; X" V2 s: m* ]: z
  503.   # Change the path only if it was modified0 t% K: ~: A2 _+ P6 m  Y# N
  504.   if [ ! -z "$TMPPATH" ]; then9 `: ]% t- S6 C9 m1 F
  505.     SRCPATH="$TMPPATH"9 z# r7 ]" Y" B" T9 j9 @0 y
  506.   fi
    8 u5 S5 F4 d% Z

  507. : c( f# W0 \3 ?% c
  508.   # Validate source path8 _; Q3 T% x0 F* |- M# E  m, b  @% G1 o
  509.   if [ ! -d "$SRCPATH" ]; then. s. m7 K# J8 B4 d% j
  510.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \  A  t' m: E0 }2 M! u% a+ _* V
  511.       --yesno "Would you like to create the directory "$SRCPATH"?" 8 60
    / V/ G: {+ n) |" }2 }

  512. 6 e" _4 c0 U/ q6 o. `
  513.     if [ $? -eq 0 ]; then* {1 V  l$ k2 Z& S1 c- u) ~
  514.       Log "Creating source path: $SRCPATH" 1
    , o* v" ~0 w/ @2 E+ b
  515.       mkdir -p "$SRCPATH" > /dev/null 2>&1
    & Q; R4 N( c# `; ]: a
  516. - u% l1 E& ], k7 F# P
  517.       # Check to see if the directory was created7 I: ^# m9 _. K
  518.       if [ $? -ne 0 ]; then, m6 Q/ W6 E7 R% a) d$ E4 U
  519.         Log "Error: Failed to create the specified source-code directory!" 17 _' u7 x! D+ ?' P
  520.         exit 1/ [$ _2 O$ t) z/ g, ]
  521.       fi
    - @% G( s* l( w! i' y- k; h
  522.     else$ R) y/ W. M% \9 _( o  a% J
  523.       Log "Source path creation cancelled. No modifications have been made to your system." 1
    ' o/ g8 |$ M- i; {7 T
  524.       exit 0
    2 v, k/ ]# X& V2 e& D5 d  X
  525.     fi+ Z3 h4 t( w+ c" T% x
  526.   else
    - B6 Y: Z' v- |* U) r2 C5 h3 x
  527.     # Check for old sources
    6 B) _- H  j2 C% ^( i
  528.     if [ -d "$SRCPATH/server" ] || [ -d "$SRCPATH/database" ]; then1 L% F3 H8 D- G/ I7 A
  529.       # Ask to remove the old sources+ n& m9 Q. E- e1 j
  530.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    ! v& N# P  `: [4 k, Y8 P
  531.         --yesno "Would you like to remove the old sources? (Answer yes if you are cloning MaNGOS)" 9 604 ?% l, ]  p& g7 h
  532. 3 Q* G9 J% A' `. P. I
  533.       # Remove the old sources if requested
    " n6 N/ h5 n0 z( A) Z
  534.       if [ $? -eq 0 ]; then
      k% g: N+ u' s: E/ `/ `, ^1 B
  535.         Log "Removing old sources from: $SRCPATH/*" 1
    # ]# m' R9 u8 [. a6 ^/ ^
  536.         rm -rf $SRCPATH/*8 L+ w8 N( B! G* p

  537. , ^9 P6 W1 F" I
  538.         # Check for removal failure
    / a# b$ ^2 f3 z3 {/ b
  539.         if [ $? -ne 0 ]; then
    " M$ F, Z- x6 B* O
  540.           Log "Error: Failed to remove old sources!" 1
    " B+ G( x1 n, U! A
  541.           exit 1
    # e, R0 k8 b' Y: V# x  E6 M8 ^* k0 |
  542.         fi
    % i3 i, \# z, Q( a7 @. U1 D0 J
  543.       fi
    : {, z, _/ s( O
  544.     fi
    9 \9 }2 `( F" F' U3 x7 e9 w
  545.   fi
    & @0 K) `+ g+ H( Y
  546. : Q7 C0 Q- S& b2 T
  547.   # Set the installation path$ j0 E6 g. H) x! v) |4 d
  548.   TMPPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Installation Path" \9 E6 v$ Y" g# N7 F+ [/ W
  549.     --inputbox "Default: $INSTPATH" 8 60 3>&2 2>&1 1>&3)
    $ x7 o. l: {# w6 }

  550. # ^/ f7 E' M9 Q! z* m2 a
  551.   # Exit if cancelled
    . x" M/ m; D  \; E, P
  552.   if [ $? -ne 0 ]; then
    & u9 [- L0 e9 S, A# s. L# @
  553.     Log "Install path selection cancelled. Only the source path has been created." 14 V7 G' f6 v) \+ k( U; K
  554.     exit 08 I9 [: d5 O8 Z9 j8 t; _9 R; n* ]: a
  555.   fi
    7 R) J7 e( G; ^4 X0 w! y5 {

  556. # ~3 C6 N: O- D0 G9 f% t
  557.   # Change the path only if it was modified, J4 J  W& W  v
  558.   if [ ! -z "$TMPPATH" ]; then
    9 F' s, c5 `) M3 ~& r! T
  559.     INSTPATH="$TMPPATH"
    - T* {4 X2 N- r* R' S5 b& h, K
  560.   fi
    ! l- w% a6 N6 j4 K4 w

  561. & h% y, O1 Q5 x0 f/ T& e/ r3 V
  562.   # Validate install path' N, [0 F( `9 B' a1 k7 C5 E: k
  563.   if [ ! -d "$INSTPATH" ]; then# p) r3 N1 }1 o8 U$ d, ]9 G3 y# r
  564.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path does not exist" \+ A; N& o  E' B2 T5 D3 f
  565.       --yesno "Would you like to create the directory "$INSTPATH"?" 8 60
    ; S/ v5 T2 V; s0 ]$ O
  566. $ M3 Q; M% Q8 J8 N+ f6 X
  567.     if [ $? -eq 0 ];then
    ' N) X  X, n. R0 N1 n6 y3 `
  568.       Log "Creating install path: $INSTPATH" 1: g$ Z0 h7 b# o  ?" x" Q
  569.       mkdir -p "$INSTPATH" > /dev/null 2>&1
    ! N! H+ M' @/ i; A

  570. , d5 A/ w1 \+ K
  571.       # Check to see if the directory was created
    / y' d$ v" U# H/ h, @- b  Q* O
  572.       if [ $? -ne 0 ]; then
    0 ^2 \" e; @! c# G( w3 R: _' m' \
  573.         Log "Error: Failed to create the specified installation directory!" 1) S1 X7 D; Z% t* |
  574.         exit 1' N* W2 H& m' a; ?- T' x- Y- e
  575.       fi
    4 c- k( N$ N4 y0 K
  576.     else2 }. _0 P5 z: a1 J" p7 C, d
  577.       Log "Install path creation cancelled. Only the source path has been created."
    7 B, P8 \& F6 u% H
  578.       exit 0
    7 X! @7 T+ D5 s* d" P: P0 y
  579.     fi- P3 W& [  s+ z. }; m
  580.   else$ ^+ U3 L: H* v- _* W
  581.     # Check for an old installation
    , \8 v& d. j3 Q& B0 P8 S0 j; _/ z
  582.     if [ -d "$INSTPATH/bin" ] || [ -d "$INSTPATH/lib" ] || [ -d "$INSTPATH/include" ]; then! n" Y7 {0 |( U5 G- [3 d6 a
  583. : `6 e0 ~# r/ z  q
  584.       # Ask to remove the old installation' i) z) q! o5 Z/ z5 g' f8 ^
  585.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Path already exists" \
    2 S/ q& z, h( W9 \+ v! X* y/ T7 b# `
  586.         --yesno "Would you like to uninstall the current version of MaNGOS first?" 0 0
    4 Q$ v1 Z7 A" K7 Y6 K

  587. - J1 |2 R4 f. q0 s
  588.       # Check the user's response
    9 W3 {5 ]5 Y" _  w: v
  589.       if [ $? -eq 0 ]; then
    ! t& C& k. u8 @  e! ?. a
  590.         Log "Removing old MaNGOS installation..." 12 A3 {6 |- i! |* \- _+ |1 k
  591. ! \( @2 J4 N/ Q1 {* O/ J
  592.         # Clean up the binaries
    ) Y" U5 F& z6 v# C, N. U
  593.         if [ -d "$INSTPATH/bin" ]; then
    $ o$ P" ]& t  B' n- q/ m) r0 j
  594.           rm -rf $INSTPATH/bin" j- G+ w4 J3 W1 X) n& E) ?
  595.         fi
    ( R$ e$ ^) k" r' _# j

  596. ; n- l$ z  J: H
  597.         # Clean up the old includes: D' w8 T5 |4 Z! j2 k2 P
  598.         if [ -d "$INSTPATH/include" ]; then
    3 k/ c3 }7 s; P* y. X! E5 P2 T
  599.           rm -rf $INSTPATH/include4 i, E. G* H7 P8 P! B* K  e
  600.         fi8 _$ J( Q9 t! w! u* b: S2 F
  601. . M% R  a% H+ w* {, v. H# F
  602.         # Clean up the library files
    7 D( K( E3 x7 A5 Z/ I1 U
  603.         if [ -d "$INSTPATH/lib" ]; then' k- m  |* b  d' L. x2 ~5 S* N
  604.           rm -rf $INSTPATH/lib
      M/ c) P. H1 V' [) }: e" r
  605.         fi
    ) Y$ s# S! b- \, o" j( W3 \
  606. 3 E/ d$ g# E. g% y. G
  607.         # Clean up the old logs% T) j$ g, H' `& S8 X
  608.         if [ -d "$INSTPATH/logs" ]; then
    , X. F" ~" G7 J! F  ?3 V) }
  609.           rm -rf $INSTPATH/logs/*: Z+ l! b- C$ Z3 e) f. S
  610.         fi' h9 H. ^4 d+ R, ^3 p( S" R5 g
  611.       fi8 o6 T& q/ ~" U8 E" i1 l
  612.     fi
    * \4 D" N: C7 D( r- h
  613.   fi4 n4 l1 A9 w( a- l1 `" P" r
  614. 4 W# w) |6 ~" b2 t8 P( _
  615.   # Log the settings" v/ V! V. V2 k0 m
  616.   Log "Install path: $INSTPATH" 01 w& i- T' N9 b3 }
  617.   Log "Source path: $SRCPATH" 09 W) |$ F2 r; [0 d1 n, V6 A# X- U
  618. }
    8 h' w8 x9 |  R
  619. ) ^( D7 T0 r; w5 ~1 {

  620. 8 l( d# _8 `6 v0 c/ R9 m6 ?

  621. ( G- {- t2 z5 }" s, ?  `8 K. Y
  622. # Function to clone or update sources
    & a+ F1 h6 z2 r5 T
  623. function GetMangos()) d1 D# _: A9 ^1 I# Z
  624. {' e, |0 {0 E1 ^2 S: F
  625.   local CLONE="0"6 U: S2 m9 c* X4 E- J4 _
  626.   local BRANCH=""% Q4 m3 d5 |; x4 b2 k

  627. . X8 i6 c7 {9 q' Q% q: Q/ h
  628.   CLONE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Clone or update MaNGOS" \
    8 |6 V4 X$ |. X; v2 |
  629.     --menu "Would you like to clone, update, or continue?" 0 0 3 \  [- }4 [1 i' p% P6 v0 e8 r  ?% q
  630.     0 "Clone a fresh copy of MaNGOS" \; C4 r2 \/ a& S) e3 w) ~. I! `
  631.     1 "Update your existing copy of MaNGOS" \4 Y: _/ R% {" {, Y; Z
  632.     2 "Use existing copy" \
    9 J) P8 x" Z, K
  633.     3>&2 2>&1 1>&3)* ?3 y. B# O! h! b# P0 p
  634. & J. t/ G3 s% e* C  z, }
  635.   # Exit if cancelled* ?: g$ C3 @( {/ e4 |5 F1 m
  636.   if [ $? -ne 0 ]; then
    . m5 K; X# ]  d( n3 O
  637.     Log "Source cloning cancelled. Only the install and source paths have been created." 1
    " q3 f% Q1 P5 x. l5 V3 {
  638.     exit 0
    # R( s4 D" x4 f3 x
  639.   fi5 p, W3 c; b+ R' T( W

  640. 6 G5 S* Q2 D, q9 W5 Q+ _2 A
  641.   # Clone from scratch if selected
    5 m% ~" [" k0 T6 @
  642.   if [[ $CLONE = *0* ]]; then
    . g# _8 z0 ^, W6 l. j8 e2 J+ }1 S
  643.     # Pull a different branch?  Y1 u2 A0 X" v( U8 L; r
  644.     case "$VERSION" in
    * L; p& h) a' f$ j
  645.       0)
    5 k" a" H+ ?' e1 m* U2 n
  646.         releases=$(curl -s 'https://api.github.com/repos/mangoszero/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')! S0 i# j4 F7 E
  647.         ;;. ?- B2 f# {. X, t
  648.       1)0 W$ m( f  X! U# B: ]: s& B
  649.         releases=$(curl -s 'https://api.github.com/repos/mangosone/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    7 U0 O, A% o, F( {. i- }6 P
  650.         ;;
    + w& o+ J. o% ?. U. q9 b- H
  651.       2)& ]% l! R0 `8 P) a, ]9 W
  652.         releases=$(curl -s 'https://api.github.com/repos/mangostwo/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    $ |- J6 I, V$ W2 T5 m
  653.         ;;
    2 F9 O: l) Y! C4 d. A
  654.       3)# L$ c2 l+ s( i* e! h
  655.         releases=$(curl -s 'https://api.github.com/repos/mangosthree/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    / P6 W9 @" v2 Q& |: _- ?- e8 O
  656.         ;;( e3 |3 v9 y9 X& P& j) g
  657.       4): m" {% |  \/ ~0 n5 w" s
  658.         releases=$(curl -s 'https://api.github.com/repos/mangosfour/server/branches' | grep "name" | awk 'BEGIN{FS="""}{print $4}' | tr '\n' ' ')
    / Y. z0 c. F1 h* Y
  659.         ;;# t/ L9 b' D% a' R, j- G
  660.       *)
    ) B1 g' S! D# i, v6 @
  661.         Log "Error: Unknown version to select branch" 1$ u# J- m5 w2 P$ K' A8 m& J
  662.         ;;
    4 x+ T9 Z0 J- v  T1 V4 w+ P
  663.     esac
    4 L* {( n% O% J
  664. ; K6 g8 w6 Y) ~) J
  665.     COUNTER=1
    / D- h" h. _4 x/ z2 j0 K$ o+ B
  666.     RADIOLIST=""  # variable where we will keep the list entries for radiolist dialog2 \( `9 @) D- V. R, L: ^. q
  667.     for i in $releases; do
    * ]6 @# n) z1 i# P( m( B  g
  668.       if [ $COUNTER -eq 1 ]; then
    7 ]' [1 S2 ^) e, `
  669.         RADIOLIST="$RADIOLIST $COUNTER $i on "
    " b( v6 U# T5 K/ V
  670.         BRANCH=$i
    4 e- B  @: p$ ?+ ?; K
  671.       else
    / h9 K  o9 w2 i) a9 }7 W
  672.         RADIOLIST="$RADIOLIST $COUNTER $i off "+ h1 F) J8 `, s( z( |5 U2 b
  673.       fi
    ! A; `5 e  k: H4 U+ T- k
  674.       let COUNTER=COUNTER+1
    9 F  g. F/ z( P& C& W7 O  O
  675.     done+ U, v4 }0 ^3 ^1 N0 R
  676. : y2 S; ^$ ]3 R  _5 E; _. J
  677.     TMPBRANCH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Branch" \9 X1 p+ G2 A' S& H4 Z
  678.       --radiolist "Default: $BRANCH" 0 0 $COUNTER \
    + [6 A" f* ?0 A) C' @0 |
  679.       $RADIOLIST \
    1 E/ V- a# }, A
  680.       3>&2 2>&1 1>&3)$ }+ O# i% J4 n
  681. 2 n' a7 _: ]5 X5 m, V/ {
  682.     # Exit if cancelled
    . U2 F0 I- C: F& K1 I
  683.     if [ $? -ne 0 ]; then* ?% N+ B2 O7 Q7 @. I) {
  684.       Log "Branch selection cancelled. Only the install and source paths have been created." 1- G/ q% l) B! Y
  685.       exit 0; H4 L8 K& r+ {. J& N: _+ x
  686.     fi
    ; K# [/ r9 k7 t& b
  687. 5 E: R! V0 ?" c! Y  b, Z
  688.     BRANCH=$(echo $releases | awk '{print $'$TMPBRANCH'}')
    1 s, }; A1 z8 a) P  |! l; j( T

  689. 4 v- b- ~& }4 b1 r' _  j
  690.     # Set the branch
      s& F- G6 ]/ _) c: {
  691.     if [ -z "$BRANCH" ]; then: e7 o% n+ s+ h, C3 B. c% |3 I' C
  692.       BRANCH="$releases | awk '{print $1}'"/ q: x; @3 J" H: K, B
  693.     fi* n" j3 `; `; s' Y5 ^+ _+ Y! s
  694. ' i0 g( \# j  [1 p- ~
  695.     # Clone the selected version( H3 ?5 o& U* u* n: b* F  Y  y3 u9 A
  696.     case "$VERSION" in" f0 S0 z  m+ G( f+ B! o
  697.       0)
    * |: \/ o. M2 U( N1 i& U
  698.         Log "Cloning Zero branch: $BRANCH" 1: z, B/ @( b. ~) N
  699.         git clone http://github.com/mangoszero/server.git "$SRCPATH/server" -b $BRANCH --recursive) _- P$ a7 L4 H$ S! U) w5 R9 G
  700.         git clone http://github.com/mangoszero/database.git "$SRCPATH/database" -b $BRANCH --recursive$ d. x. @5 z4 E, y4 t
  701.         ;;1 V/ v0 i- w0 D( T1 T  H

  702. * I* E3 V7 j/ b0 E8 N
  703.       1)
    : q0 G0 b# B; e4 T/ [- G8 y2 Y
  704.         Log "Cloning One branch: $BRANCH" 17 t3 I4 A" `, e$ D# b9 X. F
  705.         git clone http://github.com/mangosone/server.git "$SRCPATH/server" -b $BRANCH --recursive) X% _" C( W/ f" R4 S$ ^
  706.         git clone http://github.com/mangosone/database.git "$SRCPATH/database" -b $BRANCH --recursive5 q. g6 P/ R0 e2 v
  707.         ;;
    1 V4 @; ^8 h4 A0 u/ p* m, m
  708. / y9 G0 H4 x4 p4 E2 K2 m! w2 _
  709.       2)+ Q% ^, j/ H3 c* ]
  710.         Log "Cloning Two branch: $BRANCH" 1
    , o- R! S' |8 I3 N
  711.         git clone http://github.com/mangostwo/server.git "$SRCPATH/server" -b $BRANCH --recursive
      D% H, \0 ?4 |( p' A9 x
  712.         git clone http://github.com/mangostwo/database.git "$SRCPATH/database" -b $BRANCH --recursive
    ; F7 A! M( u3 Q; j
  713.         ;;
    9 c, _) C4 f* D! a& L' y

  714.   _5 M- w5 a  J2 J. n/ Z3 B: U
  715.       3)( T5 w. d7 S5 k, E" V/ N# Y' ]
  716.         Log "Cloning Three branch: $BRANCH" 18 E" o" M, M* b7 s# T
  717.         git clone http://github.com/mangosthree/server.git "$SRCPATH/server" -b $BRANCH --recursive
    . `1 Z4 o8 m& L& q
  718.         git clone http://github.com/mangosthree/database.git "$SRCPATH/database" -b $BRANCH --recursive
    4 A& P4 M' b; y# W3 l
  719.         ;;
    $ l' F( z3 B: X

  720. . O" m& p( z# W+ P/ h1 I
  721.       4)3 v# Z' ?. M+ S; N
  722.         Log "Cloning Four branch: $BRANCH" 1% w% c; h! N2 S& k
  723.         git clone http://github.com/mangosfour/server.git "$SRCPATH/server" -b $BRANCH --recursive& u$ u1 p% t# z% N) C: q8 t, W
  724.         git clone http://github.com/mangosfour/database.git "$SRCPATH/database" -b $BRANCH --recursive9 Y/ L. A" e- A' \' _# ?
  725.         ;;3 i/ M# \( @) y
  726. 8 V6 X* ^" a$ n5 W
  727.       *)
    % i1 `+ }' i% E. L1 {8 [
  728.         Log "Error: Unknown release selected for cloning!" 1/ R0 z& D1 ^! q
  729.         exit 1  x! f: i5 P7 x5 ~# S) ]
  730.         ;;
    # I! @3 Y& h8 ]6 `" u
  731.     esac
    ) F* _  T1 T) a/ |! j9 u5 `
  732. ; `8 E1 r+ h/ `0 t5 U
  733.     # Log success
    0 L% X+ Y. R, d7 N$ \3 O
  734.     Log "Cloned the selected repository!" 1
    6 C" P( C* v- h) `: ]' s
  735.   fi
    2 @6 H) R( w; ~# t/ k
  736. $ ^! d" V9 e  c; \' k/ i' E" n3 N
  737.   # Update the local repositories if selected$ H2 A+ z3 `$ o1 ^( V9 n
  738.   if [[ $CLONE = *1* ]]; then4 W7 E. j' ]# H) o+ Y3 b0 a
  739.     Log "Updating your local repository..." 1! E' f* y4 p  ^8 Z; A3 J4 F
  740. , x; H' L& G/ `' W
  741.     # Update the core sources& j3 U) H1 f; V; S2 |
  742.     cd "$SRCPATH/server"" ]' k7 H! w; o" t
  743.     git pull
    8 y, G6 o$ R  H! p" Y

  744. 3 \& o, }  Y" O8 P- Q
  745.     # Now update the database sources
    1 w; B8 s  o  o3 K2 ?
  746.     cd "$SRCPATH/database"  |- p) L( A( T$ [
  747.     git pull' o8 D% L# u( C" R/ N+ U

  748. ! R" v; h+ e4 @3 S$ L& _  g
  749.     # Log success/ K* j2 o4 R  T/ s
  750.     Log "Updated the local respository!" 1) L% f- X& l$ l+ V$ y9 F, R2 i
  751.   fi
    + ^: N, L  m6 @' R' o. A4 A1 d$ U

  752. 3 D# K1 R0 k. n' t$ O- M2 `
  753.   # use existing repository  ?1 J3 b* }5 g7 e
  754.   if [[ $CLONE = *2* ]]; then4 D0 s3 E) }) b. v" o3 L
  755.     Log "Using existing local repository" 1
    " M( ]" g( A* }# k
  756.   fi5 x0 D! g! D6 \: m/ H6 J7 q- O- g4 x+ I
  757. }
    & r1 {- S2 S4 m6 [

  758. + i! e8 Z8 ^% J1 P6 k" ^; p  Q: G
  759. 6 d8 X6 `% H. z) ~

  760.   }- G8 \+ Y% B) ~3 A
  761. # Function to set the build options% K0 t" o8 }5 K: R  ^& P) I
  762. function GetBuildOptions(): U4 Q' @  h$ U1 o( Y
  763. {
    ! y9 Z4 _3 A. ^- C. c
  764.   # Select build options
    % \8 A2 K* N" v5 s
  765.   OPTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" \7 ?0 ]  A6 u; Z5 M" u
  766.     --title "Build Options" \
    ( v* s9 H' ?: H  K
  767.     --checklist "Please select your build options" 0 56 7 \
    0 y: J  [" R' V, Q' @  c& k
  768.     1 "Enable Debug" Off \
    % f4 G' y  e! {+ b$ K2 d) K8 M
  769.     2 "Use Standard Malloc" On \3 p1 D4 _& c( }. z, A' ]
  770.     3 "Use External ACE Libraries" On \
    " a% f5 l( b  z! m8 v  f0 P" N
  771.     4 "Use PostgreSQL Instead Of MySQL/MariaDB" Off \
    % h# U" r, z9 ~$ I
  772.     5 "Build Client Tools" On \7 q% e: Y9 w8 {
  773.     6 "Use SD3" On \
    9 B. b: ?7 V+ B0 `1 j
  774.     7 "Use Eluna" On \: N4 ^# b5 @, q# S- b( e/ W& z) e
  775.     8 "Use SOAP" Off \
    * w6 l. S/ Z0 T' b
  776.     9 "Use Player Bots AI" Off \
    % ~9 W# y1 `5 l8 }. A7 w
  777.     3>&2 2>&1 1>&3)
    5 }2 L1 R; K! x( [! t# ?' n
  778. ' ~3 q9 {) i$ W! a9 O; H; t, W5 }; r
  779.   if [ $? -ne 0 ]; then$ y+ n7 _/ p" I% U/ r$ ?
  780.     Log "Build option selection cancelled. MaNGOS sources have been cloned." 1
    6 A. Q* p. U" A4 N. ~/ {
  781.     return 0
    $ o! w5 S) `4 [  i9 V
  782.   fi! b2 N9 q1 S# r8 I4 N0 t

  783. ) ^1 \9 Z6 Y$ N+ n: C( a/ E8 b8 H
  784.   # See if debug was selected
    / }% s/ ]: h" u7 ?* N0 K4 ]
  785.   if [[ $OPTIONS == *1* ]]; then
    6 s3 ~; }6 _% t- ]+ g, d' z
  786.     P_DEBUG="1"
    0 \/ U6 v6 n( f( q" c
  787.   else
    * R5 K) D9 l$ K/ o( B* I
  788.     P_DEBUG="0"
    5 u7 k$ @3 Q7 H! N
  789.   fi. ]8 [" n  h+ h. U) T

  790. + i' A8 F9 C5 k# i3 D
  791.   # See if standard malloc was selected
    0 S  p' t! f% {" B4 \' M
  792.   if [[ $OPTIONS == *2* ]]; then( S0 E9 }9 l  |& Y/ i, W. T
  793.     P_STD_MALLOC="1"; e% U. U* `# ^" Y% B  R* H, x, Y
  794.   else
    & B- p4 d3 Z: S
  795.     P_STD_MALLOC="0"8 W5 {, h9 c+ q1 S
  796.   fi7 n1 P( U- d7 U) X5 A. Q* d
  797. / I0 f: ]3 |. b: S4 M
  798.   # See if external ACE was selected
    % M! c" Q4 H6 V7 h3 L
  799.   if [[ $OPTIONS == *3* ]]; then
    # k7 _7 P& x( K5 ~. l+ M
  800.     P_ACE_EXTERNAL="1"
    % P! I3 H6 E$ A: y  B
  801.   else
    0 V% x7 ^4 N' A3 S+ ?: I
  802.     P_ACE_EXTERNAL="0"
    7 Q0 m; O/ x1 I* l& i2 t4 L* p
  803.   fi7 u' H' c/ p/ t6 q' j7 _2 A

  804. , Y- |. h# }/ d0 B: p
  805.   # See if PostgreSQL was selected$ s% j8 K& A# @% l
  806.   if [[ $OPTIONS == *4* ]]; then
    # m$ M/ |$ E1 a2 Q) Y
  807.     P_PGRESQL="1"
    - @: O( j: t- j. K" i. t* Q
  808.   else5 V. a& G0 f, V: T
  809.     P_PGRESQL="0"
    . n  e* a5 {# p! I  x
  810.   fi
      R2 A3 b; w' ?6 s5 ]7 y# M
  811. 1 W+ d& m9 U  C. S+ Z% s2 Y
  812.   # See if the client tools were selected
    . Y0 ?8 L  C; I" w+ W
  813.   if [[ $OPTIONS == *5* ]]; then
    & o: B5 Y$ e4 j" j* w
  814.     P_TOOLS="1"
    ! z$ O" e: A& @& V9 P! \
  815.   else4 |" D+ ]9 C; Y& A) _1 c5 p
  816.     P_TOOLS="0"8 J% A2 B: U+ A6 u
  817.   fi
    ) P3 d8 A& {+ M" D

  818. . M5 E# l3 d8 p$ S- e6 K: |
  819.   # See if SD3 will be used
      t$ u9 D' p1 L; P9 N
  820.   if [[ $OPTIONS == *6* ]]; then; _( J7 P2 G# A6 I. k% A
  821.     P_SD3="1"1 N1 X% u) V4 [. E3 H
  822.   else8 j# U) `; n& ~, O2 n5 Q
  823.     P_SD3="0"
    4 b8 b' R: s! B( n' M" D
  824.   fi, U& S/ [: [0 L! G' `
  825. ! c: q3 n% U, ?- ]% X- _, Z# o& B7 k& f
  826.   # See if Eluna will be used
    * u% A  _* D4 c) l$ B
  827.   if [[ $OPTIONS == *7* ]]; then
    5 i0 _; H( ?  r' P7 ^! b; q
  828.     P_ELUNA="1"/ C, r" ~- F" @( T
  829.   else1 S2 Z: \$ N/ x/ `6 ~: ~1 `
  830.     P_ELUNA="0"
    ' |6 b0 Y" w& O% `
  831.   fi+ ?+ D9 I5 W% S# D5 X7 y9 E$ D
  832. + T- Z: s$ Z) p5 B) w; @) b3 L
  833.   # See if SOAP will be used
    $ k9 G$ i& E6 Q# a
  834.   if [[ $OPTIONS == *8* ]]; then3 \7 B9 Y# u: A! S: |
  835.     P_SOAP="1"
      g6 F$ L5 L7 M$ [1 A% H& M
  836.   else
    5 |8 C  M9 P' E: G' @# o
  837.     P_SOAP="0"3 Y% y' k  @9 E) h
  838.   fi& S$ u% p" v$ W  v* A. X2 ?$ j9 G
  839. ! Z5 \3 E- c: I+ ?6 P
  840.   if [[ $OPTIONS == *9* ]]; then( l9 e5 Y0 Z( \, V8 N
  841.     P_BOTS="1"
    - }5 `& H. T4 Q1 U+ v& ~8 x& ?4 J
  842.   else
    4 i/ z1 _: }, t& M8 ~$ i! Z
  843.     P_BOTS="0"
    * o% ?* h1 x* l7 g: t& M/ t
  844.   fi
    : S! B- d# ^% J/ g  z2 g* a

  845. 5 @5 v1 ^& @# o7 Y( [1 h
  846.   # Verify that at least one scripting library is enabled5 O' ]& S( B' B7 q8 H
  847.   if [ $P_SD3 -eq 0 ] && [ $P_ELUNA -eq 0 ]; then! q" V" }& j8 D0 V' L9 I( l
  848.     Log "Error: You must enable either SD3, Eluna, or both to build MaNGOS!" 1
    1 O1 p* j9 m3 G: u1 A
  849.     exit 15 _" z. |: c: V7 U" X
  850.   fi/ \; n* G9 n) E; \2 o0 k
  851. }, Y' F/ r& c; }2 l
  852. , d& G' i1 ^3 u
  853. , l, a8 ^9 V- e  \" q2 q" P
  854. ; k8 T4 ~; B: U8 I8 }. k7 b
  855. # Function to build MaNGOS& m, T+ M. O! X: Z$ x3 l0 B3 Z
  856. function BuildMaNGOS()5 z" [4 s" a* V% G
  857. {$ U, h* X5 [% K" B+ ~
  858.   # Last chance to cancel building
    4 s4 a, ]- \. D9 D1 D
  859.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Proceed to build MaNGOS" \
    # k) W" o& J; u6 ~, q; w8 l, U- J
  860.     --yesno "Are you sure you want to build MaNGOS?" 8 60
    / i1 d- q$ X7 z/ c) ]0 l. l. J; ?

  861. 0 _3 y0 U8 |) A3 m- @) L1 Q/ u& b6 y
  862.   # Check the user's answer4 O/ m' z. w" \8 ?, e) P% I
  863.   if [ $? -ne 0 ]; then
    - U% B+ q3 C% e& `* C
  864.     Log "Cancelled by user. MaNGOS has been cloned but not built." 1& P* G3 U0 D" i* M! G
  865.     exit 0& v/ }5 P5 ]' b5 |4 i, w6 o0 U
  866.   fi  Q% v: h) d7 d( C' G; ]
  867. ; d# _" {9 D/ l) M: o6 p9 p
  868.   # See if the build directory exists and clean up if possible8 _. m3 [- P) P2 ]; H6 z
  869.   if [ -d "$SRCPATH/server/linux" ]; then% E) p- ]6 H. p% s1 {" T/ g: b
  870.     # See if a makefile exists and clean up
    % W6 G% Q! y7 c2 L( w
  871.     if [ -f $SRCPATH/server/linux/Makefile ]; then( q4 l! u: r9 O; G
  872.       Log "Cleaning the old build..." 1
    % H( G! t0 j2 X4 m& K# n8 D" L' d: H
  873.       cd "$SRCPATH/server/linux"+ V% E9 X+ F/ K, i" a  z# ]
  874.       make clean
    & p0 w& U: ?% h: g
  875.     fi/ V1 p! k* G' H  m; O! `8 K; @
  876.   fi
      L3 x) r, A" R0 Z2 |
  877. 4 c: N, y7 C6 F
  878.   # Attempt to create the build directory if it doesn't exist/ x- F8 W8 t5 `, i2 W' K
  879.   if [ ! -d "$SRCPATH/server/linux" ]; then
    , p- y* p+ f" S# V- |# ]3 q" `
  880.     mkdir "$SRCPATH/server/linux"
    3 q, Y' _1 c- }3 w
  881. 3 V) m, x8 J+ C/ I3 j/ p. b
  882.     # See if creation was successful  [: ^. g' Z, B' _+ H: M6 F. |; i
  883.     if [ $? -ne 0 ]; then
    / X8 l) ~0 R% @0 t$ @7 O" m4 T
  884.       Log "Error: Failed to create the build directory!" 1
    ! V2 l4 v. V7 @$ R& v, k
  885.       exit 1, E, z* I0 M( V( ?
  886.     fi
    0 Z8 Y/ `5 Z1 O2 S1 }7 f) P0 O, T
  887.   fi1 D2 W( \/ m8 I  {1 i& r2 t

  888. 8 N5 y# P. @  ~5 B3 v+ v! L' a& x2 C. k
  889.   # Attempt to configure and build MaNGOS
    7 f* O2 C% I& p- Z3 r! D# {* U
  890.   Log "Building MaNGOS..." 0
    1 r: ]) k- \! t6 G0 E- k% y
  891.   cd "$SRCPATH/server/linux"
    * R- c/ f# ^$ T, ?: n
  892.   # make sure we are using the cmake36 \8 W8 _2 ]+ y
  893.   UseCmake3) {. b7 Y: ?- k! i, C4 i
  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"
    : k4 q8 v4 ?) L8 J4 L5 @* u$ n. f
  895.   make3 g  W6 v9 s, g& N) L9 f

  896.   l6 v5 `% r5 v! a* ~9 j
  897.   # Check for an error/ g' ]& d$ f! Z3 ~6 B# L, p
  898.   if [ $? -ne 0 ]; then
    : i' W, O6 e( J) Y6 O' _7 `3 P5 v
  899.     Log "There was an error building MaNGOS!" 1* P! v. \9 c; l* O2 R& h+ a
  900.     exit 1
    , D9 V- e' w4 T: ~% A
  901.   fi
    , p( Q4 C) e% l

  902. . Y5 E, B8 p" J/ B
  903.   # Log success
    2 `5 `7 }  z- ~: v. L7 R9 _
  904.   Log "MaNGOS has been built!" 0* r* N% @: c3 Z, M  K: b
  905. }
    ' F/ X, Q$ |' ~# b7 x
  906. 4 w* Z& P& n* ~5 r
  907. 2 U+ g' o' c- Y2 W) k

  908. + S- u: ]' R; C! H! |
  909. # Function to install MaNGOS
    / K/ f$ v& J0 N  `$ m' m
  910. function InstallMaNGOS()
      B5 x1 B# ~% t- S9 b" t
  911. {
    9 I8 Y9 m) F  t! D) p
  912.   # Ask to install now
    # i( }$ q- Y- R  z6 C1 j
  913.   $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    ; F, R2 x& D' l6 O' }. N
  914.     --yesno "Do you want to install MaNGOS now?" 8 0
    ( l% _) E3 f/ i5 |  k

  915. 8 Q6 d& d- I) D( Z' R# o
  916.   # Return if no
    # f/ V" X9 M. X7 {2 l: W
  917.   if [ $? -ne 0 ]; then
    ) u6 r! \4 a. R3 D( J
  918.     $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Install MaNGOS" \
    ; p" G8 ~+ o* q) c5 D3 j1 P
  919.       --msgbox "You may install MaNGOS later by changing to:\n$SRCPATH/server/linux\nAnd running: make install" 24 60
    # m. K" H) Q  M4 N

  920. 9 J  q! D$ m" w/ M
  921.     Log "MaNGOS has not been installed after being built." 1+ k+ _/ b) `6 z$ b' _" k* n- W8 d
  922.     exit 0
    - i/ S6 ^' S* ?+ a- R3 }& s
  923.   fi" m$ x. j, i1 u

  924. * G% n- v% T, Q# D; V& g
  925.   # Install MaNGOS- |1 Q) k# g+ q1 F8 u. C8 _
  926.   cd "$SRCPATH/server/linux"; N- p& t( I8 {# Y  X. O) s
  927.   make install
    7 I. c# W9 V& k% f

  928. . d, U+ i8 G  H5 b1 m- f: v# `
  929.   # Make sure the install succeeded, x$ Q2 X+ f2 m9 O
  930.   if [ $? -ne 0 ]; then
    , z! C8 ~; b( j) P# R! t
  931.     Log "There was an error installing MaNGOS!" 1
    4 J) z  f: I& f/ s, r& b
  932.     exit 1
    5 w0 s% R0 _& T  Z
  933.   fi
    6 f7 B5 s/ n5 ]. c5 w$ e
  934. }
    : C1 Y' e. t0 O$ z5 j* f" n
  935. # A' x2 a1 |7 ~# P2 g0 E
  936. # Function to apply database updates: ?( a2 q, d6 h1 r8 K
  937. function UpdateDatabases()
    : Y* b) c: y! T4 ?
  938. {
    & J( e' v% H& B/ @
  939.   local DB_HOST="$1"
    * E2 h: f9 i% g" g/ s3 t
  940.   local DB_TYPE="$2"
    * K9 s5 [! N3 L% E( }; p" ~( r
  941.   local DB_COMMAND="$3"1 v! E6 J, K& W1 _# @
  942.   local DB_USER="$4"1 }1 h6 Y: x2 l' U: Q5 A
  943.   local DB_UPW="$5"# m- x3 Z7 ]" ~* M) j
  944.   local DB_REALM="$6"8 W1 w4 C2 @: d
  945.   local DB_WORLD="$7"
    $ i( i7 y- s& i& ?  m
  946.   local DB_TOONS="$8"
    4 q0 ?  ~& \# c# q0 J
  947. ! Y* g# u5 H9 K  B2 [" w
  948.   # Loop through the character files
    8 n% ^% U8 }5 S4 b- J9 ^
  949.   for pFile in $(ls $SRCPATH/database/Character/Updates/$(ls -a $SRCPATH/database/Character/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    - h# k" d% P2 k( W
  950.     if [ ! -f "$pFile" ]; then9 J" F, x+ o" [* |% ]" K, O
  951.       continue
    ( q6 o! Q7 M  f
  952.     fi
    6 g" n% U- ~$ Q
  953.     # Attempt to apply the update, a4 Q$ E! }1 C( `  ?3 Z% \( Z2 j
  954.     $DB_COMMAND $DB_TOONS < "$pFile" > /dev/null 2>&1
    % p. ?' T' W% \3 M* i, B/ v

  955. " A2 l2 X/ y3 e$ n2 g
  956.     # Notify the user of which updates were and were not applied' Z! ^# \6 w% m. h( {/ \9 R
  957.     if [ $? -ne 0 ]; then
    * L/ M" X' @! L  |: Y
  958.        Log "Database update "$pFile" was not applied!" 0
    8 i. q5 O# ~( j- `/ b5 |
  959.        Log "Database update "$pFile" was not applied!" 1
    ; O& Z3 L& F& j3 ~# B3 c6 a
  960.     else
    : m1 [7 _9 ?: r  P7 U" H
  961.        Log "Database update "$pFile" was successfully applied!" 01 O7 v/ `- z, x% K
  962.        Log "Database update "$pFile" was successfully applied!" 1
    % p, d+ r$ B+ e5 w4 f
  963.     fi
    6 K' k; j9 m( |
  964.   done
    # g% f) i* }% E8 a9 T8 u" n
  965. 4 E$ A3 m1 f: \& G  u9 B  P
  966.   # Loop through the realm files
    0 D5 A8 O' ]( U8 z! m! E! T8 V, P
  967.   for pFile in $(ls $SRCPATH/database/Realm/Updates/$(ls -a $SRCPATH/database/Realm/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    9 j8 o5 _/ a" M; A% p  Z, F" k& o
  968.     if [ ! -f "$pFile" ]; then
    & {" ^: l- E6 a) N* ]# `% h. w
  969.       continue; M% r. Y7 F2 i' Y
  970.     fi/ ~2 P: W* o3 O6 r! Z
  971.     # Attempt to apply the update! L2 v3 x. g3 ]( J9 b: v
  972.     $DB_COMMAND $DB_REALM < "$pFile" > /dev/null 2>&1
    ( f# M7 N' U* k3 T$ _+ j" Y! S( ?
  973. ; M: ~, L# l! Y, G2 Y! `, w
  974.     # Notify the user of which updates were and were not applied" }, y5 M/ C+ _8 E: O& M
  975.     if [ $? -ne 0 ]; then) k( M/ v' l2 k) U
  976.       Log "Database update "$pFile" was not applied!" 0
    ' E1 s3 k" d; E4 j/ L  C' @
  977.       Log "Database update "$pFile" was not applied!" 17 c8 |6 f9 i- B% H: L
  978.     else
    / g  Z) W( F% d* b
  979.       Log "Database update "$pFile" was successfully applied!" 0: J8 f; `5 e' V: b) s' f# h# w
  980.       Log "Database update "$pFile" was successfully applied!" 10 X5 L/ A5 i! U9 R
  981.     fi4 I2 i( |2 V; ^  I/ h2 v
  982.   done; H% l. Z1 m5 \# J! l& t4 u0 p0 S
  983. ! K2 c. Z5 M1 L. \
  984.   # Loop through the world files; K: ]" J, E* I- U% u- Z5 I
  985.   for pFile in $(ls $SRCPATH/database/World/Updates/$(ls -a $SRCPATH/database/World/Updates/ | tail -1)/*.sql 2>>/dev/null); do
    ; ~- ?+ q7 W0 d; }7 `
  986.     if [ ! -f "$pFile" ]; then
    / L2 Z1 X' [" C$ f: L2 ^
  987.       continue
    / S! j- V, Z  V- _& r0 ~
  988.     fi
    , j- y2 ]2 q$ r; {8 I, A
  989.     # Attempt to apply the update8 L" E2 Q2 U7 [" e) D; B
  990.     $DB_COMMAND $DB_WORLD < "$pFile" > /dev/null 2>&1
      X- e5 H0 v! C3 k8 B) }

  991. $ B4 y' G( U; Q) I. p$ ~
  992.     # Notify the user of which updates were and were not applied
    2 |5 D5 ^2 }4 H8 M7 K1 Y
  993.     if [ $? -ne 0 ]; then& Y. |- O3 b) Q0 i/ Z+ w
  994.       Log "Database update "$pFile" was not applied!" 0
    2 O; |8 X* R& r$ [! s
  995.       Log "Database update "$pFile" was not applied!" 1% [7 w; X$ l! ^. K7 j* \1 @
  996.     else- m" k% u7 C, u0 ?
  997.       Log "Database update "$pFile" was successfully applied!" 0+ V; k6 E9 x8 K7 P& C
  998.       Log "Database update "$pFile" was successfully applied!" 11 b0 m2 M. p9 ~  T" e# U$ o
  999.     fi
    2 ?& Q; ~3 u; _' r3 r3 \
  1000.   done
    . o. l4 ^1 H3 l+ D! E1 X
  1001. }
    6 n, ]0 w, p$ v

  1002. $ E8 ]/ _0 O. F7 l. B) R1 p8 K* D
  1003. # Function to install or reinstall the databases
    6 _  l6 C  e" |; r$ @
  1004. function InstallDatabases()
    7 j9 i: g' e/ F+ w" G
  1005. {: Y& d# T4 T9 m! y  w4 Y% J
  1006.   local DB_HOST="$1", t2 i2 x' I& o% y
  1007.   local DB_TYPE="$2"( E& W( U( W9 C
  1008.   local DB_COMMAND="$3"/ O1 s4 `; V; b/ |# B+ ?- b
  1009.   local DB_USER="$4"
    ! d) L  g" q$ ^" J1 Z
  1010.   local DB_UPW="$5"
    % A1 ]1 u# U" x& |' Q0 e6 a
  1011.   local DB_REALM="$6"
    % P6 a1 F& R' N7 K- }/ g
  1012.   local DB_WORLD="$7"
    0 w. {0 Q! \5 U; Y6 M5 b
  1013.   local DB_TOONS="$8"
    , R$ Y! l% a* {0 H6 v

  1014. - H) K7 a9 f- U3 G
  1015.   # First create the realm database structure8 j" g, g. W! r' {8 }; C$ p
  1016.   $DB_COMMAND $DB_REALM < $SRCPATH/database/Realm/Setup/realmdLoadDB.sql
    ! d/ q( ?- F" r' @- `

  1017. 5 j4 J& o- \1 R  n) J4 ]
  1018.   # Check for success
    0 q) V0 z* U0 h0 K5 f
  1019.   if [ $? -ne 0 ]; then2 v0 P# J- n- ]
  1020.     Log "There was an error creating the realm database!" 1
    6 v8 A1 N9 L2 S6 g# ~- N0 {2 g5 q- h
  1021.     return 18 h2 p' B* W" X/ X& Q! n0 k
  1022.   else
    $ ?( C. |# ^) s: G7 l3 C# R
  1023.     Log "The realm database has been created!" 10 V; r, y! R6 q; c
  1024.   fi3 i0 b  E+ q* B5 R  T

  1025. " T. a% z4 z+ ?1 l# I
  1026.   # Now create the characters database structure
    8 a$ ^) ?6 b0 d1 P1 F- X9 W* o& o
  1027.   $DB_COMMAND $DB_TOONS < $SRCPATH/database/Character/Setup/characterLoadDB.sql
    ! Q. M/ H- t  k; T( _: x
  1028. $ \% h& A! M# @
  1029.   # Check for success+ v& S- U6 U" {3 X3 r: S, A" [) o
  1030.   if [ $? -ne 0 ]; then
    + c" ]  Z% o/ W: [9 r' y; x
  1031.     Log "There was an error creating the characters database!" 1
    # T0 {! M4 w! d% k5 }5 _3 E
  1032.     return 1* a/ S% _0 I% r7 _+ H4 S0 t
  1033.   else
    5 d/ K0 i7 R1 v
  1034.     Log "The characters database has been created!" 1
    3 P- S0 n" ~; L7 `& A8 Y* R0 Y
  1035.   fi
    & J3 g1 H; \& \3 h: N; g1 p
  1036.   F1 _8 E5 \( Y# r' Y
  1037.   # Next create the world database structure
    $ T( C) p" J0 x. ^8 O& E
  1038.   $DB_COMMAND $DB_WORLD < $SRCPATH/database/World/Setup/mangosdLoadDB.sql  `2 ~) U/ ?( O' Q/ L
  1039. 0 w& C9 u7 ~# X* M( U  d! `
  1040.   # Check for success4 ~0 Z, W  g( x
  1041.   if [ $? -ne 0 ]; then
    + [. l' ], b( \0 J
  1042.     Log "There was an error creating the world database!" 1
    # J. B: F4 I+ H
  1043.     return 19 Y5 |3 T& B+ R6 R/ m
  1044.   else
    3 ^8 l; W% Y8 m
  1045.     Log "The world database has been created!" 1% G, C' ]3 O0 W1 ?
  1046.   fi
    . s0 E# ~' M4 ~, T) f2 i

  1047. 9 b3 V, {& f, a# ]% r. J% I
  1048.   # Finally, loop through and build the world database database; w) C' J4 g0 E9 X- d. Q/ T& K
  1049.   for fFile in $SRCPATH/database/World/Setup/FullDB/*.sql; do
    ) E. p4 ?! t+ ?
  1050.     # Attempt to execute the SQL file0 @$ p$ i8 F( G% J* W) P
  1051.     $DB_COMMAND $DB_WORLD < $fFile* z& G8 a, @! J1 ?, Y$ a

  1052. # [* ?5 v+ o( Y9 e
  1053.     # Check for success
    3 C( B0 J4 \1 y- E
  1054.     if [ $? -ne 0 ]; then
    " B" M. [, y/ v' H: U* u4 g
  1055.       Log "There was an error processing "$fFile" during database creation!" 14 U, x9 a. B0 K/ N4 t2 s9 {
  1056.       return 1$ S5 r& h; N* i
  1057.     else
    " h( L, j+ d5 l+ [) O, N1 Y/ U
  1058.       Log "The file "$fFile" was processed properly" 1
    ( r) F* S8 q7 `8 J/ g, d9 d
  1059.     fi
    ! S0 \6 ^3 z8 w. T5 x2 I6 L
  1060.   done: K9 V# f- R/ m& O! v" u2 L
  1061. 4 e! |# T) }# {/ m# I
  1062.   # Now apply any updates
    ; M  d: m' v( a: O# O# _2 B
  1063.   UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    2 ]8 j3 {3 z; H% _7 ^
  1064. }
      A1 s1 w& Q1 G1 I$ v+ O
  1065. 1 _1 X; M6 m) v" v9 Z' J
  1066. # Function to install or update the MySQL/MariaDB databases
    - m' j1 \. ]0 c3 Q/ V  g
  1067. function HandleDatabases()
    , _' f. E1 y( |0 \; Q( |  b" b0 i
  1068. {
    $ G3 ?1 d1 W1 A$ a* o, F
  1069.   local DBMODE="0"4 F: P+ M8 I) d. l+ Q' i3 b
  1070.   local DB_TYPE="0"8 D2 b3 D! X$ N0 j3 H
  1071.   local DB_COMMAND=""  M3 n+ t( I$ b# d, O% u( i
  1072.   local DB_TMP="0", c7 k9 a3 s. n) `6 \9 K
  1073.   local DB_USER="mangos"
    % K7 s. Z! Q- E
  1074.   local DB_UPW="mangos"
    9 u0 z( N. [8 o( p; |
  1075.   local DB_HOST="localhost"
    " |( D  K- ~2 d
  1076.   local DB_PORT="3306"0 m& Z7 S$ A- Q) Z; ~# r  k. Q
  1077.   local DBSEL="3"
    $ e. ?  W, R& \2 n6 S9 ?
  1078.   local DB_REALM="_realm"
    * H0 A( s' O4 Y1 f( c- _5 M0 G8 w5 Y
  1079.   local DB_WORLD="_world"5 b8 A( K' l: c# V8 T
  1080.   local DB_TOONS="_characters"( |' r& f) j% j2 E" I0 A3 G
  1081. - Y% a6 B  C% M5 |+ o: y3 `
  1082.   # Ask the user what to do here  s4 k3 P" I. u" Y
  1083.   DBMODE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Operations" \; L) {# ?& W  I) o9 }
  1084.     --menu "What would you like to do?" 0 0 3 \7 W5 T* ~8 V8 G/ u
  1085.     0 "Install clean databases" \
    8 n( a  I+ D8 ]' }$ Y* [4 w
  1086.     1 "Update existing databases" \
    + o" e  Q$ i, c2 w2 ^, O% e
  1087.     2 "Skip database work" \
    / C. w( v6 B" a- g0 t
  1088.     3>&2 2>&1 1>&3)
    ; M5 _* M- ~) E0 v

  1089. ( U1 R: a. t# v7 b7 @4 z
  1090.   # Exit if cancelled; ]9 @: F1 }' \# s+ Q
  1091.   if [ $? -ne 0 ]; then
    ' u* F. i) _* O! p% ^& F% q" V5 I
  1092.     Log "Database operations cancelled. No modifications have been made to your databases." 1
    ! M, Q6 r+ G% p
  1093.     return 0  T$ Q! S1 y0 N/ j3 z+ v
  1094.   fi9 z8 Z; A1 K* v) F, _$ v/ i, L( i

  1095. - i, j' k! F- V' n) J& O
  1096.   # Exit if skipping
    3 m# u) G" t, a0 f/ u( J' `
  1097.   if [ "$DBMODE" = "2" ]; then7 p  P' `( ~  A3 i5 d
  1098.     Log "Skipping database work. Nothing has been modified." 1) ]& }0 e# P9 B9 u4 x% r
  1099.     return 01 [9 p4 j  G/ ?, X! D- X
  1100.   fi/ p7 Y, |6 f3 k' a( q( }9 ~

  1101. - _( m5 a. q: {& h; W% I; m2 A
  1102.   # Ask the user the DB type" I; n) e" Z' a7 b" `: F
  1103.   DB_TYPE=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Type" \; j5 z: f& W: M: M, ^
  1104.     --menu "Which database are you using?" 0 0 3 \1 l% u8 E* h* e; e6 N5 Z
  1105.     0 "MariaDB" \8 m. ~2 E- z$ O/ I$ X! L9 a
  1106.     1 "MySQL" \
    3 D  [8 Z; A, Y, \  T3 ~8 i8 N
  1107.     2 "PostgreSQL" \
    1 U, i# d. v: m) L+ Q0 w
  1108.     3>&2 2>&1 1>&3)
    " c9 T/ ]5 l' D3 G/ D! \  V

  1109.   O8 T+ \' H' s" _9 X0 G- w
  1110.   # Exit if cancelled
    . ]+ u* {: D7 s9 r' R, w
  1111.   if [ $? -ne 0 ]; then! N; V. q) O$ x: L& P$ z: J% k
  1112.     Log "Database type selection cancelled. No modifications have been made to your databases." 15 m( h) w' G- W5 {, p5 z) Q8 a
  1113.     return 0
    6 I: v! A; G) k# O
  1114.   fi
    5 U2 c0 y, {) R, O0 L
  1115. 4 X" n0 t# V, C! ?1 X1 x% S
  1116.   # Get the database hostname or IP address
    # }9 q. h0 R4 x5 e4 O
  1117.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database Hostname Or IP Address" \
    3 e# d8 }8 W, F! t& V" f6 i6 e
  1118.     --inputbox "Default: localhost" 0 0 3>&2 2>&1 1>&3)
    7 p: V$ k0 u9 n
  1119. 3 O5 W# n$ w" X
  1120.   # Exit if cancelled3 B9 `; x! R; Y/ Y: ?( S  ]
  1121.   if [ $? -ne 0 ]; then0 B3 P1 H3 l0 F: i6 o
  1122.     Log "DB host entry cancelled. No modifications have been made to your databases." 1: R2 N1 C! u. y7 }. _8 U
  1123.     return 0, ?0 I2 M) t' H$ ?4 ^# V
  1124.   fi, m8 d2 E( v' M2 {

  1125. + E* k0 W& c8 w
  1126.   # Set the hostname or IP address if one was specified
    % t2 @& b$ [; U/ p7 x$ p9 F
  1127.   if [ ! -z "$DB_TMP" ]; then- {( I- h0 [+ J! a# u
  1128.     DB_HOST="$DB_TMP"
    : f& b% S: ?) L4 C/ f
  1129.   fi
    0 \5 D9 o. w: p# Y+ f
  1130. 7 L) U+ G( l  W" x# q, c
  1131.   # Get the database port( D! [+ d! q8 [8 I* J. ]8 ~% o
  1132.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database port" \
    / @# {3 I  k/ z. V
  1133.     --inputbox "Default: 3306" 0 0 3>&2 2>&1 1>&3)
    . A+ r8 d" F! t9 @# y) @6 |
  1134. 0 A/ i9 v2 R9 n
  1135.   # Exit if cancelled
    2 {# O9 ~# y$ G% F+ C' A3 Z, I
  1136.   if [ $? -ne 0 ]; then
    - {- D, s6 u5 P
  1137.     Log "DB port entry cancelled. No modifications have been made to your databases." 1: M& ^( }6 c; d8 n- d3 N' A3 b! T
  1138.     return 0
    1 D8 u4 ~8 D! {5 @6 X
  1139.   fi6 h. i4 c+ g' v# g' a3 M3 Z/ V

  1140. 8 r) q- l" ~2 r9 e' |
  1141.   # Set the port number if one was specified  z6 H% d& ^# \2 i2 h
  1142.   if [ ! -z "$DB_TMP" ]; then
    . ?& T6 L9 k; Z* P, u, H
  1143.     DB_PORT="$DB_TMP"
    2 J5 j, M/ U# U
  1144.   fi
    0 L. O: A5 E9 q! D  C

  1145. 3 t4 |3 p$ f4 D: G7 W9 Q
  1146.   # Get the database user username
    # W/ ^: w  P6 W8 W
  1147.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Username" \/ y! l- ^+ J5 d$ d5 I4 S+ S9 t
  1148.     --inputbox "Default: $DB_USER" 8 60 3>&2 2>&1 1>&3)9 K" X' x' ~3 h7 I& x

  1149. 3 z5 s: p5 \( E/ s6 X7 q* K
  1150.   # Exit if cancelled
    0 ~4 ]2 x' J; k# |2 y- W
  1151.   if [ $? -ne 0 ]; then( }5 ^0 A' o! a/ `2 [' C. _
  1152.     Log "DB user name entry cancelled. No modifications have been made to your databases." 1: u6 \4 ]3 w2 J3 y: h2 n& Y; A8 Y; d. z
  1153.     return 0( U3 G" W/ W( W
  1154.   fi8 V, a$ G3 ^8 c
  1155. # r' u, x7 N. k
  1156.   # Set the user username if one was specified8 w, f; Z4 ~+ m- [6 f/ o3 m
  1157.   if [ ! -z "$DB_TMP" ]; then
    # c. x) E5 {7 p5 w. d  z
  1158.     DB_USER="$DB_TMP"
    # Q& [2 x! n  E* T( g5 A; B  ^
  1159.   fi: y% v7 Q5 }& X

  1160. ' b! f/ C! W2 L* ~, g
  1161.   # Get the database user password9 w8 ?: C7 h. _; B2 W  l
  1162.   DB_TMP=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Database User Password" \9 P% }9 a& F- I, d$ N$ g( l4 ^
  1163.     --passwordbox "Default: $DB_UPW" 8 60 3>&2 2>&1 1>&3)
    7 m! U3 |3 u% C; ]& U$ }+ ~
  1164. / _0 C  j% H& S
  1165.   # Exit if cancelled
    ' W; C1 E& K9 E- J% [5 u+ B" ^9 K
  1166.   if [ $? -ne 0 ]; then
    # ]+ }0 k, `: W. F8 ^0 {( @
  1167.     Log "DB user PW entry cancelled. No modifications have been made to your databases." 1
    9 U7 V. b1 x  I  M; `0 y4 Z
  1168.     return 03 s( W6 T' t- q. @2 O
  1169.   fi: G4 t; S* `/ ~9 B1 @$ m- U, S( q
  1170. ' v6 X9 u: A6 q, u
  1171.   # Set the user password if one was specified
    4 ^4 M1 u' n2 v1 {3 v( v9 U
  1172.   if [ ! -z "$DB_TMP" ]; then
    " n- j" q6 k! T- K" D+ Q
  1173.     DB_UPW="$DB_TMP"* S- @: x9 `7 B9 n# P0 H. R
  1174.   fi
    ' }5 Y9 L: x( u7 c
  1175. ) f9 p3 D8 b) u1 H1 j
  1176.   case "${DB_TYPE}" in
    + {$ w0 i7 [% V7 Q
  1177.     "0")% R- r/ a( g. t( w' `
  1178.         DB_COMMAND="mysql -u ${DB_USER} -p${DB_UPW} "
    1 \0 e) l: M$ |/ E% c8 |
  1179.         ;;
    . {: ]* ]8 O- |0 Y
  1180.     "1"), z5 i  ^4 k' Q3 c) K
  1181.         printf "Confirm your MySQL password\t, "
    . E( C9 B: ?* {$ g
  1182.         mysql_config_editor set --login-path=local --host=$DB_HOST --port=$DB_PORT --user=$DB_USER --password --skip-warn
    5 Y  x# [' }: c5 Y# R
  1183.         DB_COMMAND="mysql --login-path=local -q -s "
    $ ~/ C( L) M/ ~; |$ v" X
  1184.         ;;
    ' J" q% n: [! x' R
  1185.     "2")
    4 B0 K9 f6 \$ ~  d
  1186.         Log "Currently not supported." 1
    6 k9 g  n5 q+ x7 I0 m' `
  1187.         return 0
    : j& \2 h! p- H& l* {8 a
  1188.         ;;+ Z4 ]) O9 n# U. l
  1189.   esac% s9 [8 i9 N' P! V9 y! v* `

  1190. , n6 Q0 O! t/ y/ t5 L% S6 @' q4 r. w
  1191.   # Setup database names based on release
    5 r8 h0 ?6 _+ _
  1192.   DB_REALM="$DB_PREFIX$DB_REALM"! J4 l1 k+ o- y* @
  1193.   DB_WORLD="$DB_PREFIX$DB_WORLD"2 [2 t. f9 T8 I, m; V& o& U9 }) I
  1194.   DB_TOONS="$DB_PREFIX$DB_TOONS"
    ( k/ F% H9 e+ d" T1 y: i

  1195. 1 B/ m; E. z, o+ z$ S) |8 f
  1196.   # Install fresh databases if requested
    # o! @, Z- R% L% a' z* G
  1197.   if [ "$DBMODE" = "0" ]; then
    9 c7 r& T* D& \' t7 D2 z) r" i
  1198.     # Ask which databases to install/reinstall0 A6 u* d; z+ [# k; X/ d1 V8 S
  1199.     DBSEL=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Databases" \
    # H( \/ O& Z: ]5 Q" U
  1200.       --checklist "Select which databases should be (re)installed" 0 60 4 \
    3 S! s  a5 q+ |( F( w, q
  1201.       0 "(Re)Install Realm Database" On \
    ( ?( X1 H! M2 a; y
  1202.       1 "(Re)Install World Database" On \
    + f0 z- s& ?# r8 @
  1203.       2 "(Re)Install Characters Database" On \) ?3 p& ]2 ^1 s/ T9 g4 i' m
  1204.       3 "Update the realmlist" On \5 R5 {# `! q6 x8 a0 d2 ^
  1205.       3>&2 2>&1 1>&3)
    + M+ \- {" |& ^% e6 m1 w: K
  1206. ' L2 T! g# f. v: d* ?, Q9 e
  1207.     # Exit if cancelled) i* I, K( v) C! k; `+ K5 ^0 q4 @. i
  1208.     if [ $? -ne 0 ]; then
    ; @9 f* q! f1 b% \: U. t2 G
  1209.       Log "DB selection cancelled. No modifications have been made to your databases." 1! u3 x# m& ^2 ?% J7 M
  1210.       return 0" J3 i1 N. X: |0 w2 x8 a
  1211.     fi
    & r7 t- o, j5 K7 z
  1212. 3 B, ?6 r8 [" e6 i, w& i
  1213.     # Remove and create the realm DB if selected
    / c4 w  I/ t: q7 x1 |1 j$ q- k
  1214.     if [[ $DBSEL == *0* ]]; then
    5 n4 M, C1 _  C) E( N7 `) n* k
  1215.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_REALM;"
    ) u5 d" Y' z: N7 b' y
  1216.       $DB_COMMAND -e "CREATE DATABASE $DB_REALM;"" b  P3 |' ~4 E* m; P4 n
  1217.     fi/ ~6 p2 l# ?! B# a; A5 |! I

  1218. * ^& H0 H! ?1 G6 s( Z0 q4 E
  1219.     # Remove and create the world DB if selected9 H# f, l- L4 X$ f4 N+ s
  1220.     if [[ $DBSEL == *1* ]]; then; l1 i* A1 L# V
  1221.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_WORLD;"
    / ^4 i0 t! D2 M' x' s0 Q: E$ \! I: s
  1222.       $DB_COMMAND -e "CREATE DATABASE $DB_WORLD;"
    ) Y7 M' y+ `5 D* I
  1223.     fi) A. T; @. o8 B+ y' n* l# d& |; r
  1224. 4 ^  _. z% a' ?3 D- K3 _* r
  1225.     # Remove and create the character DB if selected4 [# s7 z- `9 h, [
  1226.     if [[ $DBSEL == *2* ]]; then, L2 y. P9 C1 Q2 A: }
  1227.       $DB_COMMAND -e "DROP DATABASE IF EXISTS $DB_TOONS;"
    ! E6 w6 }9 ?2 v) Q: m' C/ k: C
  1228.       $DB_COMMAND -e "CREATE DATABASE $DB_TOONS;"
    : X+ z/ U& Y* n6 z) e  t5 ?- f1 N
  1229.     fi' g+ J# J( `3 M9 ^6 m1 T. |

  1230. 1 F, P& D/ u9 I6 |( I9 K
  1231.     # Validate success. R( V! `& Z& w4 n9 G
  1232.     if [ $? -ne 0 ]; then1 e9 p  X8 `$ x0 \7 ?7 v4 O
  1233.       Log "There was an error creating the databases!" 19 t3 M$ @4 K( I1 [- L2 h
  1234.       return 1
    9 Q' A" j% Y3 v# a# V1 T6 s+ g
  1235.     fi  ]" c1 f* H5 Z7 D  t+ ^5 N
  1236. . I: m' H; w9 y! o* n
  1237.     # Finally, populate the databases& z( s2 B) }' R1 n% S) l
  1238.     InstallDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS
    + G5 D( D/ Q' Y
  1239. 5 f$ [, i& A; R
  1240.     # Updating the realmlist
    8 W$ [& g" j% D4 X
  1241.     if [[ $DBSEL == *3* ]]; then$ m* ?4 X1 H) P3 U
  1242.       $DB_COMMAND $DB_REALM < $SRCPATH/database/Tools/updateRealm.sql
    2 n& C2 @9 x% m# d, c7 a
  1243.     fi8 f+ u9 J7 P* m6 O# M9 b
  1244.   fi7 F8 w0 ^) @+ h1 G5 Z3 C
  1245. 7 ]7 W7 T  E/ ~6 a# B! _
  1246.   # Update the databases if requested' W" J4 U: d- S' \# H5 S
  1247.   if [ "$DBMODE" = "1" ]; then
    - s9 Z( Q+ o$ d' R0 S$ n2 h1 W- b
  1248.     UpdateDatabases $DB_HOST $DB_TYPE "$DB_COMMAND" $DB_USER $DB_UPW $DB_REALM $DB_WORLD $DB_TOONS9 q- E4 W# g) I
  1249.   fi
      }7 P# l  w' @' L* `! Q
  1250. }1 E6 X9 J9 |6 W! B  y* d3 n; L" Z4 _

  1251. . N: l4 F/ ]; t4 x8 _- Y6 f
  1252. # Function helper to extract resources (mmaps, vmaps, dbc, ...) from the game
    ) L0 V( i3 n7 s" J6 Y! O2 [1 P# s
  1253. function ExtractResources
    - P2 i# d7 W3 e# U2 F  X' O
  1254. {
    1 `+ n/ z: d, t" i+ i: r/ i6 T
  1255.   INSTGAMEPATH=$(dirname $(find /home -name "WoW.exe"| head -1 2>>/dev/null))
    3 r: j/ }2 U. u  C5 ^
  1256. # }4 G; w; l: P7 K: j4 r8 ?
  1257.   GAMEPATH=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "WoW Game Path" \- W3 ~8 \1 Z- r  U+ l$ |
  1258.     --inputbox "Please, provide the path to your game directory. Default: $INSTGAMEPATH" 8 60 3>&2 2>&1 1>&3)
    ! H& k( Z: z, \- |4 M$ b
  1259. " ^5 t, c: E& L5 [' m2 n; |8 ]
  1260.   if [ -z "$GAMEPATH" ]; then1 M7 S' ?2 K/ A$ w
  1261.     GAMEPATH="$INSTGAMEPATH"
    3 I  Q9 d+ n/ S4 x4 |+ \; |; o9 V
  1262.   fi
    3 P1 b3 ]8 q9 `3 P' B

  1263. 9 G, l3 d6 r0 T1 l. z5 X
  1264.   if [ ! -d "$GAMEPATH" ]; then
    * s# }9 [1 c6 a9 \' K
  1265.     Log "There is no game at this location" 1$ j9 e$ M* L* i" a5 x
  1266.     exit 19 F: N% \2 l3 O# b7 _
  1267.   fi
    5 G% U7 p: l& S( f4 U) t

  1268. % s% n: U+ ^9 h' \1 m" @% S
  1269.   ACTIONS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \
    . F" C, `! @/ [7 M2 X
  1270.     --checklist "Please select the extractions to perform" 0 70 3 \* K. C4 W0 ~) D( j6 {) n/ i0 H
  1271.     1 "DBC and Maps" On \! v& Z3 `) Q) b# s  D
  1272.     2 "Vmaps" On \
    3 u" G4 a6 @; K% {% l- j, M
  1273.     3 "Mmaps" On \1 N' f$ C, T7 i; m" G: z1 c
  1274.     3>&2 2>&1 1>&3)/ w9 J0 m9 U8 y4 |) I1 y

  1275. 2 s) W3 h0 W# ^2 O  {2 _1 D' r
  1276.   if [ ! -d "$INSTPATH/bin/tools" ]; then
    4 s/ b6 s2 S, r0 m8 u, w( L8 H
  1277.     Log "The client tools have not been built, cannot extract data" 1/ a/ E# c2 _; v( Y2 h; T; x
  1278.     exit 1
    , o/ [/ ?2 n  d
  1279.   fi% _0 K0 ?6 M7 v' H! R0 u$ C& V

  1280. # k' V- @8 N% Q0 l
  1281. #TODO What if DBC are not yet generated ??
    & i. c0 O. D, z$ x
  1282.   if [[ $ACTIONS == *1* ]]; then4 ^2 Y# O# M) [- g! C) g' U1 r& ?
  1283.     if [ -d "$GAMEPATH/dbc" ]; then1 k, T; s& G+ V) l0 G9 ]8 r/ C1 E
  1284.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "DBC and Maps were already generated" \
    . M+ A6 H& D3 g) w9 |
  1285.         --yesno "Do you want to generate them again?" 8 607 i& V0 o6 W2 n1 `$ O

  1286. ! X$ b& U8 |. |. J5 w0 [4 f
  1287.       # Check the user's answer
    ! n  Y# E# I; g; Q: Q
  1288.       if [ $? -eq 0 ]; then3 p: |' A/ `' W! G
  1289.         Log "Deleting DBC and Maps previously generated." 1
    . g7 C" Q2 t, A9 t
  1290.         rm -rf "$GAMEPATH/dbc"
    1 O1 t9 a$ }0 ]$ Z+ s; H1 ]( n, c
  1291.         rm -rf "$GAMEPATH/maps"
    0 Y7 S% k7 L$ k5 _, O$ c$ b
  1292. 1 R+ U6 C/ ~: y" _7 d/ L* j! h& M
  1293.         Log "Copying DBC and Maps extractor" 0: r) N: G# W4 i3 A
  1294.         rm -f "$GAMEPATH/map-extractor"" p) A9 ?1 A7 u% D3 p9 P; N
  1295.         cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"5 z7 n8 E) ?/ Z1 Z

  1296. , t9 }5 I8 j7 G. h$ C* Z- l& d
  1297.         Log "Extracting DBC and Maps" 02 o% n3 ^; t+ U% R$ w
  1298.         cd "$GAMEPATH"& o* C1 V! S8 C' C
  1299.         ./map-extractor4 |) c  R! U1 s3 E2 E; }: t( \
  1300. ( }' c: w, d; |  M6 h/ A
  1301.         if [ $? -eq 0 ]; then" f* Q3 X9 |- Y" k, l9 I8 @
  1302.           Log "DBC and Maps are extracted" 03 d; E) L+ S; ]& J$ K
  1303.           Log "Copying DBC and Maps files to installation directory" 0
    ) i( m5 P6 ^2 ]
  1304.           cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"
    ' m& j& }4 s9 k$ p
  1305.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    , f8 R+ G% @7 T
  1306.           rm -rf "$GAMEPATH/map-extractor"
    $ {- u$ F2 \) P7 ?6 N: n3 r1 i
  1307.           Log "Changing ownership of the extracted directories"" q( F! V3 q% C$ k
  1308.           chown -R $USER:$USER "$INSTPATH"
    ; g  i$ z6 P6 _, `0 [5 d1 }! S& [
  1309.         else
    ' O, ]$ Z$ a* o
  1310.           Log "There was an issue while extracting DBC and Maps!" 17 w2 u: h2 d- V5 @
  1311.           rm -rf "$GAMEPATH/map-extractor"- Y: w3 N4 P! u- x
  1312.           rm -rf "$GAMEPATH/dbc"
    : W6 J/ n3 _$ c1 w( `* N1 W# @7 G
  1313.           rm -rf "$GAMEPATH/maps"
    9 z, u, Z  t- t* Q& l- J
  1314.           exit 1% |- {) R# x3 w; K2 Q& Z3 g
  1315.         fi5 n5 w0 W( v$ t- K
  1316.       else0 t! [8 N& s5 Z
  1317.         Log "Copying DBC and Maps files to installation directory" 0
    $ p0 Q; h  B% r; O( R: D& ^
  1318.         cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"- }, t' S0 I' @% P: x3 u+ }. y
  1319.         cp -R "$GAMEPATH/maps" "$INSTPATH/bin"
    ( W" n% R& f- M' u2 @" F- i" P
  1320.       fi
    9 ]5 _. x6 q2 ], r- V
  1321.     else
    : F3 D) }  K# J7 d1 W" y
  1322.     rm -rf "$GAMEPATH/map-extractor"
    4 k) y! H" a5 `9 F7 M
  1323.     cp "$INSTPATH/bin/tools/map-extractor" "$GAMEPATH"
    " \% U3 f  `* H; }- o; y3 G
  1324. 8 S# _8 I: D: [
  1325.     Log "Extracting DBC and Maps" 0" m! W: }& x! l+ b1 }0 ?7 U- z
  1326.     cd "$GAMEPATH"
    5 D0 j2 Y% |+ R$ w' ?. w
  1327.     ./map-extractor( O3 T  \' h* G9 L) h

  1328. 6 F4 z, G5 a- P1 C+ w% h
  1329.     if [ $? -eq 0 ]; then2 ]# [& s3 r) y9 P# r" o
  1330.       Log "DBC and Maps are extracted" 0
    6 ]/ f# x. \8 H4 F3 Q
  1331.       Log "Copying DBC and Maps files to installation directory" 0
    ( x) c2 K$ \4 j& c. B! \- P8 Q, o9 k
  1332.       cp -R "$GAMEPATH/dbc" "$INSTPATH/bin"- \$ l  E' `5 E" L  k$ s% m: Y, h
  1333.           cp -R "$GAMEPATH/maps" "$INSTPATH/bin"1 Z! E/ c! ]& q- A9 O
  1334.           rm -rf "$GAMEPATH/map-extractor"
    / ^; p% ?5 |( v0 }& d% M" L/ j
  1335.           Log "Changing ownership of the extracted directories"9 N, p, E/ c6 V$ i3 j7 w: j
  1336.           chown -R $USER:$USER "$INSTPATH"* M+ V! u" X" c; c8 M$ w0 h
  1337.         else
    5 S( e+ V/ l. [3 V  n/ I
  1338.           Log "There was an issue while extracting DBC and Maps!" 1% b. G7 N; _' U3 {4 K6 J
  1339.           rm -rf "$GAMEPATH/map-extractor"
    - U" G9 @. J4 a# D+ V+ m
  1340.           rm -rf "$GAMEPATH/dbc"
    . l+ _) Y0 F! x# N& B4 `* d
  1341.           rm -rf "$GAMEPATH/maps"
    - E) @5 h" U" L" z
  1342.           exit 1! t" m8 `: z  \( x5 G
  1343.         fi
    0 F( o, U; c" \, ~2 v* p: @  i
  1344.     fi- J8 A% E+ v7 e
  1345.   fi$ L8 l" C/ u( E; s0 q& }
  1346. ! H! W% \9 g# A, A$ ]
  1347.   if [[ $ACTIONS == *2* ]]; then6 k( b4 @+ I3 b, H
  1348.     if [ -d "$GAMEPATH/vmaps" ]; then) M% D$ a( o* X. f8 p& B5 G6 K8 l
  1349.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "VMaps were already generated" \8 c' U$ O$ k3 y% F. L
  1350.         --yesno "Do you want to generate them again?" 8 607 ?- }! g2 {; V( Z/ g) C
  1351. $ U6 w9 }2 L# u$ @) ^
  1352.       # Check the user's answer
    $ M' j' d. E1 u' V* h
  1353.       if [ $? -eq 0 ]; then. B3 R: ~* H: d& D- j
  1354.         Log "Deleting VMaps previously generated." 1" A# {  w  b, A$ B1 w% t
  1355.         rm -rf $GAMEPATH/vmaps
    3 J( M2 |- Y. z3 n
  1356.         Log "Copying VMaps extractor" 0  V  d2 M( i  S. @% b
  1357.         rm -f "$GAMEPATH/vmap-extractor"8 R' ?: Q+ p8 ]0 U
  1358.         cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    ) R) l, h# U% m+ l6 u  p

  1359. ( G8 a/ z& v/ D
  1360.         Log "Extracting VMaps" 0+ C+ h$ H- M# @7 [
  1361.         cd $GAMEPATH
    - |8 V$ B0 A  @, L! `+ O
  1362.         # Make sure there is no previous vmaps generation that cause issue.6 X/ D5 \" N/ A& y, K
  1363.         rm -rf Buildings
    8 Z$ F7 N3 T* c: r: f
  1364.         ./vmap-extractor
    ' \+ Q3 z2 I) Q% h2 H) L

  1365. " B, m8 n* F) x
  1366.         if [ $? -eq 0 ]; then6 S4 E5 _+ k- t8 z" g
  1367.           Log "VMaps are extracted" 02 \8 u3 m' ?+ [7 C6 t
  1368.           Log "Copying VMaps files to installation directory" 0- O  q! B- y! P* _5 X3 h9 {) t
  1369.           cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    1 e6 `1 a! ]# Y' v9 X
  1370.           rm -rf "$GAMEPATH/vmap-extractor"( B4 `! {- W  h3 F$ P* Y
  1371.           Log "Changing ownership of the extracted directories"( t/ D8 Y; T9 ]" ]' T: i
  1372.           chown -R $USER:$USER "$INSTPATH"
    / X6 w$ C: i1 K& g5 x
  1373.         else7 `8 I9 n& T, C8 _+ S) q3 x
  1374.           Log "There was an issue while extracting VMaps!" 1, M3 J2 k' S2 d4 B0 c0 b9 J
  1375.           rm -rf "$GAMEPATH/vmap-extractor"' q9 E; x) H3 K% q+ e
  1376.           rm -rf "$GAMEPATH/vmaps"/ U$ ?9 l" c& a* i
  1377.           exit 1. K* p4 O5 \: h& a0 {: W
  1378.         fi' z( C  }  S* v
  1379.       else, T5 T# ?* h: Y1 V: q9 M
  1380.         Log "Copying VMaps files to installation directory" 0
    9 h- _7 C% j) X. x
  1381.         cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin") I1 E' Z+ y- A5 r0 p. E! Y* w+ [
  1382.       fi2 x* Q* p" T+ Y* n/ S
  1383.     else! V; N3 f  g) Q* @1 K$ V9 X* [
  1384.      Log "Copying VMaps extractor" 0
    0 D& Z7 n2 G/ y. r* y0 p
  1385.      rm -f "$GAMEPATH/vmap-extractor"# @) G: g7 A  B+ F- ~
  1386.      cp "$INSTPATH/bin/tools/vmap-extractor" "$GAMEPATH"
    + `2 p$ m8 m. `( |: @
  1387. ! v8 }) u+ l' P. {+ p1 V& q9 ^
  1388.      Log "Extracting VMaps" 07 |4 D3 V5 v2 `" Q6 h: O
  1389.      cd $GAMEPATH, @- A1 u0 j% g6 X- w
  1390.      # Make sure there is no previous vmaps generation that cause issue.
    & }7 P' t: w" a' |4 o) s
  1391.      rm -rf Buildings  g' F; ?* ]7 M, X9 ~+ V" ]0 ?
  1392.      ./vmap-extractor
    # {1 f. W0 A0 x
  1393. 1 ^8 y. J8 r% {. r$ ~; H, o
  1394.      if [ $? -eq 0 ]; then
    " N3 D! a% e5 f0 w9 A6 F
  1395.        Log "VMaps are extracted" 0; ]: V4 z" I' Z$ T* F* N$ u
  1396.        Log "Copying VMaps files to installation directory" 0% ]6 L1 _  t, b- s
  1397.        cp -R "$GAMEPATH/vmaps" "$INSTPATH/bin"
    " [% \9 r2 e* h% @4 |( b; e9 n
  1398.        rm -rf "$GAMEPATH/vmap-extractor"/ A$ i- r2 F  c$ X0 i6 v+ {
  1399.        Log "Changing ownership of the extracted directories"
    # u1 Z! A3 J5 d* b; K
  1400.        chown -R $USER:$USER "$INSTPATH"
    8 J2 P+ h$ L7 Y- j& j) N' N% M
  1401.      else1 i- k9 X* k" g7 |5 U
  1402.        Log "There was an issue while extracting VMaps!" 17 P* ^# d5 _5 {4 w  K, D
  1403.        rm -rf "$GAMEPATH/vmap-extractor"
    . M. \+ k2 S1 l- q0 Q
  1404.        rm -rf "$GAMEPATH/vmaps". a: \% S5 D/ A- |/ C9 f! T
  1405.        exit 1
    $ g# I( O* ?, [! i8 M
  1406.      fi
    ; \" |6 m6 f8 F; D
  1407.     fi. ^- [6 x/ m5 V
  1408.   fi$ z' D* i. P1 Q2 N$ P/ v! u

  1409. ; Z6 I4 g6 |& A3 Z
  1410.   if [[ $ACTIONS == *3* ]]; then
    ' T/ |2 u  ~# L. R0 N, m3 t6 f
  1411.     if [ ! -d "$GAMEPATH/maps" ]; then
    6 t& M% Y0 M7 [% F: Y
  1412.       Log "Error: maps files must be created to be able to generate MMaps!" 1* z0 n. f6 w5 ~. B3 G
  1413.       exit 1
    8 i6 A! `- B  Y
  1414.     fi) `  _) f5 s  t9 Y! h0 Y- r) z, S
  1415. : l; ]5 Q" Z" L
  1416.     if [ -d "$GAMEPATH/mmaps" ]; then
    , R- l% X7 |4 l, R# P
  1417.       $DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "MMaps were already generated" \
    5 @: b( i/ q9 [9 l4 m! v
  1418.         --yesno "Do you want to generate them again?" 8 60
    : R9 m% |1 u. T. }! N+ J8 w4 s8 f

  1419.   Q+ e8 u# O- k, b  @% P
  1420.       # Check the user's answer
    ' K3 K, ~! {# t$ \& w
  1421.       if [ $? -eq 0 ]; then! J- \, Y; ]$ T) q- `* s+ ]
  1422.         Log "Deleting MMaps previously generated." 1
    1 N5 P3 g! j, a0 \
  1423.         rm -rf $GAMEPATH/mmaps
    . X2 F9 A8 q( Z$ n
  1424. $ ]; S$ m8 z5 E5 c! S
  1425.         Log "Copying MMaps extractor" 0
    ; A! n9 O- t) n* ]
  1426.         rm -f "$GAMEPATH/MoveMapGen.sh"
    3 N$ d- m5 j* \' U. `
  1427.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    * p( _: a9 r8 Y
  1428.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"; `( @* L6 t6 t
  1429.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"
    5 @+ d* Y' m! O3 q
  1430.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    : A* J* Y1 |' c
  1431. 2 i! Z( d& a! C: ~7 U) t" P
  1432.         CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \/ n6 ~; h; e9 A
  1433.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3)
    ; H: i; T4 q9 `

  1434. + _" m) U! E/ ]3 d+ I7 B
  1435.         # User cancelled his choice, set default to 1.' E/ `4 j! `7 R, j' W- t2 m
  1436.         if [ $? -ne 0 ]; then
    # C& ~" X% a) E, [
  1437.           Log "User selection was cancelled. Max CPU set to 1." 11 j& X4 w; p! _2 b& j: v, h4 n& F/ p
  1438.           CPU=11 c8 n0 f. q) z2 K1 B6 T0 Q7 r
  1439.         fi
    7 `' h9 p- T1 n; b" z0 @2 ]8 x

  1440. 3 R8 `( Q" |; Q7 \' ^# d& t
  1441.         if [ -z "$CPU" ]; then
    " _9 I  a8 H3 K! S' l) \$ x! a
  1442.           Log "User didn't gave any value. Max CPU set to 1." 1% i4 ^& C$ _4 k1 u/ n( O5 l& U
  1443.           CPU=17 m& X8 e/ k) p8 x% Q! F& b
  1444.         fi
      }. F6 K6 N8 H7 N/ P9 ?$ A
  1445. 6 F; |. v& d: h/ |" ^9 k
  1446.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then
    $ K2 U$ z, ^, t! u$ d+ l
  1447.           Log "User entered invalid value. Max CPU set to 1." 1
    7 Z, V' a/ N1 A
  1448.           CPU=1
    5 ?# G4 j% m( q
  1449.         fi
    ) r' e" ^- I, a3 J- h

  1450. / v  ]/ E* ]* s5 H
  1451.         Log "Extracting MMaps" 09 z' v* N7 C/ v7 Z" U& k* _
  1452.         cd $GAMEPATH
    & t5 C) A# n$ i  G" k- y
  1453.         # Making sure we can execute the script
    ( H+ c. M( K4 I0 G! L: n
  1454.         chmod 700 MoveMapGen.sh
    + B  _0 [# w) u
  1455.         ./MoveMapGen.sh $CPU
    $ R0 `, K  w+ b4 I$ `2 O9 R( ~& O9 J
  1456. % k* b8 F6 l# v  K) i
  1457.         if [ $? -eq 0 ]; then$ R7 E0 B9 I' J7 L5 ]
  1458.           Log "MMaps are extracted" 0
    ! q) [( H& T0 c# q
  1459.           Log "Copying MMaps files to installation directory" 0
    7 E- d: K1 {  S8 v4 T7 z  e3 P
  1460.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"! v4 O! i* E5 ^! Q. X' U1 ~% U& C+ u
  1461.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    1 L! `# E4 q; e& l2 o0 H
  1462.           rm -rf "$GAMEPATH/offmesh.txt"
    0 Z: U2 G* b( S4 Y$ |& c
  1463.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    # \7 c/ ^2 m& U3 @
  1464.           rm -rf "$GAMEPATH/mmap-extractor"9 ?5 N  J+ n! c5 }) k" A8 M
  1465.           Log "Changing ownership of the extracted directories"3 V: A. R5 Y6 A2 B6 {4 |7 b9 \
  1466.           chown -R $USER:$USER "$INSTPATH"; p: ?6 i7 o. K5 v# }/ b1 V- A( z
  1467.         else8 a6 z3 o& V& ~/ |
  1468.           Log "There was an issue while extracting MMaps!" 1' i9 G9 U* ~# N
  1469.           rm -rf "$GAMEPATH/MoveMapGen.sh"# \* _) Z6 g  P+ O4 ?8 u: a0 Y3 M6 l
  1470.           rm -rf "$GAMEPATH/mmaps"+ |# L% x. j5 [
  1471.           rm -rf "$GAMEPATH/offmesh.txt"4 J! j0 x' r3 J- R% Y
  1472.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ) L9 P' J! H& [- E! \: Q
  1473.           rm -rf "$GAMEPATH/mmap-extractor"
    " i4 n  {) {6 S4 Z
  1474.           exit 1. O! D; B, h4 e' B; \: l
  1475.         fi
    , t' `" S7 j* x0 q( [
  1476.       else" f* e- B$ p" A+ I
  1477.         Log "Copying MMaps files to installation directory" 0" a3 ?, K: M, s9 k9 E% S0 }( @2 d
  1478.         cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
    5 J! Q8 s" C/ F' C
  1479.       fi
    & m* n8 A( [! }! I' k
  1480.     else
    . \' ]6 I! x+ y
  1481.     Log "Copying MMaps extractor" 0* I0 X" w9 G+ }; z) C" g
  1482.         rm -f "$GAMEPATH/MoveMapGen.sh"' f( b: i9 Q" k, A1 m
  1483.         cp "$INSTPATH/bin/tools/MoveMapGen.sh" "$GAMEPATH"
    8 ]7 k' q; K  _
  1484.         cp "$INSTPATH/bin/tools/offmesh.txt" "$GAMEPATH"5 t4 ?& j; t. s
  1485.         cp "$INSTPATH/bin/tools/mmap_excluded.txt" "$GAMEPATH"2 |, g% E$ i" b
  1486.         cp "$INSTPATH/bin/tools/mmap-extractor" "$GAMEPATH"
    / `, P7 q; W) y' L; I! J8 K, \9 B% O7 L
  1487.     CPU=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Please provide the number of CPU to be used to generate MMaps (1-4)" \
    ' R% h0 k. n& E9 X, ]! }! Z: C
  1488.          --inputbox "Default: 1" 8 80 3>&2 2>&1 1>&3), S" @- t3 G5 t, v
  1489. % S; @: Z, h! O4 W  a3 n) D
  1490.         # User cancelled his choice, set default to 1." v+ f: m* ?9 e' I
  1491.         if [ $? -ne 0 ]; then
    $ Z1 _5 M! }4 M) P! [) b
  1492.           Log "User selection was cancelled. Max CPU set to 1." 1
    / u5 @# F# c8 d1 S
  1493.           CPU=18 Y- X# l; ?3 q$ x0 U' P
  1494.         fi9 q1 c) v9 E0 |. W8 s5 J  e0 L7 ^2 c1 M

  1495. ; `& P5 a! a: g6 d. Y$ i
  1496.         if [ -z "$CPU" ]; then1 x; A+ g1 e; u6 F
  1497.           Log "User didn't gave any value. Max CPU set to 1." 11 O& g; _" J: q' G0 l4 u
  1498.           CPU=16 R+ L  q' S2 D# u
  1499.         fi! n" G* z6 `+ `' R5 W: F/ [

  1500. 1 L) o. T- X# B" M
  1501.         if [ "$CPU" -lt 1 ] || [ "$CPU" -gt 4 ]; then2 ]" h( L+ ]. L- I+ X1 @
  1502.           Log "User entered invalid value. Max CPU set to 1." 1
    6 x2 w" ^6 i& \0 Z% w) j3 s) Z
  1503.           CPU=1
    * K' D  A$ s. P0 l
  1504.         fi
    # n) x2 x: ?& f

  1505. 5 Q9 A$ A" ~5 g1 y% ^4 y* B& t
  1506.         Log "Extracting MMaps" 0
    : M# v% b8 S9 \) }& j* e
  1507.         cd $GAMEPATH
    8 w9 @. Z5 R* z7 R$ X+ N
  1508.         # Making sure we can execute the script( d+ T& S5 y' o# J
  1509.         chmod 700 MoveMapGen.sh2 k! r7 S- n8 X! P( z' L) y+ d
  1510.         ./MoveMapGen.sh $CPU! ?3 o2 |# f8 z  b! s1 b. e( g7 N

  1511. / u7 f! {- A4 f  g/ p- V$ c
  1512.         if [ $? -eq 0 ]; then6 N) S+ c3 }: @5 r
  1513.           Log "MMaps are extracted" 0
    $ g/ C; t4 [; d: r  m
  1514.           Log "Copying MMaps files to installation directory" 0
    : e" P8 p8 B8 n% z6 x/ l" I
  1515.           cp -R "$GAMEPATH/mmaps" "$INSTPATH/bin"
      C% v- Q" X) k% w
  1516.           rm -rf "$GAMEPATH/MoveMapGen.sh", I* N( D+ m! [8 \
  1517.           rm -rf "$GAMEPATH/offmesh.txt"- B- z- w0 S; R$ K$ Z
  1518.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    : p: @$ D) ^6 ]9 C0 H5 U2 _
  1519.           rm -rf "$GAMEPATH/mmap-extractor"
    # }. _$ |- T4 g; b5 x/ C/ f8 e
  1520.           Log "Changing ownership of the extracted directories"/ ~3 W) m* ^% @( _
  1521.           chown -R $USER:$USER "$INSTPATH"
    * t8 F) G/ `3 h" W; f9 J+ z, P9 d# E1 F
  1522.         else
    ( t: \2 w/ @/ U; K
  1523.       Log "There was an issue while extracting MMaps!" 1
    . C; l% E1 H. E
  1524.           rm -rf "$GAMEPATH/MoveMapGen.sh"
    % p  A6 y: C! @" I: {
  1525.           rm -rf "$GAMEPATH/mmaps"
    $ v1 r% ^) J* L- i
  1526.           rm -rf "$GAMEPATH/offmesh.txt"
    3 V; A: B$ V4 k; Q4 l& {
  1527.           rm -rf "$GAMEPATH/mmap_excluded.txt"
    ! |% W. S6 D, C: R( j9 u
  1528.           rm -rf "$GAMEPATH/mmap-extractor"
    - i  o# v. B; ]
  1529.           exit 1
    / w8 o- N4 f% \/ \+ H( C% U* u0 Q
  1530.         fi8 f$ ^/ j5 K) i9 I
  1531.     fi
    + B" F7 A+ Y8 g- B0 W* d! p; O
  1532.   fi
    3 ~! r% }' ]' z
  1533. }
    * y) t0 H. m! c, Y& q

  1534. + g: ^, }" [: Y$ s+ l
  1535. # Function to create a Code::Blocks project
    ' k5 Z6 N( ?" ]% U4 p$ V2 h1 `
  1536. function CreateCBProject% v3 q4 y# e+ z; |
  1537. {
      g4 V, \2 `2 ?7 U; Q0 ]
  1538.   # Create the dircetory if it does not exist
    7 ?8 ?' |& |# @. I
  1539.   if [ ! -d $SRCPATH/server/linux ]; then4 J/ G) V* `) E7 N$ |
  1540.     mkdir $SRCPATH/server/linux
    5 n- t$ k5 J. _2 n( g; S
  1541.   fi3 V* b' @% e& |! R- _
  1542. " i' y* L! D. k* x' |1 [1 ^2 [# l
  1543.   # Now create the C::B project5 z; J' P% I* U* i, d( T/ Z
  1544.   cd $SRCPATH/server/linux: e4 R7 D$ J5 n# X
  1545.   # make sure we are using the cmake3
    " x' w& H( V# A/ ~
  1546.   UseCmake3
    4 y9 C' B+ A8 f) O1 I9 M% ?$ U: Z
  1547.   $CMAKE_CMD .. -G "CodeBlocks - Unix Makefiles"
    " }4 ~1 s9 V& s; T8 V
  1548. }" T, ~( W. G4 j% A# P9 p
  1549. 9 g# c5 e/ |+ W- U4 N$ c! H
  1550. , r% b  _- p. V  O% h/ n
  1551. / L7 J3 s4 b/ N" @% |
  1552. # Prepare the log9 S' b/ Z, [0 n+ _+ I9 E
  1553. Log "+------------------------------------------------------------------------------+" 0% v! q' m% j3 @4 Z" Z. Z# c; }& ~" p
  1554. Log "| MaNGOS Configuration Script                                                  |" 02 u. |. C/ b9 ?% |1 b- b
  1555. Log "| Written By: Ryan Ashley                                                      |" 0
    + ]- e9 q& n  ?! H4 s; M8 b4 v/ C
  1556. Log "| Updated By: Cedric Servais                                                   |" 07 x& L; r. r. f( s! T0 g
  1557. Log "+------------------------------------------------------------------------------+" 0% l( H1 N3 k& c3 W' Y/ `
  1558. 0 G/ h( i$ |! Y, h- F! `! o8 Y
  1559. # Check if user who is running this is root
    & |: F8 L% F" F' b3 X
  1560. CheckRoot) v) l( X3 W# A) o  c6 P% i. [; `+ \+ Y
  1561. * ]. E6 ]/ d) z" y
  1562. # Select which dialog to use  X. T. q; e$ [8 B7 W% v5 {/ e
  1563. UseDialog% J9 b4 B8 }9 }- N* u: A

  1564. ( f) j& {/ W! X  F) r8 S1 {, C2 @% [
  1565. # Select which activities to do
    3 [$ b/ `! e7 W* |1 h* ]
  1566. TASKS=$($DLGAPP --backtitle "MaNGOS Linux Build Configuration" --title "Select Tasks" \" L3 P* ?. L2 B9 S  ?
  1567.   --checklist "Please select the tasks to perform" 0 70 8 \9 }. C0 J5 x" Q) B8 K/ E) u
  1568.   1 "Install Prerequisites" On \
    * {- x% L0 a8 r0 o$ m
  1569.   2 "Set Download And Install Paths" On \
    0 F# r9 K+ k# x5 j3 p
  1570.   3 "Clone Source Repositories" On \
    # z/ q7 i7 w5 t9 z4 N' i0 M
  1571.   4 "Build MaNGOS" On \# ?2 V! G1 v+ |
  1572.   5 "Install MaNGOS" On \  C3 r( t' t+ W# |; b, l% c4 o3 O! h7 H$ C
  1573.   6 "Install Databases" On \
    # j$ U# c' d0 m0 U
  1574.   7 "Extract Resources" On \. L2 m! o+ l" A9 @
  1575.   8 "Create Code::Blocks Project File" Off \5 s5 m9 D+ B  |- G, O! X( t7 n
  1576.   3>&2 2>&1 1>&3)( f1 r+ N" c  E9 D

  1577. 9 p" |- A& a$ C& v/ Q
  1578. # Verify that the options were selected
    / ^" ]& e( Z9 ~( I& B
  1579. if [ $? -ne 0 ]; then
    # l+ m0 N5 B& x7 @: T+ P- m# E) O
  1580.   Log "All operations cancelled. Exiting." 1- z& f% v/ b) e, K4 ^/ _# Z
  1581.   exit 0
    ( x4 y1 K; j" A1 U9 r
  1582. fi
    6 z+ s1 }6 c# K3 x! E6 ]2 L

  1583. - o' A2 O. e% l
  1584. # Install prerequisites?# K5 D; j# @1 A4 [! a4 @
  1585. if [[ $TASKS == *1* ]]; then
    " i( y2 g$ m% l6 e3 J% I
  1586.   GetPrerequisites
    . `- y9 S% Q$ i+ n9 \
  1587. fi
    ( W3 U$ R7 A% w6 j. |1 L0 M; y
  1588.   w4 Y5 u, w1 E& @1 Q
  1589. # Select release and set paths?2 {8 l8 Y. A* }$ X  h+ E) ]4 |* f
  1590. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    * g+ I/ y" m3 k/ ?1 N
  1591.   GetUser$ N% n* C3 u% e! \! l, z+ g4 u
  1592.   GetRelease8 A* \3 X7 c8 C
  1593. fi0 t& Q' C5 L1 H2 `$ f
  1594. ( m: g  u* ?1 l. s" b! W; |
  1595. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *6* ]] || [[ $TASKS == *7* ]]; then
    7 F4 @; E$ \* z5 C/ j+ ?
  1596.   GetPaths0 R$ C: ?' i+ j7 X
  1597. fi
    ( u: R- Q5 e2 K8 u
  1598. 5 A; ^8 a8 E2 k: a
  1599. # Clone repos?2 c( O# R( t, D$ P* |1 k
  1600. if [[ $TASKS == *3* ]]; then
    * Z) \6 M9 L  M
  1601.   GetMangos
    ) {* j2 |  d' U
  1602. fi
    7 i2 x* |& g( {
  1603. % a: k  U7 |) p! \/ a
  1604. # Build MaNGOS?
    ; P( J. h# @: h5 o1 X8 r' z+ E
  1605. if [[ $TASKS == *4* ]]; then% R7 E/ C# _: B6 R% g+ q- s
  1606.   GetBuildOptions
    4 P4 [! x4 _5 h9 A: U& p* D
  1607.   BuildMaNGOS1 o5 j" l* L9 c# o1 N, R
  1608. fi
    7 g9 e9 m6 j- k
  1609. 9 C; H& n3 ~+ F7 k% o
  1610. # Install MaNGOS?$ [  \' c! H8 C8 I6 D
  1611. if [[ $TASKS == *5* ]]; then- Y5 h/ n3 O. W7 Y+ @- I
  1612.   InstallMaNGOS
    : y* y+ V* j6 W% H- f
  1613. fi) Y- n% d, r, B2 Z- |9 z7 @
  1614. , }0 c' p% F0 m1 i& y  u! H1 s
  1615. # Install databases?- F3 A2 P+ ]9 |: p
  1616. if [[ $TASKS == *6* ]]; then
    6 H) N- }7 Z) V& o  T
  1617.   HandleDatabases- |$ R) |7 N4 h$ Q& t/ c& B
  1618. fi* a" s2 f# P/ _' P( G# f8 d% |5 Z

  1619. 8 c. R" P. X! d
  1620. # Extract resources from the game?
    ! M5 ^" T# w# u; p: t
  1621. if [[ $TASKS == *7* ]]; then0 w5 z5 C4 C% B* w$ Z' F; j
  1622.   ExtractResources
    % {5 F4 L! h, d! d3 J- B+ I& Y$ L% I
  1623. fi9 e7 F5 t  ~( T  G! r
  1624. - y! p1 t4 P- Q3 h
  1625. # Create C::B project?+ Y( X$ v. \) I5 {
  1626. if [[ $TASKS == *8* ]]; then# u7 L& Y$ [% N& Y9 D$ P
  1627.   CreateCBProject; J* D% N# Z* _& n  }+ a$ M0 a
  1628. fi
    6 V" S  s* @6 `5 ~

  1629. 2 T1 ?9 X% }6 t3 s' N3 {
  1630. # If one of these actions has been performed, then we know the user.
    4 B- V; w+ H0 I( [! @
  1631. if [[ $TASKS == *2* ]] || [[ $TASKS == *3* ]] || [[ $TASKS == *4* ]] || [[ $TASKS == *5* ]] || [[ $TASKS == *7* ]]; then
    . q. p( N; _- f6 _
  1632.   Log "Changing ownership of the extracted directories" 1
    $ Y: U; g1 W: ?* ]$ k* \! F) l, _
  1633.   chown -R $USER:$USER "$INSTPATH"" B* G0 x9 ^; i6 [6 {% c& d
  1634. fi/ K. L3 t& P; E0 _+ w; \( H$ J3 Y$ G
  1635. . l0 v/ @. \* L
  1636. # Display the end message) F2 H2 D" }( X2 I1 k6 U
  1637. echo6 s6 F+ O( p) c# @/ V/ v# N
  1638. echo "================================================================================"0 @# ^) z0 h1 }% @$ q( F
  1639. echo "The selected tasks have been completed. If you built or installed Mangos, please") D6 F- c& {& m5 x
  1640. echo "edit your configuration files to use the database you configured for your MaNGOS": O- ^  H. d) i$ O, }" S
  1641. echo "server. If you have not configured your databases yet, please do so before"4 e# H3 p9 I) ~1 a
  1642. echo "starting your server for the first time.". v1 _  }1 A! i8 N1 U+ Z( J. ~
  1643. echo "================================================================================"
    5 {4 u6 ~, |1 \
  1644. exit 0
复制代码
  1. wget -c https://raw.githubusercontent.com/mangostwo/database/master/InstallDatabases.sh && bash InstallDatabases.sh
复制代码
  1. #!/bin/sh
      l* X+ T, f6 D
  2. ##############################################################################
    % }) r4 j# q( _2 w% U* }0 \
  3. # This utility assist you in setting up your mangos database.                #) }& M8 E# s8 z& A( k
  4. # This is a port of InstallDatabases.bat written by Antz for Windows         #
    ; l. }* A; v, \, m$ L
  5. #                                                                            #' E+ n8 o4 ?( v
  6. ##############################################################################! o8 r6 Q: i; v8 z7 c$ b

  7. : f6 ^) ^2 t- Y" D5 n. ?9 P
  8. OLDRELEASE="Rel21"
    % l! f% x/ s; w$ }' ~3 w
  9. RELEASE="Rel22"
    0 R* U6 I" z+ h6 S7 V2 K3 e0 C
  10. DUMP="NO"
    / g! H: A+ }* B- h2 D/ S0 i

  11. / q. j/ s) ]  R% A. z- V
  12. dbname=""$ e; L; j/ \# p$ X
  13. dbcommand=""5 v# e! n! r3 c9 C& g! ^

  14. & S- h5 J- z7 k% m- \
  15. createcharDB="YES"/ z' ^4 ~9 M/ e) s+ d! w
  16. createworldDB="YES"; {- k  X* p2 b6 L. E- D
  17. createrealmDB="YES"* L0 ^" Z3 I+ J0 W3 o7 G

  18. % G# G) r; q# y: j
  19. loadcharDB="YES"3 L7 |) ^: v8 p; n: b
  20. loadworldDB="YES"
    / c( P8 }$ f: U- Q9 _5 o/ _
  21. loadrealmDB="YES"
    - D9 T/ @& v  b% y' P+ z( S
  22. dbType="POPULATED"
    - |3 [+ D, y0 y& ^9 A
  23. ' U% O5 b" @) _" h0 o2 J7 J
  24. updatecharDB="YES"
    ' {- s6 Y* U* s% i7 f
  25. updateworldDB="YES", ~, E0 Z3 P1 s
  26. updaterealmDB="YES"/ H* L1 B7 v6 Z  Y, V

  27. : o* S6 D; f0 P( O; }, T2 o* z
  28. addRealmList="YES"$ z  u, b3 A4 D6 t5 p: D' L

  29. 2 ~( Q7 H8 a# L. o, F8 i# V5 N& J. t3 S
  30. svr_def="localhost"( M( i7 m, X/ \% o
  31. user_def="mangos"
    - E) z' V& G3 M/ f
  32. pass_def="mangos"
    / J5 K; h2 ^8 L
  33. port_def="3306"
    ! I; G$ i% Q5 ^) p
  34. wdb_def="mangos2"# p. c* N& R: U- f+ C( y' K
  35. cdb_def="character2"9 C+ F% r$ Y. a$ [
  36. rdb_def="realmd"
    3 e. O5 d; y- _+ ^" f+ P6 B
  37. # N$ ?: _2 L4 V; \2 d
  38. printHelp()
    4 |# `9 T! d% \& k* |  t' t
  39. {% Q# s" Z( l+ [1 A+ F
  40.         printf "Usage: $0 [-s] [-u] [-d] [-h]\n"
    % e1 L' V) G# S# D' R5 s
  41.         printf "\t-s: Run this script in silent mode, only prompt for the database information\n"
    ; R) w" ]- n* s" Z( v) n+ N
  42.         printf "\t-u: Run only the updates of the database\n"
    / A% o6 x) N. L. T: p* y9 e
  43.         printf "\t-d: Dump the database configuration into the home directory of the user\n"0 t- A/ i' l6 Z2 {8 c7 E
  44.         printf "\t-h: Display this help\n"
    , Q* v- h1 }. r" q& _
  45. }
    & `+ A+ ^+ R" T. }# B/ ]1 Z" j9 L
  46. 1 p; ]- e, @' t! T! L# }
  47. printBanner()
    % d7 E0 G# G! v1 C7 Z
  48. {( R$ L* ^" x3 Q8 `  p
  49.         clear' ~3 i) Y3 F0 V/ [3 Q
  50.         printf " #     #     #    #   #  ###   ###   ####  \n"
    ! R" P5 b$ u7 y
  51.         printf " ##   ##    # #   ##  # #     #   # #      \n"
    - E  v0 Q; o* q4 t  Y2 T; w" v
  52.         printf " # # # #   #   #  # # # # ### #   #  ###   \n"7 A, B4 u5 K' \9 Z
  53.         printf " #  #  #  ####### #  ## #   # #   #     #  \n"
      _, B7 |7 p: Y- H
  54.         printf " #     #  #     # #   #  ###   ###  ####   \n"
    / C5 w* _" \" U: _9 Y
  55.         printf "\n"
    6 ~* P' U- S0 G) V* a4 ]$ u
  56.         printf " Database Setup and World Loader v0.03         \n"
    1 D4 i) g- Z& k( I/ r1 H$ m
  57.         printf " ---------------------------------------------- \n", O2 e; `' r. P
  58.         printf "  Website / Forum / Wiki : https://getmangos.eu \n"
    # |5 q  [8 a* T% R$ x
  59.         printf " ---------------------------------------------- \n"; R0 z& n4 M( ]$ |2 s
  60.         printf "\n"
    2 w8 F" `$ }) C& R) }
  61.         printf "\n"7 d( n& p) S! X# {
  62. }
    & y5 ?' |! |4 \; s% K0 X

  63. - l9 R2 f" H# l+ M! f- T, ?
  64. printActivities()' ?9 a: u" L1 _0 R
  65. {( [: k- g/ s' C# s" W) V. Q1 T
  66.         printf "\tCharacter Database : \tV - Toggle Create DB (${createcharDB})        \n"/ Y% Y5 j$ M! e* _) u/ P
  67.         printf "\t\t\t\tC - Toggle Create Structure (${loadcharDB}) \n") F4 H* a. ~" q/ K8 l4 H
  68.         printf "\t\t\t\tB - Apply Character DB updates (${updatecharDB})\n"0 u2 i0 q: s/ \) B% T
  69.         printf "\n"$ X! n" q: B8 j8 M- [  Z
  70.         printf "\t    World Database : \tE - Toggle Create DB (${createworldDB}) \n"
    5 c2 [' Y% F$ `3 E$ x& t
  71.         printf "\t\t\t\tW - Toggle Create Structure (${loadworldDB}) \n"        2 i2 W1 D/ H& O' B' w
  72.         if [ "${loadworldDB}" = "YES" ]; then  d! a- x5 y0 f. F: |* M
  73.                 printf "\t\t\t\tD - Toggle World Type (${dbType})\n"3 w# K* f; v* B0 o1 V' a1 _
  74.         fi) o) s4 l! d0 }$ ^
  75.         printf "\t\t\t\tU - Apply World DB updates (${updateworldDB})\n"
    : a6 b8 `, Z9 Y
  76.         printf "\n"
    ; a( A) {2 x2 D9 q) K8 g7 l) r
  77.         printf "\t    Realm Database : \tT - Toggle Create DB (${createrealmDB})\n"  F5 G! l/ I) }. H
  78.         printf "\t\t\t\tR - Toggle Create Structure (${loadrealmDB})\n"
    9 ?$ H3 Z: F& e! y5 x
  79.         printf "\t\t\t\tY - Apply Realm DB updates (${updaterealmDB})\n"
    . \1 T" e, v7 ]9 A. h0 K
  80.         printf "\t\t\t\tL - Toggle Add RealmList Entry (${addRealmList})\n"       
    ; X  w. ^& j) }: h. S. l% c
  81.         printf "\n"- K  k/ ?& }+ w) y0 L0 Y+ m
  82.         printf "\t\t\t\tN - Next Step\n"2 A0 T: f% i2 l" N. w) Y
  83.         printf "\t\t\t\tX - Exit\n"( [) ^* ^' }" ]7 B
  84. }3 `  P% u& M7 }
  85. ; r" c2 W3 `; M/ Y
  86. determineDBName(), p9 W) ~+ k- F0 t4 K9 F' v8 I
  87. {7 s: t! `. l% F
  88.         if [ $(which mariadb) ]; then
    8 j6 V  g  f0 Q4 o  [3 K8 e6 w1 g
  89.                 printf "MariaDB found.\n"! ~. Y! I& t2 C: {
  90.                 dbname="MariaDB"
    - O9 Q/ R! ]9 q- V7 b8 c
  91.         elif [ $(which mysql) ]; then
    7 W* u6 a+ q) G* ]9 Q
  92.                 printf "MySQL found.\n"/ _' {5 n8 e: u/ \9 V  I1 T4 A! D
  93.                 dbname="MySQL"
    - G% `( p$ P* l9 A- r4 G, t
  94.         else" p; v, Y& z0 }2 w# }
  95.                 printf "Did not find mariadb or mysql.\n"" O9 c( T0 U3 D$ }: D* \! o
  96.         fi6 M. [' ]5 }1 E$ g! o
  97. }
    & N7 c! ?: L6 M8 m0 C( C! X

  98. ' {/ k6 ^( X( v8 g0 ^( w
  99. mysqlconfigeditor()
    % F3 t% h4 N, j
  100. {
    5 ?8 q/ ]0 d, p
  101.         dbconfig="mysql_config_editor set --login-path=local --host=${svr} --port=${port} --user=${user} --password --skip-warn"8 c( w( f* x5 ?3 ?; n- b
  102. }% I; e+ d+ k1 X$ h

  103. ; ?* [6 Z% s- e+ I) p# X
  104. determineDBCommand()$ E1 W; y6 w7 e, Y9 Q
  105. {
    6 X( F7 Y( P1 F# P  j% f; E3 f
  106.         if [ $dbname = "MariaDB" ]; then, J" U# S  [! i# w% _; s
  107.                 dbcommand="mariadb -h ${svr} -u ${user} -p${pass} -q -s"
    ) D4 t: C- N+ L- j) f, |
  108.         elif [ $dbname = "MySQL" ]; then
    0 ~* O; T, s9 L3 Z6 Y
  109.                 dbcommand="mysql --login-path=local -q -s"
    , K1 ?, w- E9 M( }, ]
  110.         else
    * J' y6 e+ f9 {! |4 n# B# Z
  111.                 printf "Did not find mariadb or mysql.\n"
    ' a8 @( W/ h" S/ h2 M
  112.         fi# ]6 \7 q, s- Z: ]
  113. }" g6 r7 E% W* D
  114. 3 c% c0 a. X; G4 i, \" O/ [9 e3 e
  115. createCharDB()* i& }: u  v/ u7 ^
  116. {- }1 ~: t3 d( Y. u
  117.         printf "Creating Character database ${cdb}\n": s( j. O' Y2 `0 L% @
  118.         $(${dbcommand} -e "Create database ${cdb}")
    % L5 C% H. B0 f

  119. 7 b, L0 S% }5 a/ c1 p$ w# i
  120.         if [ "${loadcharDB}" = "YES" ]; then
    # [9 Y! f: N3 S5 n( a, D" m/ `
  121.                 loadCharDB8 R& b( U5 w; B, F
  122.         fi' g/ i8 j) X& g: V6 M/ \- A
  123. }" v# H+ ]: ?& f# \; S! K5 m
  124. , p1 a. V0 c. h" N
  125. loadCharDB()
    7 K6 Z; X! K! ~) ?( j
  126. {- e9 j  ?+ R! _  A* n  q0 f
  127.         printf "Loading data into character database ${cdb}\n"
    3 x+ v- N6 z7 f, S! E2 r
  128.         $(${dbcommand} ${cdb} < Character/Setup/characterLoadDB.sql)
    , C6 T, r' w9 {# e& F$ ^9 L7 |
  129. + j: l/ L0 r; K9 J" K1 X3 e4 f7 Y
  130.         if [ "${updatecharDB}" = "YES" ]; then
    % W# b  U, ]/ t" m$ t
  131.                 updateCharDB$ O8 Y, h6 K& f: X2 \8 j4 ^. ~# C
  132.         fi3 f+ x9 m1 h4 r! n' v. t6 A1 N  S6 k
  133. }% m- {& C4 z- f4 ]( g
  134. / `  n9 D' p# H7 j
  135. updateCharDB()& `1 i6 P  W5 [% w1 }! o' k
  136. {
    : }) p( ]: t8 r& Y  F2 J1 y
  137.         printf "Updating data into the character database ${cdb}\n"8 U  |7 o$ E/ Y1 g1 {$ y
  138.         for file in $(ls Character/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')- u$ d$ B" R4 V1 L  l% w6 O3 e, r
  139.         do
    - t% n" a* e( g+ K
  140.                 file=$(echo ${file} | tr '|' ' ')& D/ |5 K5 R2 y- U, I& L( M
  141.                 printf "Applying update ${file}\n"' p! i, ]/ p  h3 D( G0 j4 P* v- z
  142.                 ${dbcommand} "${cdb}" < "${file}"2 r* m4 i) T  N( b. h
  143.                 printf "File ${file} imported\n"$ W2 x: n) D5 N; o: P
  144.         done
    / c6 H. F5 @. `/ i

  145. 3 c! T$ x6 @+ u% m: U
  146.         for file in $(ls Character/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')3 y  \: {9 c" k* o7 P
  147.         do) J/ g1 K# I7 ]! q. \
  148.                 file=$(echo ${file} | tr '|' ' ')
    % d# J6 s' t' y* r& }
  149.                 printf "Applying update ${file}\n"
    " N$ ^# t! ^* ~" a
  150.                 ${dbcommand} "${cdb}" < "${file}"9 v9 \+ Y, x( t7 P( e' F, h. M
  151.                 printf "File ${file} imported\n"
    4 A) v7 Q1 H4 Q  t" |$ n" h2 s6 ~
  152.         done
    3 \* ~$ J- \4 t5 K- u$ Y) A
  153. }& F7 t7 @0 G) \

  154. ( ?0 r5 l  g, e6 L7 |- z
  155. createWorldDB()
    9 r) X* \+ L6 a; B7 g+ @
  156. {# h8 n$ F9 v* p/ J4 W, y
  157.         printf "Creating World database ${wdb}\n"( m1 B5 b& P+ N, J
  158.         $(${dbcommand} -e "Create database ${wdb}")9 b# L& f) o! e3 w  h: V* ]8 G7 m( P
  159. , P3 B2 D$ F  w' v5 s
  160.         if [ "${loadworldDB}" = "YES" ]; then/ k7 j* T( Y% {' m1 A6 `
  161.                 loadWorldDB+ y6 }6 q* t& e
  162.         fi& D6 j; M! Q7 n1 W, `" _% I
  163. }/ L, d# O; W/ H9 Y

  164. ) M: A; ~& D: {0 ^
  165. loadWorldDB()
    8 @& T# G% n' c( a% K8 n
  166. {6 ~& Z# h6 K& P0 f# q- n. R% X0 G
  167.         printf "Loading data into world database ${wdb}\n"( \8 e6 J: v8 I) b% q! e8 `3 Z1 V1 S
  168.         $(${dbcommand} ${wdb} < World/Setup/mangosdLoadDB.sql)' z3 C# k; B) v: B* I
  169.   e0 x& d. L3 \# F" D& J& J
  170.         if [ "${dbType}" = "POPULATED" ]; then, y& a/ b- J$ ^5 C* M
  171.                 populateWorldDB( y% Q9 l) \9 J2 V5 F5 E$ J+ q. b
  172.         fi9 d: v9 r) V: n2 J; C
  173. }
    9 c/ Y1 G) p: d  y1 _# s
  174. . q0 b+ D8 N8 p. j. X
  175. populateWorldDB()
    4 n* ~8 T& r/ N5 `  T" L! u
  176. {
    , }4 J+ C2 V5 ~, I  I
  177.         printf "Importing World database ${wdb}\n"$ R; F, A4 p) l0 f1 }+ F
  178.         for file in $(ls World/Setup/FullDB/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ') 2 f; A7 t! I/ u& S' W
  179.         do, ?  N  U" f* I; _
  180.                 file=$(echo ${file} | tr '|' ' ')
    + A: T$ u8 e/ X' y
  181.                 printf "Importing file ${file}\n"
    6 M3 u1 M3 y' f- q4 B1 |
  182.                 $(${dbcommand} ${wdb} < ${file})8 r6 i! s& k5 C6 R4 l
  183.                 printf "File ${file} imported\n"
    4 X7 w2 ]9 D! E% ?1 A8 d% x0 V
  184.         done  W8 O7 h: b1 {* p" v) N3 z
  185. 8 ?/ J4 `" V; V* P" G$ H6 r$ ^
  186.         for file in $(ls World/Setup/FullDB/*.sql | tr ' ' '|' | tr '\n' ' ') . E/ I$ i7 M" t& H5 N
  187.         do
    7 F5 U& C: |  H3 T8 K
  188.                 file=$(echo ${file} | tr '|' ' ')
    . x/ O: i, u2 B* z1 D/ r
  189.                 printf "Importing file ${file}\n"
    . h% H& C& f- i5 D" m/ {& u
  190.                 $(${dbcommand} ${wdb} < ${file})
    0 r; Q3 z5 ~; R- H( m: u. @& a
  191.                 printf "File ${file} imported\n"
    : r" P" i) e2 n: R' W' j2 S
  192.         done
    & @% X0 W' ]9 ^# m6 O% w
  193. }
    * L4 h) T; `6 U2 s5 A9 f: W2 A

  194. , Q( D' s: v  F4 F( H+ b  R" d9 {
  195. updateWorldDB()
    ) z  R9 i' s. l& V* P5 c1 W
  196. {$ t' |) f& k2 h( s, M6 @# X6 w
  197.     printf "Updating data into the World database ${wdb}\n"$ X) u- W2 R9 ^4 j
  198.     for file in World/Updates/${OLDRELEASE}/*.sql
    ' a3 Q0 @2 o" p  ?$ V
  199.     do0 U, e: {8 I2 c8 y& R
  200.         printf "Applying update ${file}\n"
    - s0 t- W( Y" u/ t8 w
  201.         ${dbcommand} "${wdb}" < "${file}"0 h) F* _- ^4 Q) @1 b
  202.         printf "File ${file} imported\n"+ {1 g' U* U: F6 b
  203.     done% u3 p# c% n+ H: `8 W. t

  204. 1 E/ m. t# z8 p, A7 X7 N
  205.     for file in World/Updates/${RELEASE}/*.sql
    4 a9 a# H" y  W# |9 W+ p* ?+ o
  206.     do. g4 c8 y, s% I0 W: h5 y* T- o
  207.         printf "Applying update ${file}\n"$ F. J0 M2 k$ u+ {6 r7 J$ S
  208.         ${dbcommand} "${wdb}" < "${file}". E6 [; X* K* V7 u  d
  209.         printf "File ${file} imported\n"3 q' ?$ d0 N; {
  210.     done) h8 @+ T- [( h  V; O
  211. }
    9 x& N( h) \6 v
  212. . g0 u* j$ n3 j) K) p
  213. createRealmDB()8 u2 H6 d8 l0 ~3 {) v  N% }
  214. {% W5 j* g) s- j
  215.         printf "Creating realm database ${rdb}\n"( C8 b1 p# @* ~7 n2 O, F% S! w, m
  216.         $(${dbcommand} -e "Create database ${rdb}")
    6 j# j! k1 l+ _1 f8 F; G
  217. - A( n; E  D) H$ n
  218.         if [ "${loadrealmDB}" = "YES" ]; then
    1 Q; _: W1 g. u% i7 `( ~& v
  219.                 loadRealmDB8 R2 {5 s8 r* l4 n2 |
  220.         fi" v' z0 }0 r- {( C/ B
  221. }
    / `' p5 Y. t8 _& L7 k6 Q' o  [6 ^

  222. 3 ?' V) h" F& Q- v
  223. loadRealmDB()
    2 s" n8 Q$ j3 ~  u
  224. {" b+ J' i5 E/ Z5 \/ p$ H
  225.         printf "Loading data into realm database ${rdb}\n"        * a0 g8 R( y2 M4 s# T
  226.         $(${dbcommand} ${rdb} < Realm/Setup/realmdLoadDB.sql)* B' u9 U! }$ G/ L3 J
  227. }5 Y5 Q" Q1 Y7 [6 K& n3 C0 w+ E

  228. 9 N& C$ h# h6 Q& L' [
  229. updateRealmDB()
    5 Y9 T/ G4 p/ O6 X0 G( v; n
  230. {) ^! C" l7 G1 u$ A
  231.         printf "Updating data into the Realm database ${rdb}\n"
    6 J4 @9 J! \& ~" ]9 q8 `
  232.         for file in $(ls Realm/Updates/${OLDRELEASE}/*.sql | tr ' ' '|' | tr '\n' ' ')9 f; @0 s5 c4 v
  233.         do4 N0 j4 g5 E6 k& Z; I. y
  234.                 file=$(echo ${file} | tr '|' ' ')2 k+ I- B* U  j9 V. ?& p. V) [
  235.                 printf "Applying update ${file}\n"
    4 J' w% \9 _0 e4 u9 s
  236.                 $(${dbcommand} ${rdb} < ${file})
    7 u( o# v# p. P/ j
  237.                 printf "File ${file} imported\n", E7 y7 S1 q& r) ?" d5 z4 U- ?
  238.         done
    7 ~8 k% b/ Q6 {# T2 f7 J

  239. & C; @4 X; Y* w
  240.         for file in $(ls Realm/Updates/${RELEASE}/*.sql | tr ' ' '|' | tr '\n' ' '): q2 G9 u2 h, v( Q3 D
  241.         do: I1 ]" H& U) h( \! b& K5 v3 L- r
  242.                 file=$(echo ${file} | tr '|' ' ')) k1 g% e+ h6 b: C1 S) \* m" Y
  243.                 printf "Applying update ${file}\n": r9 M$ @' m. S9 m8 c; U
  244.                 $(${dbcommand} ${rdb} < ${file})! G' k/ C- V4 O# ?' u8 s
  245.                 printf "File ${file} imported\n"
    4 L5 A$ ?0 n8 w0 O: r
  246.         done
    2 o) I3 D$ _- V: s) a# z* C0 m  {7 n
  247. }. t* e2 k% ?' e( u3 l9 ~& t2 W+ U& |
  248. 6 i& J+ g9 k. @& @* W+ T
  249. addRealmList()
    # w* y* g5 P* j' l( {# b2 w
  250. {
    / h8 K$ D0 p  E: q- U7 V$ Z/ }
  251.         printf "Adding realm list entries\n"# J# r2 l0 _  W0 E4 T+ P- Q, C: A
  252.         $(${dbcommand} ${rdb} < Tools/updateRealm.sql)
    9 W, Q% z6 _8 R! L
  253. }
    1 X4 V; ~8 E. i9 a& q

  254. / o, W& K1 S. `3 |
  255. activity=""
    : ^  Z: T* N6 R3 T1 @$ \% m' l! C
  256. ! D+ m# g, J4 \' S
  257. while getopts "suh" o; do
    3 X) `7 B5 B0 ]
  258.         case "${o}" in
    , I; e" o. m2 r9 O) f+ Q, ~
  259.                 s)& x7 ?! d" p# W. [, s. v+ A' U
  260.                         activity="N"
    8 E5 p; @7 M6 Y) i; _  d3 N- d
  261.                         printf "You selected silent mode\n"
    $ R. F; j  N- P6 [. e' h
  262.                         ;;
    0 p% a6 W$ f" x+ H! c- Z! k
  263.                 u)4 q$ |0 B8 [! C1 A8 q1 K
  264.                         createcharDB="NO"
    - F. }2 c3 \+ m/ b; _& v
  265.                         createworldDB="NO"/ H5 x; k+ S6 D# s
  266.                         createrealmDB="NO"0 o' T6 c' J# p& r# F% o
  267. 0 t% l+ V0 W0 ]* i
  268.                         loadcharDB="NO"6 ^, Q2 m& @% q" t
  269.                         loadworldDB="NO"
    , r' o3 L- ~3 s; D4 W& I- L% o
  270.                         loadrealmDB="NO"- c! i' a; Z2 @# V% c8 t) j
  271.                         dbType="EMPTY"
    # S, U. d5 Q! ?& z; P
  272.                         printf "You selected update only\n"- K  y: j2 x  h9 d2 J9 }
  273.                         ;;
    4 O# \( r  I4 l' |# x$ i
  274.                 d)1 j' C& L. o! S) y+ W6 t& [
  275.                         DUMP="YES"  A* F6 g$ r6 G
  276.                         ;;
    ' o9 F9 j' K8 j
  277.                 h)
    % b2 V. d# v  m6 b' a
  278.                         printHelp8 k. F" e- h) ~% D. o' E' w
  279.                         exit 0
    - e% H: d4 Z/ F2 {5 c. i. n/ G  G
  280.                         ;;
    / l! u& }' T) b$ l5 b
  281.         esac( b) G! }) S( K( H
  282. done
    6 N7 _. P( I7 n; {+ K6 n

  283. $ Q6 y! B6 \, q0 H: B) J
  284. while [ -z "${activity}" ] || [ "${activity}" != "N" ]1 D* H1 L3 [0 c- ]5 ^6 ^5 o5 r, @
  285. do
    4 K& V! w( h2 W) U4 T/ ~9 t6 T
  286.         printBanner
    # y9 ?( v6 b- O" j# l6 W' a7 f4 Z
  287.         printActivities
    6 }0 }& S* [" T/ X: w9 q
  288.         printf "Please select an activity : "
    2 T" v6 }# t+ h# v! C5 e+ z5 M; R
  289.         read activity: J' X5 ~' X/ r% e" D' g
  290.         activity=$(echo ${activity} | tr '[:lower:]' '[:upper:]' )' i2 t; C. M! \8 F
  291.         case ${activity} in
    : k+ S7 ]9 h5 {, |
  292.                 "V"): H3 C8 l, y( @& \' Z) i
  293.                         if [ "${createcharDB}" = "YES" ]; then, [* }' }. y# w) U( F
  294.                                 createcharDB="NO"2 l8 e% s) O& n: `
  295.                         else
    ) H: a8 g  t1 n, u9 Z9 {2 L+ R
  296.                                 createcharDB="YES"+ x/ o- A  L, m! v! O8 O# a: Y& M
  297.                         fi
    * b4 ^% Y0 c- ?$ `( `0 ^8 _0 y
  298.                         ;;
      r, R- R) i' L5 ?
  299.                 "C")
    & O: f5 y7 }- l) k
  300.                         if [ "${loadcharDB}" = "YES" ]; then
    " f0 q% x7 U  H5 A. U
  301.                                 loadcharDB="NO"4 y; q- Z1 C+ `" X; x+ W
  302.                         else   c6 B  t6 l. s5 U) w/ i
  303.                                 loadcharDB="YES"
    4 ^8 y4 [5 k; {% H3 z
  304.                         fi
    % I$ M6 ]$ J# H2 r" M7 v
  305.                         ;;* l$ z4 S' k6 R. g
  306.                 "B")) m4 |7 Y% @5 w7 w
  307.                         if [ "${updatecharDB}" = "YES" ]; then
    4 v9 M3 z. j4 t: u
  308.                                 updatecharDB="NO"
    ) d: _+ Y9 r! P- j" z
  309.                         else
    4 f& C- [5 G& Y  J  W  t
  310.                                 updatecharDB="YES"! C/ [, }; \9 C* B
  311.                         fi
    & e% e: Z  y4 \* M1 Z3 Y: V
  312.                         ;;
    ! r8 z2 r2 @4 c4 N
  313.                 "E")+ z9 R% R: ?5 F  t) R3 S
  314.                         if [ "${createworldDB}" = "YES" ]; then
    7 m* u4 e4 Y! U. W5 `
  315.                                 createworldDB="NO". T% p! H" ?* k1 l1 z/ V3 s# l
  316.                         else 6 d. W2 p: i# a" G: s4 s
  317.                                 createworldDB="YES"6 b1 b& D) H) [0 T, I( r: A( P
  318.                         fi        , {3 ~2 M/ b. R& x% ]/ B
  319.                         ;;
    ) x: Y! P' Y: D. m0 q. r- J+ {
  320.                 "W"). S- ~! Q: g1 o" h* a
  321.                         if [ "${loadworldDB}" = "YES" ]; then* k( }. g9 W& Z  l4 |2 f
  322.                                 loadworldDB="NO"
    8 \! h6 ?/ J! @1 W. Q" r
  323.                         else
    " {" M) c2 w! L* g. d4 H8 K
  324.                                 loadworldDB="YES"
    5 c3 B4 S$ V4 b% }
  325.                         fi        4 j, r) m& W* @# O
  326.                         ;;& g" P/ v; {& x+ V% {- X+ h
  327.                 "D")
    $ o6 U0 I6 J( u1 u8 j; e
  328.                         if [ "${dbType}" = "POPULATED" ]; then
    ! O4 y9 v* ?/ i8 ~( B5 @* S! T6 \
  329.                                 dbType="EMPTY"$ y0 l: I; h" R' v  }8 s
  330.                         else
    . R8 u$ ?1 [5 O( o/ u$ s
  331.                                 dbType="POPULATED"
    1 e: d' L- w2 L5 d+ H" k
  332.                         fi                                
    3 K( w. ^7 \1 p3 F+ L7 @. w
  333.                         ;;
    3 I' D& `5 x) h" [. `  R
  334.                 "U")& H; R% o8 {& B8 b5 K% `
  335.                         if [ "${updateworldDB}" = "YES" ]; then
    8 d& Y; d- [0 I7 J0 `
  336.                                 updateworldDB="NO"
    6 g- `, z/ a" u
  337.                         else
    - D& C5 z. M4 T. P
  338.                                 updateworldDB="YES"
    + i* f" m5 V) ]! U1 k1 R3 I
  339.                         fi
    6 e  R: e2 `( S8 v0 I
  340.                         ;;1 f) x: L- f3 S% W% c* D
  341.                 "T")
    7 N4 Y' @! I- r( _/ ]
  342.                         if [ "${createrealmDB}" = "YES" ]; then
    / H- r  Y: Y8 {" [/ }
  343.                                 createrealmDB="NO"5 N5 Q4 w8 H# X, J
  344.                         else - n7 I  b, F2 v& ^" i4 |) d
  345.                                 createrealmDB="YES"
    / r5 ?3 r" Z3 r8 P1 W- }, V5 |
  346.                         fi                                 * x' F# G5 z5 T5 @
  347.                         ;;+ c2 ?: z# U4 g5 c$ U) X
  348.                 "R")4 x- U& f* S" b1 b% y9 n
  349.                         if [ "${loadrealmDB}" = "YES" ]; then9 q) i: K/ |$ s: f" ]7 I; j' o
  350.                                 loadrealmDB="NO"                       
    5 z7 v1 G( F* I) ~/ ~1 s- s
  351.                         else
    5 z5 o% d) `4 o# ^. t
  352.                                 loadrealmDB="YES"" A% S% A4 s5 T( n% u2 P
  353.                         fi
    # J6 g  n+ @; S& P
  354.                         ;;
    3 b4 e7 R$ r7 K5 W6 U
  355.                 "Y")
    % E5 e$ O" q7 i0 o5 i' R
  356.                         if [ "${updaterealmDB}" = "YES" ]; then
    ( Q( e8 u$ Y: Q1 J) S& e  R; ]- }
  357.                                 updaterealmDB="NO"' z' Y* W3 F, l$ z! U6 V
  358.                         else
    * g$ E8 P# r; @& [6 b
  359.                                 updaterealmDB="YES"
    8 R! X% k" b6 I6 B+ H( |
  360.                         fi
      y  q4 j: O2 ?! l+ i
  361.                         ;;
    8 o5 t9 p7 s: s* m% {; R, b8 v
  362.                 "L"). J4 f& G) @- w' X9 C% J
  363.                         if [ "${addRealmList}" = "YES" ]; then( i; N. N# _2 M
  364.                                 addRealmList="NO"/ a0 |) p6 |$ U9 W) s7 ~
  365.                         else * a9 O7 J1 c8 j+ H3 n0 d% g1 e! ^
  366.                                 addRealmList="YES"
    8 D$ o- u: ?& G) i
  367.                         fi
    ! K( }3 u# Y# X. H6 C% f2 Q
  368.                         ;;) f5 U4 n% c$ C) l# S
  369.                 "X")
    / v% v, n6 C) D9 o
  370.                         exit 0;;( Z9 r4 ]0 c- r0 Y4 Z
  371.                 *)
    / n4 i+ f8 b5 I* R7 R* Y
  372.                         printf "Invalid selection";;$ [4 G" D" V# V) d2 p1 q( E
  373.         esac
      i9 \  t; l7 M% \+ R  F9 S
  374. done
    . p- ?5 A6 n6 i7 \
  375. ( A0 x: Q! ?2 N! K+ d9 I" k1 X% G
  376. printBanner# _4 y) m- B  g- G7 K# {7 t" O
  377. determineDBName
    2 O" k8 K2 [+ W5 n+ T- G9 K
  378. printf "What is your ${dbname} host name ?\t[${svr_def}]: "  t. c5 D' I1 {8 `/ ]+ |; b6 n
  379. read svr" P- g$ T1 K" r5 g+ K/ ]; M" @
  380. svr=${svr:-${svr_def}}2 a; l* ^! J6 G5 ?6 o& j$ g
  381. printf "What is your ${dbname} user name ?\t[${user_def}]: "
    ) b8 n' ^$ m, j' ^3 L1 w# L9 K
  382. read user
    - r- K6 g7 v. d4 f4 }
  383. user=${user:-${user_def}}4 x3 U: c$ s# S2 n0 {* r) a
  384. printf "What is your ${dbname} port ?\t[${port_def}]: "
    ) K. A3 n7 q7 |7 t7 {# X
  385. read port8 U3 M2 _* u* N2 ^# n. g' ~' `
  386. port=${port:-${port_def}}
    * z0 ?+ {6 c: Q: |6 K. \' J3 [
  387. if [ $dbname = "MariaDB" ]; then# k- }+ S% N" `/ z( L
  388.         printf "What is your ${dbname} password ?\t []: "' k, D# l9 J8 I" j2 |  i3 T
  389.         read pass0 N+ }: A( p+ d) K7 A% h/ h
  390.         pass=${pass:-${pass_def}}3 E& }$ }6 E* U
  391. elif [ $dbname = "MySQL" ]; then9 H2 P* i: N: }
  392.         mysqlconfigeditor
    ) B' c: P8 h% F7 I0 f  b" }- B
  393.         $dbconfig
    4 f8 \& e" c4 u7 ?0 B/ [( Q1 Q
  394. fi
    1 {6 }+ \2 }1 J5 z0 x) l7 o. l' e
  395. determineDBCommand+ A2 U9 U3 I  k5 _3 K1 Y: ?! S" x% n
  396. , `. r% q" D3 |2 k9 T: Q% @
  397. if [ "${DUMP}" = "YES" ]; then! \6 \' a& }7 N" E, u1 n7 J
  398.         printf "Enter it again \t[]: "
    7 K' `$ m4 U# H0 X7 `% K
  399.         read pass
    " l; D* I+ p6 u
  400. fi. P  o2 Z; f7 V6 s
  401. . ~1 t! V4 L/ c  ~7 q' T* p
  402. if [ "${createcharDB}" = "YES" ] || [ "${loadcharDB}" = "YES" ] || [ "${updatecharDB}" = "YES" ]; then$ \( J! f% k$ W2 r2 t1 I$ ^2 O* G8 Z
  403.         printf "What is your Character database name ?\t[${cdb_def}]: "
    7 J- F% M: s6 K, N4 v
  404.         read cdb  G! M* [8 ?4 N* F: Q  q% ?
  405.         cdb=${cdb:-${cdb_def}}/ k6 P( n) v9 x! p1 z
  406. fi; N+ k$ `1 |: @
  407. 1 k; |% T$ S, H" G
  408. if [ "${createworldDB}" = "YES" ] || [ "${loadworldDB}" = "YES" ] || [ "${updateworldDB}" = "YES" ]; then
    ' p4 E6 a$ l9 x5 b6 J. k: f. z; _: f
  409.         printf "What is your World database name ?\t[${wdb_def}]: "
    : `. i" {3 k. m/ R" y6 L* J
  410.         read wdb
    / N7 [( B) X1 q% R/ {
  411.         wdb=${wdb:-${wdb_def}}. x9 H* B5 H5 J: s4 d+ f
  412. fi! m: [5 A2 O9 n& X; N

  413. " y& P# b5 J, o( r6 j2 F, J/ N: \
  414. if [ "${createrealmDB}" = "YES" ] || [ "${loadrealmDB}" = "YES" ] || [ "${updaterealmDB}" = "YES" ] || [ "${addRealmList}" = "YES" ]; then( S/ |7 k) ]( C& t9 |* R
  415.         printf "What is your Realm database name ?\t[${rdb_def}]: "
    % D) P1 M2 K0 q% ]7 X2 O
  416.         read rdb, x: w9 j8 ^+ q! Z
  417.         rdb=${rdb:-${rdb_def}}
      g& k$ S( m) f0 X1 b
  418. fi. D+ y: v! A" h/ P5 k- h( B" E; v( Y3 z
  419. $ n# H7 E$ U" u2 Q, v6 p
  420. if [ "${createcharDB}" = "YES" ]; then
    4 J8 v& Q& [3 r  P: o
  421.         createCharDB! G! U5 j: i. \
  422. fi% ?# H+ r' z  b( n8 k# N+ a! K

  423. $ a. F$ N2 q( c$ k! J) {
  424. if [ "${createworldDB}" = "YES" ]; then
    " ]" t4 I) s2 ~; u( Q3 J
  425.         createWorldDB, h. T$ j% ]: f" d: z& w8 H
  426. fi
    ' ]! X" x0 [1 O, J
  427. 1 T' R6 ^! p. w, ]: Y
  428. if [ "${createrealmDB}" = "YES" ]; then6 k7 v) a$ X: e& ?6 n/ m* e
  429.         createRealmDB, M  S( n; n! y; c- E# h4 G9 [+ ^
  430. fi
    ! v: k" C3 i- O2 g+ c
  431. 0 P" o2 m' x2 a& V# J' Q% M" z+ q- c
  432. if [ "${updateworldDB}" = "YES" ]; then
    0 G/ L1 [& y) V9 W$ V
  433.         updateWorldDB
      y8 Z3 F9 P5 w% a3 ^7 L  w
  434. fi
    9 D, `+ ?- s8 ?6 \# B
  435. 4 v7 w4 a* u9 d
  436. if [ "${updaterealmDB}" = "YES" ]; then
    6 Q: M9 @; w; r! u
  437.         updateRealmDB
    3 W. D' a/ u2 F( P6 c
  438. fi' B' p/ V+ p0 G; j' ^

  439. # k; N1 v  d6 d) b' n. d: E
  440. if [ "${addRealmList}" = "YES" ]; then
    * F) G3 g0 D2 I' Q. s
  441.         addRealmList% X% w% J$ q$ S  l8 T; W9 L5 w  Z
  442. fi, m! p. n! n1 q8 k. u7 l0 C' K

  443. / ]% m4 M; K8 q# J. q
  444. if [ "${DUMP}" = "YES" ]; then
    % `1 `3 w" f& m
  445.         printf "Dumping database information...\n"5 P' d2 i$ l5 |* L& P. m
  446.         echo "${svr};${port};${user};${pass};${rdb}" > ~/db.conf. E2 ]) d9 ~! P. P$ S
  447.         echo "${svr};${port};${user};${pass};${wdb}" >> ~/db.conf: r$ b# f0 v! }: B: b# |
  448.         echo "${svr};${port};${user};${pass};${cdb}" >> ~/db.conf
    + H* K) p1 b5 Y' D0 x3 o4 m
  449. fi
    7 i/ K- q. s9 _! S* M1 ^

  450. : O0 ^0 e9 l3 W! n8 N8 B
  451. printBanner' T% [- W% s9 [; |2 u
  452. printf "Database creation and load complete :-)\n", _3 l$ I* e- I8 X% o/ p
  453. printf "\n"
复制代码
! @! T. P+ ]& |( }$ @: G5 {% _
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 2022-7-29 17:24:34 | 显示全部楼层
Playerbot AI 命令2 i8 ?% z( `, {: M

- `7 ?- H6 L7 A2 t3 u/ I1 V使用 Playerbot 密钥的指南:9 }4 m0 M# G: r  @( ~

/ l1 E5 Z$ b2 l  H标识符说明  L/ u$ {. {3 V9 L9 G
机器人名称    机器人的名称2 X8 F- {8 n+ J( L% q$ [
朋友    命名机器人或玩家角色
; |& |/ ]7 w( W, @目标    选择目标玩家、尸体或NPC(非玩家角色)
  ~' J% m, k7 H  k" [. ?|    逻辑或
2 C4 O) N0 C2 N+ U, e&    逻辑与( u$ _" C4 |/ {1 b( C# p* P
..    多个实例
" w- N" P5 _; A! h/命令    MARCO 命令6 z) E! \" |# C' `% w
/s    聊天:说( q3 _$ X% m& A2 {
/p    聊天派对$ d5 j" l& ^* P' h4 w8 X
/t 机器人名称    聊天:TELL BOTNAME
$ A5 Z, f7 \2 Y5 D. P) u: U) h/w 机器人名称    聊天:告诉 BOTNAME3 m% Y/ Q# N- j7 d) g  C( U& L
<名称链接>    名字=
9 ?, [5 H/ C$ y2 b. |(捷径)    为命令或子命令分配快捷方式* _0 b! l0 ?& ]5 k" L' r4 k- ]

3 K2 F. a& o$ |( b$ t9 `可用 PlayerBot AI 命令的完整列表 SAY 命令:语法说明5 _# h" n3 o, ~/ w- B. A1 ]' ?- _
.bot 添加 BOTBNAME    为世界添加角色! Q8 F' j4 V4 |9 [6 _
.bot 删除 BOTNAME    从世界中删除角色. G( A. X$ A; e& P

. H$ v: r- t, |& h  }; G+ ]3 H当前仅与以下 playerbot 代码一起使用:portalzero 和 portalclassic(所有其他代码使用新修订的“命令战斗”命令来设置机器人角色)
, Y' f0 F9 A/ O$ T: o/ C' D.bot < co | 战斗命令 > BOTNAME    分配机器人角色
9 a. Y( G/ V) \9 n8 j$ ~5 W! `0 h: H3 p  G9 U* T" k9 U0 W* z
宏命令:; @% e4 c. o2 J* }& a" N' M
句法    描述
2 `3 V, O7 W$ ?+ U8 }/邀请机器人名称    机器人将自动接受聚会邀请
! F) T+ p8 j3 J4 ~$ n/uninvite BOTNAME    机器人将自动接受派对不邀请7 h" o2 n6 g7 u" P: p

4 L8 v: c: c: f2 r9 N( o+ jTELL/PARTY 命令:(某些命令可能不适用于某些内核)3 N9 y$ }) Q3 h, w1 N& {
句法    描述
9 Q* {0 F/ I- D协助目标    机器人协助列出的角色,在他们攻击时进行攻击。0 S/ p) S7 G9 H, [& y3 I
攻击目标    命令机器人攻击选定的目标,类似于宠物可以攻击的方式
8 b& S; y& K/ G% ^9 P0 H拍卖    命令机器人寻找附近的拍卖师并显示机器人的活动 1< Auction LINK >..
  |$ ~# c" C+ `) S拍卖 (a)add 1< ItemLINK >..    命令机器人寻找附近的拍卖师并添加 1< ItemLINK >..
  A3 W7 D5 t+ c, ~3 Y, O拍卖 (r)emove 1< 拍卖链接 >..    命令机器人寻找附近的拍卖师并删除 1< Auction LINK >..
% O  A+ h- w* t! N银行    命令机器人寻找附近的银行家并列出机器人的银行余额1 i4 b& c+ x' ^
银行 (d)eposit 1< ItemLINK >..    命令机器人寻找附近的银行家并将 1< ItemLINK >.. 存入银行
  A5 Y8 T$ K: `银行 (w)withdraw 1< 项目链接 >..    命令机器人寻找附近的银行家并从银行提取 1< ItemLINK >..
# V% z" e8 R) ~$ {8 C, l$ N2 V% ?(b)uy 1< 项目链接 >..    命令机器人寻找附近的供应商并购买 1< ItemLINK >..4 F% Y$ t4 n5 e  t
©ast SPELL    拼写 = >
& p/ U3 n8 e2 o搜集    显示收集对象选项和当前收集状态
- ~2 W' a/ A; Y6 _/ E9 m收集对象    设置收集状态,OBJECT = <所有非战斗战利品对象职业任务>
4 D7 x9 j) z/ i3 B- ^  Q2 T8 e工艺1<配方链接>..    如果机器人知道,则创建所有列出的食谱
5 ~% Q2 }. M" y4 U. g# x( K8 x工艺1<配方链接>全部    如果机器人知道,则创建一个配方的多个实例, ?# G, N( ^% E* O* o# \$ O
工艺(a)炼金术    显示所有炼金术配方 1< 配方链接 >,如果由机器人学习
  K2 U7 i; t( E# r( e' K工艺(b)锻造    显示所有锻造配方 1< 配方链接 >,如果由机器人学习+ o% e1 [2 p' f" _7 ]
工艺(c)烹饪    显示所有烹饪食谱 1< 食谱链接 >,如果由机器人学习, z4 @, l  T. g
工艺(电子)工程    显示所有工程配方 1< 配方链接 >,如果通过机器人学习' s6 M# l% w& [! Y8 s
工艺(f)irstaid    显示所有急救食谱 1< 食谱链接 >,如果由机器人学习
* c( s( P4 g( k" {工艺(i)题字    显示所有铭文配方 1< 配方链接 >,如果通过机器人学习6 z2 E. Y% h" ~. ]/ ?+ \
工艺 (j)ewelcrafting    显示所有珠宝制作配方 1< 配方链接 >,如果由机器人学习0 u/ X; I- E+ h/ g
手工艺 (l) 皮革加工    显示所有制革配方 1< 配方链接 >,如果由机器人学习
7 F  Y+ z; [. ]  T1 j/ w/ a工艺(m)魔法    显示所有可制作的附魔(例如魔杖等)recipes1<recipe LINK>,如果由机器人学习
" N0 x9 B& v' t. L8 @# i工艺熔化    显示所有矿石冶炼配方 1< 配方链接 >,如果由机器人学习' E, h+ J3 ~/ Z6 _3 Y7 o# Y
工艺(t)裁缝    显示所有裁缝配方 1< 配方链接 >,如果由机器人学习: a5 {' u1 G/ {
掉落 1< 物品链接 >..    命令机器人掉落并销毁指定物品 1<Item LINK>../ M4 V2 W3 V% l( k  |( b) T
全部放弃    当机器人库存变满时,丢弃所有低级物品。2 r7 A! v; y  X4 g( [, F
附魔    列出机器人学习的所有结界 1< Spell LINK >/ q' p+ ?4 p$ l! n) d0 ^
附魔1<法术链接>..    附魔选择可交易 1< 物品链接 > 装备或包中1 \3 U2 d) z! T) L$ U- D4 v
(e)quip 1< 物品链接 >..    从它的库存中为机器人配备容器、武器、盔甲和小饰品
1 F7 d! r4 a/ E% c(e)quip auto on    打开自动装备,也立即检查
& J6 N; ]; E" k) }- c(e) 装备自动关闭    关闭自动装备。
. R' G+ }7 X; b, E  v7 b2 N6 ?' [(e)quip auto 一次    运行一次自动装备,然后将其关闭。: u7 i8 N8 U" Q/ [* W0 L
(e)quip 信息    显示装备自动切换状态(开/关)。
7 r2 x/ o( w0 L' S8 U4 ]" U2 x(f)ind 1< 游戏对象链接 >    命令机器人定位 1< Gameobject LINK > 然后等待。对任务目标有用
/ e7 ~, k4 b7 K7 d% e& y跟随    命令机器人跟随玩家;如果死了也会复活机器人,如果很远也会传送机器人* _5 }* S& S) Z
跟随汽车    切换自动跟随距离(开/关)7 P% t; N& M* D' h6 o( N7 d
关注信息    显示机器人当前的自动跟随距离,切换状态(开/关)3 l2 }% e$ ^8 z9 i
跟着远    机器人跟随,远离主人。6 Y: I/ G7 q5 J; r8 M" Q
跟随附近    机器人跟随,更接近主人
7 ^6 k/ k9 c3 [" B3 A跟随重置    机器人跟随距离重置为原始默认值
3 u! I. R6 p& d1 [3 T(g)et 1< GameobjectLINK >..    获取选中的 1< Gameobject LINK >.. 然后返回给玩家2 Y" ]7 l% P: P( n6 b" f9 d0 j
订单    显示机器人的战斗命令
" \7 o* p0 P3 \/ c+ s订单延迟<0-10>    在机器人开始战斗之前激活延迟。
3 ~' a, p) W  T! `" \命令战斗 ASSIST FRIEND    协助链接的友方目标,集中我们的杀伤力。+ r4 `& c" U/ J. s$ k  O) q- M" A
命令战斗治疗    命令机器人治愈。最好用于萨满、牧师、德鲁伊或圣骑士。  N$ |" A9 F' s) c8 `5 [; `
命令战斗保护朋友    保护列出的友方目标,试图让仇恨远离目标。
. H( Q) z& K/ v5 O" }* U, l$ I命令战斗坦克    命令机器人坦克。最适用于圣骑士、战士、德鲁伊或死亡骑士。; {+ {2 F# h  v
命令战斗RESET    重置机器人战斗命令,就好像他们根本没有下达过一样。
! {& K7 C" M1 a- u( o订单恢复    将战斗命令恢复到注销前的状态。  _. R% [  w* B. g" S+ B% O
邮件收件箱 1< MailboxLINK >    列出来自选定 1<Mailbox LINK> 的所有机器人邮件。邮件按 1< 邮件 ID > 索引。$ u6 T3 Z6 i4 e$ p) P
mail getcash 1<邮件ID>..    从所有选定的 1< 邮件 ID > 中获取资金..) _' s8 C7 U; a$ t& H
邮件getitem 1<邮件ID>..    从所有选定的 1<Mail ID> 中获取项目..) L8 x' w2 q9 d  Q2 e
邮件删除1<邮件ID>..    删除所有选定的 1< Mail ID >..; |4 U; a- F1 V
宠物遗弃    放弃活跃的猎人宠物。
4 D( q) s6 d* [7 p: |6 J% y' u宠物驯服目标    驯服选定的生物,如果机器人在法术书中有“驯服野兽”法术5 S1 x: ^' l" |( R& W: p
宠物法术    显示 bot 的宠物已知的法术。自动施法法术将显示为绿色% {3 J( G0 F0 _4 |# Q
宠物施放法术    拼写 = >- l! n# o( P" ]/ P' g
宠物切换法术    SPELL = >为给定的法术切换自动施法
- @+ a9 Z; S5 D8 ?0 i' y9 P8 Z9 a宠物状态    显示机器人宠物的当前反应模式$ c4 a/ ]3 ?& a, I! H5 p
宠物反应模式    模式 = <(a) 激进 | (d)防御性| (p)被动>
' |0 w% b' x: p$ m. r过程 (d)isenchant1< 物品链接 >..    分解绿色 1< 物品链接 > 或更好的
7 C# Y9 g! K' e5 P  s9 X# `处理 (m)ill 1< ItemLINK >..    研磨 5 种药草 1< 物品链接 > 以产生色素
& M. x# H+ p7 U- F+ }过程(p)前景1<项目链接>..    搜索 5 个金属矿石 1< 物品链接 > 寻找珍贵的宝石
5 f( F2 g' ^6 i, b拉目标    以协调的队伍/袭击方式拉动目标。3 s4 ^  a7 `& v  S& M- b
拉力测试    机器人会告诉您它们是否可以拉动(可以在任何地方使用)。
5 E/ j) v/ O. ?: q' J' z. ~' m' v准备就绪    机器人会告诉您它们是否准备好立即拉动(在具有有效目标的位置上使用)。9 J4 l+ P; ^& k
寻求    列出机器人当前的任务( n( u4 p, I' B' {3 B* U
quest (a)dd 1< QuestLINK >..    命令机器人寻找附近的 questgiver 并添加 1< Quest LINK >..
9 o8 J8 g0 z* ]5 W0 ~( n( h, I. Mquest (d)rop 1< QuestLINK >    命令机器人放弃 1< 任务链接 >. U( E+ O  B, x* v. O( D
追求 (e)nd    命令机器人寻找附近的任务提供者并上交所有相关的已完成任务2 |2 u9 c2 ]! a
寻求(r)报告    报告机器人完成任务所需的所有物品、生物或游戏对象: @/ H) [6 N4 J6 S$ u
任务(l)列表    命令机器人寻找任务提供者并显示新的可用 1< 任务链接 >..
1 p- S, o. d9 N$ ^6 p6 o: u1 A1 Qquest (c)完成 1< Quest LINK >    自动完成(GM 批准)任务,可在数据库中找到
) x) Q, Q. {0 R0 u9 l  X修复1<项目链接>..    命令 bot 寻找附近的 armourer 并修复选定的 1<Item LINK>..
) ?2 T  X+ m7 w7 X- O3 c全部修复    命令机器人寻找附近的装甲师并修理所有损坏的装备或包中的物品! G- a2 i9 @9 W( |; M  ]8 f
重置    重置状态、命令和战利品清单2 V. r0 v! l- K% s
(s)ell 1<项目链接>..    命令机器人寻找附近的供应商并出售 1< ItemLINK >..3 E1 V: x% l: M/ r2 v8 H4 H
(s)卖掉所有    所有低级白色物品的一次性销售(命令不会持续)。
5 x" W$ T4 O3 h) K技能    列出 bot(s) 1< Profession LINK >.. 主要职业和武器技能
+ I$ f4 X& f$ n7 }7 e技能 (l) 获得    命令机器人寻找附近的培训师并列出可用的 1< 培训链接 >..( W% h! F* h+ x& w/ [. K. y
技能 (l) 获得 1< 训练链接 >..    命令 bot 寻找附近的教练并学习 1< TrainingLINK >..
) n& T5 y# j; W- J技能 (u)nlearn 1< 职业链接 >    命令机器人在附近寻找训练师并忘记 1< 职业链接 > 和相关法术
9 U9 L0 a+ f# r" S3 r! x% b咒语    显示机器人已知的所有法术
" }, b  ?" `# j' y4 o2 S$ ~9 a  _统计数据    显示机器人可用资金、可用库存空间和估计的项目维修成本% Q; R) r9 b: I  W5 _
停留    命令机器人站立而不跟随玩家
; U8 l* B) t5 c: w& G召唤    玩家附近的传送机器人6 W3 l8 V/ u5 {/ t* b$ ~
民意调查    在机器人周围的局部范围内显示所有可用的 1< Gameobject LINK >.., D# f1 W3 w2 d
使用 1< 项目链接 >..    使用物品(例如食物、饮料等)
% W" \1 U" ~% Z使用 1< 项目链接 >TARGET    在目标上使用物品(例如任务物品)  L5 j% V3 O  z: J7 E
句法    描述
8 j" j; U  f/ O! a天赋    列出机器人 1< Talent LINK >.. & 1< Glyph LINK >..,未使用的天赋点数和重置所有天赋的费用4 y, f6 Q+ G# r# k# C
人才学习1<人才链接>..    为 bot 选项卡或 1< TalentLINK >..â†'talent> 学习选定的天赋
  g5 ?  O) C. n: H& G天赋重置    命令机器人寻找附近的班级教练并重置所有天赋2
4 j* i! S' o, i! i: J4 d1 M人才规格    列出机器人可以使用的所有天赋规格(编号为 #)。
0 l# i  _2 k  D, ?( v* T天赋规格#    机器人将遵循此天赋规范。  m4 g1 v. l* `% R/ R4 P

( \1 I: O! n& e" U& Z& I9 |% t$ w1 要选择 , 。
+ ]1 C9 Y; ]4 I  s$ A3 D1 X' i2 每个机器人的税收增加,每次重置天赋。
, u( W! s0 c0 m* ^& I
" R# C) R' S$ o9 ]
2 C& X( V* q; W6 j
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 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)
7 `0 P) Z+ n) H( A
0 y6 m/ k, G: Y/ X4 X1 Y6 b1. Make a folder for ACE in your preferred location ( I use /opt)
: e, _1 K7 Y& Z' v3 j; w4 [2 o" b
mkdir /opt/ace && cd /opt/ace
* X9 l8 |: i" Y3 E6 d% `
0 I7 p( N1 J, A  _- Y' ~& Q2. Download and unpack ACE
; x9 k: B8 h9 i# W+ r0 V8 `: b  ]6 `& T
wget http://download.dre.vanderbilt.edu/previous_versions/ACE-6.4.7.tar.gz
; l' s. D3 A; ftar -xvf ACE-6.4.7.tar.gz  e' C& ?9 e' j3 n
# `/ r; F# h/ H
3. Add needed environment variables
2 }3 [6 c, U2 H5 R2 }: }: {' u+ \4 U7 K- }# H5 I' F- h
cat >> /etc/profile <<EOF5 ~7 d. }* i" F. ~1 o
export ACE_ROOT=/opt/ace/ACE_wrappers5 z) [; Z* _) e4 n5 c
EOF
: z% X# C/ k; e. bsource /etc/profile
1 `, b4 R2 j6 U) X
* B2 H( J1 k2 j/ S, @. i% m
4. Add the desired headers: R2 M. i4 S! z
6 l, i9 p3 a- U! H* n
cat > /opt/ace/ACE_wrappers/ace/config.h <<EOF+ y% _) h1 b& Q( n9 x
#include "ace/config-linux.h"
* `' l/ Z. _8 HEOF
# r4 K% Y! b) c. dcat > /opt/ace/ACE_wrappers/include/makeinclude/platform_macros.GNU <<EOF9 k$ J" a: y0 a* ^
INSTALL_PREFIX = /usr/local
/ T; G4 o: [6 @5 F8 q; qinclude $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
. Y  x( w- [7 X/ X2 ]; M0 n+ Z' TEOF

* ~5 ^$ v9 W! J' b$ t
% q" u7 p2 ?$ P( b5. Build ACE* z% o( O( l( E  R6 u, b& q
: _$ `( J! O( Q+ s& V3 p
cd /opt/ace/ACE_wrappers
  g$ \4 h' C6 L/ G% u, `8 Mmake
3 b5 A/ N4 o- h$ L# [make install

; t' o3 t( Q5 v2 |# x4 n( c4 s3 o8 H* ~' M% M# M
6. Add the library to the public path2 F, ?; u1 w! y, m0 S" B

, _; a" m& K6 d7 rcat > /etc/ld.so.conf.d/ace.conf <<EOF
: ~% z* g* m. p- X6 d/opt/ace/ACE_wrappers/lib% L* N, _+ _1 p$ ~# \: ^* |3 a
EOF
8 F0 S& F3 _/ @+ B9 jldconfig -v

+ `$ a  X4 _( k1 j7 r& a
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

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

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 2022-7-30 13:54:45 | 显示全部楼层
Download WoW Wotlk 3.3.5 Client
) F# Y/ E& w' y) r& `0 d3 G2 tTorrent Download! K: }& e' E; l7 V4 J4 f: @# l0 `$ Q/ Z

6 N# Z2 {& m% b, ~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
+ k# z- `$ Z7 e9 a: V. c0 r5 b0 @
2 k- N% v: I0 J- ~, i7 l    Torrent – Client from Dalaran WoW (Recommended)5 a9 E4 r- U8 J# v! A! c
    Torrent– Client from Sunwell (Recommended – Fast torrent download, due to a lot of seeds)0 G* U* w5 {1 _! Q! z, Q! f- _
    Magnet – Client from TrueWoW. a& R, m  d# G7 E9 t1 U8 K
, U, |7 j; q  _- k7 Z. r3 W6 r
Direct Download, m- P  @+ L4 P2 I7 W, o, v" H  y
9 {' {; n% X& G2 g
Below, you will find direct client download links. Instead of downloading through a torrent, it will download through a media upload service. If you can’t download through a Torrent, we recommend the ones below.6 m3 X+ W9 u* T. U3 ~

9 ^% Q5 u7 ~7 J# U( y  R% d/ {    Direct – English Windows client
3 t1 s+ g; p, S4 N5 \% C& m' L! F! h" H
3.3.5 Wotlk MacOS Client
0 {( ^8 M% N; U6 T6 e) I$ C3 q7 f; Z* m- D! n2 \* C" m: I! @
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.
4 e9 h2 l2 N' p$ n  H2 B/ y( d+ E! K, v$ k! ]. N
    Direct 3.3.5 MacOS Download – Client from Sunwell
: K, i  t2 r2 p; P2 g4 ^  P' {    Direct – Client from Paragon-Servers (French)(Mac)
; I' o# U) Y# b( Q8 d3 E6 ^8 p$ x0 p
Modified Clients, LegionRemaster:  y0 o. f6 k  _6 }0 r4 k' y4 Z

  v( m5 m$ S6 r3 C+ `    3.3.5 LegionRemaster Torrent – From Sunwell and Finsternis
, d1 U' h: f8 ~    LegionRemaster Patch (modified)
  x3 R9 k& p' a    LegionRemaster ReadMe (Custom) 8 B; @* b. K/ u' _" k, ?. z" x4 h
https://zremax.com/blog/wotlk-3- ... e-lich-king-client/
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 2022-7-31 00:24:58 | 显示全部楼层
开源的魔兽世界 Mangos  I5 d/ Y; I- U9 Y3 |2 R9 ^% q3 V  c

: @$ L! q& p9 j: B/ ^( M1 U# p在sourceforge上开发的 (Ma ssive N etwork G ame O bject S erver) 项目是基于GPL协议的。据说是和魔兽世界独立无关的网络游戏服务器引擎程序。游戏的内容部分(数据库内容)又是由独立的小组开发的,这样也许避免了很多 法律上的问题。但是大多数魔兽世界的盈利的私服都是基于这个开源的项目的,为此开发小组表示这样盈利性质的服务器和对他们项目的使用是违背协议和非法的。
) y/ T/ |7 w: p. }4 Y0 A3 S9 n  K/ P) E8 Y# B! m
本文 是对mangos作了一个粗略的介绍,并且使用了魔兽世界的客户端对mangos作了一些测试。
; D! p: [1 C, z
$ Q$ |) B1 I! `/ y, ~正文如下:* J4 `' r4 S7 X9 Q. ?

( i6 V1 `0 ?! w% w+ `7 x开源社区常常有很多出人意表的项目,让人往往击节叹赏。例如当年在普通PC电脑上虚拟运行苹果机系统的 。把微软游戏机xbox改装成家庭影音中心的 ,以及在ipod上安装linux的 等项目。在电脑游戏方面当然也有很多出色的开源项目。5 V# I- @: R! l; u' @1 Y* t

% z4 X3 ^  \9 A2 {1 w3 {" J- y- r暴雪公司的游戏历来都是精品。网络游戏大热以后,它推出的基于10年游戏历史的网游:《魔兽世界》也更是名声在外(当然有好有坏,坏名声在于它太吸引 人以致 于很多人沉湎其中)。网络游戏的盈利模式和传统电脑游戏不同,月费和其他的周边产品使得其赢利空间远远大于传统电脑游戏。对于网游运营商来说很大的一个问 题是私服的问题。很多私服的软件是从网游开发公司或者运营公司内部非法的流出来的,比如说网游《仙境传说》的私服。% J, o. n6 x. @

$ u* \1 i$ O8 a+ ?1 o3 P1 [而现在大多数魔兽世界 的“私服”实际上是服务端软件的模拟器。是在对客户端游戏软件和与服务端的进行通信的数据进行分析解密以后,开发出来的模拟原游戏服务器功能的软件,这样 的模拟器软件大都也是开源软件。比如像现在大部分魔兽私服使用的Mangos服务端软件,mangos项目是一个开源的自由软件(如同linux或者 firefox),并且遵守其中最为严格的GPL协议。$ n0 c# E) G0 j. C- Y* D6 j& n
# Y6 Y! L* ?8 f3 Q8 D8 y' h
  MaNGOS 是(Ma ssive N etwork G ame O bject S erver) 的缩写。由于暴雪公司对类似的开发小组采取过一些法律行动。为了避免麻烦,如同它的名字,mangos强调自己并非一个魔兽服务器模拟器,而是一个开源的 多人在线游戏服务器的软件。说到底是个网游的游戏引擎。Mangos开发小组强调其软件是用c++和C#编程语言,实现 的一个支持大型多人在线角色扮演游戏服务器的程序框架,在这个框架下,它理论上应该支持任何客户端的网络游戏,由于现在很多人使用魔兽世界来对它进行测 试,所以针对魔兽世界的脚本和数据库文件比较完善,很多人就利用这个开源项目来实现魔兽私服。而游戏的内容,例如故事情节,任务场景的脚本等都是由别的小 组独立开发的。
2 l  L: R, F/ L& ^1 U+ W
4 z/ C1 w5 ?; `- x* p开发小组一再强调,这是个研究,教育性质的对怎样开发大型网游的服务器端有好处的项目,是一个技术细节毫无保留向公众开放的软件,是一件很有 意义的事情,如果你使用它作为盈利目的,那你本身就违反了软件的协议。所以任何利用mangos项目进行私服活动的组织和个人都违反了mangos的宗 旨,mangos项目也不会对它们负责。4 L/ L- j  ?& U/ m

. c/ d. A- V# E& S! X! Emangos的技术细节上是这样的,核心部分是个和特定游戏没有关系的核心框架程序,主要是进行进程调度,创造世界,建立心跳机制,处理网络接入 等。数据库可以使用的开源数据库软件MySQL。至于游戏内容数据库,游戏人物,时间,世界脚本,都是由这个核心程序所支持的扩展 脚本来实现,所以有一些独立出来的项目专门模拟魔兽世界来开发支持mangos的核心程序。现在mangos的核心程序已经放到著名的协同开发网站 sourceforge上开发了,使用的开发工具是subversion。大家都可以从sourceforge的subversion数据库中下载最新的 源代码程序。/ p2 w$ t- R2 B1 J
0 T6 v) h1 l  v5 f5 h
: l. s( B5 [9 `& z6 o5 B; v2 C
为了测试这个Mangos我自己安装了一个测试了以下,自己对魔兽世界的游戏本身没有太多的了解,请了几个玩过魔兽世界的朋友测试了一下,都说各方面 已经很 完美了。最新的Mangos项目已经支持了魔兽世界的扩展版“燃烧的远征”,简称TBC,对应的魔兽客户端版本到了2.0以上。以下的安装测试步骤适用于 魔兽世界客户端1.12.x的版本。
. f' o2 v% Z6 m9 L+ z
4 d. [2 E; C+ I6 ^. d% Q! ~$ V% O一、安装需求:
  • 操作系统Windows Xp,解压软件推荐 。(mangos论坛上有人在linux,macosx上安装,为了提取地图方便这里使用windows XP)
  • 魔兽世界的客户端软件,升级到1.12.1版本以上。
  • 编译好的Mangos二进制文件。(你也可以自己编译,我这里提供的是Mangos Rev 3462,3462是开发数据库的版本号),下载地址:9 M2 V# z6 `0 x2 |/ X! Q
  • 地图提取工具ad.exe(这个地图提取工具是专门针对1.12.x版本的客户端的,TBC需要比较新的ad.exe,TBC的地图提取工具不适用老版本的地图),下载地址:
  • mpq文件包提取工具MPQE_1.2.rar,暴雪公司的游戏都采用一种叫mpq的文件格式,是M ike O'Pack 的缩写,这个Mike就是暴雪公司的首席游戏程序开发人员,和创始者。我们需要使用mpqe.exe从客户端里提取相关文件。下载地址:4 u" o) r6 W( w" g" [* t7 e- v3 J* X
    Brien
  • 开源数据库软件MySql+ n2 ]& j' i7 @2 {+ ?/ V0 ]- J+ p
    官网:MySQL

    0 g0 Z1 t2 |' k3 g8 w% U或者用我下载的版本:
  • MySQL的客户端软件SQLyog,编译管理操作数据库5 n2 o: ]) E9 t. a6 a
    官网:
    6 f4 w5 I8 F5 o* L- t
    我下载的版本5.30:
  • 游戏内容数据库,配合Mangos Rev 3462的版本。
    6 c# o9 d8 P! d; F/ r& H- |. |: w文件名:CompleteSDB156-Mangos3462.rar
    4 ^9 @; F- Y2 t/ [+ V# n下载地址:3 b0 I4 ~  ~& B( ^( w
    & ^* ?  [* A7 J- d; o- K+ \- U
二、安装MySQL数据库,以及SQLyog客户端
  • 点击安装文件选择典型安装(Typical)
  • 配置数据库服务器"Configure the MySQL Server Now",选择标准配置"Standard Configuration"。
  • 确认安装成windows的服务程序和自动启动服务"Install as Windows Service"、"Launch the MySQL Server Automatically"。
  • 输入你的root用户的密码。可以打开的使用root远程管理数据库的选项,便于远程管理,和链接。
  • 应用你的设置。
  • 点击安装SQLyog的安装文件,安装到缺省路径,运行SQLyog。
  • 当SQLyog运行后,需要输入以下信息:
    • MySQL主机地址:可以输入你的本机IP地址或者"localhost"。
    • 用户名(UserName):root
    • 密码(Password):在第4步里面你配置的密码。
    • 数据库(database(s))输入:"realmd;mangos"
      # W# V4 A+ d  r5 q
    ! j/ W8 E. P; S$ y6 w, @; d7 _
点击连接,这样客户端就连接到你的MySQL数据库服务器上了。在左边一栏右键点击“root@localhost”,选择建立数据库"Create Database"。当提示输入数据库名称的时候输入:"mangos"。重复第9,10步建立数据库"realmd"。 三、安装Mangos服务器,配置路径
& d' l' k7 H! ~! v/ y
  • 建立一个目录,例如:"C:\MaNGOS"
  • 把你下载的mangos的二进制文件解压到这个目录里面。
  • 检查你的两个重要的服务器配置文件:“ mangosd .conf”和“realmd.conf”。其中“mangosd .conf”里面可以配置物品,金钱的掉落率,经验值的增长率等等。
    / E8 `7 \/ m  t/ f! \( G4 u
四、解压安装地图文件
/ L; _9 x% \2 H0 v' E7 g
  • 把ad.exe放在魔兽世界的安装目录下,例如("C:\World of Warcraft")
  • 建立一个子目录叫maps,结构为:("C:\World of Warcraft\maps")
  • 运行ad.exe文件。耐心等待ad.exe把魔兽世界的地图信息提取到maps目录下。
  • 将maps子目录拷贝到"C:\MaNGOS"目录下,结构为:"C:\MaNGOS\maps",里面的地图文件大概有2400多个。
  • 可以安全的删除"C:\World of Warcraft"下的maps子目录了。
    9 L0 F# ]# T* o' a& U
五、解压安装提取的*.dbc文件
* }  c, D8 l) w) N
  • 在你的mangos的安装目录下建立dbc子目录,结构为:("C:\MaNGOS\dbc")
  • 为了将暴雪公司的mpq文件的内容解压出来,将提取工具mpqe.exe拷贝在魔兽世界安装目录的data目录下,结构为:("C:\World of Warcraft\data")
  • 打开dos窗口,进入魔兽世界的data目录(cd "C:\World of Warcraft\data")。
  • 执行以下命令:
    ' J4 z! D/ `0 u) Wmpqe /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")了。
    - m8 a0 u" z4 B: ]
七、下载安装数据库内容,前文说过,mangos只是游戏引擎,游戏的内容,建立的数据库由独立小组开发,我们这里使用著名的Silver's Database Site的库。版本号为SDB156.
9 s' h- }4 @8 a0 g$ O% v+ J
  • 将下载的CompleteSDB156-Mangos3462.rar文件解压,里面有几个数据库文件。找到其中“realm-database-full.sql”和“mangos-full-for-rev3462.sql”文件。
  • 使用SQLyog连接到你的数据库。
  • 在左栏找到realmd ,点击右键选择"Restore from SQL Dump",找到“realm-database-full.sql”,导入数据库文件。
  • 同样找到mangos, 点击右键选择"Restore from SQL Dump",找到“mangos-full-for-rev3462.sql”,导入数据库文件。8 q2 K+ r5 u$ m# p1 a! w. _+ o4 n
八、配置数据库,配置文件,运行开源魔兽服务器!本文只为测试游戏,在局域网中玩。
% R2 }1 c9 @( B
  • 使用SQLyog连接到你的数据库。
  • 找到realmd,展开找到"realmlist"选项。
  • 在右下找到"Table Data"。
  • 在name一项填入你的服务器名字,例如叫faif
  • 在地址address一项可以使用"localhost" 或者你的IP地址。
  • 在realmd数据库下找到account表,点击"Table Data",建立你的游戏帐号,里面已经由几个内置的帐号,你可以参照gm,普通玩家的 帐号建立 你的用户名,密码。
  • 在mangos目录下打开realmd.conf 文件,找到
    3 a# g. ^: l0 t6 J5 ^"LoginDatabaseInfo ="' S$ z# d# S% g% z
    改为:"LoginDatabaseInfo = "127.0.0.1;3306;root;[password ];realmd"6 w' [$ [+ C7 R, }2 O* `! C
    这里的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"3 h3 K) @/ E5 |" H+ J# K/ |

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

& e3 Y/ J, |! E' g- w* G
1 y4 R6 e% R4 z$ F5 z+ ~5.安装数据库7 T; S# m! q. W* X3 \/ i  {
使用mysql建立 mangos 数据库9 Q" a9 d' f3 a0 L

1 v% d" r8 h' T% ~% Ea1)使用官方最小数据库,mysql用户名及数据权限等请自行设置
  o3 v7 f1 S8 f- }' ]; \mysql -u root -p mangos< /usr/local/mangos/share/mangos/sql/mangos.sql 导入数据
: k. o2 H1 i9 S% l1 k6 ~/ m" N
# d4 R5 g1 l! m: q0 L) W, l, Ja2)使用sdb数据库,mysql用户名及数据权限等请自行设置
  h4 N/ J* g1 n- B) u" i假设sdb数据库文件为 /home/wow/SDB/trunk/SDB_r1178.sql9 I% C: Z; b# P: F* P: u% q+ q
mysql -u root -p mangos< /home/wow/SDB/trunk/SDB_r1178.sql 导入数据6 |' \# D- P3 f  J4 r! y1 Z) z

+ T6 u& Q, `+ Q, lb)编辑 mangos 数据库的 realmlist 表,修改 address 为你运行mangos服务器的IP地址,这里设为192.168.1.1/ A8 \( d6 M% |5 O! f! l
3 [3 ^+ T! e( O7 m- L
6.编辑配置文件- U6 g, G3 }& V, p. i9 Z& w
编辑 /usr/local/mangos/etc/mangosd.conf
. j: B; S, f  \. G$ K+ I. y6 H3 a+ |7 V; \9 @' l
a)找到 DatabaseInfo = \"127.0.0.1;mangos;mangos;mangos\"
0 D1 m' K9 x5 N  T为你自己的配置,格式为 DatabaseInfo = \"mysql服务器ip:mysql用户名:密码:mangos数据库名\"' h6 J! y- Y8 ~/ z

& d/ J, \3 H# _. a; p/ t/ sb)找到 Host = localhost
; u( S: n2 L" q& [& i! M: l为你自己的配置 Host = 你的IP或域名,这里设为192.168.1.1$ J5 s" Z/ C; ~. k- p

; q6 C+ V# Q, E( k+ d0 r7 b1 q
回复

使用道具 举报

989

主题

92

回帖

5万

积分

管理员

积分
55361
 楼主| 发表于 2022-7-31 00:42:45 | 显示全部楼层
您好,在本教程中,我将逐步说明在 CentOS 7 Linux 系统上配置、安装和运行Mangos的方法。要完全执行安装,您需要一份要运行的游戏客户端版本的原始副本。  N3 J  {  v* r( _( N( W% W

$ A% a4 E! k' T本指南已在安装最少的空 CentOS 7 系统上进行了全面测试。
& |9 E$ q; r) ^, T7 k0 G" s# [' R% O7 R# U+ M$ I& Y
我们走吧..5 [! K  I$ W7 m- C' @

" R* M8 l$ x" A$ \0 \6 Q2 z% e) R- Q设置数据库:
& D) \# l: p7 r- J( n* `; k
, K- w7 N$ S4 MCentOS 默认支持 MariaDB 而不是 MySQL。本指南的这一部分将帮助您设置 MariaDB 实例。
+ b" u9 [4 X$ _( o
0 B2 S1 p# S1 {! Z7 L' a; G启动一个终端,如果还没有,您需要成为“root”用户:+ D. d' ~- q4 W" |2 C
  M5 P" v$ q9 J4 N+ A( G# g& s
须藤苏 - 根
- n' P7 a: ^" W% R. x' Y( t0 _然后,安装 MariaDB:" f* V; q5 q- s/ }7 _5 F

0 ~3 K) Z3 {- m+ V6 Uyum -y 安装 mariadb-server/ t/ D! f/ _' g/ l4 Z7 n- X* w
     安装 MariaDB 后,启动它:( Q" B) N/ g5 a1 m" R
2 e- q& I( X0 I* w8 a
systemctl 启动 mariadb
! c4 s; J, F8 w( {+ ?( R我建议您在启动时添加 mariadb 服务以自动执行它:3 N" _. ^# @; d! X" W3 Z
& ^1 z4 _) E7 L& b. _6 Q  [8 u
systemctl 启用 mariadb
- S5 H4 N6 S. G& g" a) y( Y* ]. E让我们保护您的 mariadb 安装,执行以下命令:
& q) P% e9 A. W9 ]3 A  \+ m' j& l' E+ P. i
mysql_secure_installation
* F2 B* S7 f* A, A2 D" Z1 i  X2 z我建议您设置以下参数:
- }$ V  N2 V/ F5 b" _1 |. x
- C, E) ?$ O/ r& [; j7 e" x$ g1 W设置 Root 密码  t+ G' t9 i9 g: W5 ^
删除匿名访问: W% b& G7 z' D
禁用 root 用户的远程访问
, D, V/ k: o+ O2 r& q7 _删除测试数据库
1 t/ i3 l( P, P+ c* ~# @6 ~重新加载权限
( ]6 r( n# U' \  _. u, L4 a  v验证您的数据库配置是否正常工作,您需要提供刚刚定义的 root 密码:; h& X+ b3 _; f* v3 [! h% C7 Q$ q

$ u9 a, R  l! L! z( |mysqladmin -u root -p 版本, [; }8 o/ w  i3 z3 l# a7 P0 A, O& E2 @
如果一切正常,您应该有如下输出:
5 ?8 e) @$ h+ ~+ V) d
6 n. t) y; I: B' P( i9 Z- M& d服务器版本 5.5.52-MariaDB
7 G5 [0 Y3 k% O# J  j/ R协议版本 103 X% |/ B; g* ]6 g
通过 UNIX 套接字连接本地主机6 t$ {, o# h( ?5 F4 C( ]# E2 m
UNIX 套接字 /var/lib/mysql/mysql.sock
0 k- |" ^/ |& v0 W, e" x正常运行时间 x 秒: p4 M9 p( n8 `9 A1 \
( m9 c0 f! ^, O, |9 U2 J2 [4 u4 U
  ?/ h/ ^/ V% U
现在数据库的设置已经完成,我们需要添加芒果数据库配置的先决条件。我们需要首先为mangos创建一个用户,使用以下命令登录数据库:
; g! n7 T& T# p. w: i: B# F
* f& H) s" b( i% v! b: y2 S/ O3 Hmysql -u 根目录 -p" F) B$ G8 i' A
创建您想要的用户,给出的示例是创建一个用户“ mangos ”,该用户可以从“localhost”连接并在末尾输入密码“password”(不要忘记“;”):' S0 p6 ^. g$ }- ~

6 J( S$ T5 g- ~2 s5 j创建用户“芒果” @ “本地主机”由“密码”识别;
! U  D! n$ g" @然后,我们需要向该用户授予权限,以便我们以后可以使用它来设置Mangos模式(同样,不要忘记“;”符号):# U* Y: A, S; h! _

; M. }2 m3 h1 y6 o" q将*.* 上的所有特权授予“芒果” @ “本地主机” ;6 Z7 |( d: l2 Z/ h$ l
退出终端:4 q2 j6 |* M" ^! ?9 j
8 T, P3 w) p4 W# \( Z3 D
退出
7 G6 R+ h1 U. m: k& u8 `4 s& g恭喜,您已经在 CentOS 上设置了数据库的先决条件!
- r3 N6 j  X1 F! l. c7 J4 @0 y0 C& ]$ s7 F2 m$ x% m
2 A) {" X! s# X4 W8 F* i

' P# U4 B! v+ P6 y/ Z安装芒果:
9 f$ \0 b/ y( `: \) x. R$ S
( D6 B4 \/ U% z! C7 X' I( y' n我们现在处于有趣的部分,我们如何在 CentOS 上安装Mangos ?好吧,假设您以“root”身份登录,请转到主目录:  K9 E) |* b. ]: b
9 d- a3 h) i: B0 q" q8 O9 v
光盘~
) B$ L% F' `4 ]$ L# w, i* i4 v让我们先安装所需的依赖项,wget 是一个小实用程序,可让您下载安装程序脚本:
  v. C! d0 n# s/ m1 D0 f& }
1 b: p! H$ w. N8 T  o/ f% }5 v" O  V0 Iyum -y 安装 wget+ w% T2 B" a  N
现在,我们可以下载我们的安装程序:
9 q# P; M' i' H9 Y% z& j' `# W9 v- F4 M; t8 u& {/ X- F2 k8 G! J
wget https://raw.githubusercontent.co ... /linux/getmangos.sh8 ]3 [4 N( i) j: s0 \! l% B  E8 @
设置允许执行它的权限:4 m9 d, I, V/ u# T* k. n+ B" i6 c3 D

7 ?& y2 i' p2 Y9 n8 Jchmod 700 getmangos.sh
  e, R* {* n$ [, Y( m并执行它:3 Y, _* w4 ^. Z- L! S' ^3 K4 |
: U( x2 I0 j- g) K2 T3 e
./getmangos.sh
; H; p1 i7 K% C) t4 @  D5 a在我们进一步讨论之前,对可用活动进行一些解释:7 d3 ^' c1 p. ~9 r2 p0 Z' O
& f4 d9 N  Q' w0 [
安装先决条件将为您安装所有必要的依赖项以构建和运行mangos。默认切换。
4 o7 _' e, z+ R" D; e) h( t! X设置下载和安装路径将允许您指定必须下载源的位置以及必须安装二进制文件的位置。默认切换。" Y6 j* U, ]7 l
克隆源存储库将帮助您克隆Mangos源。默认切换。7 L2 n  E! _# o' E% T. V9 H5 g
Build MaNGOS将协助您完成MaNGOS的构建过程。默认切换。4 \, Y- `6 i) p/ ?* Z. a% u' |
安装MaNGOS将帮助您安装MaNGOS。默认切换。
, I$ W) @2 ]2 ?& P3 b' \6 R安装数据库将帮助您创建数据库模式。默认切换。
; a' B- c* u* D+ C% g  p& p提取资源将帮助您从游戏客户端中提取 DBC、地图、mmap 和 vmap。默认切换。' J/ |* a- i3 `( Z$ i
创建 Code::Blocks 项目文件将为 Code::Blocks 编辑器创建一个项目。如果您不打算编辑MaNGOS源,请不要切换此选项。; }! l% n$ E6 C4 V. R$ U1 K
现在您已经了解了所有内容,请选择默认选项并通过 Tab 键选择“确定”。该脚本现在正在您的 CentOS 上安装必要的依赖项。系统将提示您同意安装构建依赖项。选择“是”两次。
& O4 y) x: ~+ b7 Z8 `8 n' s4 P9 o0 q; V2 j3 C; }% n
用户选择:
" I% |4 R" D1 |2 \+ A* T0 A9 Z: C% t- H! n" ^" F5 l
Mangos为您提供了在“root”用户以外的其他用户下运行它的机会。这是一种很好的做法,可以隔离软件并在漏洞被利用的情况下限制安全影响。默认建议的运行用户是“ mangos ”,但您可以根据需要进行更改。选择“确定”继续。
& k( T2 d4 U/ g
* ?& `& m( D! \: b0 q% B如果您已经执行了此步骤,安装程序将询问您是否要保留该用户。我建议您回答“是”,除非您知道自己在做什么。
5 G/ |# x2 {* s  N- \+ k2 p6 [% P; Z7 G& f: J5 p, g
选择魔兽版本:8 X% |1 X' C0 M6 N2 B- ?3 n6 W8 u5 ]2 |

- V3 j" V2 g% o3 T+ S下一个屏幕要求您选择您愿意安装的 WoW 版本。选择符合您愿望的那个,然后选择“确定”。5 O8 L( Q2 J7 ~/ G3 ~0 E) M3 O5 p

# b. k4 }& Y" T源代码路径:2 E4 p* F& b6 e* v1 B

, N* x6 B8 n% D) w; ^下一个屏幕要求您提供源路径。默认情况下,建议的格式是 /home/<run user>/<wow version>/src。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:1 G9 Y1 U& R& b  _) F
. N2 T$ h8 N( k
/home/芒果/zero/src) d8 A/ l# l9 p! S/ h' \
如果目录不存在,请回复“是”以创建目录。如果它确实存在并且包含源,安装程序将询问您是否要删除该内容。
& H; T2 F, A) t2 }8 J' t; }  N; u4 k
安装路径:1 o- K! C0 b( E# W. d4 ]; U! }* ]

# v, k1 `" R8 p, ]( z下一个屏幕要求您提供安装路径。这是您将执行Mangos流程的位置。默认情况下,建议的格式是 /home/<run user>/<wow version>。例如,对于运行用户“ mangos ”和 wow 版本“Vanilla”,建议的路径将是:8 D/ w* E$ u0 G) [' T) q
, n0 {5 |2 I2 W5 d5 b, C
/home/芒果/零6 |1 Q* M, i5 R2 f3 B2 ]6 ], [
如果它确实存在并且包含已编译的源,安装程序将询问您是否要删除该内容。
4 Y4 _4 H, J; i. K3 R) y% x$ [; L; f  z3 Z/ t. X
克隆或更新MaNGOS:
( C( C* g# U, f/ }* v- }
% O3 ^5 {5 Z( [" L1 n脚本的下一步是询问您是否要克隆、更新或使用MaNGOS源的现有副本。对于全新安装,请选择选项“0 克隆MaNGOS的全新副本”。安装程序现在将连接到 Github 并检查可用的开发分支,目前,最后一个稳定版本是 Rel21,并托管在“主”分支中。
( ?# L3 w; O8 i+ [3 h+ O2 `- \/ W! s* t9 Q% U; ]( l" J4 X
安装程序现在正在克隆服务器和数据库存储库。( G' a0 N1 a. G1 t- M8 ]

$ h: O; f4 Y; G4 B8 F6 ^8 i' E构建选项:
) \- \* p* r- e$ N7 x. [5 F# S/ o
: R/ i9 q7 p$ q" v7 q您现在处于构建步骤。此屏幕上的一些解释:" ^5 R& \8 t  I' C+ P1 w- Y; Q
6 E, A1 K& Y* ?& k) D% R
Enable Debug 将在Mangos 上设置调试标志和更多跟踪。仅当您被要求修复错误时才使用此构建选项。在调试模式下构建软件会显着降低其性能。
8 d) K2 u5 O- ?0 A. N: o5 \使用标准 Malloc,切换此选项以使用标准内存分配。仅当您知道自己在做什么时才取消切换此选项。' s9 M/ L! I- z* e7 P' }* k
使用外部 ACE 库。允许您使用来自系统的 ACE 库。此选项在极少数情况下有效,并且将来会被删除,所以不要切换它(无论如何, MaNGOS有一个“内部”ACE)。
/ M3 J: N$ ~# d' {: ~使用 PostgreSQL 代替 MySQL/MariaDB。允许您使用默认数据库提供程序以外的其他数据库提供程序。此选项尚未经过测试,如果您到目前为止已经按照教程进行操作,那么您应该已经设置了 MariaDB
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-5-6 04:14 AM , Processed in 0.195312 second(s), 26 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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