Skip to content

Commit

Permalink
Merge pull request #144 from Bims-sh/main
Browse files Browse the repository at this point in the history
feat: add support for tar and zip archives
  • Loading branch information
joedwards32 authored Jan 13, 2025
2 parents 79a6436 + 0f17668 commit 9b64edf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ mp_maxrounds 16 // Shorter games

## Customisation Bundle

The container can be instructed to download a extract a Tar Gzip of configuration files and other customisations from a given URL.
The container can be instructed to download a extract a Tar Gzip bundle, Tar or Zip archive of configuration files and other customisations from a given URL.

```dockerfile
CS2_CFG_URL="" (HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods)
CS2_CFG_URL="" (HTTP/HTTPS URL to fetch a Tar Gzip bundle, Tar or Zip archive of configuration files/mods)
```

See [examples](https://github.com/joedwards32/CS2/blob/main/examples/cs2.cfg.tgz) for a correctly formatted Tar Gzip customisation bundle.
See [examples](https://github.com/joedwards32/CS2/blob/main/examples/cs2.cfg.tgz) for a correctly formatted Tar Gzip customisation bundle, the same format applies to all archive types.


# Credits
Expand Down
27 changes: 26 additions & 1 deletion bookworm/etc/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,32 @@ fi
# Download and extract custom config bundle
if [[ ! -z $CS2_CFG_URL ]]; then
echo "Downloading config pack from ${CS2_CFG_URL}"
wget -qO- "${CS2_CFG_URL}" | tar xvzf - -C "${STEAMAPPDIR}"

TEMP_DIR=$(mktemp -d)
TEMP_FILE="${TEMP_DIR}/$(basename ${CS2_CFG_URL})"
wget -qO "${TEMP_FILE}" "${CS2_CFG_URL}"

case "${TEMP_FILE}" in
*.zip)
echo "Extracting ZIP file..."
unzip -q "${TEMP_FILE}" -d "${STEAMAPPDIR}"
;;
*.tar.gz | *.tgz)
echo "Extracting TAR.GZ or TGZ file..."
tar xvzf "${TEMP_FILE}" -C "${STEAMAPPDIR}"
;;
*.tar)
echo "Extracting TAR file..."
tar xvf "${TEMP_FILE}" -C "${STEAMAPPDIR}"
;;
*)
echo "Unsupported file type"
rm -rf "${TEMP_DIR}"
exit 1
;;
esac

rm -rf "${TEMP_DIR}"
fi

# Rewrite Config Files
Expand Down
2 changes: 1 addition & 1 deletion examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- CS2_PW=changeme # (CS2 server password)
- CS2_MAXPLAYERS=10 # (Max players)
- CS2_ADDITIONAL_ARGS # (Optional additional arguments to pass into cs2)
- CS2_CFG_URL # HTTP/HTTPS URL to fetch a Tar Gzip bundle of configuration files/mods
- CS2_CFG_URL # HTTP/HTTPS URL to fetch a Tar Gzip bundle, Tar or Zip archive of configuration files/mods
# Game modes
- CS2_GAMEALIAS # (Game type, e.g. casual, competitive, deathmatch. See https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
- CS2_GAMETYPE=0 # (Used if CS2_GAMEALIAS not defined. See https://developer.valvesoftware.com/wiki/Counter-Strike_2/Dedicated_Servers)
Expand Down

0 comments on commit 9b64edf

Please sign in to comment.