Comprehensive Guide to Building a SWGEmu Server on Debian 11 (Bullseye)

This guide provides detailed instructions to help you build and configure a SWGEmu server on a Debian 11 virtual machine. All necessary steps, including the installation of dependencies and key configurations, are covered to ensure a smooth setup process.


Table of Contents

  1. Prerequisites
  2. Step 1: Download and Install Debian 11 Cinnamon
  3. Step 2: Update Your System
  4. Step 3: Install Essential Build Tools and Dependencies
  5. Step 4: Clone the SWGEmu Core3 Repository
  6. Step 5: Configure the Build Environment
  7. Step 6: Compile the Server
  8. Step 7: Set Up the Database
  9. Step 8: Configure the Server
  10. Step 9: Copy Game Data Files
  11. Step 10: Run the Server
  12. Additional Tips
  13. Resources
  14. Conclusion

Prerequisites


Step 1: Download and Install Debian 11 Cinnamon

Begin by downloading Debian 11 Cinnamon from the official Debian archives:

Install Debian 11 Cinnamon on your machine. You can choose to install it on:

Follow the Debian installation prompts to complete the setup. Ensure that you have administrative (sudo) privileges on the installed system.


Step 2: Update Your System

After installation, update your package lists and upgrade existing packages to ensure your system is up to date.

sudo apt update && sudo apt upgrade -y

Step 3: Install Essential Build Tools and Dependencies

Install the necessary packages required for building the SWGEmu server.

sudo apt install -y build-essential git cmake zlib1g-dev liblua5.3-dev \
libboost-all-dev libssl-dev libdb5.3-dev default-jdk libmariadb-dev libmariadb-dev-compat

Explanation:


Step 4: Clone the SWGEmu Core3 Repository

Clone the Core3 repository from GitHub and switch to the unstable branch.

cd ~
git clone https://github.com/swgemu/Core3.git
cd Core3
git checkout unstable

Verify the Branch:

git branch

Expected Output:

* unstable

Step 5: Configure the Build Environment

The CMakeLists.txt file is located inside the MMOCoreORB directory.

5.1: Navigate to the Correct Directory

cd ~/Core3/MMOCoreORB

5.2: Create and Enter the Build Directory

mkdir build
cd build

5.3: Run CMake with Build Type

Run CMake to configure the build system, specifying the build type.

cmake -DCMAKE_BUILD_TYPE=Release ..

Explanation:


Step 6: Compile the Server

Start the compilation process.

make -j$(nproc)

Explanation:


Step 7: Set Up the Database

SWGEmu requires a database to store game data. We'll use MariaDB, which is a drop-in replacement for MySQL.

7.1: Install MariaDB Server

sudo apt install -y mariadb-server

7.2: Secure the MariaDB Installation

Run the security script to improve MariaDB security.

sudo mysql_secure_installation

During the script:

7.3: Create the SWGEmu Database and User

Log into MariaDB as root:

sudo mariadb -u root -p

Enter the root password you set during the secure installation.

Inside the MariaDB shell, execute the following commands:

CREATE DATABASE swgemu;
CREATE USER 'swgemu'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON swgemu.* TO 'swgemu'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace 'your_password' with a strong password of your choice.

7.4: Import the Database Schema

Navigate to the sql directory and import the schema.

cd ~/Core3/MMOCoreORB/sql
mysql -u swgemu -p swgemu < swgemu.sql
mysql -u swgemu -p swgemu < datatables.sql

Enter the password for the swgemu user when prompted.


Step 8: Configure the Server

Update the server configuration to match your setup.

8.1: Locate the Configuration Directory

cd ~/Core3/MMOCoreORB/bin/conf

8.2: Edit the Configuration File

nano config.lua

8.3: Update Configuration Settings

Modify the following sections in config.lua:

Main Database Config

Update the database credentials to match those you set up in Step 7:

DBHost = "127.0.0.1",
DBPort = 3306,
DBName = "swgemu",
DBUser = "swgemu",
DBPass = "your_password",

Ensure DBPass matches the password you set for the swgemu database user.

DBSecret

Change DBSecret to a unique and reasonably long value. This secret is used for internal authentication between server components.

DBSecret = "your_unique_secret", -- Change this! This value should be unique and of reasonable length.

Replace "your_unique_secret" with a strong, unique string.

Login Server Config

Adjust the LoginRequiredVersion if necessary. This should match the client version you're using.

LoginRequiredVersion = "20050408-18:00",

If you're using a different client version, update this accordingly.

Mantis Database Config (Optional)

If you're not using Mantis for bug tracking, you can leave these settings as they are or comment them out.

-- MantisHost = "127.0.0.1",
-- MantisPort = 3306,
-- MantisName = "swgemu",
-- MantisUser = "swgemu",
-- MantisPass = "123456",
-- MantisPrfx = "mantis_", -- The prefix for your mantis tables.

8.4: Save and Exit

