From 4e2bbe9222de056e5bf1f7c24fcb6726d71a2d09 Mon Sep 17 00:00:00 2001
From: Paul Scheunemann <paul@zom.bi>
Date: Thu, 13 Apr 2017 10:46:48 +0200
Subject: [PATCH] truncate history

---
 Dockerfile        | 10 ++++++++++
 README.md         | 23 +++++++++++++++++++++++
 bin/entrypoint.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 Dockerfile
 create mode 100644 README.md
 create mode 100644 bin/entrypoint.sh

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..9bc7947
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+FROM zombi/steam-base
+MAINTAINER MadMaurice <madmaurice@zom.bi>, Paul <paul@zom.bi>
+EXPOSE 27015/udp
+
+ADD bin/entrypoint.sh /entrypoint.sh
+RUN chmod +xr /entrypoint.sh
+USER steam
+
+ENTRYPOINT ["/entrypoint.sh"]
+CMD ["+sv_pure", "1", "+map", "ctf_2fort.bsp", "+maxplayers", "24"]
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1b7230a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+## steam-tf2
+steam-tf2 is the base image for an 'Team Fortress 2' server
+
+### Building steam-tf2
+
+first build the `steam-base` image.
+
+```
+docker build -t zombi/steam-tf2 .
+```
+
+### Running steam-tf2
+
+```
+docker run -dit \
+ --name tf2-1 \
+ -p 27015:27015/udp \
+ -p 27015:27015 \
+ -v /data/steam-games/:/home/steam/games/ \
+ zombi/steam-tf2 +sv_pure 1 +map ctf_2fort +maxplayers 24
+```
+
+to start up a simple server to capture some flags.
diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh
new file mode 100644
index 0000000..daff80a
--- /dev/null
+++ b/bin/entrypoint.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# what are we trying to install?
+game_nm=tf
+game_id=232250
+
+# install game to this directory
+installdir=/home/steam/games/$game_nm
+
+# if path does not exist, create it
+mkdir -p $installdir
+
+if [[ -w $installdir ]] # can we write into the directory?
+then
+	# Install or update the game in /home/steam/games/[game name]
+	/opt/steamcmd/steamcmd.sh \
+		+login anonymous \
+		+force_install_dir $installdir \
+		+app_update $game_id validate \
+		+quit
+else
+	# install dir maybe mounted read-only, simply
+	# skip installing/updating and inform the user.
+	echo "Skipped game installation."
+fi
+
+# run the next commands from the installdir
+cd $installdir
+
+# is the game launcher not executable?
+if [[ ! -x ./srcds_run ]]
+then
+	# we cant run the game then.
+	echo "game launcher not found, installed incorrectly?"
+	exit 1
+fi
+
+# launch the game!
+exec ./srcds_run \
+	-game $game_nm \
+	-console \
+	$@ # append all remaining parameters