SWGEmu – 2019 Verbose Server Setup Guide (for Devuan Linux)

Far and away, the most popular post on this blog has been the original “SWGEmu Verbose Server Setup Guide“, so as a sort of parting gift to the handful of readers of this blog, I figured I would post an up to date version of the guide that works with the current iteration of the SWGEmu source code. I’ve decided to keep the blog live after I stop paying for “no-ads”, but I will be posting new content over on GitHub Pages rather than here.

SWGEmu Simple Server Setup using Devuan 2.0 ASCII

This guide is for people who want to setup a custom SWGEmu server, but aren’t interested in using SWGEmu project’s ZonamaDev tool. If you plan on contributing to the SWGEmu project, it’s better to use ZonamaDev, because it’s the standardized work environment for their project and they will help you solve problems with it. Using this guide will give you a working system that will build and run the server code, but you’re on your own for tech support.

Devuan 2.0 is Debian 9 without SystemD. It uses Xfce as its default desktop environment, which is convenient, because it’s both efficient and easy to use. While one could setup a server and build environment without a GUI, Xfce is so small and handy that it may as well be used, given how powerful and cheap PCs are these days.

Keep in mind that it’s not a good idea to use the generic passwords that I have provided in this guide if you’re going to be using the resulting system to host a public server!

1. Download and install VirtualBox
– I used version 5.2.16 in Window 10 Home 64Bit

2. Doanload the “netinst” network installer image for Devuan
Main Page: https://devuan.org/get-devuan
Direct File: https://mirror.leaseweb.com/devuan/devuan_ascii/installer-iso/devuan_ascii_2.0.0_amd64_netinst.iso

3. Open VirtualBox and create a new virtual machine.
– Click the New button
– Name: My SWGEmu Server
– Type: Linux
– Version: Debian 64bit
– Memory: 2048MB minimum, more is better though, so use most or all of the green area if you won’t be doing much with the host system as well.
– Create a new virtual hard disk now
– VDI (VirtualBox Disk Image)
– Dynamically allocated
– 20GB

The final size of the VirtualBox image file will only be about 6GB on the disk, but it can expand up to 20GB without you needing do anything, which is nice – probably unnecessary, but a nice potential time saver down the road.

4. Configure the setting of the new virtual machine.
– Click the settings button

General Window > Advanced Tab
– Shared Clipboard: Bidirectional

System Window > Processor Tab
– CPU Slider: Set it to the max green area.

If you have 6-8 CPUs available, but only 3 or 4 are shoring in the green area, in my experience with AMD FX processors, it’s safe to use up to 4 of 6 or 6 of 8. More CPUs exposed to the virtual machine will reduce the compile time of the SWGEmu server considerably.

– Extended Features: Enable PAE/NX

System Window > Acceleration
– Paravirtualization Interface: Default
– Hardware Virtualziation: Enable VT-x/AMD-V and Enable Nexted Paging.

Display Window > Screen Tab
– Video Memory: 64MB or more

Storage Window
– Background Information: This is where you can add “loop back file systems”, in the form of a new VDI files, which can be mounted in Linux as extra storage. The nice thing about Unix-like operating systems is that other devices, such as remote computers, other hard drives, or one of these loop back files, are seamlessly grafted onto the file system, so the OS treats it like any other part of the file system. You can use this for such things as using “mount bind in your fstab file” to put the Berkeley DB files for the server into their own file or just having a handy Linux formated backup file that is located on a different hard drive than the VDI file for your OS.
I personally have a small solid state drive (SSD), so I have my OS VDI file on the SSD with only a 512MB swap partition inside it to save space on the SSD. To augment the limited amount of swap space, I have another 8GB VDI file on my much larger normal hard drive, which acts as a Linux swap file. Linux allows for setting the priority of swap space, so it will first write to the fast 512MB on the SSD, and if that gets full it will use the slower, larger 8GB on the hard drive. Generally speaking, the swap space rarely gets used at all, even when compiling. There’s lots of powerful customizations you can come up with here, if you’re willing to research on how to use it!

