Warfork

Warfork

Not enough ratings
Warfork server: How to host your own
By psymin
This guide will walk you through the process of setting up a Warfork server on a Linux host.
   
Award
Favorite
Favorited
Unfavorite
Preface
A script to do it all
If you already have an Ubuntu 18.04 (or Debian 10) server to install a Warfork server on there is a single script to execute. Skip down to the "TL;DR" section.

If you know what you're doing and don't want to use the script, feel free to skip down to the "Installing Tools and the LinuxGSM Dependencies" section.

Originally posted by psymin:
I'll be using quote blocks like this throughout this document. Things you read here should be safe to ignore. These are mostly informative or for when things go awry.
Choosing the Operating System
Choosing a Linux distribution for your server should be a relatively simple process.

For popularity and long-term support I recommend Ubuntu 18.04[ubuntu.com] if it is an option. That is the distribution that we'll be focusing on primarily in this guide.

Originally posted by psymin:
For more information about the linux distributions supported by LinuxGSM, you can visit this page:
https://docs.linuxgsm.com/linux/distro

Any of them "should" work fine with all of the LinuxGSM scripts that we'll be using.

Debian 10 has also been tested and appears to work properly.

We will be using a fork of LinuxGSM until the Warfork code is merged.

Also, if you're having any issues with LGSM and Warfork, please let me know.

For detailed information on how to install and configure a standard Ubuntu 18.04 OS you can visit this site (It is for desktop, but similar things apply):

https://howtoubuntu.org/how-to-install-ubuntu-18-04-bionic-beaver





Optional: Hosting with Digital Ocean
Digital Ocean offers a number of different Linux distributions to choose from.
Choose "Ubuntu 18.04.3 (LTS) x64"

Digital Ocean offers many distributions to choose from.
Select "Ubuntu 18.04.3 (LTS) x64"
Select the datacenter region closest to you.

Choose the "Standard" Starter plan and the "$5/mo" server option.

For simplicity try a one-time password. Check your email for the password they've mailed to you.

Make note of the IP here. I smudged this one out a bit.

Droplet Name: ubuntu-s-1vcpu-1gb-nyc1-01 IP Address: 157.xxx.xxx.12 Username: root Password: b09205111386813768b9b5f5b4
This is the email that you should have from Digital Ocean with your one-time login information.

With the IP, username, and password you can move on to the next section and gain "Shell Access"


Originally posted by psymin:
There are other things that we should do to these machines to make them properly secured, like set up authentication for the non-root user and disable SSH access for the root user.

But that is beyond the scope of this document.




Shell Access
You need access to the console / terminal / shell of the server.

Windows users will need a client like PuTTY[www.ssh.com] to connect to a remote Linux server through SSH.

Originally posted by psymin:
Linux and MacOS users can use ssh from local terminal windows.
http://osxdaily.com/2017/04/28/howto-ssh-client-mac/
https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server-in-ubuntu

Updating the OS
Because we've just booted into a fresh operating system, it should be safe to update.*

Ubuntu
sudo apt update && sudo apt -y upgrade

This will also be a good time to test that the server does indeed come up properly upon reboot and on a new kernel.*

sudo reboot

The reboot process can take up to five minutes or so.

After an appropriate wait, connect via SSH to the remote server again.

Originally posted by psymin:
* If the machine doesn't boot after an update of a freshly installed OS, that is beyond the scope of this document. Hopefully you're able to resolve this issue with your hosting provider, hardware vendor, or linux distribution maintainers in a timely manner.
Installing Tools and the LinuxGSM Dependencies
There is a script in the "TL;DR" section that does all of this for you.

Ubuntu / Debian
sudo dpkg --add-architecture i386; sudo apt -y update
apt -y install curl wget ca-certificates file bsdmainutils util-linux python bzip2 gzip unzip binutils bc jq tmux lib32gcc1 libstdc++6:i386 npm ipcalc ufw traceroute

Originally posted by psymin:
If you're familiar with all these things, you can just clone this fork and install like you would in mainline lgsm

https://github.com/psymin/LinuxGSM/tree/warfork-stable

Creating the User
sudo useradd -m wf -k /etc/skel -s /bin/bash

Become the new user:

sudo su -l wf

