Initial Setup Of The Virtual Machine VM version 3.0 ("Irish") - SWG-Source/swg-main GitHub Wiki

This guide is intended to get you from obtaining the software through to logging into the game which is running on your own server. So let's start that process by downloading some essentials.

Virtualbox

First step is to download from here: https://www.virtualbox.org/wiki/Downloads The current version as of this guide being written is 6.0.12 You will also need the client extensions from the same page, both are highlighted in this screenshot:

The next piece of the puzzle is the virtual machine image itself. The link to the current version is available in the rules-and-info channel of the SWG Source Discord server.

Pre-configuration Info Gathering

Our next key task is to collect some information about your network so that you can be ready to supply key values when the VM / server needs them during the setup phase. It is very, very easy to get lost in the weeds with this part of the process as networking can be confusing. The primary cause of that confusion is that you first need to know what information you need but then you have to understand it in the context of YOUR network. I'm going to attempt to alleviate some of that by explaining (over explaining?) each piece of information as you gather it.

Choosing a static IP Address for the VM

Your home router automatically provides devices with an IP address. It does that by having a setting known as a "DHCP Range" (Dynamic Host Configuration Protocol) and we need to know the first and last address within that range so we can choose a free / empty / vacant address for the VM. The reason we need to do that is so that at some later time if a device connects to your router it does not get assigned the same address as you chose for your VM. So the router will handle that sort of dynamic IP assignment and your VM will instead have a static IP address. The majority of home routers give out addresses in the 192.168.x.x format. You can see the range I have set up on my router in this screenshot: The DHCP range there goes from 192.168.1.20 to 192.168.1.50 so we know to avoid those addresses. We also have to take into account that the router itself has an IP address and we need to know that too.

That screenshot gives us two important pieces of information....the router's IP and the subnet mask for the network. Firstly that means that we now know to avoid 192.168.1.254 when choosing the address for the VM. Secondly we need to know why that subnet mask is so crucial.

To understand the subnet mask, if you look at that screenshot you can see how the four pieces of the IP address are paired up with the four pieces of the subnet mask. As in 192 from the IP address is matched up with the first 255 in the subnet mask. A relatively easy way to think of this IP address / subnet mask combination purpose is like how real world mail / snail mail works. The bare minimum information for a letter to be delivered in a very small town would be the street name and the house number on that street. So the subnet mask is used to split the IP address into the equivalent of a street name and a house number. Any part of the IP address that is paired with a 255 in the subnet mask is part of the "street name" and anything else left behind is the "house number". In this example that means we have 192 paired with a 255, 168 paired with a 255 and 1 paired with 255 leaving 254 paired with a 0. So that gives us the following:

street name / network address = 192.168.1.0

house number / host address = 254

The subnet mask has now served it's purpose, we can see that hosts are identified on the network by having a different number in that house number / host address slot (host is just another word for a device on the network such as a PC or VM). So....192.168.1 is the street and x.x.x.20 or x.x.x.45 or x.x.x.254 are all different houses on that street.

Having this information now allows me to choose 192.168.1.100 as the static address for the VM. Using that address will avoid the DHCP range and the router (x.x.x.20 to x.x.x.50 and x.x.x.254 for the router). We can apply that IP address to the VM in multiple ways and we will deal with those later in this guide.

Assessing Your CPU & RAM When we set up the VM later on we will need to know how many cores from the CPU and how much RAM we can / should allocate. We can get to that information in multiple ways but let's go with the quickest. Right click on any blank / empty spot of your Windows taskbar along the bottom of the screen (unless you've moved it elsewhere). Choose Task Manager from the menu. Once it is open, click on the Performance tab at the top and you will see a screen like this:

The first thing to note here is that this CPU has 8 cores and 16 logical processors (threads). So I would recommend that we would allocate 8 or less cores to the VM to avoid assigning logical processors / threads.

We can also see in that screenshot that this PC has 64GB of RAM. The recommended amount of RAM to allocate to the VM is 16GB. That assumes that you want to run all zones (ground & space) at all times. If you need to allocate less RAM because your computer cannot afford 16GB then you can test that out by cutting down to 14GB or 12GB and seeing what the VM performance is like. The easier way to do that is just assign something like 4GB to the VM and then disable all but one or two zones in the cfg files within the VM (more on that later). For testing purposes I have run the VM with 4GB RAM allocated and just Tatooine (ground & space) active, that allows me to test something and restart the server quite quickly as I'm not trying to reload every zone for each reboot. In other words, there is some personal choice here in order to tailor the performance / experience to your particular setup.

Importing The OVA File

The OVA (Oracle Virtual Appliance) file that you downloaded earlier needs to be imported into Virtualbox so that we can then get the SWG server up and running. The process is relatively straight forward. First things first, open up Virtualbox then use the option to "Import Appliance":

Click the folder icon to open up the menu where you can navigate to where you downloaded the OVA file earlier, it looks like this:

