This commit is contained in:
Eric Myllyoja 2021-12-07 14:06:21 -05:00
parent feb1fc586c
commit 639302a55c
5 changed files with 159 additions and 74 deletions

View File

@ -17,6 +17,7 @@ On December 5th, 2021, the Darkflame Universe project released an open-source se
### Server Setup Guides
* [Elocore's Video Guide (WSL)](https://www.youtube.com/watch?v=mDGoV5AYaDo)
* [Sunflea's Guide (WSL)](https://gist.github.com/SunFlea/893fd80f39c7cf9ab31baacac284025d)
* [Drahsid's Install Script (Linux)](https://github.com/Drahsid/DarkflameServerInstallScript)
* [MaxDelayer's Quick Start Scripts (Linux)](https://github.com/maxdelayer/DLUQuickstart)

View File

@ -0,0 +1,5 @@
# 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>'

View File

@ -0,0 +1,8 @@
# 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'

View File

@ -2,12 +2,12 @@
The following is a guide to setting up a functioning Darkflame Universe server instance running in the cloud, which has several key benefits:
- These steps don't vary based on what kind of computer you have.
- You can easily start over if you mess up (just delete the instance).
- These steps don't vary based on what kind of computer you have. They're the same regardless if your home computer runs Windows, Mac, or Linux.
- You can easily start over if you mess up (just delete the instance and create a new one).
- You can easily change the server's settings and manage it from anywhere.
- The server can continue to run even if you turn off your PC.
The downside to this method is that it does technically cost money. You will have to provide a payment method with Google. However, there is a one-year trial which gives $300 in credits, and the smallest instance is about $5 a month.
The downside to this method is that it does technically cost money. You may have to provide a payment method with Google. However, there is a one-year trial which gives $300 in credits, and the smallest instance is only about $5 a month.
## WORK IN PROGRESS
@ -31,11 +31,11 @@ Darkflame Universe requires an unpacked client, both for setup and for play. An
If these folders are missing, you will need to extract them from the client resource data.
**TODO: Write good instructions on running [pkextractor](https://github.com/lcdr/utils/blob/master/utils/pkextractor.pyw)**
**TODO: Write really easy instructions on running [pkextractor](https://github.com/lcdr/utils/blob/master/utils/pkextractor.pyw)**
## Setup Resource Directory
Once you have an unpacked client, you will need to retrieve several files from it, that the DLU server needs in order for it to work.Create a folder somewhere easy to remember, and follow these steps:
Once you have an unpacked client, you will need to retrieve several files from it, that the DLU server needs in order for it to work. Create a folder called `server-resources` somewhere easy to remember, and follow these steps:
* Create a folder called `res`.
* Copy the `LEGO Universe/res/macros` folder into the `res` folder in your resource directory.
@ -43,17 +43,10 @@ Once you have an unpacked client, you will need to retrieve several files from i
* Copy the `LEGO Universe/res/names` folder into the `res` folder in your resource directory.
* Copy the `LEGO Universe/res/maps` folder into the `res` folder in your resource directory.
* Copy the `LEGO Universe/res/chatplus_en_us.txt` file into the `res` folder in your resource directory.
* Copy the `LEGO Universe/res/cdclient.fdb` folder into the `res` folder in your resource directory.
* Create a folder called `locale`.
* Copy the `LEGO Universe/locale/locale.xml` file into the `locale` folder in your resource directory.
Next, **TODO: Write good instructions on running [fdb_to_sqlite](https://github.com/lcdr/utils/blob/master/utils/fdb_to_sqlite.py)**. This will create a file called `cdclient.sqlite`.
Next, **TODO: Create a script that will download and run the migration queries on the sqlite file**. This will update the database to fix several issues with its contents.
Next, [download the navmeshes from the repository](https://github.com/DarkflameUniverse/DarkflameServer/blob/main/resources/navmeshes.zip) and extract it. Put the resulting `navmeshes` folder into the `res/maps` folder in your resource directory.
Finally, move the corrected `cdclient.sqlite` file to the `res` folder in your resource directory, and rename it to `CDServer.sqlite`.
You should have a directory containing the following file structure.
```
@ -70,11 +63,13 @@ You should have a directory containing the following file structure.
|- ...
|- ...
|-chatplus_en_us.txt
|-CDServer.sqlite
|-cdclient.fdb
|-locale
|-locale.xml
```
Finally, right click your `server-resources` folder, and select 'Send to...' > 'Compressed Folder'. This will compress the folder into a single ZIP file. You will need this ZIP file later.
## Getting Started with Google Cloud
Google makes it very easy to set up a server instance in the cloud. First, [sign up for an account with Google Cloud](https://cloud.google.com/). You should see this popup to let you know you've received $300 in trial credits:
@ -93,6 +88,73 @@ Once the instance is ready, click it, then click SSH to connect to your instance
Congratulations! What you've essentially done is reserve a tiny spot on Google's massive server farm, and created a Linux computer in it. We're going to build and install Darkflame Universe on here, and you and your friends will be able to connect and play the game.
## Setup the MySQL Database
Once you've opened the terminal, run these commands, one at a time, in order.
```
# Install almost every dependency we need.
sudo apt-get update
sudo apt-get install -y python3 python3-pip build-essential gcc libssl-dev zlib1g zlib1g-dev sqlite git gpg wget unzip
# This installs MariaDB
sudo apt-get install -y default-mysql-server
# Install the latest cmake
sudo apt remove -y --purge --auto-remove cmake
pip3 install cmake --upgrade
export PATH="$HOME/.local/bin:$PATH"
# Allocate swap space so we don't run out of memory while building.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
sudo mysql -u root
```
The last command will start a MariaDB shell. Enter the following commands one at a time (be sure to change the password on the first line to something more secure):
```
CREATE OR REPLACE USER 'darkflame'@'localhost' IDENTIFIED BY 'password';
CREATE OR REPLACE DATABASE darkflame;
GRANT ALL PRIVILEGES ON darkflame.* TO 'darkflame'@'localhost';
EXIT;
```
You will now have an empty database ready for later.
## Download and Build the Server
Next, run these commands one at a time to download and build the server:
```
git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer ~/DarkflameServer
git clone https://github.com/lcdr/utils.git ~/lcdrutils
git clone https://github.com/DarkflameUniverse/AccountManager ~/AccountManager
cd ~/DarkflameServer
chmod +x build.sh
./build.sh
```
Wait until the build process is complete. This will take a while. In the meantime, you can move on to the next steps. Just don't close the window!
## Upload Resources
Next, we're going to upload the resources folder [we created earlier](#setup-resource-directory) to the proper location. In order to do this in a way that doesn't differ between computers, we're going to create a Google Cloud Storage bucket and upload the files to it.
* Click 'Google Cloud Platform' at the top to move to the Google Cloud homepage.
* Click 'Cloud Storage' on the left.
* Click 'Create Bucket' at the top.
* Pick a name that is easy to remember and easy to type. It needs to be GLOBALLY unique apparently.
* Stick with the defaults for region, storage class, access control, and protection.
Now the bucket is created, you will see the details page for that bucket and a list of objects (i.e. files) in it.
Click 'Upload File', select your `server-resources` ZIP, and click upload. This process should take just a second.
## Configuring the Server's Firewall
Before we get started building the server, we need to configure the server's firewall. Follow these steps:
@ -116,71 +178,77 @@ Now lets assign these rules to the server.
* Scroll down to 'Network tags' and enter `darkflame-server`.
* Scroll to the bottom and click 'Save'.
## Setup the MySQL Database
Run these commands, one at a time, in order.
```
sudo apt-get update
sudo apt-get install -y python3 python3-pip build-essential gcc libssl-dev default-mysql-server zlib1g zlib1g-dev sqlite git gpg wget
# Install the latest cmake
sudo apt remove -y --purge --auto-remove cmake
pip3 install cmake --upgrade
export PATH="$HOME/.local/bin:$PATH"
# Allocate swap space so we don't run out of memory while building.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
sudo mysql -u root
```
The last command will start a MariaDB shell. Enter the following commands one at a time (be sure to change the password on the first line to something more secure):
```
CREATE OR REPLACE USER darkflame IDENTIFIED BY 'password';
CREATE OR REPLACE DATABASE darkflame;
EXIT;
```
You will now have an empty database ready for later.
## Download and Build the Server
Next, run these commands one at a time to download and build the server:
```
git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer
cd DarkflameServer
chmod +x build.sh
./build.sh
```
Wait until the build process is complete. This will take a while. Go get a snack, watch some TV, or do something else while you wait. Just don't close the window, or you'll have to start the build all over again.
## Upload Resources
Next, we're going to upload the resources folder [we created earlier](#setup-resource-directory) to the proper location.
## Setup the Server
Now we're going to do the final configur
Once the build is done, we're going to do the final configuration needed for the server.
```
# Initialize the database. You will need to enter the password you chose earlier.
mariadb darkflame -u darkflame -p < ~/DarkflameServer/migrations/dlu/0_initial.sql;
# Download the server-resources.zip file from Google Cloud Storage. Be sure to replace the bucket name.
gsutil cp gs://<BUCKET-NAME>/server-resources.zip ~/server-resources.zip
# Unzip the server-resources.zip and move files to the proper location.
unzip -q ~/server-resources.zip -d ~/server-resources/
mv ~/server-resources/server-resources/* ~/DarkflameServer/build/
# Extract the navmeshes.
unzip ~/DarkflameServer/resources/navmeshes.zip -d ~/DarkflameServer/build/res/maps
# Convert the FDB file to an SQLite file.
python3 ~/lcdrutils/utils/fdb_to_sqlite.py --sqlite_path ~/DarkflameServer/build/res/CDServer.sqlite ~/DarkflameServer/build/res/cdclient.fdb
# Fix the SQLite file.
sqlite3 ~/DarkflameServer/build/res/CDServer.sqlite ".read ${HOME}/DarkflameServer/migrations/cdserver/0_nt_footrace.sql"
sqlite3 ~/DarkflameServer/build/res/CDServer.sqlite ".read ${HOME}/DarkflameServer/migrations/cdserver/1_fix_overbuild_mission.sql"
sqlite3 ~/DarkflameServer/build/res/CDServer.sqlite ".read ${HOME}/DarkflameServer/migrations/cdserver/2_script_component.sql"
# Setup your config files.
sed -i "s/mysql_host=/mysql_host=localhost/g" ~/DarkflameServer/authconfig.ini
sed -i "s/mysql_host=/mysql_host=localhost/g" ~/DarkflameServer/chatconfig.ini
sed -i "s/mysql_host=/mysql_host=localhost/g" ~/DarkflameServer/masterconfig.ini
sed -i "s/mysql_host=/mysql_host=localhost/g" ~/DarkflameServer/worldconfig.ini
sed -i "s/mysql_database=/mysql_database=darkflame/g" ~/DarkflameServer/authconfig.ini
sed -i "s/mysql_database=/mysql_database=darkflame/g" ~/DarkflameServer/chatconfig.ini
sed -i "s/mysql_database=/mysql_database=darkflame/g" ~/DarkflameServer/masterconfig.ini
sed -i "s/mysql_database=/mysql_database=darkflame/g" ~/DarkflameServer/worldconfig.ini
sed -i "s/mysql_username=/mysql_username=darkflame/g" ~/DarkflameServer/authconfig.ini
sed -i "s/mysql_username=/mysql_username=darkflame/g" ~/DarkflameServer/chatconfig.ini
sed -i "s/mysql_username=/mysql_username=darkflame/g" ~/DarkflameServer/masterconfig.ini
sed -i "s/mysql_username=/mysql_username=darkflame/g" ~/DarkflameServer/worldconfig.ini
# Give the server the MySQL password you setup earlier. Make sure to replace PASSWORD with the proper value each time.
sed -i "s/mysql_password=/mysql_password=PASSWORD/g" ~/DarkflameServer/authconfig.ini
sed -i "s/mysql_password=/mysql_password=PASSWORD/g" ~/DarkflameServer/chatconfig.ini
sed -i "s/mysql_password=/mysql_password=PASSWORD/g" ~/DarkflameServer/masterconfig.ini
sed -i "s/mysql_password=/mysql_password=PASSWORD/g" ~/DarkflameServer/worldconfig.ini
```
## Setup the Account Manager
Before we can setup the server, we need to setup and start the account manager. This will provide a web interface for the server to manage accounts, approve usernames, and generate CD keys to give to your friends.
## Updating Darkflame Universe
In the future, updates will be release to DarkflameServer that will include bug fixes and potentially even new features. To update the server, you can run the following commands:
In the future, updates will be release to DarkflameServer that will include bug fixes and potentially even new features. To update the server, you can run the following commands, in order:
**TODO: Complete this.**
```
# Shut down the server.
**TODO: Shut down the server.**
## Contributing
# Update the server.
cd ~/DarkflameServer
git pull
./build.sh
This guide is a work in progress and could use your help.
* Complete Google Cloud setup instructions.
* Rewrite instructions for running pkextractor on the client (should be easy for anyone to follow).
* Rewrite instructions for running fdb_to_sqlite to be easier to follow (should be easy for anyone to follow).
- Maybe make an executable you can drag and drop the FDB onto?
* Rewrite instructions for running the migration queries on the SQLite to be easier to follow (should be easy for anyone to follow).
# Restart the server.
**TODO: Restart the server.**
```
## Troubleshooting
If you have an issue with any of the above steps, visit the link below to review common questions and troubleshooting tips.
[Google Cloud Setup Troubleshooting](google-cloud-troubleshooting.md)

View File

@ -0,0 +1,3 @@
# Google Cloud Setup - Troubleshooting Guide
**STUB**