Originally posted by psymin:
If you want to ssh in as this user, you'll need to set a password for that user.
As the root execute the command
passwd wf
NPM environment for gamedig
Gamedig is needed for the safe-update command. We'll install it using NPM for just the "wf" user.

chmod +x npm-env.sh
./npm-env.sh

Now install gamedig.

npm install gamedig -g

For reference, the script looks like this:

#!/bin/bash

# set up the npm environment for local user installs
# And install gamedig

mkdir ~/.node

echo "prefix = ~/.node" >> ~/.npmrc
echo "PATH=/"/$HOME/.node/bin:/$PATH/"" >> ~/.profile
echo "NODE_PATH=/"/$HOME/.node/lib/node_modules:/$NODE_PATH/"" >> ~/.profile
echo "MANPATH=/"/$HOME/.node/share/man:/$MANPATH/"" >> ~/.profile

Originally posted by psymin:
We'd love to remove the dependency for npm and gamedig. Help us extend the gsquery support for LinuxGSM!



Installing "wfserver"

chmod +x wfserver

./wfserver auto-install

./wfserver start

Originally posted by psymin:
If there are errors during the output, check the "Troubleshooting" section.
For example, tips about this message
[ WARN ] Details wfserver: Check IP: Multiple IP addresses found.
Server Configuration
LinuxGSM

The defaults ports are 44400 UDP and 44444 TCP.

Most folks shouldn't need to modify the LinuxGSM instance config.

Originally posted by psymin:
If you do want to modify the LinuxGSM configs for your instance, you can modify this file for your "wfserver" instance.

/home/wf/lgsm/config-lgsm/wfserver/wfserver.cfg

Uncomment all of the variables and set them to a proper value.
Be sure to uncomment "queryport" and "servercfgfullpath" if you change the values for "port" or "servercfg".

################################## ######## Instance Settings ######## ################################## # PLACE INSTANCE SETTINGS HERE ## These settings will apply to a specific instance ## Server Start Settings | https://docs.linuxgsm.com/configuration/start-parameters # Warfork specific configuration defaults for an instance. # Pulled in from https://github.com/psymin/LinuxGSM/tree/warfork-stable/ # These defaults work great for a single server port="44400" httpport="44444" servercfg="dedicated_autoexec.cfg" # servercfg looks in the basewf dir for the file # ~/serverfiles/Warfork.app/Contents/Resources/basewf/ # look in common.cfg in the same directory as this file to change the IP # ~/lgsm/config-lgsm/wfserver/common.cfg # or set it here to override the default in common.cfg #ip="0.0.0.0" # do not change anything below this line queryport="${port}" servercfgfullpath="${servercfgdir}/${servercfg}"

Warfork

The defaults are probably adequate and should work well.

Originally posted by psymin:
When you want to modify the server configuration, you should modify the following file:

Warforks servers can be configured in many different ways. Configuration of specific servers is beyond the scope of this document.

I'll provide a link to a server configuration guide when I find a good one to share.

Please note that the following variables are being set by LinuxGSM and hopefully override the variables that are set in the Warfork configuration:

sv_ip sv_port sv_port6 sv_http_ip sv_http_port

Optional: Setting up additional servers
cp wfserver wfserver-2
./wfserver-2 details

That should create a default LinuxGSM config for a new instance named wfserver-2.

This config is located here:
/home/wf/lgsm/config-lgsm/wfserver/wfserver-2.cfg

By default, it looks just like the wfserver.cfg file:

################################## ######## Instance Settings ######## ################################## # PLACE INSTANCE SETTINGS HERE ## These settings will apply to a specific instance ## Server Start Settings | https://docs.linuxgsm.com/configuration/start-parameters # Warfork specific configuration defaults for an instance. # Pulled in from https://github.com/psymin/LinuxGSM/tree/warfork-stable/ # These defaults work great for a single server port="44400" httpport="44444" servercfg="dedicated_autoexec.cfg" # servercfg looks in the basewf dir for the file # ~/serverfiles/Warfork.app/Contents/Resources/basewf/ # look in common.cfg in the same directory as this file to change the IP # ~/lgsm/config-lgsm/wfserver/common.cfg # or set it here to override the default in common.cfg #ip="0.0.0.0" # do not change anything below this line queryport="${port}" servercfgfullpath="${servercfgdir}/${servercfg}"

Set port to a valid port, like "44401"
Set httpport to a valid port, like "44445"
Set servercfg to another config file, like "dedicated_autoexec2.cfg"