Click Next and you will be presented with a screen where you can specify what resources are allocated to the VM. This is where the CPU and RAM info we gathered earlier will come into play.

You can adjust up or down the amount of CPU cores allocated and also the amount of system RAM to suit your personal preference and / or system capabilities. Once you have completed your selections click Import.

Wait for the dialog box to show progress has been completed so we can continue on to the next portion of the process.

Setting Up The Virtual Hardware

This section is all about making final adjustments to the VM before we boot it up. Open up Virtualbox, locate the VM in the list and click on Settings.

Let's start by setting up the VM to allow us to copy and paste text into and out of it. This isn't a requirement but the functionality of having this feature can come in handy. Click General and then open the Advanced tab. Set the "Shared Clipboard" and "Drag 'n' Drop" to Bidirectional.

We now have another opportunity to adjust the RAM allocation, click System and then Motherboard:

Next up is System and then Processor where we have another chance to adjust the CPU core allocation:

This next one is critical to get right. Click Network and then Adapter 1:

The important settings in here are "Attached To" and "Name".

Having "Attached To" set to use the network card your PC uses to get to the internet is what allows the VM to piggyback on that internet connection in order to access the software repositories and download the components of the SWG Server.

The "Name" field is where you identify the specific network card that your PC is using to access the internet, not the VM, the actual physical network card in your PC that is connected to your router.

There is one more useful piece of information in this screen that we can use for something advanced later on. Take note of the MAC Address field here. You can copy and paste the value into a text file if you choose to. This can later be used to inform your router that when it sees a request from this MAC Address to be assigned an IP Address that a specific one should be provided, this is known as a DHCP Reservation but that's not needed at this point in the process.

This next one is optional too, it allows for faster USB transfer rates by allowing the VM to use USB 3.0 which can be helpful when transferring files into and out of the VM using USB devices. Go to USB then select USB 3.0 (xHCI) Controller:

Yet another optional piece comes up next, the ability to have a folder sitting on your PC which shows up inside the VM too. This is the method I typically use when doing dev / restoration work inside the VM and find myself needing to share files back and forth. Go to Shared Folders and you will see this:

Click the Add Shared Folder icon over on the right side of the window to get this screen:

Click the drop down arrow on the "Folder Path" dialog box to get this screen:

Click on Other... to see options for where to place the folder on your PC that you want to be accessible from within the VM:

I typically use a folder on my desktop called "allusers" as you can see in the screenshot and then click Select Folder. You will now see that folder location in the dialog box and you should then select the Auto-mount option before clicking OK.

Once that is complete, it's moment of truth time....boot up the VM. Locate it in the Virtualbox main menu, right click on it, hover over Start and then click Normal Start.

Once that part is successful you will see this desktop environment:

If you look at the information along the right side of the desktop you will notice that the IP Address there is something we have been randomly asssigned (dynamically...DHCP) by the router. That will not work for our purposes and so we need to change that to be the static IP address that we settled upon earlier in this guide. The next phase of this process is likely the most common point of failure for people trying to get this VM up and running the SWG Server. Getting this part right will make everything else relatively easy to do.

Configuring IP Connectivity Inside The VM

The first step here is to locate the applet where we can configure the virtual network card within the VM. To do that follow the 3 highlighted steps in this screenshot which will get you into the Yast configuration tool:

You should then see an authentication screen (use swg as the password):

Once you are in Yast, select SYSTEM in the left pane and then NETWORK SETTINGS in the right pane:

From the OVERVIEW tab select the device named eth0 and then click EDIT:

On the ADDRESS tab select STATICALLY ASSIGNED IP ADDRESS, enter the IP chosen for your VM (example: 192.168.1.100) by entering it into the IP ADDRESS field and then for the SUBNET MASK enter 255.255.255.0 and then click NEXT:

You may need to choose eth0 again and click EDIT so you can then access HOSTNAME/DNS, you can then enter your router's IP address as Name Server 1 (example: 192.168.1.254) and the primary Google public DNS as Name Server 2 (8.8.8.8) and then open the ROUTING tab:

You can now enter your router IP address in the DEFAULT IPv4 GATEWAY field (example: 192.168.1.254) and click OK:

You should then see a screen like this one as Yast applies your new settings:

Updating the HOSTS File

Just as the DNS servers work to resolve names like github.com to IP addresses you have a file inside the VM which does the exact same job but internally, the hosts file. It's basically local network DNS. The Oracle service on the VM that runs the database needs to be able to send and receive data to a host called swg (your VM's default name). The downloaded OVA file that you used to create your VM is configured by default to use the IP address that was originally assigned to the VM when it was created. That address will not match the static IP address you chose for your VM (192.168.1.100) earlier and so we need to update that file. To do this open a terminal window:

The first thing to do is elevate our privileges within this terminal (go into admin mode). Type in su root and hit enterto do that.

