From dd1a5789812f7ad06a0b7971d2c7fe98d3b4ff30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Schottst=C3=A4dt?= Date: Sun, 7 Jun 2026 18:56:42 +0200 Subject: [PATCH] fix(cs2): use concrete postinstall script --- scrolls/lgsm/cs2server/data/postinstall.sh | 24 +++++++++++++++++++ .../data/postinstall.sh.scroll_template | 22 ----------------- scrolls/lgsm/cs2server/scroll.yaml | 2 -- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 scrolls/lgsm/cs2server/data/postinstall.sh delete mode 100644 scrolls/lgsm/cs2server/data/postinstall.sh.scroll_template diff --git a/scrolls/lgsm/cs2server/data/postinstall.sh b/scrolls/lgsm/cs2server/data/postinstall.sh new file mode 100644 index 00000000..67b58124 --- /dev/null +++ b/scrolls/lgsm/cs2server/data/postinstall.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail + +config_file="serverfiles/game/csgo/cfg/server.cfg" +password_file=".druid-rcon-password" + +if [ -n "${CS2_RCON_PASSWORD:-}" ]; then + rcon_password="$CS2_RCON_PASSWORD" +elif [ -f "$password_file" ]; then + rcon_password="$(cat "$password_file")" +else + rcon_password="$(tr -dc 'A-Za-z0-9' "$password_file" + chmod 600 "$password_file" +fi + +mkdir -p "$(dirname "$config_file")" +touch "$config_file" + +if grep -q '^rcon_password ".*"' "$config_file"; then + sed -i 's/^rcon_password ".*"/rcon_password "'"$rcon_password"'"/' "$config_file" +else + printf '\nrcon_password "%s"\n' "$rcon_password" >> "$config_file" +fi diff --git a/scrolls/lgsm/cs2server/data/postinstall.sh.scroll_template b/scrolls/lgsm/cs2server/data/postinstall.sh.scroll_template deleted file mode 100644 index 15232fea..00000000 --- a/scrolls/lgsm/cs2server/data/postinstall.sh.scroll_template +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Define the file path -file="serverfiles/game/csgo/cfg/server.cfg" - -# Define the value you want to replace/add -new_value='rcon_password "{{ .Config.rcon.password }}"' - -# Check if the line exists in the file -if grep -q '^rcon_password ".*"' "$file"; then - # Line exists, replace the value - if [[ "$OSTYPE" == "darwin"* ]]; then - # Mac OSX - sed -i '' 's/^rcon_password ".*"/'"$new_value"'/' "$file" - else - # Linux - sed -i 's/^rcon_password ".*"/'"$new_value"'/' "$file" - fi -else - # Line doesn't exist, append the value to the file - echo -e "\n$new_value" >> "$file" -fi \ No newline at end of file diff --git a/scrolls/lgsm/cs2server/scroll.yaml b/scrolls/lgsm/cs2server/scroll.yaml index b2301b9d..f5695dcf 100644 --- a/scrolls/lgsm/cs2server/scroll.yaml +++ b/scrolls/lgsm/cs2server/scroll.yaml @@ -16,8 +16,6 @@ chunks: path: log - name: postinstall path: postinstall.sh - - name: postinstall-template - path: postinstall.sh.scroll_template - name: patch-lgsm-permissions path: patch-lgsm-permissions.sh - name: serverfiles