We can create this new config file "dedicated_autoexec2.cfg" by copying the original one.


Originally posted by psymin:
The values that are set in this file are passed to the wf_server.x86_64 server binary. They override any values that are set in the Warfork configuration files (like the default config file dedicated_autoexec.cfg)

This means that as long as your instance config is setting things properly, you can't break the networking part of your dedicated_autoexec.cfg on accident.
Automating tasks with cron
You will want at least a few cronjobs.
  1. Start the Warfork server daemon when the computer boots up.
  2. Monitor the daemon and restart it if it has crashed
  3. Update the server files when updates are available
  4. Update the LinuxGSM scripts once a week.

Here is an example crontab that will work great for folks who have been following this guide from the beginning.

Since we are on a freshly installed and updated server, with a new user named "wf", executing the following command should set up these cron jobs for you.

crontab wfcron

This will add four cronjobs, and remove any that were previously set.

# Start wfserver on boot @reboot ~/wfserver start > /dev/null 2>&1 #@reboot ~/wfserver-2 start > /dev/null 2>&1 #@reboot ~/wfserver-3 start > /dev/null 2>&1 #@reboot ~/wfserver-4 start > /dev/null 2>&1 # Check the status of wfserver every five minutes # If crashed, send alerts and restart the daemon */5 * * * * ~/wfserver monitor > /dev/null 2>&1 #*/5 * * * * ~/wfserver-2 monitor > /dev/null 2>&1 #*/5 * * * * ~/wfserver-3 monitor > /dev/null 2>&1 #*/5 * * * * ~/wfserver-4 monitor > /dev/null 2>&1 # INFO: To configure alerting look at the variables in: # INFO: lgsm/config-lgsm/wfserver/_default.cfg # INFO: Don't modify those variables. Set them in: # INFO: lgsm/config-lgsm/wfserver/wfserver.cfg # Check for updates to wfserver and download/apply if found */30 * * * * ~/wfserver safe-update > /dev/null 2>&1 # Update the LinuxGSM scripts every Sunday at midnight 0 0 * * 0 ~/wfserver update-functions > /dev/null 2>&1 ############################################################## # # field allowed values # ----- -------------- # minute 0-59 # hour 0-23 # day of month 1-31 # month 1-12 (or names, see below) # day of week 0-7 (0 or 7 is Sun, or use names) # # min hour dom mon dow usercommand # * * * * * blah.sh # # wf@games:~$ man 5 crontab # # https://docs.linuxgsm.com/configuration/cronjobs

Originally posted by psymin:
LinuxGSM documentation[docs.linuxgsm.com] covers this in far more detail.
TL;DR : A script to do everything for you
So you've got everything set up already and don't want to read the document?

I hear you.

This script will set everything up for you assuming you're on an Ubuntu 18.04 server.

chmod +x wfwrapper.sh
sudo ./wfwrapper.sh

If you have issues with this script on Ubuntu 18.04 you should actually go through each step in this document.
Gathering Information for Troubleshooting
When troubleshooting, it is quite handy to have some details about the situation.
The first step should be to take a look at the output of the "./wfserver details" command.

It's all in the details: ./wfserver details

The "details" command is quite handy. Especially the "postdetails" command which takes the details and returns a URL you can share with the folks who are helping you troubleshoot.

Pay attention to this bottom of this output.