– Storage Tree: Click your FILENAME.vdi and if it is installed on an SSD, put a check in the Solid-state Drive box that pops up on the right side of the window.

Network Window > Adapter 1 Tab
– Attached to: Bridged Adapter

This will allow the virtual machine to get an IP address directly from your router, but we are going to setup a static ip address in Linix so that the game client can always find the server.

Shared Folders Window
– To save some sanity and storage space, you can have one folder to store the TRE files for both the game client and the server. It’s really easy to do by first sharing the game client folder in Windows (right click the folder > Properties > Sharing Tab > Share button > choose “Everyone” in the drop down and click the Share button), then accessing that shared folder from Linux in the virtual machine. . The Windows share will need to be given a name, I suggest calling it SWGEmu.

– Click the [+] button the right
– Folder Path: Other > Navigate to where you have SWGEmu installed > OK > OK

5. Install Devuan Linux
– Make sure you are connected to the internet.
– Select your VM and click the Start button
– In the Select Startup Disk window, navigate to where you saved the iso file for Devuan, select it, press Open, press Start
– Use the keyboard arrow keys to select Graphical Install and hit the Enter key.
– Language: Select yours!
– Country: Select yours!
– Keyboard Conig: American English is the default
– *wait a while*
– Host Name: swgemu (or any other single word you’d like)
– Domain name: leave it blank
– Root Password: 123456 or anything else you would like. 🙂
– Username: swgemu
– Username for account: swgemu
– User password: 123456 or anything else you would like. 🙂
– Timezone: Select yours!
– Partitioning: Guided – Use entire disk

If you know lots about Linux or you want a custom partition setup, this is the step where you can set that up. There are lots of guides on the internet to help you with this step. However, the default “Guided – Use entire disk” will suffice!

– Had disk selection: It’s the VDI you created earlier, so just click continue.
– Partitioning: All files in one partition (recommended for new users)
– Partitioning: Finish partitioning and write changes to disk
– Warning Message: Select Yes, press Continue again. 🙂
– *wait a while*
– Configure Package Manager: Select your country
– FTP Mirror: default Devuan mirror
– HTTP Proxy: Generally speaking, leave this blank. If you need to setup such a thing, look up how to do so on the internet.
– *wait a while*
– Popularity Contest: No
– Software Selection: Devuan desktop environment, Xfce, standard system utilities
– *wait a while*
– Grub boot loader: Yes
– Device for boot loader installation: /dev/sda (the VDI hard drive)
– Installation Complete: Continue and the system will reboot

6. Configure the desktop
– First system boot: login with swgemu / your password
– Panel (toolbar) config popup: Select single empty panel
– Grab the panel drag it to the top or bottom of the screen.

– Right click Panel > Panel Preferences
– Set the length to 100%, Row Size to 26 or so, and click Lock Panel
– Click the Items tab in the and add the following stuff to the toolbar: Applications Menu, Window Buttons, Separator, CPU Graph, Notification Area, Workspace Switcher. Feel free to add anything else you’d like too, of course.

– Right click the Separator on the Panel (it’s a vertical line) > Properties > click the Expand box and change the style to Transparent if so desired. This makes the Panel function the same as the Windows Taskbar.

7. Configure the Sudo
– Open a terminal and add the swgemu user account to the sudoers file
*enter password for the root user account*
*arrow down to the line below root ALL=(ALL:ALL) ALL and type*
swgemu ALL=(ALL:ALL) ALL
*ctl+x, yes save the file, press enter*
sudo apt-get update
*enter password for the swgemu user account*

The system is already up to date, due to the network installer downloading the latest versions of everything! 🙂

8. Configure VirtualBox
– Install the system software we will need to use the VirtualBox Guest Additions
– Open a terminal
sudo apt-get install build-essential dkms linux-headers-amd64 linux-headers-4.9.0-6-amd64