After making the necessary changes, save and exit the editor.

In nano, press Ctrl+X, then Y, then Enter.


Step 9: Copy Game Data Files

Before running the server, you need to provide the necessary game data files. The SWGEmu server requires the original game .tre files to function correctly.

9.1: Prepare the Game Data Files

9.2: Place the Files in the Correct Directory

By default, the server looks for the .tre files in a specific directory. The expected directory is:

/home/your_username/Desktop/SWGEmu/

You can either use this default directory or specify a custom path in the server's configuration.

Option 1: Use the Default Directory

Option 2: Specify a Custom Directory in Configuration

9.3: Verify File Permissions

Ensure that the server has read access to the .tre files.

chmod 644 /path/to/your/tre/files/*.tre

Step 10: Run the Server

Navigate to the bin directory and start the server.

cd ~/Core3/MMOCoreORB/bin
./core3

Note: The server runs in the foreground. To stop it, press Ctrl+C.


Additional Tips

Firewall Configuration

If your server needs to accept external connections, configure your firewall accordingly.

Note: If you build your VM using the 'NAT' network mode, you will also have to add port forwarding rules inside the VirtualBox VM settings before traffic will be passed to the VM. You can find this under VM Settings -> Network -> Adapter1 -> Port Forwarding
sudo apt install -y ufw
sudo ufw allow 44419/tcp
sudo ufw allow 44419/udp
sudo ufw allow 44453/tcp
sudo ufw allow 44453/udp
sudo ufw allow 44455/tcp
sudo ufw allow 44455/udp
sudo ufw allow 44462/tcp
sudo ufw allow 44462/udp
sudo ufw allow 44463/tcp
sudo ufw allow 44463/udp
sudo ufw enable

Check Firewall Status:

sudo ufw status

If you are running swgemu as a VM, you will also need to allow the ports on the Windows host firewall. Here is a quick Powershell script to add them.


    # Add both TCP and UDP on Port 44419 - Inbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Inbound Port 44419" -Direction Inbound -Protocol TCP -LocalPort 44419 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Inbound Port 44419" -Direction Inbound -Protocol UDP -LocalPort 44419 -Action Allow
    
    # Add both TCP and UDP on Port 44419 - Outbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Outbound Port 44419" -Direction Outbound -Protocol TCP -LocalPort 44419 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Outbound Port 44419" -Direction Outbound -Protocol UDP -LocalPort 44419 -Action Allow
    
    # Add both TCP and UDP on Port 44453 - Inbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Inbound Port 44453" -Direction Inbound -Protocol TCP -LocalPort 44453 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Inbound Port 44453" -Direction Inbound -Protocol UDP -LocalPort 44453 -Action Allow
    
    # Add both TCP and UDP on Port 44453 - Outbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Outbound Port 44453" -Direction Outbound -Protocol TCP -LocalPort 44453 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Outbound Port 44453" -Direction Outbound -Protocol UDP -LocalPort 44453 -Action Allow
    
    # Add both TCP and UDP on Port 44455 - Inbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Inbound Port 44455" -Direction Inbound -Protocol TCP -LocalPort 44455 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Inbound Port 44455" -Direction Inbound -Protocol UDP -LocalPort 44455 -Action Allow
    
    # Add both TCP and UDP on Port 44455 - Outbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Outbound Port 44455" -Direction Outbound -Protocol TCP -LocalPort 44455 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Outbound Port 44455" -Direction Outbound -Protocol UDP -LocalPort 44455 -Action Allow
    
    # Add both TCP and UDP on Port 44462 - Inbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Inbound Port 44462" -Direction Inbound -Protocol TCP -LocalPort 44462 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Inbound Port 44462" -Direction Inbound -Protocol UDP -LocalPort 44462 -Action Allow
    
    # Add both TCP and UDP on Port 44462 - Outbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Outbound Port 44462" -Direction Outbound -Protocol TCP -LocalPort 44462 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Outbound Port 44462" -Direction Outbound -Protocol UDP -LocalPort 44462 -Action Allow
    
    # Add both TCP and UDP on Port 44463 - Inbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Inbound Port 44463" -Direction Inbound -Protocol TCP -LocalPort 44463 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Inbound Port 44463" -Direction Inbound -Protocol UDP -LocalPort 44463 -Action Allow
    
    # Add both TCP and UDP on Port 44463 - Outbound
    New-NetFirewallRule -DisplayName "SWGEmu TCP Outbound Port 44463" -Direction Outbound -Protocol TCP -LocalPort 44463 -Action Allow
    New-NetFirewallRule -DisplayName "SWGEmu UDP Outbound Port 44463" -Direction Outbound -Protocol UDP -LocalPort 44463 -Action Allow
    

Logs and Debugging

Check logs for any errors or issues.

cd ~/Core3/MMOCoreORB/log
ls -l

Open log files with a text editor or view them with less:

less filename.log

Resources