From 470b98a15d5b0b3cd578d5ec5dac23df4c837593 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Thu, 30 Nov 2023 14:03:33 +0100 Subject: [PATCH 01/11] dependency: update supercronic --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a3971e..4b0eca3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ ENV STEAM_PATH="/home/steam" \ GROUP_ID=10000 \ USER_ID=10000 \ DOCKER_USER=steam \ - SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ + SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.28/supercronic-linux-amd64 \ SUPERCRONIC=supercronic-linux-amd64 \ - SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 \ + SUPERCRONIC_SHA1SUM=fe1a81a8a5809deebebbd7a209a3b97e542e2bcd \ \ \ DEBIAN_FRONTEND=noninteractive \ From 4ea87f7d24812a5bd9db4423ce7a2e3f5be70c87 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Thu, 30 Nov 2023 14:04:03 +0100 Subject: [PATCH 02/11] test: fix testfile permissions --- test/testBuild.sh | 0 test/testCaseQuick.sh | 0 test/testHealth.sh | 0 test/testStyle.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/testBuild.sh mode change 100644 => 100755 test/testCaseQuick.sh mode change 100644 => 100755 test/testHealth.sh mode change 100644 => 100755 test/testStyle.sh diff --git a/test/testBuild.sh b/test/testBuild.sh old mode 100644 new mode 100755 diff --git a/test/testCaseQuick.sh b/test/testCaseQuick.sh old mode 100644 new mode 100755 diff --git a/test/testHealth.sh b/test/testHealth.sh old mode 100644 new mode 100755 diff --git a/test/testStyle.sh b/test/testStyle.sh old mode 100644 new mode 100755 From e7aecfe6cb36c9a1c06a9874af909c86a041e613 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Thu, 30 Nov 2023 14:05:43 +0100 Subject: [PATCH 03/11] fix: continue init if variable is not found in config #27 --- gmod/initConfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index c30bb9b..fb61e95 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -14,7 +14,7 @@ function configReplace() { source="$1" target="\"$2\"" - count=$(grep -Poc "($source).+" "${CFG_PATH}") + count=$(grep -Poc "($source).+" "${CFG_PATH}" || echo 0) echo "[initConfig.sh]Request for replacing $source to $target, source is found $count times" From dc83e87e2d4989a425a12d69aa468ff59b471443 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Thu, 30 Nov 2023 14:07:09 +0100 Subject: [PATCH 04/11] clean: DEBIAN_FRONTEND=noninteractive shouldn't be global --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b0eca3..b3860d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ ENV STEAM_PATH="/home/steam" \ SUPERCRONIC_SHA1SUM=fe1a81a8a5809deebebbd7a209a3b97e542e2bcd \ \ \ - DEBIAN_FRONTEND=noninteractive \ LANG=C.UTF-8 \ TERM=xterm \ \ @@ -40,9 +39,9 @@ COPY ["lgsm/entrypoint.sh", "lgsm/initCron.sh", "lgsm/createAlias.sh", "/home/"] # iproute2 needed because of "-slim" RUN dpkg --add-architecture i386 && \ apt-get update -y && \ - apt-get install -y bc binutils bsdmainutils bzip2 ca-certificates cpio curl file gzip hostname jq lib32gcc1 lib32stdc++6 netcat python3 tar tmux unzip util-linux wget xz-utils lib32gcc1 lib32stdc++6 libsdl2-2.0-0:i386 distro-info \ - libtinfo5:i386 \ - procps iproute2 && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y bc binutils bsdmainutils bzip2 ca-certificates cpio curl file gzip hostname jq lib32gcc1 lib32stdc++6 netcat python3 tar tmux unzip util-linux wget xz-utils lib32gcc1 lib32stdc++6 libsdl2-2.0-0:i386 distro-info \ + libtinfo5:i386 \ + procps iproute2 && \ \ groupadd -g $GROUP_ID $DOCKER_USER && \ useradd -d "$STEAM_PATH" -g $GROUP_ID -u $USER_ID -m $DOCKER_USER && \ @@ -140,7 +139,7 @@ ENV CSS_PATH="/home/steam/addons/css" \ LGSM_UPDATE=true \ \ USE_MY_REPLACER_CONFIG=false - + COPY ["gmod/prepareServer.sh", "gmod/initConfig.sh", "gmod/forceWorkshopDownload.sh", "gmod/installAndMountAddons.sh", "gmod/common.cfg", "/home/"] From 828f56cf22e753717fb01546bb8a9503bef8f72a Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Thu, 30 Nov 2023 14:17:29 +0100 Subject: [PATCH 05/11] log: warning for potential script crash --- gmod/initConfig.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index fb61e95..4c6aeff 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -13,6 +13,10 @@ CFG_PATH="${SERVER_PATH}/garrysmod/cfg/gmodserver.cfg" function configReplace() { source="$1" target="\"$2\"" + + if ! echo "$2" | grep -qe "^[a-zA-Z0-9_-]+$"; then + echo "[initConfig.sh]Warning your configured value for $source doesn't match regex ^[a-zA-Z0-9_-]+$. Special symbols could crash this script because they are not sanitized." + fi count=$(grep -Poc "($source).+" "${CFG_PATH}" || echo 0) From 1a359f220394d76cc981df89b199e1c05ebe746e Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Fri, 1 Dec 2023 13:23:28 +0100 Subject: [PATCH 06/11] log: to many warnings because of incorrect regex --- gmod/initConfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index 4c6aeff..d98670f 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -14,7 +14,7 @@ function configReplace() { source="$1" target="\"$2\"" - if ! echo "$2" | grep -qe "^[a-zA-Z0-9_-]+$"; then + if ! echo "$2" | grep -qe "^[a-zA-Z0-9_-]*$"; then echo "[initConfig.sh]Warning your configured value for $source doesn't match regex ^[a-zA-Z0-9_-]+$. Special symbols could crash this script because they are not sanitized." fi From 6c8b09438e7a7af6ee47d9d87455d3d7ef2db5b9 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Mon, 4 Dec 2023 11:48:59 +0100 Subject: [PATCH 07/11] fix: update debian 10->12 #28 --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3860d6..2d95ca1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:buster-slim as lgsm +FROM debian:12-slim as lgsm # Const \\ Overwrite Env \\ Configs possible \\ Configs needed # C.UTF-8 -> en_US.UTF-8 @@ -39,7 +39,8 @@ COPY ["lgsm/entrypoint.sh", "lgsm/initCron.sh", "lgsm/createAlias.sh", "/home/"] # iproute2 needed because of "-slim" RUN dpkg --add-architecture i386 && \ apt-get update -y && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y bc binutils bsdmainutils bzip2 ca-certificates cpio curl file gzip hostname jq lib32gcc1 lib32stdc++6 netcat python3 tar tmux unzip util-linux wget xz-utils lib32gcc1 lib32stdc++6 libsdl2-2.0-0:i386 distro-info \ + DEBIAN_FRONTEND=noninteractive apt-get install -y bc binutils bsdmainutils bzip2 ca-certificates cpio curl distro-info file gzip hostname jq lib32gcc-s1 lib32stdc++6 netcat-openbsd python3 tar tmux unzip util-linux uuid-runtime wget xz-utils \ + lib32gcc-s1 lib32stdc++6 libsdl2-2.0-0:i386 \ libtinfo5:i386 \ procps iproute2 && \ \ From 494e55c95ad065b67149ce5245c32d064d8153e6 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Mon, 4 Dec 2023 11:49:27 +0100 Subject: [PATCH 08/11] fix: console log to container log --- lgsm/entrypoint.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lgsm/entrypoint.sh b/lgsm/entrypoint.sh index c6c4de7..3ce4014 100644 --- a/lgsm/entrypoint.sh +++ b/lgsm/entrypoint.sh @@ -59,7 +59,7 @@ function stopServer() { IS_RUNNING="false" echo "done!" } -./"$SERVER_EXECUTABLE" start & +./"$SERVER_EXECUTABLE" start trap stopServer SIGTERM #start cron @@ -71,9 +71,10 @@ bash "/home/initCron.sh" # --- Wait for Shutdown --- echo "Server is running, waiting for SIGTERM" +tail -f /home/steam/log/console/gmodserver-console.log & while [ "$IS_RUNNING" = "true" ] do sleep 1s done echo "entrypoint stopped" -exit 0 \ No newline at end of file +exit 0 From d6e98cf13b900a56c67c92c888b2938730664ab3 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Mon, 4 Dec 2023 11:49:55 +0100 Subject: [PATCH 09/11] log: example shouldn't throw a warning --- gmod/initConfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index d98670f..4ca6ccb 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -14,7 +14,7 @@ function configReplace() { source="$1" target="\"$2\"" - if ! echo "$2" | grep -qe "^[a-zA-Z0-9_-]*$"; then + if ! echo "$2" | grep -qe "^[a-zA-Z0-9_ -]*$"; then echo "[initConfig.sh]Warning your configured value for $source doesn't match regex ^[a-zA-Z0-9_-]+$. Special symbols could crash this script because they are not sanitized." fi From 236a1fbbb9867fcc39074f2a92205b4a61f94c4f Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 29 Jun 2024 14:17:37 +0200 Subject: [PATCH 10/11] fix(gmod): initConfig should handle multiple occurence --- gmod/initConfig.sh | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index 4ca6ccb..4f06f32 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -11,28 +11,20 @@ set -o pipefail CFG_PATH="${SERVER_PATH}/garrysmod/cfg/gmodserver.cfg" function configReplace() { - source="$1" - target="\"$2\"" + local source="$1" + local target="$2" - if ! echo "$2" | grep -qe "^[a-zA-Z0-9_ -]*$"; then - echo "[initConfig.sh]Warning your configured value for $source doesn't match regex ^[a-zA-Z0-9_-]+$. Special symbols could crash this script because they are not sanitized." - fi - - count=$(grep -Poc "($source).+" "${CFG_PATH}" || echo 0) - - echo "[initConfig.sh]Request for replacing $source to $target, source is found $count times" - - if [ "$count" == "1" ]; then - sed -Ei "/${source}.*/d" "${CFG_PATH}" - echo "$source $target" >> "${CFG_PATH}" - - elif [ "$count" == "0" ]; then - echo "" >> "${CFG_PATH}" - echo "$source $target" >> "${CFG_PATH}" - - else - echo "[initConfig.sh]can't set $1 because there are multiple in" - fi + count=$(grep -Ece "^\s*${source}\s" "${CFG_PATH}") + + echo "[initConfig.sh]Request for replacing \"$source\" to \"$target\", source is found $count times" + + sed -E -i "/^\s${source}\s.*/d" "${CFG_PATH}" + + local file_ends_on_newline=$([ "$(tail -c1 f | wc -l)" -eq 1 ] && echo true || echo false) + if ! $file_ends_on_newline; then + echo "" >> "${CFG_PATH}" + fi + echo "$source \"$target\"" >> "${CFG_PATH}" } #create default server.config @@ -56,4 +48,4 @@ if [ -n "${SERVER_RCON_PASSWORD}" ]; then fi if [ -n "${SERVER_VOICE_ENABLE}" ]; then configReplace "sv_voiceenable" "$SERVER_VOICE_ENABLE" -fi \ No newline at end of file +fi From 2105a54147c62d9f3e505ebe72c60ed6562fa7b2 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 29 Jun 2024 15:48:55 +0200 Subject: [PATCH 11/11] fix(gmod): check cfg not my local test file --- gmod/initConfig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmod/initConfig.sh b/gmod/initConfig.sh index 4f06f32..fc8bcfa 100644 --- a/gmod/initConfig.sh +++ b/gmod/initConfig.sh @@ -20,7 +20,7 @@ function configReplace() { sed -E -i "/^\s${source}\s.*/d" "${CFG_PATH}" - local file_ends_on_newline=$([ "$(tail -c1 f | wc -l)" -eq 1 ] && echo true || echo false) + local file_ends_on_newline=$([ "$(tail -c1 "${CFG_PATH}" | wc -l)" -eq 1 ] && echo true || echo false) if ! $file_ends_on_newline; then echo "" >> "${CFG_PATH}" fi