Introduction

To edit the configuration files for my Killing Floor 2 Dedicated Server more easily, I keep them in a version control repository that I sync to my main computer where I can use Emacs to edit them. This has not worked so well for several reasons:

  • The configuration files are full of autogenerated crap that I never touch.
  • They change a lot by themselves when the game server is updated.
  • Worst of all, they contain the running state of the server (for example, the current map and difficulty).

Another reason, which I can't really blame the game for, is that the server must be stopped while the configuration files are changed, or the changes will be silently discarded at some point.

Still, bad version control is usually better than no version control and this case has not been an exception. So here I share my setup.

Structure

I have a Git repository server running on one of my machines that will store the master copy of the config files. A Git repository server doesn't have to be more fancy than a directory that you can write to over SSH, but in my case I'm using Gitolite. Gitolite allows me to easily restrict read and/or write access to some set of users. Users are defined by SSH keys and don't have to be human at all. The KF2 server will get its own user account with no access to any of my other repositories.

In this guide I will assume that the repository is located at git@git.antoneliasson.se:kf2server-config.git but you can also use a Github repository or similar if you like.

Setup

As the unprivileged user running the Killing Floor 2 server, cd to the configuration directory and init a Git repository:

kf2server@kf2server:~$ cd .wine/drive_c/steamcmd/kf2server/KFGame/Config/
kf2server@kf2server:~/.wine/drive_c/steamcmd/kf2server/KFGame/Config$ git init

Optionally configure the username and e-mail address that will be used to sign your commits. Git will yell at you if you don't but since you probably won't make the repository public anyway it doesn't matter much.

$ git config --global user.email anton@thisdomain.se
$ git config --global user.name "Anton Eliasson"

Make a gitignore file listing all the stuff that you don't care about. Default*.ini files contain the default settings and are copied to the KF*.ini and PCServer-KF*.ini files if the latter do not exist. The PCServer directory contains I have no idea what.

$ cat .gitignore
/Default*
/PCServer

Now add the files that you think you might change at some point and make the first commit:

$ git add PCServer-* KFAI.ini KFWeb.ini
$ git commit

Create an SSH keypair. Since mine will only be used for the purpose of authenticating the KF2 server to the Git server and nothing else I chose to not encrypt it with a passphrase.

$ ssh-keygen
<enter>
<enter>

Now give this key read/write permissions to your master repository. Finally set up the Git remote and push your first commit:

$ git remote add origin git@git.antoneliasson.se:kf2server-config.git
$ git push -u origin master

Sit back and relax, knowing that the world is now ever so slightly more version controlled :)