Skip to content

Instantly share code, notes, and snippets.

@simondumalski
Last active March 17, 2023 05:11
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simondumalski/cee72d3e6244a51f70124ac86a2802e9 to your computer and use it in GitHub Desktop.
Save simondumalski/cee72d3e6244a51f70124ac86a2802e9 to your computer and use it in GitHub Desktop.
[GUIDE] Installing DLU with a VPS (Oracle Cloud, AWS, etc.)

[READ THIS FIRST] FREE TRIAL and FREE TIER Clarification

  • Most cloud service providers offer both a FREE TRIAL and a FREE TIER. THESE ARE NOT THE SAME.
  • The FREE TRIAL gives you credits that can be used to create services that normally aren't free. When you use up the credits, you will get charged for any services you have running that aren't free.
  • The FREE TIER has services that are 100% free. They do not use a credit system; they remain free as long as the free tier is still being offered by the cloud service provider. Choose this option if you don't want to spend any money.

[GUIDE] Installing DLU with a VPS (Oracle Cloud, AWS, etc.)

  • This guide will run you through the steps of setting up a DLU Server on a VPS from a cloud service provider such as Oracle Cloud or AWS.
  • Setting up DLU is a challenging task for anyone who does not consider themselves "techy". If you want to forgo setting up a server and would like to join one instead, send me a message on Discord, Saymoan#6969, for information on joining a friends-only private server.

Disclaimers

  • Knowing basic directory navigation commands helps tremendously with following all DLU guides. The main command you should know how to use is cd.
  • Some service providers offer a "free tier" VPS. This VPS should be capable of handling a small private server, but most certainly should not be used for larger servers.
  • If you sign up for a "free tier" VPS and are later charged for it, I am not responsible for any charges you receive. Ensure you choose the free VPS option.

Table of Contents

  1. Frequently Asked Questions (FAQ)
  2. Prerequisites
  3. VPS Creation (Oracle Cloud)
  4. VPS Creation (AWS)
  5. SSH Client Setup
  6. SFTP Client Setup
  7. Ubuntu Setup
    1. Updating Packages
    2. Install Dependencies
  8. Get DLU Server Files
    1. Clone the Repository
    2. Build the Repository
  9. Server Setup
    1. MySQL Database
    2. Resource Setup
    3. Navmesh Setup
    4. Locale Setup
    5. CDServer.sqlite Setup
    6. Chat Fix
    7. Server Configurations
  10. Firewall Setup
    1. UFW
    2. IPTables
  11. Client Setup
    1. boot.cfg
    2. Survival Minigame Fix
    3. Brick-By-Brick Building
  12. Admin Account Creation
  13. Installing AccountManager
    1. Install Dependencies
    2. Clone the Repository
    3. Create credentials.py
    4. Create resources.py
  14. Managing DLU & AccountManager
    1. Starting DLU
    2. Stopping DLU
    3. Updating DLU
    4. Starting AccountManager
    5. Stopping AccountManager
  15. Contributions

Frequently Asked Questions (FAQ)

Where do I get a client?

  • The Lego Group is not allowing the mass distribution to their client. You will have to do some searching around to get one.

What kind of client do I need?

  • For the easiest installation process, you need an unpacked client, version 1.10.64
  • You could also get a packed client and unpack it using lcdr's utils.
  • You can verify your client is the correct one using the known good SHA256 checksums found here.

How many people can I have on a free VPS?

  • I asked Mick from the DLU Team what kind of resources a server should have and this was his response:
  • Our test server always ran on the free Google Cloud tier and could comfortably handle 4-5 people.
  • The "free tier" VPS from Oracle Cloud, AWS, and Google Cloud all have the same specs of 1 vCPU and 1GB of RAM.

Which VPS provider should I use?

  • The process for each is the same for each, with the exception being creating the VPS. I personally found Oracle Cloud the easiest to navigate around, but your mileage may vary.

I keep getting the "Destroying MySQL Connection" error! What did I do wrong?

  • You haven't followed the steps for setting up the firewall on your VPS. You must follow the instructions in both the VPS Creation and Firewall Setup parts of the guide.