– In the VirtualBox window click Devices > Insert Guest Additions CDROM image…
– Applications Menu > File Manager
– In the File Manager click the CD icon that is labeled VBox_GAs… to mount the CDROM image.
– File > Open Terminal Here
– In the terminal type
sudo sh VBoxLinuxAdditions.run
– reboot (Applications Menu > Logout > Restart)
– Login again and rejoice in your ability to copy and paste between the host and the guest!
– Open a terminal and add the user to the VirtualBox share group so it can access the Windows shared directory.
sudo adduser $USER vboxsf

9. Install the other software that is required and is available from Devuan/Debian
– Open a terminal
sudo apt-get install git autoconf libdb5.3-dev gdb libtool libreadline-dev libdb-dev libssl-dev libboost-dev openjdk-8-jre openjdk-8-jre-headless mariadb-server-10.1 mariadb-server-core-10.1 libboost-dev libdb5.3 libmariadbclient-dev-compat cmake
– This will install a bunch of other packages automatically, which is normal/good.

10. Install Lua 5.3.2 from source
– Open a terminal
cd ~/Downloads
wget https://www.lua.org/ftp/lua-5.3.2.tar.gz
*wait for it to download*
tar xvzf lua-5.3.2.tar.gz
cd lua-5.3.2
sudo make linux install

– If it gives the errors:
install: cannot stat ‘lua’: No such file or directory
install: cannot stat ‘luac’: No such file or directory
– just press the up arrow and run “sudo make linux install” and it will properly copy the newly compiled binary files to the system directories…

11. Clone the SWGEmu server software
– Open a terminal
mkdir workspace
cd workspace
git clone http://review.swgemu.com/p/PublicEngine.git
*wait a while*
git clone http://review.swgemu.com/p/Core3.git
*wait a while*

You now have two new directories with the SWGEmu software:

12. Configure the SWGEmu environment
– Build the idl compiler and put it in the system path
– Open terminal
cd ~/workspace/PublicEngine/MMOEngine
chmod +x bin/idlc
sudo cp bin/idlc /usr/local/bin/idlc
– Add the idl compiler to the class path so Java can find it
echo ‘export CLASSPATH=”/home/swgemu/workspace/PublicEngine/MMOEngine/bin/idlc.jar”‘ >> /home/swgemu/.profile

Update 2019.05.27: Benjamin Castelli kindly wrote to me (thanks!) to indicate that he had to do the following to get the class path to work for the IDL compiler:
– Add CLASSPATH=”/home/swgemu/workspace/PublicEngine/MMOEngine/bin/idlc.jar” to /etc/environment

– Add a symbolic link to MMOEngine so Core3 can find it
cd ~/workspace/Core3
ln -s ../PublicEngine/MMOEngine MMOEngine
– reboot

13. Configure and build SWGEmu
– Open a terminal
cd ~/workspace/Core3/MMOCoreORB
git checkout unstable
git pull
– Note: You should have already been on the unstable branch and up to date.
make config
make cleanidl
make -j4 build-cmake
– Note: use make -j# where # is the number of cores you allocated to the virtual machine. When in doubt, count the bars in the CPU graph on the Panel.
*wait a while*

14. Give the server access to the game client files
– The server references a significant amount of data directly from the files that get installed with the game itself (“TRE” files). As such, you will need to install SWG from your original CDs, download the official SWGEmu launcher, and run the launcher so it can update your SWG installation to be compatible with SWGEmu.
– As suggested in step 4, you can simply point your virtual machine to the Windows folder where you installed SWGEmu, thus granting the server access to the TRE files that it needs. Alternately you can open that shared folder from the VM and copy the TRE files into the VM itself. I’ll describe how to do both; you can choose which suits your needs.

