📜 ⬆️ ⬇️

“Free Time Wars” or BF2 server + office statistics

Good day Habra community!
Today I will tell you how to install and configure the BattleField 2 game server and attach local player statistics to it.


Server:
HP ProLiant ML350 G5
Intel® Xeon® 5160
8 Gb RAM ECC
OS Ubuntu 12.04 LTS (GNU / Linux 3.2.0-23-generic x86_64)

Here is such a free machine caught my eye. Looking at the configuration, I decided that the Web server, database and, accordingly, the game server will get along on one machine.

I will not describe the installation of the OS, I'll start with the necessary packages.
We need Apache, MySQL and PHP for the Web server, database and web binding, as well as statistics for the apache module that supports the execution of ASM scripts.
')
For my convenience, everything about the server part I store in a separate directory in the root of the system.
sudo mkdir /server cd /server sudo mkdir site sudo mkdir bf2 

Web server installation, PHP, MySQL

So, let's proceed to the installation:
 sudo apt-get install apache2 apache2-mpm-prefork apache2-utils apache2-suexec libapache-asp-perl php5 php5-mysql libapache2-mod-php5 php-pear mysql-server mysql-client libmysqlclient15-dev 

* During installation, the MySQL server will ask you for a password.

Configure virtual hosts:

At the moment we should have a completely working Web server. We check by switching to the server's IP address through any browser from a computer on your local network. On the screen, if everything works correctly, the inscription "It, works!" Will appear.

Change the virtual hosts configuration file:
 sudo nano /etc/apache2/sites-available/default 

Erase the contents of the file and insert our new virtual host:
 <VirtualHost .IP.:80> ServerAdmin somemail@some.ru ServerName .IP. ServerAlias .IP. DocumentRoot /server/site ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ </VirtualHost> 

Now the folder where our site is /server/site .

Installing and configuring BattleField 2 servers

At this stage, I had a problem =) Since I could not find the battles on the EA site of the battles, I had to scour the Internet in the bf2-linuxded-1.5.3153.0-installer.sh list .

Downloading the bf2-linuxded-1.5.3153.0-installer file:
 sudo wget ///bf2-linuxded-1.5.3153.0-installer.sh 

After the download is completed, the installation:
 sudo chmod +x bf2-linuxded-1.5.3153.0-installer.sh sudo ./bf2-linuxded-1.5.3153.0-installer.sh 

After installation, edit the server configuration:
 sudo nano /server/bf2/mods/bf2/settings/serversettings.con 

Approximate contents of the configuration file and necessary edits in it:
 sv.serverName "" //  sv.password "" //   sv.internet 1 // 1,     . sv.serverIP "XX.XX.XX.XX" //  sv.serverPort 16567 //      sv.welcomeMessage "" //  sv.punkBuster 1 // punkBuster sv.ticketRatio 100 // 100       sv.roundsPerMap 3 //   sv.timeLimit 1800 // , 1800  = 30  sv.scoreLimit 0 //    sv.autoBalanceTeam 1 //  sv.useGlobalRank 1 sv.useGlobalUnlocks 1 //  . sv.friendlyFireWithMines 1 //    

That's basically all ... Ready to launch!
Now you can start the server and start playing on it. But if you need ranks, and complete player statistics, read on ...

Setting statistics on the server

Scripts that can be downloaded from www.bf2statistics.com will help us with statistics .
We need to download the file BF2Statistics 1.5.1 (The only thing you need to register on the site to access the files.)
Archive content -
Client Files
Server files
Web files

Let's start with the simplest.
Configure the database.
 mysql -u root -p CREATE DATABASE `bf2stats` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; 

The base is ready!

Configuring Python Parts

From the Server Files folder we copy the contents to the folder with our server (/ server / bf2) with the replacement of files according to.

Editing the file /server/bf2/python/bf2/BF2StatisticsConfig.py
 sudo nano /server/bf2/python/bf2/BF2StatisticsConfig.py =========================================================== # ------------------------------------------------------------------------------ # Backend Web Server # ------------------------------------------------------------------------------ http_backend_addr = '.IP.' http_backend_port = 80 http_backend_asp = '/ASP/bf2statistics.php' # ------------------------------------------------------------------------------ # Player Manager # ------------------------------------------------------------------------------ pm_backend_pid_manager = 1 pm_local_pid_txt_file = 'python/bf2/pid.txt' # Relative from BF2 base folder pm_ai_player_addr = '.IP.' # Not recommended to change 