Type in the password (it's swg) and hit enter. You won't see any indication on the screen that you typed any characters in. That's a security feature to ensure that anybody snooping over your shoulder doesn't know who many characters are in your password. You should then see this screen:

Now we need to begin to edit the hosts file by using this command: nano /etc/hosts

The initial state of this file includes two entries for the swg hostname as shown here:

We only need one of these for our purposes so you can remove the first one alter the second one to use static IP address of the VM (192.168.1.100):

Now press ctrl and o to write out (save) your changes. The bottom of the terminal window will show you the filename it will save your changes to, just hit enter.

You can then see confirmation at the bottom of the window that your changes have been saved / written.

Before we proceed any further... REBOOT THE VM

Testing IP Connectivity For The VM

This sectional is completely optional but is a solid way to know that your VM is operating as required from a connectivity standpoint. Before doing these tests you need to know that using ctrl+c (press and hold ctrl then press c) will terminate the command being run. This is how you can do one test, stop it and move on to the next one.

Test #1 - ping localhost This will establish that TCP/IP is working within the VM, if this fails then the VM is fundamentally borked and to save time you should delete it, extract a new one from the OVA file and start all over again.

Test #2 - ping 192.168.1.100 This will establish that the static IP we chose and assigned to the VM is working properly. If this fails then you should revisit the section of this guide about assigning the static IP address and identify where a mistake was made.

Test #3 - ping 192.168.1.254 This will establish that the VM is able to communicate with the router. If this fails then you should check the IP setup and ensure that the gateway value was entered correctly and the netmask also.

Test #4 - ping google 8.8.8.8 This will establish that the VM can send traffic through the router to the internet. If this fails then you should check that your internet connection is actually working and then check the gateway value in the IP configuration of the VM.

Test #5 - ping swg This verifies that the update to the hosts file was successful. You should see responses coming from the static IP you assigned to the VM. If this fails then you need to check the changes made to the hosts file and correct those where needed.

Test #6 - ping google.com This verifies that the VM can use DNS servers on the internet to resolve hostnames. If this fails then you should check that the DNS configuration is correct. You can also swap out the 8.8.8.8 in the configuration for 8.8.4.4 or even 1.1.1.1 just in case the primary google DNS server isn't available for some reason.

Creating The First Snapshot

This is a good point at which to make a save point / restore point / snapshot of the current state of the VM so that you can get back to this moment if you ever need to. Open up Virtualbox, locate the VM in the list and click on the icon just to the right of the VM's name.

Click on the Snapshots item:

Click on the Take button:

You should then be presented with this screen:

Name the snapshot something that makes sense to you so that you will understand it's purpose later on:

You will then see this progress bar:

You now have a backup of the VM as it currently stands i.e. with full connectivity but no work done on the SWG server yet.

Building The SWG Server

Now it's time to start compiling the SWG server itself. On the desktop you will find an icon titled "Run This Then ./install.sh" so double click that and it will create a swap file for your VM. At that point run the "./install.sh" script to initiate the build process. Once you see that it is active you are looking at about 60 mins where you have nothing to do but watch progress on the screen. At some points it will look like nothing is happening (e.g. compile_tpf) but wait it out and you will see more updates on the screen before too long. Upon completion the terminal window will close, returning you to the desktop.

The following sequence of screenshots show the process unfolding at various intervals:

Now that the server has compiled, it's time to start it up.

How To Start The SWG Server

On your desktop you have a shortcut for Terminator and another on the taskbar at the bottom.

When you run Terminator you will see the signature quad panel layout. In the lower right pane you need to type ./stationchat and in the left lower pane you need to type ./startServer.sh :

Run each of those commands and you will see both servers begin their startup sequences. Depending on the resources allocated to the VM and how many ground / space zones you are running the time to completion will vary. On my system it takes about seven minutes for all zones to boot up but I've seen it take up to 15 minutes for lesser systems.

When the process completes you will see this screen:

How To Stop The Server

Run the terminal command ant stop from the swg-main directory. If you aren't in the swg-main directory, use the command cd swg-main. It will look like this once complete:

Taking A Second Snapshot

Now that the SWG server is built and operational it's a prudent step to make another backup. So once more open the Virtualbox main menu, click the icon on the right side of the entry for your VM, click the snapshots button and then click on the Take icon at the top of the window.

Name the snapshot something that will remind you that it's for a freshly compiled server.

Once the progress bar completes you have a backup made that can return you to the moment where your server first worked.

Connecting The Game Client To Your VM / SWG Server

The first thing you need for this is the game client which you can download by logging onto the SWG Source Discord and going to the #rules-and-info channel to get the link. Unzip the client and use the UpdateSwgClient.bat script to download everything you need. Once you have the SWG client on your PC open up the main folder and locate the login.cfg file.

Open the file in any text editor (notepad / notepad++) depending on your personal preference and then locate the line that starts with loginServerAddress0= and then replace whatever IP address is there with the static IP address of your VM. It should look like this:

Save the changes and then launch the client so it can connect to your server.