├── .steamcmd ├── linux │ ├── .gitkeep │ └── output │ │ └── .gitkeep └── readme.md ├── .misc └── screenshot.jpg ├── .dockerignore ├── .markdownlint.json ├── .vscode ├── extensions.json ├── settings.json └── tasks.json ├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ └── update-dockerhub.yml ├── CONTRIBUTING.md ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── CODE_OF_CONDUCT.md ├── linux.Dockerfile └── dist └── linux └── ll-tests └── gamesvr-csgo.sh /.steamcmd/linux/.gitkeep: -------------------------------------------------------------------------------- 1 | 💾 -------------------------------------------------------------------------------- /.steamcmd/linux/output/.gitkeep: -------------------------------------------------------------------------------- 1 | 💾 -------------------------------------------------------------------------------- /.misc/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LacledesLAN/gamesvr-csgo/HEAD/.misc/screenshot.jpg -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .steamcmd/readme.md 2 | .steamcmd/linux/app 3 | .steamcmd/linux/.gitkeep 4 | .steamcmd/linux/output/.gitkeep 5 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "MD013": { 4 | "code_block_line_length": 999, 5 | "line_length": 120 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "davidanson.vscode-markdownlint", 4 | "editorconfig.editorconfig", 5 | "ms-azuretools.vscode-docker", 6 | "streetsidesoftware.code-spell-checker", 7 | "timonwong.shellcheck" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_size = 4 8 | indent_style = space 9 | trim_trailing_whitespace = true 10 | 11 | [.gitkeep] 12 | insert_final_newline = false 13 | 14 | [*.sh] 15 | indent_size = 4 16 | indent_style = tab 17 | 18 | [*.y*ml] 19 | indent_size = 2 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Enable version updates for Docker 4 | - package-ecosystem: "docker" 5 | # Look for a `Dockerfile` in the `root` directory 6 | directory: "/" 7 | # Check for updates once a month 8 | schedule: 9 | interval: "monthly" 10 | 11 | # Enable version updates for GitHub Actions 12 | - package-ecosystem: "github-actions" 13 | directory: "/" 14 | schedule: 15 | interval: "weekly" 16 | time: "11:00" 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | First off, thank you for considering contributing to `gamesvr-csgo`. It's people like you that make Laclede's LAN such a 4 | great community. 5 | 6 | ## Did you find a bug or have questions? 7 | 8 | Let us know by using [GitHub issues](https://github.com/LacledesLAN/gamesvr-csgo/issues) on this repository. 9 | 10 | ## Have a fix or feature? 11 | 12 | [Fork this repository](https://help.github.com/articles/fork-a-repo), create a branch with a descriptive name, and 13 | submit a pull request. A project maintainer will remove and either merge or provide feedback. 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf encoding=utf-8 2 | 3 | *.*ignore text 4 | *.bash text 5 | *.bat text eol=crlf 6 | *.cmd text eol=crlf 7 | *.json text 8 | *.md text diff=markdown 9 | *.ps1 text eol=crlf 10 | *.sh text 11 | *.toml text 12 | *.xml text 13 | *.yaml text 14 | *.yml text 15 | *.zsh text 16 | .editorconfig text 17 | .gitattributes text 18 | .gitconfig text 19 | .gitkeep text 20 | Dockerfile* text 21 | LICENSE text 22 | -------------------------------------------------------------------------------- /.github/workflows/update-dockerhub.yml: -------------------------------------------------------------------------------- 1 | name: Update Docker Hub Description 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build-and-push: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Update Docker HUB Description 15 | uses: peter-evans/dockerhub-description@v4 16 | with: 17 | username: ${{ secrets.DOCKERHUB_USERNAME }} 18 | password: ${{ secrets.DOCKERHUB_TOKEN }} 19 | repository: lacledeslan/gamesvr-csgo 20 | short-description: "Counter-Strike: Global Offensive Dedicated Server" 21 | readme-filepath: ./README.md 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Project Specific ### 2 | .steamcmd/** 3 | !.steamcmd/[Rr]eadme.md 4 | !.steamcmd/linux 5 | .steamcmd/linux/** 6 | !.steamcmd/linux/.gitkeep 7 | !.steamcmd/linux/output 8 | .steamcmd/linux/output/** 9 | !.steamcmd/linux/output/.gitkeep 10 | 11 | ### VisualStudioCode ### 12 | .vscode/* 13 | !.vscode/settings.json 14 | !.vscode/tasks.json 15 | !.vscode/launch.json 16 | !.vscode/extensions.json 17 | .history 18 | 19 | ### Linux Cruft ### 20 | .fuse_hidden* 21 | .directory 22 | .Trash-* 23 | .nfs* 24 | 25 | ### macOS Cruft ### 26 | .AppleDouble 27 | .com.apple.timemachine.donotpresent 28 | .DocumentRevisions-V100 29 | .DS_Store 30 | .fseventsd 31 | .LSOverride 32 | .Spotlight-V100 33 | .TemporaryItems 34 | .Trashes 35 | .VolumeIcon.icns 36 | 37 | ### Windows Cruft ### 38 | *.lnk 39 | [Dd]esktop.ini 40 | ehthumbs.db 41 | Thumbs.db 42 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "csgo", 4 | "dockerhub", 5 | "Dockerized", 6 | "freeplay", 7 | "gamesvr", 8 | "Laclede's", 9 | "Laclede’s", 10 | "lacledeslan", 11 | "srcds", 12 | "steamcmd", 13 | "tickrate" 14 | ], 15 | "markdownlint.ignore": [ 16 | ".gitkeep", "LICENSE" 17 | ], 18 | "terminal.integrated.scrollback": 2500, 19 | "[markdown]": { 20 | "cSpell.fixSpellingWithRenameProvider": true, 21 | "cSpell.advanced.feature.useReferenceProviderWithRename": true, 22 | "cSpell.advanced.feature.useReferenceProviderRemove": "/^#+\\s/", 23 | "editor.rulers": [120], 24 | "editor.unicodeHighlight.ambiguousCharacters": true, 25 | "editor.unicodeHighlight.invisibleCharacters": true, 26 | "editor.wordWrap": "on" 27 | }, 28 | "[shellscript]": { 29 | "editor.rulers": [100], 30 | "files.eol": "\n" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.steamcmd/readme.md: -------------------------------------------------------------------------------- 1 | # Optional SteamCMD Cache 2 | 3 | This folder can be used to cache SteamCMD downloads prior to executing `docker build`. This speeds up builds on slow Internet connections but slows down builds on fast connections. Your mileage will vary. 4 | 5 | ## Disabling SteamCMD Downloads 6 | 7 | If you anticipate having to do emergency builds when Internet bandwidth is at a premium disabling SteamCMD downloads and relying on an already-built cache *could* be a lifesaver. Just provide the argument of `--build-arg SKIP_STEAMCMD=true` when building the image. 8 | 9 | ## Build the Cache 10 | 11 | To populate the cache install the relevant game server data into this directory using [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD). If you are using [VSCode](https://code.visualstudio.com/) a task is already defined otherwise you can use [Laclede's LAN SteamCMD Docker](https://github.com/LacledesLAN/SteamCMD) image: 12 | 13 | ```shell 14 | docker run -i --rm -v ./.steamcmd-cache/linux:/output lacledeslan/steamcmd:linux ./steamcmd.sh +login anonymous +force_install_dir /output +app_update validate +quit 15 | ``` 16 | 17 | > Replace `XXX` with the correct [Steam CMD Application ID](https://developer.valvesoftware.com/wiki/Dedicated_Servers_List). 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Counter-Strike: Global Offensive Dedicated Server in Docker 2 | 3 | **THIS PROJECT IS RETIRED AND NO LONGER SUPPORTED** 4 | 5 | Counter-Strike: Global Offensive (CS:GO) is a multiplayer first-person shooter and is the fourth game in the 6 | [Counter-Strike series](https://en.wikipedia.org/wiki/Counter-Strike). The game pits two teams against each other: the 7 | Terrorists and the Counter-Terrorists. Both sides are tasked with eliminating the other while also completing separate 8 | objectives, the Terrorists, depending on the game mode, must either plant the bomb or defend the hostages, while the 9 | Counter-Terrorists must either prevent the bomb from being planted, defuse the bomb, or rescue the hostages. There are 10 | eight game modes, all of which have distinct characteristics specific to that mode. 11 | 12 | ![Counter-Strike Global Offensive Screenshot](https://raw.githubusercontent.com/LacledesLAN/gamesvr-csgo/master/.misc/screenshot.jpg "Counter-Strike Global Offensive Screenshot") 13 | 14 | ## Getting Started with Game Servers in Docker 15 | 16 | [Docker](https://docs.docker.com/) is an open-source project that bundles applications into lightweight, portable, 17 | self-sufficient containers. For a crash course on running Dockerized game servers check out [Using Docker for Game 18 | Servers](https://github.com/LacledesLAN/README.1ST/blob/master/GameServers/DockerAndGameServers.md). For tips, tricks, 19 | and recommended tools for working with Laclede's LAN Dockerized game server repos see the guide for [Working with our 20 | Game Server Repos](https://github.com/LacledesLAN/README.1ST/blob/master/GameServers/WorkingWithOurRepos.md). You can 21 | also browse all of our other Dockerized game servers: [Laclede's LAN Game Servers 22 | Directory](https://github.com/LacledesLAN/README.1ST/tree/master/GameServers). 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Laclede’s LAN Code of Conduct for Open Source Projects 2 | 3 | The Laclede’s LAN team and community is made up of a mixture of professionals and volunteers from the Greater Saint 4 | Louis area and beyond. In the interests of fostering a collaborative environment we have a few ground rules for 5 | community participants. 6 | 7 | * Be welcoming, friendly, and patient. 8 | * Be respectful. Disagreement is inevitable, but is no excuse for poor behavior or poor manners. Don't allow 9 | frustration with the work to become frustration directed at people. It's important to remember that a community 10 | where people feel uncomfortable or threatened is not a productive one. 11 | * Be careful with your words. Remember that sexist, racist, and other exclusionary jokes can potentially be offensive to 12 | those around you, even if you did not mean them to be. Do not insult or put down other participants. Behave 13 | professionally. 14 | * Be considerate. It is the responsibility of project maintainers to focus on Laclede’s LAN goals. Decisions may be made 15 | that reject your code or feature requests that go against our mission. At any time you may fork the projects in 16 | accordance with the applicable project license(s). 17 | 18 | When we disagree, we try to understand why. Disagreements, both social and technical, happen all the time and Laclede’s 19 | LAN is no exception. It is important that we resolve disagreements and differing views constructively. 20 | 21 | Laclede’s LAN officers and project maintainers have the right and responsibility to remove, edit, or reject comments, 22 | commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. 23 | 24 | Credits for the sources and inspiration of this code of conduct go to [Speak 25 | Up!](https://web.archive.org/web/20141109123859/http://speakup.io/coc.html) and [Contributor 26 | Covenant](https://archive.fo/ocyAN). 27 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "Linux - Build Docker Image", 8 | "type": "shell", 9 | "command": "docker pull lacledeslan/steamcmd; docker pull debian:bullseye-slim; docker build . -f linux.Dockerfile --rm -t lltest/gamesvr-csgo --no-cache --build-arg BUILDNODE=$env:computername;", 10 | "group": "build", 11 | "problemMatcher": [], 12 | "promptOnClose": true 13 | }, 14 | { 15 | "label": "Linux - Build & Execute Self Tests", 16 | "type": "shell", 17 | "command": "docker run -it --rm lltest/gamesvr-csgo ./ll-tests/gamesvr-csgo.sh;", 18 | "dependsOn": "Linux - Build Docker Image", 19 | "group": { 20 | "kind": "build", 21 | "isDefault": true 22 | }, 23 | "problemMatcher": [], 24 | "promptOnClose": true 25 | }, 26 | { 27 | "label": "Linux - Build & Run Interactive Server", 28 | "type": "shell", 29 | "command": "docker run -it --net=host lltest/gamesvr-csgo ./srcds_run -game csgo +game_type 1 +game_mode 0 -tickrate 128 +mapgroup ll_arms +map ar_baggage +sv_lan 1 +rcon_password \"test123\";", 30 | "dependsOn": "Linux - Build Docker Image", 31 | "group": "build", 32 | "problemMatcher": [], 33 | "promptOnClose": true 34 | }, 35 | { 36 | "label": "Linux - Build & Shell In", 37 | "type": "shell", 38 | "command": "docker run -it --net=host --rm lltest/gamesvr-csgo;", 39 | "dependsOn": "Linux - Build Docker Image", 40 | "group": "build", 41 | "problemMatcher": [], 42 | "promptOnClose": true 43 | }, 44 | { 45 | "label": "Linux - Build local SteamCMD cache", 46 | "type": "shell", 47 | "windows": { 48 | "command": "docker run --rm -v ${workspaceFolder}/.steamcmd/linux/output:/output lacledeslan/steamcmd:latest /app/steamcmd.sh +login anonymous +force_install_dir /output +app_update 740 validate +quit", 49 | }, 50 | "problemMatcher": [] 51 | } 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /linux.Dockerfile: -------------------------------------------------------------------------------- 1 | # escape=` 2 | FROM lacledeslan/steamcmd:linux as csgo-builder 3 | 4 | ARG contentServer=content.lacledeslan.net 5 | ARG SKIP_STEAMCMD=false 6 | 7 | # Copy in local cache files (if any) 8 | COPY --chown=SteamCMD:root ./.steamcmd/linux/output /output 9 | 10 | # Download CSGO via SteamCMD 11 | RUN if [ "$SKIP_STEAMCMD" = true ] ; then ` 12 | echo "\n\nSkipping SteamCMD install -- using only contents from steamcmd-cache\n\n"; ` 13 | else ` 14 | echo "\n\nDownloading Counter-Strike: Global Offensive via SteamCMD"; ` 15 | mkdir --parents /output; ` 16 | /app/steamcmd.sh +force_install_dir /output +login anonymous +app_update 740 validate +quit;` 17 | fi; 18 | 19 | RUN if [ "$contentServer" = false ] ; then ` 20 | echo "\n\nSkipping custom LL content\n\n"; ` 21 | else ` 22 | echo "\nDownloading custom LL content from $contentServer" &&` 23 | mkdir --parents /tmp/maps/ /output &&` 24 | cd /tmp/maps/ &&` 25 | wget -rkpN -l 1 -nH --no-verbose --cut-dirs=3 -R "*.htm*" -e robots=off "http://"$contentServer"/fastDownloads/csgo/maps/" &&` 26 | echo "Decompressing files" &&` 27 | bzip2 --decompress /tmp/maps/*.bz2 &&` 28 | echo "Moving uncompressed files to destination" &&` 29 | mkdir --parents /output/csgo/maps/ &&` 30 | mv --no-clobber *.bsp *.nav /output/csgo/maps/; ` 31 | fi; 32 | 33 | #=======================================================================` 34 | FROM debian:bullseye-slim 35 | 36 | ARG BUILDNODE=unspecified 37 | ARG SOURCE_COMMIT=unspecified 38 | 39 | HEALTHCHECK NONE 40 | 41 | RUN dpkg --add-architecture i386 &&` 42 | apt-get update && apt-get install -y ` 43 | ca-certificates lib32gcc-s1 libstdc++6:i386 locales locales-all tini tmux &&` 44 | apt-get clean &&` 45 | rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*; 46 | 47 | ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 48 | 49 | LABEL maintainer="Laclede's LAN " ` 50 | com.lacledeslan.build-node=$BUILDNODE ` 51 | org.label-schema.schema-version="1.0" ` 52 | org.label-schema.url="https://github.com/LacledesLAN/README.1ST" ` 53 | org.label-schema.vcs-ref=$SOURCE_COMMIT ` 54 | org.label-schema.vendor="Laclede's LAN" ` 55 | org.label-schema.description="Counter-Strike: Global Offensive Dedicated Server" ` 56 | org.label-schema.vcs-url="https://github.com/LacledesLAN/gamesvr-csgo" 57 | 58 | # Set up Enviornment 59 | RUN useradd --home /app --gid root --system CSGO &&` 60 | mkdir -p /app/ll-tests &&` 61 | chown CSGO:root -R /app; 62 | 63 | # `RUN true` lines are work around for https://github.com/moby/moby/issues/36573 64 | COPY --chown=CSGO:root --from=csgo-builder /output /app 65 | RUN true 66 | 67 | COPY --chown=CSGO:root ./dist/linux/ll-tests /app/ll-tests 68 | RUN chmod +x /app/ll-tests/*.sh; 69 | 70 | USER CSGO 71 | 72 | RUN echo $'\n\nLinking steamclient.so to prevent srcds_run errors' &&` 73 | mkdir --parents /app/.steam/sdk32 &&` 74 | ln -s /app/bin/steamclient.so /app/.steam/sdk32/steamclient.so; 75 | 76 | WORKDIR /app 77 | 78 | CMD ["/bin/bash"] 79 | 80 | ONBUILD USER root 81 | -------------------------------------------------------------------------------- /dist/linux/ll-tests/gamesvr-csgo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -i 2 | 3 | ##################################################################################################### 4 | ### CONFIG VARS ##################################################################################### 5 | declare LLTEST_CMD="/app/srcds_run -game csgo +game_type 0 +game_mode 1 +map poolday -insecure -tickrate 128 -norestart +sv_lan 1"; 6 | declare LLTEST_NAME="gamesvr-csgo-$(date '+%H%M%S')"; 7 | ##################################################################################################### 8 | ##################################################################################################### 9 | 10 | # Runtime vars 11 | declare LLCOUNTER=0; 12 | declare LLBOOT_ERRORS=""; 13 | declare LLTEST_HASFAILURES=false; 14 | declare LLTEST_LOGFILE="$LLTEST_NAME"".log"; 15 | declare LLTEST_RESULTSFILE="$LLTEST_NAME"".results"; 16 | 17 | # Server log file should contain $1 because $2 18 | function should_have() { 19 | if ! grep -i -q "$1" "$LLTEST_LOGFILE"; then 20 | echo $"[FAIL] - '$2'" >> "$LLTEST_RESULTSFILE"; 21 | LLTEST_HASFAILURES=true; 22 | else 23 | echo $"[PASS] - '$2'" >> "$LLTEST_RESULTSFILE"; 24 | fi; 25 | } 26 | 27 | # Server log file should NOT contain $1 because $2 28 | function should_lack() { 29 | if grep -i -q "$1" "$LLTEST_LOGFILE"; then 30 | echo $"[FAIL] - '$2'" >> "$LLTEST_RESULTSFILE"; 31 | LLTEST_HASFAILURES=true; 32 | else 33 | echo $"[PASS] - '$2'" >> "$LLTEST_RESULTSFILE"; 34 | fi; 35 | } 36 | 37 | # Command $1 should make server return $2 38 | function should_echo() { 39 | tmux has-session -t "$LLTEST_NAME" 2>/dev/null; 40 | if [ "$?" == 0 ] ; then 41 | LLCOUNTER=0; 42 | LLTMP=$(md5sum "$LLTEST_LOGFILE"); 43 | tmux send -t "$LLTEST_NAME" C-z "$1" Enter; 44 | 45 | while true; do 46 | sleep 0.5; 47 | 48 | if (( "$LLCOUNTER" > 30)); then 49 | echo $"[FAIL] - Command '$!' TIMED OUT"; 50 | LLTEST_HASFAILURES=true; 51 | break; 52 | fi; 53 | 54 | if [[ $(md5sum "$LLTEST_LOGFILE") != "$LLTMP" ]]; then 55 | should_have "$2" "'$1' should result in '$2' (loop iterations: $LLCOUNTER)"; 56 | break; 57 | fi; 58 | 59 | (( LLCOUNTER++ )); 60 | done; 61 | else 62 | echo $"[ERROR]- Could not run command '$1'; tmux session not found" >> "$LLTEST_RESULTSFILE"; 63 | LLTEST_HASFAILURES=true; 64 | fi; 65 | } 66 | 67 | function print_log() { 68 | if [ ! -s "$LLTEST_LOGFILE" ]; then 69 | echo $'\nOUTPUT LOG IS EMPTY!\n'; 70 | exit 1; 71 | else 72 | echo $'\n[LOGFILE OUTPUT]'; 73 | awk '{print "»» " $0}' "$LLTEST_LOGFILE"; 74 | fi; 75 | } 76 | 77 | # Check prereqs 78 | command -v awk > /dev/null 2>&1 || echo "awk is missing"; 79 | command -v md5sum > /dev/null 2>&1 || echo "md5sum is missing"; 80 | command -v sleep > /dev/null 2>&1 || echo "sleep is missing"; 81 | command -v tmux > /dev/null 2>&1 || echo "tmux is missing"; 82 | 83 | # Prep log file 84 | : > "$LLTEST_LOGFILE" 85 | if [ ! -f "$LLTEST_LOGFILE" ]; then 86 | echo 'Failed to create logfile: '"$LLTEST_LOGFILE"'. Verify file system permissions.'; 87 | exit 2; 88 | fi; 89 | 90 | # Prep results file 91 | : > "$LLTEST_RESULTSFILE" 92 | if [ ! -f "$LLTEST_RESULTSFILE" ]; then 93 | echo 'Failed to create logfile: '"$LLTEST_RESULTSFILE"'. Verify file system permissions.'; 94 | exit 2; 95 | fi; 96 | 97 | echo $'\n\nRUNNING TEST: '"$LLTEST_NAME"; 98 | echo $'Command: '"$LLTEST_CMD"; 99 | echo "Running under $(id)"$'\n'; 100 | 101 | # Execute test command in tmux session 102 | tmux new -d -s "$LLTEST_NAME" "sleep 0.5; $LLTEST_CMD"; 103 | sleep 0.3; 104 | tmux pipe-pane -t "$LLTEST_NAME" -o "cat > $LLTEST_LOGFILE"; 105 | 106 | while true; do 107 | tmux has-session -t "$LLTEST_NAME" 2>/dev/null; 108 | if [ "$?" != 0 ] ; then 109 | echo $'terminated.\n'; 110 | LLBOOT_ERRORS="Test process self-terminated"; 111 | break; 112 | fi; 113 | 114 | if (( "$LLCOUNTER" >= 29 )); then 115 | if [ -s "$LLTEST_LOGFILE" ] && ((( $(date +%s) - $(stat -L --format %Y "$LLTEST_LOGFILE") ) > 20 )); then 116 | echo $'succeeded.\n'; 117 | break; 118 | fi; 119 | 120 | if (( "$LLCOUNTER" > 120 )); then 121 | echo $'timed out.\n'; 122 | LLBOOT_ERRORS="Test timed out"; 123 | break; 124 | fi; 125 | fi; 126 | 127 | if (( LLCOUNTER % 5 == 0 )); then 128 | echo -n "$LLCOUNTER..."; 129 | fi; 130 | 131 | (( LLCOUNTER++ )); 132 | sleep 1; 133 | done; 134 | 135 | if [ ! -s "$LLTEST_LOGFILE" ]; then 136 | echo $'\nOUTPUT LOG IS EMPTY!\n'; 137 | exit 1; 138 | fi; 139 | 140 | if [ ! -z "${LLBOOT_ERRORS// }" ]; then 141 | echo "Boot error: $LLBOOT_ERRORS"; 142 | print_log; 143 | exit 1; 144 | fi; 145 | 146 | ##################################################################################################### 147 | ### TESTS ########################################################################################### 148 | # Stock CSGO server tests 149 | should_have 'Setting breakpad minidump AppID = 740' 'Sever started executing'; 150 | should_lack 'Server restart in 10 seconds' 'Server is not boot-looping'; 151 | should_lack 'Running the dedicated server as root' 'Server is not running under root'; 152 | should_have 'Game.dll loaded for "Counter-Strike: Global Offensive"' 'srcds_run loaded CSGO'; 153 | should_have 'Server is hibernating' 'srcds_run succesfully hibernated'; 154 | should_lack 'map load failed:' 'Server was able to load custom-content the map'; 155 | should_lack 'Your server needs to be restarted in order to receive the latest update.' 'Server is not reporting itself as out of date'; 156 | 157 | # Verify server responds to commands 158 | should_echo "say STARTING COMMAND TESTS" 'Console: STARTING COMMAND TESTS'; 159 | ##################################################################################################### 160 | ##################################################################################################### 161 | 162 | tmux has-session -t "$LLTEST_NAME" 2>/dev/null; 163 | if [ "$?" == 0 ] ; then 164 | tmux kill-session -t "$LLTEST_NAME"; 165 | fi; 166 | 167 | print_log; 168 | 169 | echo $'\n[TEST RESULTS]\n'; 170 | cat "$LLTEST_RESULTSFILE"; 171 | 172 | echo $'\n[OUTCOME]\n'; 173 | if [ $LLTEST_HASFAILURES = true ]; then 174 | echo $'Checks have failures!\n\n'; 175 | exit 1; 176 | fi; 177 | 178 | echo $'All checks passed!\n\n'; 179 | exit 0; 180 | --------------------------------------------------------------------------------