wf@games:~$ ./wfserver details
[ INFO ] Details wfserver: Check IP: 10.0.0.13 Distro Details ==================================================================================== Distro: Ubuntu 18.04.3 LTS Arch: x86_64 Kernel: 4.15.0-58-generic Hostname: games tmux: tmux 2.6 glibc: 2.27 Performance Uptime: 4d, 16h, 46m Avg Load: 0.05, 0.12, 0.09 CPU Model: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz CPU Cores: 3 CPU Frequency: 2600.050 MHz Mem: total used free cached available Physical: 12GB 294MB 12GB 4.3GB 12GB Swap: 0B 0B 0B Storage ==================================================================================== Filesystem: /dev/vda2 Total: 18G Used: 8.5G Available: 8.3G LinuxGSM Total: 716M Serverfiles: 438M Warfork Server Details ==================================================================================== Server name: Warfork Server Server IP: 10.0.0.13:44400 Internet IP: [masked]:44400 Players: 0/2 Current Map: wfdm1 Master Server: false Status: ONLINE wfserver Script Details ==================================================================================== Service name: wfserver wfserver version: v19.9.0 User: wf glibc required: 2.15 Discord alert: off Email alert: off Pushbullet alert: off IFTTT alert: off Mailgun (email) alert: off Pushover alert: off Telegram alert: off Location: /home/wf Config file: /home/wf/serverfiles/Warfork.app/Contents/Resources/basewf/dedicated_autoexec.cfg Backups ==================================================================================== No Backups created Command-line Parameters ==================================================================================== ./wf_server.x86_64 +exec dedicated_autoexec.cfg +sv_http_ip 10.0.0.13 +set sv_http_port 44444 +sv_ip 10.0.0.13 +sv_port6 44400 +sv_port 44400 Ports ==================================================================================== Change ports by editing the parameters in: /home/wf/lgsm/config-lgsm/wfserver Useful port diagnostic command: netstat -atunp | grep wf_server DESCRIPTION DIRECTION PORT PROTOCOL > Game INBOUND 44400 udp > Http INBOUND 44444 tcp Status: ONLINE command_details.sh exiting with code: 0

You can see the ports that the server is configured to use, and you can verify that it is using those ports with the "Useful port diagnostic command:"

netstat -atunp | grep wf_server

For a default setup, please ensure that your output looks like this:

wf@games:~$ netstat -atunp | grep wf_server (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:44444 0.0.0.0:* LISTEN 12062/./wf_server.x tcp6 0 0 :::44444 :::* LISTEN 12062/./wf_server.x udp 0 0 10.0.0.13:44400 0.0.0.0:* 12062/./wf_server.x udp6 0 0 :::44400 :::* 12062/./wf_server.x

The "./wfserver details" command also shows you where some handy config files are located:


Change ports by editing the parameters in: /home/wf/lgsm/config-lgsm/wfserver

Log Files
The server console output is logged to the "log/console/wfserver-console.log" file.
cat log/console/wfserver-console.log

Troubleshooting
[ FAIL ] Starting wfserver: Unable to start

Look at the console log to see if there are errors:
cat log/console/wfserver-console.log

Port and IP Conflicts

Below are some errors that can be found in the logs when the ports are misconfigured.
If your IP or ports are misconfigured, please set them in the wfserver.cfg file as described in the "Server Configuration" section.

====== Warfork Initialized ====== Couldn't execute: dedicated_autoexec_postinit.cfg Opening UDP/IP socket: 10.0.0.13:44400 Error: Couldn't open UDP socket: bind: Unknown error Opening UDP/IPv6 socket: *:44400 Error: Couldn't open UDP6 socket: bind: Unknown error ******************** ERROR: Couldn't open any socket ******************** Error: Couldn't open any socket

Error: Couldn't open TCP socket: bind: Unknown errorOpening TCP/IPv6 socket: *:44444 Error: Couldn't open TCP socket: bind: Unknown error

Voting Issues
This is potentially a port issue. Check your httpport variable in your instance config. Ensure that each server has a separate TCP port bound. (Default: 44444). Refer to the "Server Configuration" section for more information.
Originally posted by psymin:
The httpport variable for the LGSM config sets the sv_http_port variable in the warfork server config.

Serving maps to clients
This is also potentially a port issue. Check your httpport variable in your instance config. Ensure that each server has a separate TCP port bound. (Default: 44444). Refer to the "Server Configuration" section for more information.
Originally posted by psymin:
The httpport variable for the LGSM config sets the sv_http_port variable in the warfork server config.

[ WARN ] Starting wfserver: Configuration file missing!
Verify that the config file that it is looking for, exists. Default location:

[ WARN ] Details wfserver: Check IP: Multiple IP addresses found.
You need to manually set the IP that it will bind to in this file:
~/lgsm/config-lgsm/wfserver/common.cfg

The wfwrapper.sh script didn't work!? What now?!
Read this guide and try things without the script.





2 Comments
algolineu 4 May @ 4:47am 
I recommend to use the actual linuxgsm guide: https://linuxgsm.com/servers/wfserver/ since this one is out-of-date
Bebê Reborn 2 Sep, 2019 @ 4:06pm 
sv_uploads_baseurl, how to use? I want players to download maps.