Pointing to the TRE files on the Windows host system:
– The windows share is automatically mounted at /media/sf_SWG
– Open /home/swgemu/workspace/Core3/MMOCoreORB/bin/conf/config.lua (with the default text editor, Mousepad, by double clicking the file).
– Scroll down to
TrePath = “/home/swgemu/Desktop/SWGEmu”
– and change it to
TrePath = “/media/sf_SWG”
– Save the file and close it.

Copying the TRE files into the virtual machine:
– Open a terminal
mkdir ~/Desktop/SWGEmu
cp -v /media/sf_SWG/*.tre ~/Desktop/SWGEmu

15. Set a static IP Address
– In Windows open a command prompt
Start > Search Box > Type cmd > Hit the Enter Key

– Get your computer’s IP address

In the output, look for the heading Ethernet adapter Local Area Connection. Under it you will find your IPv4 address, which could look like or or on most home networks. The fist three numbers in those chains are the network address and the last number is your computer on the network. Your router (also referred to as a ‘gateway’) is most often the first device on the network, so its number would look like or etc. For your Linux VM, you want to use a unique number that won’t be used by another device as well. 87 is a safe bet!

– In the VM, create the static IP address, being sure to edit the correct ip addresses for your network.
– Open a terminal
sudo nano /etc/network/interfaces
– Arrow down and comment out the following line by putting a # before it
iface eth0 inet dhcp
– Add the following lines
iface eth0 inet static
– ctl+x to exit and save the file.
– reload the network interface to use the static ip address (or reboot)
sudo /etc/init.d/networking reload

16. Configure the MySQL database server
SWGEmu uses two database technologies, MySQL and Berkeley. The MySQL server is used to store account related information, such as character names, passwords, permission levels, and other various other bits of data. The majority of the “game data” that makes up the world, such as quest states, event timers, inventories, etc. is stored in a series of Berkeley database files. You don’t need to configure anything for the Berkeley DB, but you do need to setup the MySQL DB.

– Open up a terminal and configure the root password (to 123456). Initial password is blank. Answer Y to all questions.
sudo mysql_secure_installation

– Create the database
echo ‘CREATE DATABASE swgemu;’ | sudo mysql -uroot -p123456
echo ‘GRANT ALL ON *.* TO `swgemu`@`localhost` IDENTIFIED BY “123456”;’ | sudo mysql -uroot -p123456

– Install the SWGEmu database templates
mysql -p123456 -e source -e ~/workspace/Core3/MMOCoreORB/sql/swgemu.sql;
mysql -p123456 swgemu -e source -e ~/workspace/Core3/MMOCoreORB/sql/datatables.sql;
mysql -p123456 swgemu -e source -e ~/workspace/Core3/MMOCoreORB/sql/mantis.sql;

– Update the server IP address in the SQL database
mysql -p123456 swgemu -v -e “update galaxy set address=’′”

17. Boot the server for the first time
– Open a terminal
cd ~/workspace/Core3/MMOCoreORB/bin

– You will notice some error messages like the following, because only the planet Tatooine is enabled by default.
ERROR: Unable to load screenplay SidorasBey, zone rori is not enabled.
– If all is well, you will see the following message:
(47 s) [Core] initialized
– After that, the first time the server boots it will calculate the navigation meshes that are used by the AI, which can take a long time (and must be done for every planet).

18. Configure the game client
– Go to the directory on the host system where SWGEmu is installed…

– Edit swgemu.cfg so that it reads:
.include “swgemu_login.cfg”
.include “swgemu_live.cfg”
.include “swgemu_preload.cfg”
.include “options.cfg”
.include “user.cfg”

– Edit swgemu_login.cfg so that it points to your server:

– Edit user.cfg for Godmode, multiple instances, frame rate, and extra information when examining items:

0fd345d9 = true



19. Log into the server with the game client on the admin account
– Username: swgemu
– Password: 123456
– Log out and close the game.
– On the server, open a terminal and give the swgemu game account admin privilages
mysql -p123456 swgemu -v -e “UPDATE swgemu.accounts SET admin_level=’15’ WHERE username=’swgemu'”
– Log back into the game on the swgemu account a create a character that will now have “God Mode” privilages.

That’s all that is really needed to run a server. You could even forgo using the Xfce desktop and only install the basic command line of Devuan, but it only saves about 3GB of hard drive space by doing so, which isn’t much in today’s world. Also it should be noted that you can skip all the VirtualBox stuff and simply install Devuan directly onto the hard drive of a real computer and then copy the TRE files from your desktop to your server using a USB stick. Nothing says you must use a virtual machine, it’s just much more convenient in today’s world of multi core CPUs with 8GB+ of RAM and huge, fast storage drives.

Also of note is that I basically have fumbled my way through the SQL portion of this guide – it works, but it’s not my area of expertise. If you’re going use this guide to build a server that you plan on hosting to the public, it’s important to understand that, as with any public facing networked computer, you need to pay close attention to the configuration and security of your server. While this guide gets you a functioning SWGEmu server, it does that and ONLY that. The rest is up to you! 🙂

Update: Bad News for fellow AMD FX CPU Owners

So after playing with this setup, I discovered that compiling Core3 took literally twice as long as it used to! With the Legend of Hondo VM, based on the 2016 version of Core3 and running in a Debian 8 VM running under Windows 7 64 bit, the compile time was 492 seconds using 6 cores (as seen in this post). Today the compilation too a whopping 1140 seconds in my Devuan 2.0 guest, on a Windows 10 64bit host! WTF, eh?

Attempting to mitigate the issue, I installed the backported version of kernel 4.19, upgraded VirtualBox to 5.2.26, disabled the Spectre mitigation in Windows 10 (Meltdown is N/A for this CPU, according to Inspectre.exe, which I believe means the patch isn’t running in Windows), and added “nopti noibrs” to the kernel parameters in grub on the VM, but nothing helped.

What a bummer – compiling software with GCC was the one thing this o’l FX-8320 was great at!

For comparison, I recompiled Legend of Hondo in its Debian 8 VM on this Windows 10 host and it only took 474 seconds. That’s 2.4 times faster!

For further comparison, I compiled Core3 in a current version of the ZonamaDev environment (Debian 9 with kernel 4.9) and it also took way too long, coming in at 1061 seconds.

Well, it’s clearly not a problem with the Windows 10 host or VirtualBox. The problem is either the new version of Core3 or the new version Devuan/Debian/Linux.

Bonus: How to use Linux Kernel 4.19 in Devuan 2.0

This is something I had to do on my computer when I installed Devuan 2.0 directly, as version 4 kernels before 4.12 don’t work very well with my AMD R9 270 video card. It’s not a hard process, but it can be a bit confusing if you’ve never done it before.

1. Add the backports repo to the sources list
– Backports are software that is newer than versions that normally are available with a version of Debian/Devuan. In this case we’re using a newer version of the linux kernel itself.
– Open a terminal and type
sudo echo “deb http://deb.devuan.org/merged ascii-backports main” >> /etc/apt/sources.list
sudo echo “deb-src http://deb.devuan.org/merged ascii-backports main” >> /etc/apt/sources.list

2. Update the system
– Open a terminal and type
sudo apt-get update
sudo apt-get -t ascii-backports upgrade

3. Search for available kernels
– Open a terminal and type
apt-cache search linux-image

– This will return a list of kernel images that are available. They have specific names. At this time, we’re looking for linux-image-4.19.0-0.bpo.2-amd64, but some of the numbers might be higher by the time you read this, so change them as you need.

4. Install the kernel and kernel headers
– Open a terminal and type
sudo apt-get install linux-image-4.19.0-0.bpo.2-amd64 linux-headers-4.19.0-0.bpo.2-amd64

5. Reboot to start using the new kernel
– The system will automatically boot using the newest kernel.