From 049c5df9e3c4920b5848f8ef7345586ec026f41f Mon Sep 17 00:00:00 2001 From: Jack Hadrill Date: Sun, 31 Jul 2022 19:10:28 +0100 Subject: [PATCH] Install, patch config files, and run. --- Dockerfile | 9 +++++++++ README.md | 38 ++++++++++++++++++++++++++++++++++++-- start.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..799b844 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM steamcmd/steamcmd:ubuntu + +RUN apt-get update && apt-get install -y libcurl4 && apt-get clean + +WORKDIR /game +COPY start.sh /start.sh + +ENTRYPOINT [ "bash" ] +CMD [ "/start.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index f3bd958..6845e39 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ -# KillingFloor2Docker +# Killing Floor 2 - Docker -Dockerised Killing Floor 2 server. \ No newline at end of file +Dockerised Killing Floor 2 server. + +Run with the following environment variables: + +``` +SERVER_NAME (default: KillingFloor2) +MOTD (default: KillingFloor) +WEBSITE_LINK (default: none) +PASSWORD (default: none) +ADMIN_PASSWORD (default: VerySecurePassword) +WEB_PASSWORD (default: none) +MAX_PLAYERS (default: 12) +GAME_DIFFICULTY (default: 1) +``` + +Example `docker-compose.yml` file: + +```yml +version: '3' +services: + killingfloor2: + image: docker.nexus.jacknet.io/jackhadrill/games/killingfloor2:latest + ports: + - '7777:7777/udp' + - '27015:27015/tcp' + - '8080:8080/tcp' + environment: + SERVER_NAME: 'JackNet' + MOTD: 'Welcome to the JackNet KF2 server.' + WEBSITE_LINK: 'https://jacknet.io/' + PASSWORD: password123 + ADMIN_PASSWORD: password123 +``` + +Mount `/game` if you want to persist the server files. Else, it will download on each launch. \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..de692a1 --- /dev/null +++ b/start.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +ServerName="${SERVER_NAME:-KillingFloor2}" +Motd="${MOTD:-KillingFloor2}" +WebsiteLink="${WEBSITE_LINK:-}" +Password="${PASSWORD:-}" +AdminPassword="${ADMIN_PASSWORD:-VerySecurePassword}" +WebPassword="${WEB_PASSWORD:-}" +MaxPlayers="${MAX_PLAYERS:-12}" +GameDifficulty="${GAME_DIFFICULTY:-1}" + +# Update server. +steamcmd +login anonymous +force_install_dir /game +app_update 232130 validate +exit + +# Generate default config. +/game/Binaries/Win64/KFGameSteamServer.bin.x86_64 exit + +# Patch config files. +sed -i "s/GamePassword=.*/GamePassword=${Password}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/AdminPassword=.*/AdminPassword=${AdminPassword}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/MaxPlayers=.*/MaxPlayers=${MaxPlayers}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/GameDifficulty=.*/GameDifficulty=${GameDifficulty}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/ServerMOTD=.*/ServerMOTD=${Motd}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/WebsiteLink=.*/WebsiteLink=${WebsiteLink}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/ServerName=.*/ServerName=${ServerName}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/ShortName=.*/ShortName=${ServerName}/g" /game/KFGame/Config/LinuxServer-KFGame.ini +sed -i "s/bEnabled=.*/bEnabled=true/g" /game/KFGame/Config/KFWeb.ini + +# Run +/game/Binaries/Win64/KFGameSteamServer.bin.x86_64