Update 2016-04-15: This guide is out of date. KF 2 server now requires Wine 1.9. I'll update this guide when I find the time.
Update 2016-05-19: See Containerized Killing Floor 2 Dedicated Server for an updated guide.
Introduction
Killing Floor 2 has a dedicated server program, but it is not yet available for Linux. However, the Windows version of the program runs perfectly well in a Wine environment. See its AppDB entry.
As this is a closed-source program which will run an Internet facing network server, it makes a lot of sense to try to contain it somewhat. Ideally, it should run on its own (containerized/virtualized/bare metal) machine. If you intend to run it on your regular PC, as will be covered here, it should at least run under its own user account.
This is mostly based on the guide Installing KF 2 Server on Linux with WINE at the Tripwire forums.
Preparation
Install a recent version of Wine. I used the official PPA for Ubuntu to install Wine 1.8.
Create a new local user account on the machine that will run the server, and su
to it:
# useradd --system --create-home kf2server
# su - kf2server
--system
makes it a system account which, among other things, will make it not show up at the login screen if you are using a full desktop environment. --create-home
creates an empty home directory for the account. You may also want to use the --base-dir
option to specify a different location for the home directory than the default /home.
Installation
Run winecfg once to create a Wine directory hierarchy:
$ winecfg
Use winetricks to install Microsoft Visual C Runtime 2010 in Wine:
$ winetricks vcrun2010
(Without it, the server would crash on startup with the error message "BugSplatRC resource DLL not found".)
Download SteamCMD for Windows. Extract the executable to .wine/drive_c/steamcmd/ in the kf2server user's home directory. Use the following command to install the server into C:/steamcmd/kf2server:
$ wine "C:/steamcmd/steamcmd.exe" +login anonymous +force_install_dir kf2server +app_update 232130 +quit
The same command is later used to update the existing installation when Tripwire releases a new version of the dedicated server.
Now run the server once to let it create its configuration files with default values:
$ wine "C:/steamcmd/kf2server/Binaries/Win64/KFServer.exe" kf-burningparis
Note that it is required to specify a map on the command line, otherwise Web Admin will not be accessible. To stop it, press Ctrl+C twice.
Configuration
Edit the configuration files to your liking (located in .wine/drive_c/steamcmd/kf2server/KFGame/Config/). See the Tripwire wiki page for details. I suggest only setting an administrator's password for the Web Admin interface, and doing the rest of the configuration there.
Automatic start/stop
On startup the server checks if it is connected to a controlling terminal. If not, it attempts to start an xterm, presumably so that the user can see the console output even if they started the server by double-clicking it in Windows Explorer. This somewhat obstructs unattended startup of the server, for instance by a init script. One workaround is to fake a controlling TTY using the program unbuffer from expect (see also expect Ubuntu packages.
The following is a sample systemd service unit for the Killing Floor 2 Dedicated Server.
[Unit]
Description=Killing Floor 2 Dedicated Server
[Service]
ExecStart=/usr/bin/unbuffer /usr/bin/wine "C:/steamcmd/kf2server/Binaries/Win64/KFServer.exe" kf-burningparis
# The user account that will run the server
User=kf2server
Group=kf2server
# The server is stopped by sending it a SIGINT (Ctrl-C)
KillSignal=SIGINT
# This hides most of the fixme errors in Wine, which are harmless in this case and just clutter up the output
Environment="WINEDEBUG=fixme-all"
[Install]
WantedBy=multi-user.target
Place it in /etc/systemd/system/kf2server.service. Now you can easily start and stop the server using the systemctl command, as in the following example:
# systemctl start kf2server.service
# systemctl status kf2server.service
● kf2server.service - Killing Floor 2 Dedicated Server
Loaded: loaded (/etc/systemd/system/kf2server.service; disabled; vendor preset: enabled)
Active: active (running) since mån 2016-01-25 16:52:16 CET; 35s ago
Main PID: 25624 (tclsh8.6)
CGroup: /system.slice/kf2server.service
[...]
To enable automatic start on system startup, run systemctl enable kf2server.service
. Happy fragging!