Jump to content
ZLOFENIX Games

Creating a ZLO BF3 Server on Linux Headless Server (no gui)


Recommended Posts

Disclaimer: This tutorial is for advanced linux users. If you have no idea what youre doing dont attempt this, as i wont be answering questions which are obvious.

This tutorial is written for Ubuntu Server 20.04 Focal Fossa, but works for older and newer releases as well. Just adjust the Wine versions. This method is especially useful for hosters who dont have much money to get windows servers, linux servers are much cheaper. Performance is same as windows server.

Let's get started!

0.5) What you need: (Ubuntu Server or similar with x11 forwarding, MobaXTerm to ssh to your server with xserver, maybe WINscp to move the server files to the server)

1.) The Prerequisits (Installation and Setup for Wine)

First we have to enable support for 32bit packages

sudo dpkg --add-architecture i386

Next we have to get the repository key

wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key

Add the repository (Focal meaning 20.04)

sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'

Update your packages

sudo apt update

Install the stable branch

sudo apt install --install-recommends winehq-stable

set the winearch to 32 bit

WINEARCH=win32 wine wineboot

2.) Set up the xvfb (virtual frame buffer) and install the C runtime for 32bit

First we create a temporary folder

mkdir /temp

Next we're going to install xvfb and unzip

sudo apt install -y xvfb unzip

Switch to the temp folder and download the Visual C runtime 

cd /temp
wget -nc https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe

Start the installation of VCR

xvfb-run wine vcredist_x86.exe 

3.) Getting the ZLO files

Sadly you cant use wget to download the BF3 server files. You have to download the .zip archive on windows and move it to your server. I used WinSCP to move the archive to the servers Battlefield 3 folder

Unzip the archive

cd ~/Battlefield3 
unzip BF3_R40_1427727.zip

Download ZServer

wget ZServer.exe https://zloemu.net/files/ZServer.exe

If youre not using MobaXterm by now you should download and use it to ssh to your server because now were doing the initial ZServer setup

wine ZServer.exe

Wait some time and the ZServer.exe will open. Insert you data just like on windows.

Important: Set "Autostart" to yes! It has to be on or we wont be able to start the server without a gui, and it wont run as a service

Start the server once, wait for "IN_GAME" status then close

4.) Running the server without XServer, no gui and creating a screen session so it keeps running after you close the shell

Previously we ran the server with xServer enabled which allowed us to input the profile and our ZLO credentials. However when we close the window our server stops. In order to prevent this we need a virtual frame buffer, which emulates a xServer also known as xvfb.

We also want our server to run the entire time. So we need to create a "screen" session.

screen -S Battlefield_3 xvfb-run wine ZServer.exe

"screen -S Battlefield_3" is the name of our screen session. We can use "Ctrl + a, Ctrl + d" to detach from our screen session and have it run in the background. To reconnect we use 

screen -r Battlefield_3

"xvfb-run wine ZServer.exe" enables us to run the ZServer without any display which normally isnt possible.

5.) (if you dont know what you're doing stop here) Create a service

sudo nano /etc/systemd/system/bf3server.service

Insert following:

[Unit]
Description=Our Battlefield 3 Server
After=network.target

[Service]
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=20
Type=forking
ExecStart=/usr/bin/screen -dmS zlobf3 /usr/bin/xvfb-run /usr/bin/wine ~/battlefield3/ZServer.exe
ExecStop=/usr/bin/screen -XS zlobf3 quit
ExecStop=/usr/bin/wineserver -k
Restart=always
RestartSec=20

[Install]
WantedBy=multi-user.target

reload the daemon

systemctl daemon-reload

enable the service and have it run on boot

systemctl enable bf3server.service

 

Procon Linux tutorial soon... ;)

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...