From e89f499848d15e67a91f65f3988a23242f22b0f7 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 10 Oct 2021 02:30:00 +0200 Subject: [PATCH 01/15] Extend server.cfg template Mention some other CVARs the server owner should care about (frag limit, allow upload, logging, hints to customize mapcycle and motd). Also correct mp_timeleft to mp_timelimit (timeleft is in seconds and seems to be read-only, it's rather to query the actual time life while the round is running) and a typo. --- config/server.cfg | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/config/server.cfg b/config/server.cfg index 80cf7d5..c1f5aa8 100644 --- a/config/server.cfg +++ b/config/server.cfg @@ -10,7 +10,10 @@ echo "Executing custom config/server.cfg" hostname "My awesome HLDM Docker Server!" // Change map after 60 minutes. -mp_timeleft 60 +mp_timelimit 60 + +// Set frag limit +// mp_fraglimit 50 // Set password for remote console. // rcon_password "SECRET_PASSWORD" @@ -18,6 +21,19 @@ mp_timeleft 60 // Enable LAN server mode // sv_lan 1 -// Indecate that the server is located in Europe +// Indicate that the server is located in Europe // sv_proxy 3 +// Allow clients to upload custom content (spraypaint decals, player models) +// sv_allowupload 1 + +// Enable logging (logs will be located in the valve/logs subdirectory within the container) +// mp_logfile 1 +// mp_logmessages 1 +// log on + +// Use custom mapcycle.txt (you'll need to create it in same directory as this file) +// mapcyclefile "config/mapcycle.txt" + +// Use custom Message Of The Day +// motdfile "config/motd.txt" From 9f63c18492ff1484fffc251fb8a18c0ed041bae0 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 10 Oct 2021 23:00:00 +0200 Subject: [PATCH 02/15] Add update and deploy script Attempt to update HLDS via SteamCMD before starting the server. Deploy the contents of valve/config/deploy/gamedir into the valve directory, which gives server owners the opportunity to install additional assets (e.g. maps, models, mods) or overwrite existing files without rebuilding the Docker image. --- Dockerfile | 8 ++++++-- misc/hldm.update | 4 ++++ misc/hlds_deploy | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 misc/hldm.update create mode 100755 misc/hlds_deploy diff --git a/Dockerfile b/Dockerfile index 34ab343..55901af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN dpkg --add-architecture i386 \ USER steam WORKDIR /opt/steam COPY ./misc/hldm.install /opt/steam +COPY ./misc/hldm.update /opt/steam # Download SteamCMD and install HLDM. RUN curl -sL media.steampowered.com/client/installer/steamcmd_linux.tar.gz | tar xzvf - \ @@ -44,13 +45,16 @@ RUN echo 70 > steam_appid.txt RUN rm -fr cstrike # Copy configs, Metamod and Stripper2. -COPY valve valve +COPY --chown=steam:steam valve valve + +# Copy deploy script +COPY ./misc/hlds_deploy /opt/steam/hldm EXPOSE 27015 EXPOSE 27015/udp # Start server. -ENTRYPOINT ["./hlds_run", "-timeout 3"] +ENTRYPOINT ["./hlds_deploy", "-timeout 5"] # Default start parameters. CMD ["+maxplayers 12", "+map crossfire"] diff --git a/misc/hldm.update b/misc/hldm.update new file mode 100644 index 0000000..ea04518 --- /dev/null +++ b/misc/hldm.update @@ -0,0 +1,4 @@ +login anonymous +force_install_dir ./hldm +app_update 90 +quit diff --git a/misc/hlds_deploy b/misc/hlds_deploy new file mode 100755 index 0000000..a910365 --- /dev/null +++ b/misc/hlds_deploy @@ -0,0 +1,40 @@ +#!/bin/sh + +announce() { +sep="--------------------------------------------------------------------------------" +printf "\n\n%s\n %s\n%s\n\n" "${sep}" "$1" "${sep}" +} + +cat << END + + +-------------------------------------------------------------------------------- + + # # # ###### ##### + # # # # # # # + # # # # # # + ####### # # # ##### + # # # # # # + # # # # # # # + # # ####### ###### ##### + + ((( Docker Deployment ))) + +-------------------------------------------------------------------------------- + +END + + +announce "Updating HLDS via SteamCMD..." +../steamcmd.sh +runscript hldm.update + +announce "Deploying gamedir..." +if [ -d valve/config/deploy/gamedir ] +then + find valve/config/deploy/gamedir -mindepth 1 -maxdepth 1 -exec cp -vr {} valve/ \; +else + printf "No gamedir deploy found.\n" +fi + +announce "Starting HLDS..." +exec ./hlds_run "$@" From 49cc3c2f5e7fa589af8c153275f37ac621a269e4 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 15 Jan 2023 05:20:00 +0100 Subject: [PATCH 03/15] Set force_install_dir before login SteamCMD started to require it, not just nicely asking. --- misc/hldm.install | 2 +- misc/hldm.update | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/hldm.install b/misc/hldm.install index 1be8e11..e8bf155 100644 --- a/misc/hldm.install +++ b/misc/hldm.install @@ -1,5 +1,5 @@ -login anonymous force_install_dir ./hldm +login anonymous app_set_config 90 mod valve app_update 90 app_update 90 diff --git a/misc/hldm.update b/misc/hldm.update index ea04518..1b27beb 100644 --- a/misc/hldm.update +++ b/misc/hldm.update @@ -1,4 +1,4 @@ -login anonymous force_install_dir ./hldm +login anonymous app_update 90 quit From a828dfcd645beefdfcfe35e850af6d9ac3d4dc59 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 15 Jan 2023 05:30:00 +0100 Subject: [PATCH 04/15] Correct factual error in server.cfg --- config/server.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/server.cfg b/config/server.cfg index c1f5aa8..5a83817 100644 --- a/config/server.cfg +++ b/config/server.cfg @@ -24,7 +24,7 @@ mp_timelimit 60 // Indicate that the server is located in Europe // sv_proxy 3 -// Allow clients to upload custom content (spraypaint decals, player models) +// Allow clients to upload spraypaint decals // sv_allowupload 1 // Enable logging (logs will be located in the valve/logs subdirectory within the container) From 91d76cb842a8263dc881baf1ec35a78c31a1cedc Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 15 Jan 2023 15:15:00 +0100 Subject: [PATCH 05/15] Add ability to deploy archives The deploy script now looks into two additional directories, install-assets and install-maps, to find archive files to extract into the game directory (valve) and maps directory (valve/maps) respectively. Various archive formats are recognized and extracted appropriately. Also gamedir was renamed to copy-gamedir from where the script just copies the files into gamedir. --- Dockerfile | 11 ++++- misc/hlds_deploy | 114 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 55901af..e635051 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,16 @@ RUN groupadd -r steam && useradd -r -g steam -m -d /opt/steam steam # Update base image and install dependencies. RUN dpkg --add-architecture i386 \ +&& sed -i "s/main$/main non-free/g" /etc/apt/sources.list \ && apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ + file \ + gzip \ + bzip2 \ + xz-utils \ + zstd \ + p7zip-rar \ libc6:i386 \ && apt-get clean @@ -29,8 +36,8 @@ RUN curl -sL media.steampowered.com/client/installer/steamcmd_linux.tar.gz | tar COPY ./misc/appmanifest_70.acf /opt/steam/hldm/steamapps/appmanifest_70.acf COPY ./misc/appmanifest_90.acf /opt/steam/hldm/steamapps/appmanifest_90.acf -# Download HLDS again. -RUN ./steamcmd.sh +runscript hldm.install +# Download HLDS again, fail compose if unsuccessful. +RUN ./steamcmd.sh +runscript hldm.install && stat ./hldm/valve/gfx.wad # Fix error that steamclient.so is missing. RUN mkdir -p $HOME/.steam \ diff --git a/misc/hlds_deploy b/misc/hlds_deploy index a910365..50b7087 100755 --- a/misc/hlds_deploy +++ b/misc/hlds_deploy @@ -1,10 +1,89 @@ #!/bin/sh +DEPLOY=valve/config/deploy +DEPLOY_MAPS=${DEPLOY}/install-maps +DEPLOY_ASSETS=${DEPLOY}/install-assets +DEPLOY_GAMEDIR=${DEPLOY}/copy-gamedir +TARGET_GAMEDIR=valve +TARGET_MAPS=${TARGET_GAMEDIR}/maps announce() { sep="--------------------------------------------------------------------------------" printf "\n\n%s\n %s\n%s\n\n" "${sep}" "$1" "${sep}" } +is_multiplayer_map() { + BSPFILE="$1" + grep -q "^\"classname\" \"info_player_deathmatch\"$" "${BSPFILE}" +} + +decompress_with() { + COMMAND="$1" + SWITCHES="$2" + SOURCE="$3" + TARGET="$4" + + outfile="${TARGET}/${filename%.*}" + eval "${COMMAND}" "${SOURCE}" "${SWITCHES}" > "${outfile}" + touch -r "${SOURCE}" "${outfile}" +} + +deploy_archive() { + SOURCE="$1" + TARGET="$2" + + filename="$(basename "${SOURCE}")" + filetype="$(file -b --mime-type "${SOURCE}")" + filetype="${filetype#"application/"}" + + printf "\nConsidering %s, it is a(n) %s...\n" "${SOURCE}" "${filetype}" + case "${filetype}" in + "gzip") + decompress_with gunzip -vc "${SOURCE}" "${TARGET}";; + "x-bzip2") + decompress_with bunzip2 -vc "${SOURCE}" "${TARGET}";; + "x-xz") + decompress_with unxz -vc "${SOURCE}" "${TARGET}";; + "zstd") + zstd -vdfo "${TARGET}/${filename%.*}" "${SOURCE}";; + "x-7z-compressed" | "zip" | "x-rar" | "x-arj") + 7z x -bb1 "${SOURCE}" -y -o"${TARGET}/";; + *) + printf "ERROR! Skipping %s due to unknown file type.\n" "${SOURCE}" >&2 + esac +} + +deploy_archive_map() { + SOURCE="$1" + TARGET="$2" + + filename="$(basename "${SOURCE}")" + fileext="${filename##*.}" + filetype="$(file -b --mime-type "${SOURCE}")" + + if [ "${fileext}" = "bsp" ] + then + if is_multiplayer_map "${SOURCE}" + then + printf "\nFound BSP %s...\n" "${SOURCE}" + cp -pv "${SOURCE}" "${TARGET}/" + else + printf "\nFound %s, but it is not a Half-Life muptiplayer map!\n" "${SOURCE}" >&2 + fi + elif [ "${fileext}" = "res" ] + then + if [ "$(file -b --mime-type "${SOURCE}")" = "text/plain" ] + then + printf "\nFound RES %s...\n" "${SOURCE}" + cp -pv "${SOURCE}" "${TARGET}/" + else + printf "\nFound %s, but it is not a valid resource file!\n" "${SOURCE}" >&2 + fi + else + deploy_archive "${SOURCE}" "${TARGET}" + fi +} + + cat << END @@ -25,13 +104,40 @@ cat << END END -announce "Updating HLDS via SteamCMD..." -../steamcmd.sh +runscript hldm.update +# This often breaks HLDS, rather not try +#announce "Updating HLDS via SteamCMD..." +#../steamcmd.sh +runscript hldm.update + +announce "Deploying assets..." +if [ -d "${DEPLOY_ASSETS}" ] +then + find "${DEPLOY_ASSETS}" -mindepth 1 -maxdepth 1 | while read -r sourcefile + do + deploy_archive "${sourcefile}" "${TARGET_GAMEDIR}" + done + printf "Contents of %s:\n" "${TARGET_GAMEDIR}" + ls -l "${TARGET_GAMEDIR}" +else + printf "No assets deploy found.\n" +fi + +announce "Deploying maps..." +if [ -d "${DEPLOY_MAPS}" ] +then + find "${DEPLOY_MAPS}" -mindepth 1 -maxdepth 1 | while read -r sourcefile + do + deploy_archive_map "${sourcefile}" "${TARGET_MAPS}" + done + printf "Contents of %s:\n" "${TARGET_MAPS}" + ls -l "${TARGET_MAPS}" +else + printf "No maps deploy found.\n" +fi announce "Deploying gamedir..." -if [ -d valve/config/deploy/gamedir ] +if [ -d "${DEPLOY_GAMEDIR}" ] then - find valve/config/deploy/gamedir -mindepth 1 -maxdepth 1 -exec cp -vr {} valve/ \; + find "${DEPLOY_GAMEDIR}" -mindepth 1 -maxdepth 1 -exec cp -vr {} "${TARGET_GAMEDIR}"/ \; else printf "No gamedir deploy found.\n" fi From 8607af45dcbf1d4bb451472e35da841d4e124d53 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Mon, 16 Jan 2023 00:00:00 +0100 Subject: [PATCH 06/15] Add ability to extract compressed tar --- misc/hlds_deploy | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/misc/hlds_deploy b/misc/hlds_deploy index 50b7087..d08e82d 100755 --- a/misc/hlds_deploy +++ b/misc/hlds_deploy @@ -36,6 +36,17 @@ deploy_archive() { filetype="${filetype#"application/"}" printf "\nConsidering %s, it is a(n) %s...\n" "${SOURCE}" "${filetype}" + + # Check for tar compressed with gzip, bzip2, xz, zstd + if [ "${filetype}" = "gzip" ] || [ "${filetype}" = "x-bzip2" ] || [ "${filetype}" = "x-xz" ] || [ "${filetype}" = "zstd" ] + then + if [ "$(file -bz --mime-type "${SOURCE}")" = "application/x-tar" ] + then + printf "Found x-tar compressed with %s.\n" "${filetype}" + filetype="x-tar" + fi + fi + case "${filetype}" in "gzip") decompress_with gunzip -vc "${SOURCE}" "${TARGET}";; @@ -45,6 +56,8 @@ deploy_archive() { decompress_with unxz -vc "${SOURCE}" "${TARGET}";; "zstd") zstd -vdfo "${TARGET}/${filename%.*}" "${SOURCE}";; + "x-tar") + tar xvfC "${SOURCE}" "${TARGET}";; "x-7z-compressed" | "zip" | "x-rar" | "x-arj") 7z x -bb1 "${SOURCE}" -y -o"${TARGET}/";; *) From aa85a5994e83133aaa6c5fdeac3c675cf49db24c Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Mon, 16 Jan 2023 01:15:00 +0100 Subject: [PATCH 07/15] Auto-generate mapcycle.txt --- misc/hlds_deploy | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/misc/hlds_deploy b/misc/hlds_deploy index d08e82d..775487c 100755 --- a/misc/hlds_deploy +++ b/misc/hlds_deploy @@ -5,6 +5,7 @@ DEPLOY_ASSETS=${DEPLOY}/install-assets DEPLOY_GAMEDIR=${DEPLOY}/copy-gamedir TARGET_GAMEDIR=valve TARGET_MAPS=${TARGET_GAMEDIR}/maps +MAPCYCLE=${TARGET_GAMEDIR}/mapcycle.txt announce() { sep="--------------------------------------------------------------------------------" @@ -155,5 +156,21 @@ else printf "No gamedir deploy found.\n" fi +announce "Generating mapcycle.txt..." +printf "" > "${MAPCYCLE}" +find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -name \*.bsp | while read -r bspfile +do + mapname="$(basename "${bspfile}")" + mapname="${mapname%.*}" + printf "%-30s: " "${mapname}" + if is_multiplayer_map "${bspfile}" + then + printf "%s\n" "${mapname}" >> "${MAPCYCLE}" + printf "added\n" + else + printf "skipped (not a multiplayer map)\n" + fi +done + announce "Starting HLDS..." exec ./hlds_run "$@" From dd497e34ad5488262e6b8356cbde62749f9bfc4d Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Wed, 18 Jan 2023 01:45:00 +0100 Subject: [PATCH 08/15] Add comments, clean code --- misc/hlds_deploy | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/misc/hlds_deploy b/misc/hlds_deploy index 775487c..30515fc 100755 --- a/misc/hlds_deploy +++ b/misc/hlds_deploy @@ -7,16 +7,24 @@ TARGET_GAMEDIR=valve TARGET_MAPS=${TARGET_GAMEDIR}/maps MAPCYCLE=${TARGET_GAMEDIR}/mapcycle.txt +# announce text +# Print text with separator lines. announce() { -sep="--------------------------------------------------------------------------------" -printf "\n\n%s\n %s\n%s\n\n" "${sep}" "$1" "${sep}" + sep="--------------------------------------------------------------------------------" + printf "\n\n%s\n %s\n%s\n\n" "${sep}" "$1" "${sep}" } +# is_multiplayer_map bspfile +# Determines is given BSP file is a multiplayer map by searching for an +# info_player_deathmatch entity. is_multiplayer_map() { BSPFILE="$1" grep -q "^\"classname\" \"info_player_deathmatch\"$" "${BSPFILE}" } +# decompress_with command switches source target +# Use the specified command and its switches to decompress the source file +# to the given destination directory. decompress_with() { COMMAND="$1" SWITCHES="$2" @@ -28,6 +36,8 @@ decompress_with() { touch -r "${SOURCE}" "${outfile}" } +# deploy_archive source target +# Extracts an archive file (source) to the target directory. deploy_archive() { SOURCE="$1" TARGET="$2" @@ -66,6 +76,10 @@ deploy_archive() { esac } +# deploy_archive_map source target +# The source may be an archive, a BSP file, or a RES file. In case the source +# is an archive, extract it with deploy_archive. If it is a multiplayer map or +# accompanying resource file, copy it to the target directory. deploy_archive_map() { SOURCE="$1" TARGET="$2" @@ -81,7 +95,7 @@ deploy_archive_map() { printf "\nFound BSP %s...\n" "${SOURCE}" cp -pv "${SOURCE}" "${TARGET}/" else - printf "\nFound %s, but it is not a Half-Life muptiplayer map!\n" "${SOURCE}" >&2 + printf "\nFound %s, but it is not a Half-Life multiplayer map!\n" "${SOURCE}" >&2 fi elif [ "${fileext}" = "res" ] then @@ -122,6 +136,7 @@ END #announce "Updating HLDS via SteamCMD..." #../steamcmd.sh +runscript hldm.update +# Deploy archives to the base game directory announce "Deploying assets..." if [ -d "${DEPLOY_ASSETS}" ] then @@ -129,12 +144,11 @@ then do deploy_archive "${sourcefile}" "${TARGET_GAMEDIR}" done - printf "Contents of %s:\n" "${TARGET_GAMEDIR}" - ls -l "${TARGET_GAMEDIR}" else printf "No assets deploy found.\n" fi +# Deploy archives to the maps directory announce "Deploying maps..." if [ -d "${DEPLOY_MAPS}" ] then @@ -142,12 +156,11 @@ then do deploy_archive_map "${sourcefile}" "${TARGET_MAPS}" done - printf "Contents of %s:\n" "${TARGET_MAPS}" - ls -l "${TARGET_MAPS}" else printf "No maps deploy found.\n" fi +# Copy miscellaneous files to the game directory announce "Deploying gamedir..." if [ -d "${DEPLOY_GAMEDIR}" ] then @@ -156,6 +169,9 @@ else printf "No gamedir deploy found.\n" fi +# Generate a mapcycle.txt by enumerating all multiplayer maps +# In case the server owner prefers to use a hand-made mapcycle.txt, this file +# might be overridden by specifying a different mapcycle file in server.cfg announce "Generating mapcycle.txt..." printf "" > "${MAPCYCLE}" find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -name \*.bsp | while read -r bspfile @@ -172,5 +188,7 @@ do fi done +# Execute the hlds_run script, replacing the current process, thus this +# deployment script and its shell interpreter will be unloaded from memory announce "Starting HLDS..." exec ./hlds_run "$@" From 4aeb7e66378f0ceb6dbb6f29d8cb056abd47ae92 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Wed, 18 Jan 2023 03:20:30 +0100 Subject: [PATCH 09/15] Check for misinstalled maps --- misc/hlds_deploy | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/misc/hlds_deploy b/misc/hlds_deploy index 30515fc..44247f0 100755 --- a/misc/hlds_deploy +++ b/misc/hlds_deploy @@ -188,6 +188,26 @@ do fi done +# Check for potentially misinstalled maps +if [ "$(find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -name \*.bsp | wc -l)" -gt 0 ] +then + announce "WARNING! Misinstalled maps in root game directory!" + printf "%s\n%s\n\n" \ + "The following maps found in the root game directory, likely came from" \ + "archive files you should have put into $(basename "${DEPLOY_MAPS}") instead:" + ls -l "${TARGET_GAMEDIR}"/*.bsp +fi + +rmdir "${TARGET_MAPS}/maps" 2> /dev/null +if [ -d "${TARGET_MAPS}/maps" ] +then + announce "WARNING! Misinstalled maps in ${TARGET_MAPS}/maps directory!" + printf "%s\n%s\n\n" \ + "The following files likely came from an archive you should have put" \ + "into $(basename "${DEPLOY_ASSETS}") instead:" + ls -l "${TARGET_MAPS}/maps" +fi + # Execute the hlds_run script, replacing the current process, thus this # deployment script and its shell interpreter will be unloaded from memory announce "Starting HLDS..." From 9475d9780fba010c49da6043b1b719fa4004e6e2 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Thu, 19 Jan 2023 02:45:00 +0100 Subject: [PATCH 10/15] Extend README with usage of the deploy feature --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 3883f98..9aa734f 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,14 @@ docker run -it --rm -d -p27015:27015 -p27015:27015/udp -v config:/opt/steam/hldm You should see `Executing custom config/server.cfg` in the server log when starting the server. +You can also add custom content by creating the following directories under `config/deploy`: + + - `install-assets`: You can put archive files here to be extracted into the root game directory (`valve`). + - `install-maps`: Put archive files or BSP, RES files here to be deployed into the `maps` subdirectory. + - `copy-gamedir`: The entire directory structure will be copied verbatim into the root game directory. + +The following archive formats are supported: `zip`, `7z`, `rar`, `tar`, `gzip`, `bzip2`, `xz`, `zstd`, `arj`. To remove content, you can simply remove the files from `deploy` and then recreate your container. + ## About this Docker image From 4329d17cb212cc123f379ed37a367c6315098ef0 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sat, 18 Nov 2023 12:30:00 +0100 Subject: [PATCH 11/15] Update to Debian Bookworm --- docker/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 11e19d7..ec10d73 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,14 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim -ENV VERSION 2021.9 -ENV RELEASE_DATE 2021-09-05 +ENV VERSION 2023.11 +ENV RELEASE_DATE 2023-11-18 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 ENV DEBIAN_FRONTEND noninteractive # Update base image and install dependencies. RUN dpkg --add-architecture i386 \ - && sed -i "s/main$/main non-free/g" /etc/apt/sources.list \ + && sed -i "s/^Components: main$/Components: main non-free/g" /etc/apt/sources.list.d/debian.sources \ && apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ From 40d13a18e9a63d4d8616d5672d50e09a435a752e Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Fri, 1 Dec 2023 23:00:00 +0100 Subject: [PATCH 12/15] Install libstdc++ on Bookworm As of today, the libstdc++.so.6 library is not shipped with HLDS anymore. Meanwhile, this library was also removed from the debian:bookworm-slim image. As a result, the libstdc++:i386 package needs to be installed via the Dockerfile. --- docker/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ec10d73..006a022 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ FROM debian:bookworm-slim -ENV VERSION 2023.11 -ENV RELEASE_DATE 2023-11-18 +ENV VERSION 2023.12 +ENV RELEASE_DATE 2023-12-01 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 ENV DEBIAN_FRONTEND noninteractive @@ -19,6 +19,7 @@ RUN dpkg --add-architecture i386 \ zstd \ p7zip-rar \ libc6:i386 \ + libstdc++6:i386 \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ && groupadd -r steam && useradd -r -g steam -m -d /opt/steam steam \ && mkdir /deploy From 631ccd93f7bba7166a7549308688115f829d878c Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Thu, 4 Jan 2024 14:30:26 +0100 Subject: [PATCH 13/15] Deploy: Look for BSP files case-insensitively --- docker/hlds_deploy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/hlds_deploy b/docker/hlds_deploy index 172c1f2..fd1932e 100755 --- a/docker/hlds_deploy +++ b/docker/hlds_deploy @@ -85,7 +85,7 @@ deploy_archive_map() { TARGET="$2" filename="$(basename "${SOURCE}")" - fileext="${filename##*.}" + fileext="$(printf "%s" "${filename##*.}" | tr 'BSPRE' 'bspre')" filetype="$(file -b --mime-type "${SOURCE}")" if [ "${fileext}" = "bsp" ] @@ -174,7 +174,7 @@ fi # might be overridden by specifying a different mapcycle file in server.cfg announce "Generating mapcycle.txt..." printf "" > "${MAPCYCLE}" -find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -name \*.bsp | while read -r bspfile +find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp | while read -r bspfile do mapname="$(basename "${bspfile}")" mapname="${mapname%.*}" @@ -189,13 +189,13 @@ do done # Check for potentially misinstalled maps -if [ "$(find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -name \*.bsp | wc -l)" -gt 0 ] +if [ "$(find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp | wc -l)" -gt 0 ] then announce "WARNING! Misinstalled maps in root game directory!" printf "%s\n%s\n\n" \ "The following maps found in the root game directory, likely came from" \ "archive files you should have put into $(basename "${DEPLOY_MAPS}") instead:" - ls -l "${TARGET_GAMEDIR}"/*.bsp + find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp -ls fi rmdir "${TARGET_MAPS}/maps" 2> /dev/null From 200bffe1194afed19310b01d6cb42d9260aac6a0 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Mon, 8 Jan 2024 00:00:00 +0100 Subject: [PATCH 14/15] Deploy: Look for misinstalled maps in entire tree --- docker/hlds_deploy | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docker/hlds_deploy b/docker/hlds_deploy index fd1932e..8307ca7 100755 --- a/docker/hlds_deploy +++ b/docker/hlds_deploy @@ -189,15 +189,19 @@ do done # Check for potentially misinstalled maps -if [ "$(find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp | wc -l)" -gt 0 ] +tmplist="$(mktemp)" +find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp -ls > "${tmplist}" +if [ "$(wc -l < "${tmplist}")" -gt 0 ] then announce "WARNING! Misinstalled maps in root game directory!" printf "%s\n%s\n\n" \ "The following maps found in the root game directory, likely came from" \ "archive files you should have put into $(basename "${DEPLOY_MAPS}") instead:" - find "${TARGET_GAMEDIR}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp -ls + cat "${tmplist}" fi +# First try to remove the bogus directory which will fail if it's not empty, +# so we avoid listing an empty directory rmdir "${TARGET_MAPS}/maps" 2> /dev/null if [ -d "${TARGET_MAPS}/maps" ] then @@ -208,6 +212,20 @@ then ls -l "${TARGET_MAPS}/maps" fi +# Find maps from various other subdirectories +find "${TARGET_GAMEDIR}" -mindepth 2 -type f -iname \*.bsp -not -ipath "${TARGET_MAPS}/*.bsp" -ls > "${tmplist}" +find "${TARGET_MAPS}" -mindepth 2 -type f -iname \*.bsp -ls >> "${tmplist}" + +if [ "$(wc -l < "${tmplist}")" -gt 0 ] +then + announce "WARNING! Misinstalled maps!" + printf "%s\n%s\n\n" \ + "The following maps found in subdirectories where they are not supposed to be," \ + "likely came from incorrectly structured archive files:" + cat "${tmplist}" +fi +rm "${tmplist}" + # Execute the hlds_run script, replacing the current process, thus this # deployment script and its shell interpreter will be unloaded from memory announce "Starting HLDS..." From df22f20a5f8fd4622b0db16776fc31b326ae23a3 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Mon, 8 Jan 2024 03:00:30 +0100 Subject: [PATCH 15/15] Deploy: Find maps with invalid filenames --- docker/hlds_deploy | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docker/hlds_deploy b/docker/hlds_deploy index 8307ca7..b455e16 100755 --- a/docker/hlds_deploy +++ b/docker/hlds_deploy @@ -174,7 +174,7 @@ fi # might be overridden by specifying a different mapcycle file in server.cfg announce "Generating mapcycle.txt..." printf "" > "${MAPCYCLE}" -find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp | while read -r bspfile +find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -type f -iname \*.bsp -not -iname \*~\*.bsp | while read -r bspfile do mapname="$(basename "${bspfile}")" mapname="${mapname%.*}" @@ -224,6 +224,15 @@ then "likely came from incorrectly structured archive files:" cat "${tmplist}" fi + +# Warn about maps with invalid filenames +find "${TARGET_MAPS}" -mindepth 1 -maxdepth 1 -iname \*~\*.bsp -ls > "${tmplist}" +if [ "$(wc -l < "${tmplist}")" -gt 0 ] +then + announce "WARNING! Maps with invalid filenames!" + printf "The '~' character is not allowed in map names, thus these maps will not be functional:\n\n" + cat "${tmplist}" +fi rm "${tmplist}" # Execute the hlds_run script, replacing the current process, thus this