Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for tar and zip archives #144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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