Prerequisites

Unpacked Client (Version: 1.10.64)

  • An unpacked client or a packed client that you can unpack.

An SSH Client (https://www.putty.org/)

  • Any will do, I will be using PuTTY.
  • Any will do, I will be using FileZilla.
  • Make sure you download the FileZilla client, not the server.

VPS Creation (Oracle Cloud)

These instructions are for an Oracle Cloud VPS. If you are using something else, skip these steps.

Basic Setup

  • Go to https://www.oracle.com/ca-en/cloud/ and create a free account. You will be prompted to enter payment information, but you will not be charged unless you upgrade your account.
  • Go to Compute > Instances > Create instance or press Create a VM instance if the option is available.
  • Change the image to Canonical Ubuntu.
  • Change the shape to VM.Standard.E2.1.Micro.

Adding SSH Keys

  • Scroll down to Add SSH keys and download the private key.

DO NOT LOSE THESE KEYS. YOU WILL NOT BE ABLE TO ACCESS THE INSTANCE WITHOUT THEM

  • After you download your keys, press create and your VPS will start to boot up.

Public IP

  • After your VPS is created, you will be taken to your VPS dashboard.
  • On the right-hand side, there is a Public IP address. Copy this to your clipboard, as we will need it.

Firewall Setup

  • On your VPS Dashboard, click on the Virtual cloud network under Instance details on the left-hand side.
  • Click on Security Lists on the left-hand side.
  • Click on Default Security List for your VCN (name may differ).
  • Click Add Ingress Rules and use these settings:
Source Type: CIDR
Source CIDR: 0.0.0.0/0
IP Protocol: UDP
Destination Port Range: 1001,2000-2200,3000-3200
  • Once you are done, add another rule with these settings.
Source Type: CIDR
Source CIDR: 0.0.0.0/0
IP Protocol: TCP
Destination Port Range: 5000

VPS Creation (AWS)

These instructions are for an AWS VPS. If you are using something else, skip these steps.

Initial Setup

  • Go to https://aws.amazon.com/free/ and create a 12-month free account. You will be prompted to enter payment information, but you will not be charged unless you use a service that is not free. It may take several hours for your account to be created.
  • Once your account is made, go to the AWS Management Console and click on Launch a virtaul machine.
  • Choose Ubuntu Server 20.04 LTS as your machine image and choose 64-bit (x86) as your architecture.
  • Click on select.
  • Choose t2.micro as your instance type (It should said "Free tier eligible" under it).
  • Click on "Next: Configure Instance Details" in the bottom right-hand corner to continue.
  • Find Auto-assign Public IP and ensure it is enabled.
  • Click on Next: Add Storage in the bottom right-hand corner to continue.
  • Set your volume size to 30GB.
  • Click on Next: Add Tags in the bottom right-hand corner to continue.
  • Click on Next: Configure Security Group in the bottom right-hand corner to continue.

Firewall Setup

Don't touch the SSH rule, as it is needed to SSH into the VPS.

  • Add 4 new rules using the Add Rule button.
  • Use these settings for your rules:
# First rule
Type: Custom UDP Rule
Protocol: UDP
Port Range: 1001
Source: Custom - 0.0.0.0/0

# Second rule
Type: Custom UDP Rule
Protocol: UDP
Port Range: 2000-2200
Source: Custom - 0.0.0.0/0

# Third rule
Type: Custom UDP Rule
Protocol: UDP
Port Range: 3000-3200
Source: Custom - 0.0.0.0/0

# Fourth rule
Type: Custom TCP Rule
Protocol: TCP
Port Range: 5000
Source: Custom - 0.0.0.0/0

Starting the VPS

  • Click on Review and Launch in the bottom right-hand corner to continue.
  • Click on Launch to start your VPS.

Adding SSH Keys

  • Scroll down to Add SSH keys and download the private key.

DO NOT LOSE THESE KEYS OR YOU WILL NOT BE ABLE TO ACCESS YOUR VPS AND WILL HAVE TO RESTART

Public IP

  • After your VPS is created, you will be taken to your VPS dashboard.
  • On there is a Public IP address. Copy this to your clipboard, as we will need it.

SSH Client Setup

PuTTY

  • Open the PuTTY application and paste the Public IP address you got into the Host Name section.
  • Navigate to Connection > Data and enter ubuntu into the Auto-login username field.
  • Open the PuTTYgen application and go to Conversions > Import key.
  • Find the private key you downloaded earlier and select it.
  • Under Actions, click Save private key and say yes to the warning.
  • Save the key somewhere on your computer.
  • Go back to PuTTY and navigate to Connection > SSH > Auth.
  • At the bottom, select your private key.

Save Configuration

  • Go back to Session and type in a name for this configuration. Press save, and now you can easily load this configuration in the future.

Connecting to the VPS

  • Press Open and when prompted to, accept the certificate.
  • You are now connected to your VPS!

SFTP Client Setup

FileZilla

  • Open the 'FileZilla' application. In the top left-hand corner, goto File > Site Manager.
  • In the new window that opened, click on New site.
  • On the right-hand side, set Protocol: to SFTP - SSH File Transfer Protocol via the drop-down menu.
  • Paste your public IP address into the Host: field.
  • Set Logon Type: to Key file.
  • Set User: to ubuntu.
  • Click Browse... and select your private key.
  • Click Rename in the bottom left-hand corner and give this site a name such as DLU Server.
  • Click Connect and you should now be connected to your VPS.

Ubuntu Setup

Updating Packages

  • Update your package information using:
sudo apt update && sudo apt upgrade -y

Install Dependencies

  • Install DLU software dependencies using:
sudo apt-get install -y git gcc cmake zlib1g-dev build-essential mariadb-server sqlite python3 python3-pip net-tools unzip dos2unix tmux

Get DLU Server Files

Clone the Repository

  • Clone the DarkflameServer Repository to your ubuntu directory using:

If you have just logged in, you should already be in your ubuntu directory. You can verify by using pwd. The output should be /home/ubuntu.

git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer

Build the Repository

  • Go to the DarkflameServer directory and create a folder called build.
# Navigate to the DarkflameServer directory
cd DarkflameServer
  • Make a directory called build and navigate to it.
# Make the build directory
mkdir -p build

# Navigate to the build directory
cd build
  • Compile the DLU server files.
# Run CMake to generate needed files
cmake ..

# Run make to build the server files
make

This will take a very long time if you are using a frree VPS, as it only one core. If your VPS has more than one core, you can append -j to the end of make to utilize more cores. Ex. -j4

Server Setup

MySQL Database

  • While still in the build directory, start the MySQL service.
sudo service mysql start
  • Run the MySQL Secure Installation script.
sudo mysql_secure_installation
  • You will be asked several questions to setup MySQL. Answer them like this.
# Enter current password for root (enter for none):
<enter>

# Set root password? [Y/n]
y

# New password:
<password>

# Re-enter new password:
<password>

# Remove anonymous users? [Y/n]
y

# Disallow root login remotely? [Y/n]
n

# Remove test database and access to it? [Y/n]
y

# Reload privilege tables now? [Y/n]
y
  • Login to MySQL as the root user.
sudo mysql -u root
  • Create a database for the server to use. You can change the database name if you'd like.
# Create a database
# USAGE: CREATE DATABASE <database name>;
CREATE DATABASE DLU;

# Set it as your active database
# USAGE: USE <database name>;
USE DLU;

# Setup the database based on DarkflameServer files
SOURCE ../migrations/dlu/0_initial.sql;
  • Create a user for the server to use. You can change the user credentials if you'd like.
# Create a user for the server to use
# USAGE: CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
CREATE USER 'dluserver'@'localhost' IDENTIFIED BY 'darkflame';

# Give the user permission for the database
# USAGE: GRANT ALL PRIVILEGES ON <database>.* TO '<username>'@'localhost';
GRANT ALL PRIVILEGES ON DLU.* TO 'dluserver'@'localhost';

# Flush out the privileges
FLUSH PRIVILEGES;

# Exit MySQL
exit

Resource Setup

  • In the build directory, make a new directory called res and navigate to it.
# Make the res directory
mkdir -p res

# Navigate to the res directory
cd res
  • Open your SFTP Client and connect to your VPS.
  • Navigate to home/ubuntu/DarkflameServer/build/res on your VPS (right pane).
  • Navigate to the res directory in your unpacked client on your PC (left pane).
  • Copy macros, BrickModels, chatplus_en_us.txt, names, and maps from your unpacked client's res directory over to the newly created res directory on your VPS.

This can take a few minutes because of all the individual files. To speed it along, you can zip the required files on your PC, move the zip to your VPS, and unzip it using unzip res.zip in the directory your zip file is in.

Navmesh Setup

  • Unzip the navmeshes.zip file into your build/res/maps directory
unzip ../../resources/navmeshes.zip -d maps

Locale Setup

  • Navigate to the build directory and make a directory called locale.
# Make the locale directory
mkdir -p locale
  • On your SFTP Client, navigate to the locale directory in your unpacked client.
  • Copy the locale.xml file to the locale directory on your VPS.

CDServer.sqlite Setup

  • On your SFTP Client, navigate to the res directory in your unpacked client.
  • Locate the cdclient.fdb file and copy it to the build directory on your VPS.
  • Navigate to the ubuntu directory on your VPS and install lcdr's utils.

The ubuntu directory is located one level above the DarkflameServer directory.

# Install lcdr's utils and all of its dependencies
pip3 install git+https://github.com/lcdr/utils

# Clone lcdr's utils to your ubuntu directory to make them easy to access
git clone https://github.com/lcdr/utils
  • Once lcdr's utils are installed, convert the cdclient.fdb file to a sqlite file.
python3 utils/utils/fdb_to_sqlite.py DarkflameServer/build/cdclient.fdb --sqlite_path DarkflameServer/build/res/CDServer.sqlite
  • After the file is converted, navigate to the build directory and run these commands.
sqlite3 res/CDServer.sqlite < "../migrations/cdserver/0_nt_footrace.sql"
sqlite3 res/CDServer.sqlite < "../migrations/cdserver/1_fix_overbuild_mission.sql"
sqlite3 res/CDServer.sqlite < "../migrations/cdserver/2_script_component.sql"

If nothing happens after you run each command, then you did it right.

Chat Fix

  • There is a problem with gmlevel 0 users and chat.
  • To fix this, navigate to the res directory and run dos2unix chatplus_en_us.txt.
  • Chat should now work.

Server Configurations

  • Navigate to the build directory.
  • Edit the worldconfig.ini using the nano <filename> command to include your database login credentials.
  • NOTE: You can enable single-player racing by setting solo_racing= to 1. This is not required (iEvillan).
# MySQL connection info:
mysql_host=localhost
mysql_database=DLU
mysql_username=dluserver
mysql_password=darkflame
  • Edit the authconfig.ini and chatconfig.ini using the nano <filename> command to include your database login credentials and public IP.

This is the same one as your used in your SSH client.

# MySQL connection info:
mysql_host=localhost
mysql_database=DLU
mysql_username=dluserver
mysql_password=darkflame

# The public facing IP address. Can be 'localhost' for locally hosted servers
external_ip=<public ip>
  • Edit the masterconfig.ini using using the nano <filename> command to include your database login credentials, public IP, and enable sudo for the auth, chat, and world configurations.
# MySQL connection info:
mysql_host=localhost
mysql_database=DLU
mysql_username=dluserver
mysql_password=darkflame

# The public facing IP address. Can be 'localhost' for locally hosted servers
external_ip=<public ip>

# Use sudo when launching the auth server.
# Required by default if on Linux as auth runs on port 1001
use_sudo_auth=1

# Use sudo when launching the chat server
use_sudo_chat=1

# Use sudo when launching world servers
use_sudo_world=1

Firewall Setup

  • These instructions are only needed if your Ubuntu installation came with an already configured firewall (Oracle Cloud).
  • If sudo ufw status comes back as inactive, you can ignore UFW.
  • If sudo iptables -L comes back looking like the following, you can ignore IPTables.
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

UFW

  • If you are using UFW as your firewall, run these commands to open the correct ports.
sudo ufw allow 1000:1001/udp
sudo ufw allow 2000:2200/udp
sudo ufw allow 3000:3200/udp

sudo ufw allow 5000/tcp

IPTables

  • Navigate to the ubuntu directory and backup your current firewall settings.
sudo iptables-save > FirewallBackup.rules
  • Enable all of the required ports for DarkflameServer and AccountManager.
# Enable ports required by DarkflameServer and AccountManger
sudo iptables -I INPUT 1 -p tcp -m multiport --dports 5000 -j ACCEPT
sudo iptables -I INPUT 1 -p udp -m multiport --dports 1000,1001,2000:2200,3000:3200 -j ACCEPT
  • Login as the root user and save the firewall configuration as the default.
# Login as the root user
sudo su

# Save the firewall configuration as the default
iptables-save > /etc/iptables/rules.v4

# Exit the root user
exit

Client Setup

  • You can find the official guide here.

boot.cfg

  • In your unpacked client, find the boot.cfg file.
  • Open it in a text editor, such as Notepad++.
  • Find where it says AUTHSERVERIP=0:localhost,.
  • Replace localhost with your public IP.
  • Save and exit the file.

Survival Minigame Fix

  • In your unpacked client, navigate to res/scripts/ai/minigame/survival.
  • Right-click on the l_zone_survival_client.lua file and click properties.
  • Under attributes, make sure Read-only is unchecked.
  • Open l_zone_survival_client.lua with a text editor.
  • Scroll down to line 617 (near the bottom).
  • Change PlayerReady(self) to onPlayerReady(self).
  • Save and exit the file.

Brick-By-Brick Building

Brick-By-Brick Building on properties can soft-lock your character. Users beware.

  • In your unpacked client, find the boot.cfg file.
  • Open it in a text editor, such as Notepad++.
  • Find where it says PATCHSERVERIP=0:localhost,.
  • Replace localhost with 404.maxoverlack.dev
  • Save and exit the file.

Admin Account Creation

  • Navigate to the build directory on your VPS.
  • Run ./MasterServer -a to make an admin account.
  • You will be prompted to enter a username and password.

Installing AccountManager

Clone the Repository

  • In the ubuntu directory, clone the AccountManager repository.
# Clone the AccountManager repository
git clone https://github.com/DarkflameUniverse/AccountManager

Install Dependencies

  • Run sudo apt-get install -y python3-testresources to install a dependency.
  • Enter the AccountManager directory that was just cloned from the repository.
  • Run pip3 install -r requirements.txt to install the dependencies.

Create credentials.py

  • In the AccountManager directory, create the credentials.py file using the nano <filename> command.
  • The SECRET_KEY can be any string of numbers and characters.
  • Make sure to enter your database credentials.
# credentials.py

# Make sure this is a long random string
SECRET_KEY = 'long-random-string'

# Replace instances of <> with the database credentials
DB_URL = 'mysql+pymysql://<mysql-user>:<mysql-password>@<mysql-host>/<mysql-database>'

You can copy-paste in PuTTY by copying your text, and using right-click to paste.

Create resources.py

  • In the AccountManager directory, create the resources.py file using nano <filename> command.
# resources.py

# Path to the logo image to display on the application
LOGO = 'logo/logo.png'

# Path to the privacy policy users have to agree to
PRIVACY_POLICY = 'policy/Privacy Policy.pdf'

# Path to the terms of use users have to agree to
TERMS_OF_USE = 'policy/Terms of Use.pdf'
  • AccountManager should now be installed.

Managing DLU & AccountManager

  • Run tmux ls to see if the dlu-server or dlu-accountmanager sessions are already running.
  • If they are already running, skip the tmux new -s <session name> step.
  • If you get an error saying error connecting to /tmp//tmux-1001/default (No such file or directory), continue as though the sessions are not already running.

Starting DLU

  • Run the command tmux new -s dlu-server to start a new session.
  • In the new session, navigate to the DarkflameServer/build directory.
  • Run sudo ./MasterServer to start the server.
  • Press CTRL + B and then D to detach from the session.
  • You can reattach to the dlu-server session with tmux a -t dlu-server. This will let you see the server console.
  • Your server should now be running.

Stopping DLU

  • Reattach to the dlu-server session with tmux a -t dlu-server.
  • Press CTRL + C to stop the server.
  • Press CTRL + B and then D to detach from the session.

Updating DLU

UPDATING THE SERVER IS DONE AT YOUR OWN RISK

  • When the DarkflameServer repository is updated, you'll need to pull the changes and recompile.
  • Stop your server using the steps above.
  • Stop your MySQL database with service mysql disable.
  • In the DarkflameServer directory, pull the changes with git pull --recurse-submodules.
  • If any changes are in the migrations folder, you'll have to redo that files SQL command as well.
  • Refer to Build the Repository for re-building the server.
  • Refer to MySQL Database or CDServer.sqlite for any migration file commands.
  • Start your MySQL database with service mysql enable.

Starting AccountManager

  • Run the command tmux new -s dlu-accountmanager to start a new session.
  • In the new session, navigate to the AccountManager directory.
  • Run python3 app.py to start AccountManager.
  • Press CTRL + B and then D to detach from the session.
  • You can reattach to the dlu-accountmanager session with tmux a -t dlu-accountmanager. This will let you see the AccountManager console.
  • AccountManager should now be running.

Accessing AccountManager

  • You can access the AccountManager from your web browser.
# Login as an Admin and create CD keys
http://yourpubliciphere:5000/login

# Create a new account as a non-admin user
# You will require a CD key from the admin login
http://yourpubliciphere:5000/activate

Stopping AccountManager

  • Reattach to the dlu-accountmanager session with tmux a -t dlu-accountmanager.
  • Press CTRL + C to stop the server.
  • Press CTRL + B and then D to detach from the session.

Contributions

Elocore#9700

  • Created a video tutorial that help me make this guide.
  • Check it out here.

Deleted User d183a1c4#7217

  • Created a guide that help me make this guide.
  • Check it out here.

Majo#4443

  • Providing a Brick-By-Bricking Building solution that forgoes the need to have an HTTP server running.

iEvillan

  • Suggestion to add the fix for the gmlevel 0 user chat issue.
  • Suggestion to add that you can turn on single-player races in the worldconfig.ini.
  • Clarification that these instructions work on ALL VPS, not just Oracle Cloud.
@christopherpsterry
Copy link

Excellent write-up! It was very clear and informative ;)

