Skip to content

Commit

Permalink
Maintain existing gameinfo.gi instead of trying to update it
Browse files Browse the repository at this point in the history
  • Loading branch information
1zc committed Dec 21, 2023
1 parent 9a169d8 commit 67af95e
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sleep 1
# Make internal Docker IP address available to processes.
export INTERNAL_IP=`ip route get 1 | awk '{print $NF;exit}'`

# Retain gameinfo.gi file - CS2 updates tend to reset this file to default, so we try to retain it.
GAMEINFO_FILE="/home/container/game/csgo/gameinfo.gi"
if [ -f "${GAMEINFO_FILE}" ]; then
mv "$GAMEINFO_FILE" "$GAMEINFO_FILE.tmp"
fi

# Update Source Server
if [ ! -z ${SRCDS_APPID} ]; then
if [ ${SRCDS_STOP_UPDATE} -eq 0 ]; then
Expand Down Expand Up @@ -59,33 +65,14 @@ if [ ! -z ${SRCDS_APPID} ]; then
fi
fi

# Restore gameinfo.gi file
if [ -f "${GAMEINFO_FILE}" ]; then
rm "$GAMEINFO_FILE" && mv "$GAMEINFO_FILE.tmp" "$GAMEINFO_FILE"
fi

# Replace Startup Variables
MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')`
echo ":/home/container$ ${MODIFIED_STARTUP}"

# Edit /home/container/game/csgo/gameinfo.gi to add MetaMod path
# Credit: https://github.com/ghostcap-gaming/ACMRS-cs2-metamod-update-fix/blob/main/acmrs.sh
GAMEINFO_FILE="/home/container/game/csgo/gameinfo.gi"
GAMEINFO_ENTRY=" Game csgo/addons/metamod"
if [ -f "${GAMEINFO_FILE}" ]; then
if grep -Fxq "$GAMEINFO_ENTRY" "$GAMEINFO_FILE"; then
echo "File gameinfo.gi already configured. No changes were made."
else
awk -v new_entry="$GAMEINFO_ENTRY" '
BEGIN { found=0; }
// {
if (found) {
print new_entry;
found=0;
}
print;
}
/Game_LowViolence/ { found=1; }
' "$GAMEINFO_FILE" > "$GAMEINFO_FILE.tmp" && mv "$GAMEINFO_FILE.tmp" "$GAMEINFO_FILE"

echo "The file ${GAMEINFO_FILE} has been configured successfully."
fi
fi

# Run the Server
eval ${MODIFIED_STARTUP}

0 comments on commit 67af95e

Please sign in to comment.