We save.

ASP setup part


Copy the ASP folder, as well as all the files from the bf2sclone directory from the Web Files directory to our site directory (/ server / site), I did this using an FTP server and the mc file manager.

In order not to be soared with the rights, I set 777 permissions on the / server / site folder:
 sudo chmod 777 -R /server/site 

If security is important to you, here is a list of files with 777 access rights that are necessary for the server:
/ASP/_config.php
/ASP/_config.php.bak
/ Asp / _backup
/ ASP / logs
/ ASP / logs / _processed

Configure the ASP part of the statistics.
Editing /server/site/sys-games/ASP/system/config/config.php
 sudo nano /server/site/sys-games/ASP/system/config/config.php =============================================================== $db_host = '.IP.'; #    $db_name = 'bf2stats'; #    $db_user = 'root'; #    $db_pass = 'my_pass'; #    $admin_user = 'admin'; #    $admin_pass = 'admin_password'; #    $admin_hosts = array('127.0.0.1','.IP./'); # IP   IP       Web- $stats_lan_override = '.IP.'; $stats_local_pids = array('LocalPlayer01','.IP.','LocalPlayer02','.IP.'); $game_hosts = array('127.0.0.1','.IP.','.IP./24'); # IP-         .     . 

Next, open the browser, go to .ip./ASP .ip./ASP . The admin panel will open, go with the credentials that you entered when editing the configuration file. In the left menu, click Install DB .
After installing the database, you will be given a report on the passed DB test. If everything is fine, then each item will have a Passed value.
Next, go to the left menu "System => Edit Configuration", you can take a closer look at the server configuration.

Nastryoka web strapping

Next, open the browser, go to .ip. .ip. . The stats server web page installation page will open, follow the instructions of the installation script.
After a successful installation, you can edit the configuration file binding:
 sudo nano /server/site/config.inc.php ====================================================== $DBIP = 'localhost'; //    $DBNAME = 'bf2stats'; //    $DBLOGIN = 'root'; //    $DBPASSWORD = ''; //    $TITLE = ''; //   


At this stage, the installation of statistics is completed. As usual, we take a large file and finish our “locomotive to the state of the ship” ...

File handling

So that our server does not check the validity of the keys:
Install the iptables package:
 sudo apt-get install iptables 

Next, I added to the configuration "when connected to the network" such lines with port blocking:
 sudo nano /etc/network/if-up.d/upstart iptables -A INPUT -m udp -p udp --sport 29910 -s 0/0 -j DROP iptables -A INPUT -m udp -p udp --sport 139 -s 0/0 -j DROP iptables -A INPUT -m tcp -p tcp --sport 29910 -s 0/0 -j DROP iptables -A INPUT -m tcp -p tcp --sport 1433 -s 0/0 -j DROP iptables -A INPUT -m tcp -p tcp --sport 1434 -s 0/0 -j DROP iptables -A INPUT -m tcp -p tcp --sport 139 -s 0/0 -j DROP 


Change cards:
To change maps on the server, you must edit the file /server/bf2/mods/bf2/settings/maplist.con
 sudo nano /server/bf2/mods/bf2/settings/maplist.con ===================================================== //mapList.append _ _ _ mapList.append mashtuur_city gpm_cq 16 mapList.append road_to_jalalabad gpm_cq 16 mapList.append sharqi_peninsula gpm_cq 16 


Client part of the game:
The security policy of our domain does not allow to use the vbs script which is offered to us on the website bf2statistic.com. Therefore, I went the other way.

In the% SystemRoot% / Drivers / etc folder I created the hosts.ics file to which I added the line: .IP. bf2web.gamespy.com
This line allows you to redirect our game to our server.

Server startup

I think everything. You can run the server:
 cd /server/bf2 ./start.sh 

or via screen
 sudo screen cd /server/bf2 ./start.sh 

Unlink the screen with the key combination Ctrl + A then press D.

This article is completed, if you have any questions or problems, consult me ​​in the comments.

UPD1 : Fixed typos in the text.

Source: https://habr.com/ru/post/149947/


All Articles