To clarify for other readers, this works for ALL VPS, not just Oracle.

One thing I would consider adding is a quick fix for the chat problem for gmlevel 0 users, which is to install dos2unix with sudo apt install dos2unix and run dos2unix chatplus_en_us.txt in /build/res before restarting the server.

Another note is that it's possible to run AccountManager and MasterServer at the same time if you want to do that, I saw a script on discord for that purpose and there are also hacky ways to do that.

@simondumalski
Copy link
Author

@iEvillan Thanks for the comment! Have a question for you!

  • For the chat fix using dos2unix, does that command need to be executed while the server is running, and then you restart DLU after?
    If I stumble across the AccountManager and MasterServer script you were mentioning, I'll add that here!

@christopherpsterry
Copy link

Stop the server and run the command before restarting it.

Another thing I thought of is maybe a note that you can toggle single-player races in worldconfig.ini under the solo_racing variable.

@Angoose884
Copy link

For the AccountManager requirements the command should be "pip3 install -r requirements.txt" if you're already in the AccountManager directory (which it says to go to in the previous step).

@simondumalski
Copy link
Author

@Angoose884 good catch! Thanks for letting me know.

@Angoose884
Copy link

Could you also add a note for the Ubuntu section that you should be using the PuTTY window? It should be pretty obvious, but I already had Ubuntu installed from a different server attempt and went through that whole section entering commands into my Ubuntu application instead, so I had to do it over again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment