From 4dfd8a3a44b846b677b2964063c25deb4426fbf6 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Sat, 28 Apr 2018 04:53:47 +0000 Subject: [PATCH] Update Dockerfile Update Dockerfile to work again. Add updated FPS script. Add overlay placeholde directory. --- .gitignore | 4 ++- Dockerfile | 28 +++++++++--------- README.md | 15 +++++++++- entry.sh | 1 + overlay/.placeholder | 0 scripts/fps.py | 68 ++++++++++++++++++++++++++++++++++++++++++++ scripts/fps_data.py | 20 ------------- 7 files changed, 101 insertions(+), 35 deletions(-) create mode 100644 overlay/.placeholder create mode 100755 scripts/fps.py delete mode 100644 scripts/fps_data.py diff --git a/.gitignore b/.gitignore index a1e0ea0..74fa4a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -cfg/*.* +overlay/* +!overlay/.placeholder logs +scripts/data* diff --git a/Dockerfile b/Dockerfile index 684f2b0..065ab44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,9 @@ FROM ubuntu RUN dpkg --add-architecture i386 && \ apt-get update && \ - apt-get -y install wget lib32gcc1 lib32stdc++6 libcurl3 unzip liblz4-tool + apt-get -y install wget lib32gcc1 lib32stdc++6 libcurl3 unzip liblz4-tool libcurl3:i386 gcc-multilib g++-multilib +# Accept ToS RUN printf "\n2\n"|apt-get install -y steamcmd RUN useradd -m steam @@ -29,31 +30,32 @@ RUN mkdir -p ~/.steam/sdk32 && ln -s ~/.steam/steamcmd/linux32/steamclient.so ~/ WORKDIR /home/steam/hlds +# Install NS RUN wget 'https://www.ensl.org/files/server/ns_dedicated_server_v32.zip' COPY --chown=steam files/ns.sha /home/steam/hlds # RUN sha256sum -c ns.sha - RUN unzip ns_dedicated_server_v32.zip -# NS workaround -RUN echo 70 > ns/steam_appid.txt -RUN mv ns/dlls/ns_i386.so ns/dlls/ns.so +WORKDIR /home/steam/hlds/ns -# Copy own configs including bans -ADD --chown=steam cfg/ /home/steam/hlds/ns/ +# NS workarounds +RUN echo 70 > steam_appid.txt +RUN mv dlls/ns_i386.so dlls/ns.so + +# ENSL package +RUN cp liblist.gam liblist.bak +RUN wget https://github.com/ENSL/ensl-plugin/releases/download/v1.4/ensl_srvpkg-v1.4.zip -O srv.zip +RUN unzip -o srv.zip # Use seperate server.cfg because autoexec.cfg is unreliable RUN touch /home/steam/hlds/ns/server.cfg +# Copy own configs including bans +ADD overlay /home/steam/hlds/ns/ COPY entry.sh /home/steam/hlds - -USER root -RUN apt-get update && apt-get install -y libcurl3 libcurl3:i386 gcc-multilib g++-multilib -USER steam +RUN chown -R steam:steam /home/steam WORKDIR /home/steam/hlds -RUN wget https://github.com/ENSL/ensl-plugin/releases/download/v1.3/ensl_srvpkg-v1.3.zip -O srv.zip -RUN unzip srv.zip # VAC, HLDS, RCON, HLTV EXPOSE 26900 diff --git a/README.md b/README.md index 875afe8..abf2f21 100644 --- a/README.md +++ b/README.md @@ -1 +1,14 @@ -# ensl_hlds +# ENSL HLDS Dockerfile. + +How to use: +* `make build` to build Docker image +* `make run` to start NS1 server at default port on localhost +* `make stop` to stop the NS1 server +* `make clean` to clean containers and images + +Add any custom configs you want to to overlay directory. + +Features: +* Basically installs HLDS + NS1 server + ENSL Plugin. +* Also adds log compression with LZ4. +* Optional argument to enable HLTV. diff --git a/entry.sh b/entry.sh index 92ec3ef..7f6fb83 100755 --- a/entry.sh +++ b/entry.sh @@ -15,3 +15,4 @@ if [ -z $ROTATE_LOGS ]; then fi ./hlds_run -game ns +maxplayers 32 +log on +map ns_veil +exec ns/server.cfg +bash diff --git a/overlay/.placeholder b/overlay/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/scripts/fps.py b/scripts/fps.py new file mode 100755 index 0000000..f1ebcf0 --- /dev/null +++ b/scripts/fps.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +import rHLDS, yaml, re, time, os, argparse +from bokeh.plotting import figure, output_file, show +from datetime import datetime + +def write_data(filename): + # Default port 27015 + srv = rHLDS.Console(host=os.environ['RCON_HOST'], port=os.environ['RCON_PORT'], password=os.environ['RCON_PASSWORD']) + srv.connect() + + timestamp = time.time() + file1 = open(filename, "a+") + + try: + while True: + data = srv.execute("stats") + fps = re.search('(\d+.?\d*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)', data).group(7) + if fps: + file1.write("%d,%s\n" % (time.time(), fps)) + print(fps + " ", end='') + time.sleep(5) + except: + pass + + file1.close() + srv.disconnect() + +# Read data +def read_data(filename): + file1 = open(filename, "r") + fps_time = [] + fps_data = [] + + while True: + line = file1.readline() + if not line: break + time = re.search('(\d+),(\d+).(\d*)', line).group(1) + fps = re.search('(\d+),(\d+)', line).group(2) + if fps and time: + print('time: ' + time) + print('fps: ' + fps) + fps_time.append(datetime.fromtimestamp(int(time)/1000)) + fps_data.append(fps) + + # output to static HTML file + output_file("%s.html" % filename) + + # create a new plot with a title and axis labels + p = figure(title="hlds_linux stats", x_axis_label='time', y_axis_label='FPS') + + # add a line renderer with legend and line thickness + p.line(fps_time, fps_data, legend="FPS", line_width=2) + + # show the results + show(p) + +filename = "data.%d" % time.time() + +parser = argparse.ArgumentParser() +parser.add_argument("--file", help="Use the given file") +args = parser.parse_args() + +if not args.file: + write_data(filename) +else: + filename = args.file + +read_data(filename) diff --git a/scripts/fps_data.py b/scripts/fps_data.py deleted file mode 100644 index 14b9127..0000000 --- a/scripts/fps_data.py +++ /dev/null @@ -1,20 +0,0 @@ -import rHLDS, yaml, re, time, os - -# Default port 27015 -srv = rHLDS.Console(host=os.environ['RCON_HOST'], port=os.environ['RCON_PORT'], password=os.environ['RCON_PASSWORD']) - -# Connect to server -srv.connect() - -file1 = open("data.txt", "a+") - -while True: - data = srv.execute("stats") - fps = re.search('(\d+.?\d*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)(\d+.?\d*\s*)', data).group(7) - if fps: - file1.write("%d,%s\n" % (time.time(), fps)) - time.sleep(10) - -file1.close() -srv.disconnect() -