From c601c9acbb4363d6794d009888f8ff60d6309e8e Mon Sep 17 00:00:00 2001 From: pcace <{ID}+{username}@users.noreply.github.com> Date: Sun, 18 Feb 2024 13:00:20 +0100 Subject: [PATCH] fix: :bug: fixes metamod installation on cs2 update currently the gamemode.gi gets overwritten when updating the cs2 installation, but metamod needs to be referenced in the gamemod.gi. this fix adds the fix to the file if it is not there and if metamod is installed. --- lgsm/modules/core_modules.sh | 5 +++++ lgsm/modules/fix.sh | 2 +- lgsm/modules/fix_cs2.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 lgsm/modules/fix_cs2.sh diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index 1afac30c7a..267bf9fd56 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -371,6 +371,11 @@ fix_csgo.sh() { fn_fetch_module } +fix_cs2.sh() { + modulefile="${FUNCNAME[0]}" + fn_fetch_module +} + fix_dst.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module diff --git a/lgsm/modules/fix.sh b/lgsm/modules/fix.sh index 2801127280..ef9d1f8b69 100644 --- a/lgsm/modules/fix.sh +++ b/lgsm/modules/fix.sh @@ -52,7 +52,7 @@ fn_apply_fix() { fi } -apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins kf nmrih onset pvr rust rw samp sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr) +apply_pre_start_fix=(arma3 armar ark av bt bo csgo cs2 cmw dst hw ins kf nmrih onset pvr rust rw samp sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr) apply_post_install_fix=(av kf kf2 ro ut2k4 ut ut3) # validate registered fixes for safe development diff --git a/lgsm/modules/fix_cs2.sh b/lgsm/modules/fix_cs2.sh new file mode 100644 index 0000000000..2ff60ed9cb --- /dev/null +++ b/lgsm/modules/fix_cs2.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# LinuxGSM fix_csgo.sh module +# Author: https://github.com/pcace +# Contributors: http://linuxgsm.com/contrib +# Website: https://linuxgsm.com +# Description: Resolves issues with Counter-Strike: Global Offensive. + +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" + +# Fixes: metamod installation (if installed) on cs2 updates +GAMEINFO="${serverfiles}/game/csgo/gameinfo.gi" +METAMOD_DIR="${serverfiles}/game/csgo/addons/metamod" + +if [ -d "$METAMOD_DIR" ]; then + + # Remove Windows line endings (\r) from gameinfo.gi + sed -i 's/\r$//' "$GAMEINFO" + + # Check if the line "Game csgo/addons/metamod" exists in the file + if ! grep -q "Game csgo/addons/metamod" "$GAMEINFO"; then + + # Open gameinfo.gi in the game/csgo directory + sed -i 's/#.*\n//g' "$GAMEINFO" + + # Add Game csgo/addons/metamod to the SearchPaths section + sed -i '/Game_LowViolence/{ + a Game csgo/addons/metamod + }' "$GAMEINFO" + + fi +fi