From a5d332637600412989b88bf681ee8757a0472015 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 11 Oct 2022 00:06:03 +0300 Subject: [PATCH 01/16] Changes entrypoint by adding instance support --- README.md | 3 ++- entrypoint.sh | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9db44da..1bc9ba0 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ services: container_name: csgoserver environment: - GAMESERVER=csgoserver + - GAMESERVER_INSTANCE=1 - LGSM_GITHUBUSER=GameServerManagers - LGSM_GITHUBREPO=LinuxGSM - LGSM_GITHUBBRANCH=master @@ -38,7 +39,7 @@ services: restart: unless-stopped ``` # First Run -Edit the `docker-compose.yml` file changing `GAMESERVER=` to the game server of choice. +Edit the `docker-compose.yml` file changing `GAMESERVER=` to the game server of choice. If you are running multiple instances, make sure to change `GAMESERVER_INSTANCE=` to an int of your choosing. On first run linuxgsm will install your selected server and will start running. Once completed the game server details will be output. ## Game Server Ports Each game server has its own port requirements. Becuase of this you will need to configure the correct ports in your `docker-compose` after first run. The required ports are output once installation is completed and everytime the docker container is started. diff --git a/entrypoint.sh b/entrypoint.sh index edf7c52..0e0f8d2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,6 +14,7 @@ trap exit_handler SIGTERM echo -e "Welcome to the LinuxGSM Docker" echo -e "================================================================================" echo -e "GAMESERVER: ${GAMESERVER}" +[ ! -z ${GAMESERVER_INSTANCE} ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" echo -e "UID: $UID" echo -e "" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" @@ -39,10 +40,16 @@ if [ ! -f "${GAMESERVER}" ]; then ./linuxgsm.sh ${GAMESERVER} fi +# Create game server instance + +if [ ! -f "${GAMESERVER_INSTANCE}" ]; then + echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" + mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} + # Install game server if [ -z "$(ls -A -- "serverfiles")" ]; then - echo "installing ${GAMESERVER}" - ./${GAMESERVER} auto-install + [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install fi echo "starting cron" @@ -50,14 +57,14 @@ sudo cron # Update game server echo "" -echo "update ${GAMESERVER}" -./${GAMESERVER} update +[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update echo "" -echo "start ${GAMESERVER}" -./${GAMESERVER} start +[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start sleep 5 -./${GAMESERVER} details +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || || ./${GAMESERVER}${GAMESERVER_INSTANCE} details tail -f log/script/* From 16ea9ea7c0404a1f0d4207e152b427fad7729a80 Mon Sep 17 00:00:00 2001 From: Rasmus Koit Date: Tue, 11 Oct 2022 00:24:44 +0300 Subject: [PATCH 02/16] Create docker-image.yml --- .github/workflows/docker-image.yml | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..625687e --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,35 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.repository }}:latest From e0942639612fb52262fff5c874609c0a15a80865 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 11 Oct 2022 00:26:29 +0300 Subject: [PATCH 03/16] removes old workflow --- .github/workflows/docker-publish.yml | 45 ---------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 8c52bf2..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: ci - -on: - push: - branches: - - 'main' - schedule: - - cron: '0 0 * * *' - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2.0.0 - - - name: Login to DockerHub - uses: docker/login-action@v2.0.0 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3.0.0 - with: - context: . - platforms: linux/amd64 - push: true - tags: | - gameservermanagers/linuxgsm-docker:latest - ghcr.io/gameservermanagers/linuxgsm-docker:latest From 29c1c086deed83f760ed14122442e316e43a2bfc Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 11 Oct 2022 00:29:45 +0300 Subject: [PATCH 04/16] repo to lower --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 625687e..fed9d0f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,4 +32,4 @@ jobs: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.repository }}:latest + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/linuxgsm-docker:latest From 778a36a7c47dbe1894307188d038b492e6b2bacd Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 11 Oct 2022 01:09:33 +0300 Subject: [PATCH 05/16] typo --- README.md | 2 +- entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bc9ba0..1b5eceb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Below is an example `docker-compose` for csgoserver. Ports will vary depending u version: '3.4' services: linuxgsm: - image: "ghcr.io/gameservermanagers/linuxgsm-docker:latest" + image: "raks321/linuxgsm-docker:latest" container_name: csgoserver environment: - GAMESERVER=csgoserver diff --git a/entrypoint.sh b/entrypoint.sh index 0e0f8d2..8ea3332 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -64,7 +64,7 @@ echo "" [ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start sleep 5 -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || || ./${GAMESERVER}${GAMESERVER_INSTANCE} details +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details tail -f log/script/* From 3e54c1e8ab6d6f9d9e0acfb5b20854524930d83f Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 11 Oct 2022 01:21:57 +0300 Subject: [PATCH 06/16] sad --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8ea3332..d7f7d11 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,8 +2,8 @@ exit_handler () { # Execute the shutdown commands - echo "recieved SIGTERM stopping ${GAMESERVER}" - ./${GAMESERVER} stop + [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop exit 0 } @@ -42,7 +42,7 @@ fi # Create game server instance -if [ ! -f "${GAMESERVER_INSTANCE}" ]; then +if [ ! -z "${GAMESERVER_INSTANCE}" ]; then echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} From 4177ff9a761d9083e072576738ca990cac467dbd Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 17:46:31 +0300 Subject: [PATCH 07/16] Testing docker image building --- entrypoint.sh | 29 ++++++++--------- entrypoint_orig.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 entrypoint_orig.sh diff --git a/entrypoint.sh b/entrypoint.sh index d7f7d11..ecb1eaf 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,12 @@ #!/bin/bash +#[ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" + + exit_handler () { # Execute the shutdown commands - [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop + echo "recieved SIGTERM stopping ${GAMESERVER}" + ./${GAMESERVER} stop exit 0 } @@ -14,7 +17,7 @@ trap exit_handler SIGTERM echo -e "Welcome to the LinuxGSM Docker" echo -e "================================================================================" echo -e "GAMESERVER: ${GAMESERVER}" -[ ! -z ${GAMESERVER_INSTANCE} ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" +echo -e "GAMESERVER_INSTANCE: ${GAMESERVER_INSTANCE}" echo -e "UID: $UID" echo -e "" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" @@ -40,16 +43,10 @@ if [ ! -f "${GAMESERVER}" ]; then ./linuxgsm.sh ${GAMESERVER} fi -# Create game server instance - -if [ ! -z "${GAMESERVER_INSTANCE}" ]; then - echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" - mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} - # Install game server if [ -z "$(ls -A -- "serverfiles")" ]; then - [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install + echo "installing ${GAMESERVER}" + ./${GAMESERVER} auto-install fi echo "starting cron" @@ -57,14 +54,14 @@ sudo cron # Update game server echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update +echo "update ${GAMESERVER}" +./${GAMESERVER} update echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start +echo "start ${GAMESERVER}" +./${GAMESERVER} start sleep 5 -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details +./${GAMESERVER} details tail -f log/script/* diff --git a/entrypoint_orig.sh b/entrypoint_orig.sh new file mode 100644 index 0000000..afa5391 --- /dev/null +++ b/entrypoint_orig.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +exit_handler () { + # Execute the shutdown commands + echo "recieved SIGTERM stopping ${GAMESERVER}" + ./${GAMESERVER} stop + exit 0 +} + +# Exit trap +echo "loading exit trap" +trap exit_handler SIGTERM + +echo -e "Welcome to the LinuxGSM Docker" +echo -e "================================================================================" +echo -e "GAMESERVER: ${GAMESERVER}" +echo -e "UID: $UID" +echo -e "" +echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" +echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" +echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" + +echo -e "" +echo -e "Initalising" +echo -e "================================================================================" +# Correct permissions in home dir +echo "update permissions for linuxgsm" +sudo chown -R linuxgsm:linuxgsm /home/linuxgsm + +# Copy linuxgsm.sh into homedir +if [ ! -e ~/linuxgsm.sh ]; then + echo "copying linuxgsm.sh to /home/linuxgsm" + cp /linuxgsm.sh ~/linuxgsm.sh +fi + +# Setup game server +if [ ! -f "${GAMESERVER}" ]; then + echo "creating ./${GAMESERVER}" + ./linuxgsm.sh ${GAMESERVER} +fi + +# Install game server +if [ -z "$(ls -A -- "serverfiles")" ]; then + echo "installing ${GAMESERVER}" + ./${GAMESERVER} auto-install +fi + +echo "starting cron" +sudo cron + +# Update game server +echo "" +echo "update ${GAMESERVER}" +./${GAMESERVER} update + +echo "" +echo "start ${GAMESERVER}" +./${GAMESERVER} start +sleep 5 +./${GAMESERVER} details + +tail -f log/script/* + +# with no command, just spawn a running container suitable for exec's +if [ $# = 0 ]; then + tail -f /dev/null +else + # execute the command passed through docker + "$@" + + # if this command was a server start cmd + # to get around LinuxGSM running everything in + # tmux; + # we attempt to attach to tmux to track the server + # this keeps the container running + # when invoked via docker run + # but requires -it or at least -t + tmux set -g status off && tmux attach 2> /dev/null +fi + +exec "$@" \ No newline at end of file From 70d0b9e32d7a4fa4f145707cfc1e5d8d8a8f98c2 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 18:06:31 +0300 Subject: [PATCH 08/16] Rework build pipeline --- .github/dependabot.yml | 9 --------- .github/workflows/docker-image.yml | 6 ++---- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index c49a301..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Set update schedule for GitHub Actions -version: 2 -updates: - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - # Check for updates to GitHub Actions every weekday - interval: "daily" \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fed9d0f..a6085a5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,11 +7,8 @@ on: branches: [ "main" ] jobs: - build: - runs-on: ubuntu-latest - steps: - name: Checkout @@ -27,9 +24,10 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v3.0.0 with: context: . + platforms: linux/amd64 file: ./Dockerfile push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/linuxgsm-docker:latest From f37bffab1ead5d5cc47a8374556b83a30ce327b0 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 18:41:43 +0300 Subject: [PATCH 09/16] Adds back previous variable changes --- entrypoint.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ecb1eaf..96ab051 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,9 @@ #!/bin/bash -#[ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" - - exit_handler () { # Execute the shutdown commands - echo "recieved SIGTERM stopping ${GAMESERVER}" - ./${GAMESERVER} stop + [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop exit 0 } @@ -17,7 +14,7 @@ trap exit_handler SIGTERM echo -e "Welcome to the LinuxGSM Docker" echo -e "================================================================================" echo -e "GAMESERVER: ${GAMESERVER}" -echo -e "GAMESERVER_INSTANCE: ${GAMESERVER_INSTANCE}" +[ ! -z ${GAMESERVER_INSTANCE} ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" echo -e "UID: $UID" echo -e "" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" @@ -43,10 +40,16 @@ if [ ! -f "${GAMESERVER}" ]; then ./linuxgsm.sh ${GAMESERVER} fi +# Create game server instance + +if [ ! -z "${GAMESERVER_INSTANCE}" ]; then + echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" + mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} + # Install game server if [ -z "$(ls -A -- "serverfiles")" ]; then - echo "installing ${GAMESERVER}" - ./${GAMESERVER} auto-install + [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install fi echo "starting cron" @@ -54,14 +57,14 @@ sudo cron # Update game server echo "" -echo "update ${GAMESERVER}" -./${GAMESERVER} update +[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update echo "" -echo "start ${GAMESERVER}" -./${GAMESERVER} start +[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start sleep 5 -./${GAMESERVER} details +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details tail -f log/script/* @@ -82,4 +85,4 @@ else tmux set -g status off && tmux attach 2> /dev/null fi -exec "$@" +exec "$@" \ No newline at end of file From c5aa250ec90acf67d9ec2f166938289cd29dd52a Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 18:42:50 +0300 Subject: [PATCH 10/16] Adds instance variables --- README.md | 2 +- docker-compose.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b5eceb..e11dd90 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ services: container_name: csgoserver environment: - GAMESERVER=csgoserver - - GAMESERVER_INSTANCE=1 + - GAMESERVER_INSTANCE=01 - LGSM_GITHUBUSER=GameServerManagers - LGSM_GITHUBREPO=LinuxGSM - LGSM_GITHUBBRANCH=master diff --git a/docker-compose.yml b/docker-compose.yml index 9a7c258..ed2147d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,11 @@ version: '3.4' services: linuxgsm: - image: "ghcr.io/gameservermanagers/linuxgsm-docker:latest" + image: raks321/linuxgsm-docker:latest container_name: csgoserver environment: - GAMESERVER=csgoserver + - GAMESERVER_INSTANCE=01 - LGSM_GITHUBUSER=GameServerManagers - LGSM_GITHUBREPO=LinuxGSM - LGSM_GITHUBBRANCH=master From 9770b24c5ae95cf037c2e8bdea421ee33d946908 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 18:58:33 +0300 Subject: [PATCH 11/16] Unexpected file ending --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 96ab051..d7f7d11 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -85,4 +85,4 @@ else tmux set -g status off && tmux attach 2> /dev/null fi -exec "$@" \ No newline at end of file +exec "$@" From 53dfcc4302a76c3af56480cf73e780a639155e1f Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Oct 2022 19:18:16 +0300 Subject: [PATCH 12/16] File endings and fix missing FI --- entrypoint.sh | 15 +++++---- entrypoint_orig.sh | 81 ---------------------------------------------- 2 files changed, 8 insertions(+), 88 deletions(-) delete mode 100644 entrypoint_orig.sh diff --git a/entrypoint.sh b/entrypoint.sh index d7f7d11..1285ced 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,10 @@ #!/bin/bash exit_handler () { - # Execute the shutdown commands + # Execute the shutdown commands [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop - exit 0 + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop + exit 0 } # Exit trap @@ -14,7 +14,7 @@ trap exit_handler SIGTERM echo -e "Welcome to the LinuxGSM Docker" echo -e "================================================================================" echo -e "GAMESERVER: ${GAMESERVER}" -[ ! -z ${GAMESERVER_INSTANCE} ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" +[ -n "${GAMESERVER_INSTANCE}" ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" echo -e "UID: $UID" echo -e "" echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" @@ -37,14 +37,15 @@ fi # Setup game server if [ ! -f "${GAMESERVER}" ]; then echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${GAMESERVER} + ./linuxgsm.sh ${GAMESERVER} fi # Create game server instance -if [ ! -z "${GAMESERVER_INSTANCE}" ]; then +if [ -n "${GAMESERVER_INSTANCE}" ]; then echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} +fi # Install game server if [ -z "$(ls -A -- "serverfiles")" ]; then @@ -74,7 +75,7 @@ if [ $# = 0 ]; then else # execute the command passed through docker "$@" - + # if this command was a server start cmd # to get around LinuxGSM running everything in # tmux; diff --git a/entrypoint_orig.sh b/entrypoint_orig.sh deleted file mode 100644 index afa5391..0000000 --- a/entrypoint_orig.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -exit_handler () { - # Execute the shutdown commands - echo "recieved SIGTERM stopping ${GAMESERVER}" - ./${GAMESERVER} stop - exit 0 -} - -# Exit trap -echo "loading exit trap" -trap exit_handler SIGTERM - -echo -e "Welcome to the LinuxGSM Docker" -echo -e "================================================================================" -echo -e "GAMESERVER: ${GAMESERVER}" -echo -e "UID: $UID" -echo -e "" -echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" -echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" -echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" - -echo -e "" -echo -e "Initalising" -echo -e "================================================================================" -# Correct permissions in home dir -echo "update permissions for linuxgsm" -sudo chown -R linuxgsm:linuxgsm /home/linuxgsm - -# Copy linuxgsm.sh into homedir -if [ ! -e ~/linuxgsm.sh ]; then - echo "copying linuxgsm.sh to /home/linuxgsm" - cp /linuxgsm.sh ~/linuxgsm.sh -fi - -# Setup game server -if [ ! -f "${GAMESERVER}" ]; then - echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${GAMESERVER} -fi - -# Install game server -if [ -z "$(ls -A -- "serverfiles")" ]; then - echo "installing ${GAMESERVER}" - ./${GAMESERVER} auto-install -fi - -echo "starting cron" -sudo cron - -# Update game server -echo "" -echo "update ${GAMESERVER}" -./${GAMESERVER} update - -echo "" -echo "start ${GAMESERVER}" -./${GAMESERVER} start -sleep 5 -./${GAMESERVER} details - -tail -f log/script/* - -# with no command, just spawn a running container suitable for exec's -if [ $# = 0 ]; then - tail -f /dev/null -else - # execute the command passed through docker - "$@" - - # if this command was a server start cmd - # to get around LinuxGSM running everything in - # tmux; - # we attempt to attach to tmux to track the server - # this keeps the container running - # when invoked via docker run - # but requires -it or at least -t - tmux set -g status off && tmux attach 2> /dev/null -fi - -exec "$@" \ No newline at end of file From 4f390410c47329edd738545be0309b8bcfcc2488 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 1 Nov 2022 20:51:00 +0200 Subject: [PATCH 13/16] Update image to newer version --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1285ced..f14a41a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash exit_handler () { # Execute the shutdown commands From 18416b4ecc96c2b6b327dbae21ca9237ccf870cb Mon Sep 17 00:00:00 2001 From: Rasmus Koit Date: Sat, 26 Nov 2022 16:56:30 +0200 Subject: [PATCH 14/16] Modifies the docker image to simplify one file change --- .editorconfig | 24 ++-- .github/workflows/docker-image.yml | 66 +++++------ Dockerfile | 147 +++--------------------- LICENSE | 42 +++---- README.md | 114 +++++++++--------- docker-compose.yml | 42 +++---- entrypoint.sh | 178 ++++++++++++++--------------- 7 files changed, 247 insertions(+), 366 deletions(-) diff --git a/.editorconfig b/.editorconfig index 5fb9773..a961991 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,13 +1,13 @@ -# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. -# Atom: Please assure your Atom's config setting Tab Type is set to auto, otherwise Atom-EditorConfig may not work as expected. Also disable whitespace package. -# http://editorconfig.org/ - -root = true - -[*] -charset = utf-8 -indent_style = tab -indent_size = 4 -trim_trailing_whitespace = true -end_of_line = lf +# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. +# Atom: Please assure your Atom's config setting Tab Type is set to auto, otherwise Atom-EditorConfig may not work as expected. Also disable whitespace package. +# http://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true +end_of_line = lf insert_final_newline = true \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a6085a5..5f7241b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,33 +1,33 @@ -name: Docker Image CI - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push - uses: docker/build-push-action@v3.0.0 - with: - context: . - platforms: linux/amd64 - file: ./Dockerfile - push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/linuxgsm-docker:latest +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Build and push + uses: docker/build-push-action@v3.0.0 + with: + context: . + platforms: linux/amd64 + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/linuxgsm-docker:latest diff --git a/Dockerfile b/Dockerfile index 9b3fdab..a6ac22d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,133 +1,14 @@ -# -# LinuxGSM Base Dockerfile -# -# https://github.com/GameServerManagers/LinuxGSM-Docker -# - -FROM ubuntu:20.04 - -LABEL maintainer="LinuxGSM " - -ENV DEBIAN_FRONTEND noninteractive -ENV TERM=xterm -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Install UTF-8 unicode -RUN echo "**** Install UTF-8 ****" \ - && apt-get update \ - && apt-get install -y locales apt-utils debconf-utils -RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 - -## Upgrade Ubuntu -RUN echo "**** apt upgrade ****" \ - && apt-get update; \ - apt-get upgrade -y - -## Install Base LinuxGSM Requirements -RUN echo "**** Install Base LinuxGSM Requirements ****" \ - && apt-get update \ - && apt-get install -y software-properties-common \ - && add-apt-repository multiverse \ - && apt-get update \ - && apt-get install -y \ - bc \ - binutils \ - bsdmainutils \ - bzip2 \ - ca-certificates \ - cron \ - cpio \ - curl \ - distro-info \ - file \ - gzip \ - hostname \ - jq \ - lib32gcc1 \ - lib32stdc++6 \ - netcat \ - python3 \ - tar \ - tmux \ - unzip \ - util-linux \ - wget \ - xz-utils \ - # Docker Extras - cron \ - iproute2 \ - iputils-ping \ - nano \ - vim \ - sudo \ - tini - -# Install SteamCMD -RUN echo "**** Install SteamCMD ****" \ - && echo steam steam/question select "I AGREE" | debconf-set-selections \ - && echo steam steam/license note '' | debconf-set-selections \ - && dpkg --add-architecture i386 \ - && apt-get update -y \ - && apt-get install -y --no-install-recommends libsdl2-2.0-0:i386 steamcmd \ - && ln -s /usr/games/steamcmd /usr/bin/steamcmd - -# Install NodeJS -RUN echo "**** Install NodeJS ****" \ - && curl -sL https://deb.nodesource.com/setup_16.x | bash - \ - && apt-get update && apt-get install -y nodejs - -# Install GameDig https://docs.linuxgsm.com/requirements/gamedig -RUN echo "**** Install GameDig ****" \ - && npm install -g gamedig - -# Install Cleanup -RUN echo "**** Cleanup ****" \ - && apt-get -y autoremove \ - && apt-get -y clean \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /tmp/* \ - && rm -rf /var/tmp/* - -##Need use xterm for LinuxGSM## - -ENV DEBIAN_FRONTEND noninteractive - -ARG USERNAME=linuxgsm -ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -## Add linuxgsm user -RUN echo "**** Add linuxgsm user ****" \ -# Create the user - && groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && chown $USERNAME:$USERNAME /home/$USERNAME - -# Create /opt/linuxgsm -#RUN echo "**** Create /opt/linuxgsm ****" \ -# && mkdir -p /opt/linuxgsm \ -# && chown linuxgsm:linuxgsm /opt/linuxgsm - -## Download linuxgsm.sh -RUN echo "**** Download linuxgsm.sh ****" \ - && set -ex \ - && wget -O linuxgsm.sh https://linuxgsm.sh \ - && chmod +x /linuxgsm.sh - -WORKDIR /home/linuxgsm -ENV PATH=$PATH:/home/linuxgsm -USER linuxgsm - -# Add LinuxGSM cronjobs -RUN (crontab -l 2>/dev/null; echo "*/5 * * * * /home/linuxgsm/*server monitor > /dev/null 2>&1") | crontab - -RUN (crontab -l 2>/dev/null; echo "*/30 * * * * /home/linuxgsm/*server update > /dev/null 2>&1") | crontab - -RUN (crontab -l 2>/dev/null; echo "0 1 * * 0 /home/linuxgsm/*server update-lgsm > /dev/null 2>&1") | crontab - - -COPY entrypoint.sh /home/linuxgsm/entrypoint.sh - -ENTRYPOINT [ "/usr/bin/tini", "--" ] -CMD [ "bash","./entrypoint.sh" ] +# +# LinuxGSM Base Dockerfile +# +# https://github.com/GameServerManagers/LinuxGSM-Docker +# + +FROM gameservermanagers/linuxgsm-docker:latest + +LABEL maintainer="Rasmus Koit " + +COPY entrypoint.sh /home/linuxgsm/entrypoint.sh + +ENTRYPOINT [ "/usr/bin/tini", "--" ] +CMD [ "bash","./entrypoint.sh" ] diff --git a/LICENSE b/LICENSE index 08e74de..95f95b8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2017-2022 Daniel Gibbs - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2017-2022 Daniel Gibbs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e11dd90..ee8fae0 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,57 @@ -

-
- LinuxGSM - LinuxGSM Docker Container -

- -[LinuxGSM](https://linuxgsm.com) is the command-line tool for quick, simple deployment and management of Linux dedicated game servers. - -> This docker container is under development is subject to significant change and not considured stable. - -A dockerised version of LinuxGSM https://linuxgsm.com - -Dockerhub https://hub.docker.com/r/gameservermanagers/linuxgsm-docker/ -# Usage - -## docker-compose -Below is an example `docker-compose` for csgoserver. Ports will vary depending upon server. - ``` -version: '3.4' -services: - linuxgsm: - image: "raks321/linuxgsm-docker:latest" - container_name: csgoserver - environment: - - GAMESERVER=csgoserver - - GAMESERVER_INSTANCE=01 - - LGSM_GITHUBUSER=GameServerManagers - - LGSM_GITHUBREPO=LinuxGSM - - LGSM_GITHUBBRANCH=master - volumes: - - /path/to/serverfiles:/home/linuxgsm/serverfiles - - /path/to/log:/home/linuxgsm/log - - /path/to/config-lgsm:/home/linuxgsm/lgsm/config-lgsm - ports: - - "27015:27015/tcp" - - "27015:27015/udp" - - "27020:27020/udp" - - "27005:27005/udp" - restart: unless-stopped -``` -# First Run -Edit the `docker-compose.yml` file changing `GAMESERVER=` to the game server of choice. If you are running multiple instances, make sure to change `GAMESERVER_INSTANCE=` to an int of your choosing. -On first run linuxgsm will install your selected server and will start running. Once completed the game server details will be output. -## Game Server Ports -Each game server has its own port requirements. Becuase of this you will need to configure the correct ports in your `docker-compose` after first run. The required ports are output once installation is completed and everytime the docker container is started. -## Volumes -volumes are required to save persistant data for your game server. The example above covers a basic csgoserver however some game servers save files in other places. Please check all the correct locations are mounted to remove the risk of loosing save data. -# Run LinuxGSM commands - -Commands can be run just like standard LinuxGSM using the docker exec command. - -``` - -docker exec -it csgoserver ./csgoserver details - -``` -# +

+
+ LinuxGSM + LinuxGSM Docker Container +

+ +[LinuxGSM](https://linuxgsm.com) is the command-line tool for quick, simple deployment and management of Linux dedicated game servers. + +> This docker container is under development is subject to significant change and not considured stable. + +A dockerised version of LinuxGSM https://linuxgsm.com + +Dockerhub https://hub.docker.com/r/gameservermanagers/linuxgsm-docker/ +# Usage + +## docker-compose +Below is an example `docker-compose` for csgoserver. Ports will vary depending upon server. + ``` +version: '3.4' +services: + linuxgsm: + image: "raks321/linuxgsm-docker:latest" + container_name: csgoserver + environment: + - GAMESERVER=csgoserver + - GAMESERVER_INSTANCE=01 + - LGSM_GITHUBUSER=GameServerManagers + - LGSM_GITHUBREPO=LinuxGSM + - LGSM_GITHUBBRANCH=master + volumes: + - /path/to/serverfiles:/home/linuxgsm/serverfiles + - /path/to/log:/home/linuxgsm/log + - /path/to/config-lgsm:/home/linuxgsm/lgsm/config-lgsm + ports: + - "27015:27015/tcp" + - "27015:27015/udp" + - "27020:27020/udp" + - "27005:27005/udp" + restart: unless-stopped +``` +# First Run +Edit the `docker-compose.yml` file changing `GAMESERVER=` to the game server of choice. If you are running multiple instances, make sure to change `GAMESERVER_INSTANCE=` to an int of your choosing. +On first run linuxgsm will install your selected server and will start running. Once completed the game server details will be output. +## Game Server Ports +Each game server has its own port requirements. Becuase of this you will need to configure the correct ports in your `docker-compose` after first run. The required ports are output once installation is completed and everytime the docker container is started. +## Volumes +volumes are required to save persistant data for your game server. The example above covers a basic csgoserver however some game servers save files in other places. Please check all the correct locations are mounted to remove the risk of loosing save data. +# Run LinuxGSM commands + +Commands can be run just like standard LinuxGSM using the docker exec command. + +``` + +docker exec -it csgoserver ./csgoserver details + +``` +# diff --git a/docker-compose.yml b/docker-compose.yml index ed2147d..e0bbc26 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,21 @@ -version: '3.4' -services: - linuxgsm: - image: raks321/linuxgsm-docker:latest - container_name: csgoserver - environment: - - GAMESERVER=csgoserver - - GAMESERVER_INSTANCE=01 - - LGSM_GITHUBUSER=GameServerManagers - - LGSM_GITHUBREPO=LinuxGSM - - LGSM_GITHUBBRANCH=master - volumes: - - /home/docker/linuxgsm/csgoserver/serverfiles:/home/linuxgsm/serverfiles - - /home/docker/linuxgsm/csgoserver/log:/home/linuxgsm/log - - /home/docker/linuxgsm/csgoserver/config-lgsm:/home/linuxgsm/lgsm/config-lgsm - ports: - - "27015:27015/tcp" - - "27015:27015/udp" - - "27020:27020/udp" - - "27005:27005/udp" - restart: unless-stopped +version: '3.4' +services: + linuxgsm: + image: raks321/linuxgsm-docker:latest + container_name: csgoserver + environment: + - GAMESERVER=csgoserver + - GAMESERVER_INSTANCE=01 + - LGSM_GITHUBUSER=GameServerManagers + - LGSM_GITHUBREPO=LinuxGSM + - LGSM_GITHUBBRANCH=master + volumes: + - /home/docker/linuxgsm/csgoserver/serverfiles:/home/linuxgsm/serverfiles + - /home/docker/linuxgsm/csgoserver/log:/home/linuxgsm/log + - /home/docker/linuxgsm/csgoserver/config-lgsm:/home/linuxgsm/lgsm/config-lgsm + ports: + - "27015:27015/tcp" + - "27015:27015/udp" + - "27020:27020/udp" + - "27005:27005/udp" + restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh index f14a41a..2abce7c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,89 +1,89 @@ -#!/bin/bash - -exit_handler () { - # Execute the shutdown commands - [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop - exit 0 -} - -# Exit trap -echo "loading exit trap" -trap exit_handler SIGTERM - -echo -e "Welcome to the LinuxGSM Docker" -echo -e "================================================================================" -echo -e "GAMESERVER: ${GAMESERVER}" -[ -n "${GAMESERVER_INSTANCE}" ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" -echo -e "UID: $UID" -echo -e "" -echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" -echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" -echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" - -echo -e "" -echo -e "Initalising" -echo -e "================================================================================" -# Correct permissions in home dir -echo "update permissions for linuxgsm" -sudo chown -R linuxgsm:linuxgsm /home/linuxgsm - -# Copy linuxgsm.sh into homedir -if [ ! -e ~/linuxgsm.sh ]; then - echo "copying linuxgsm.sh to /home/linuxgsm" - cp /linuxgsm.sh ~/linuxgsm.sh -fi - -# Setup game server -if [ ! -f "${GAMESERVER}" ]; then - echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${GAMESERVER} -fi - -# Create game server instance - -if [ -n "${GAMESERVER_INSTANCE}" ]; then - echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" - mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} -fi - -# Install game server -if [ -z "$(ls -A -- "serverfiles")" ]; then - [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install -fi - -echo "starting cron" -sudo cron - -# Update game server -echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update - -echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start -sleep 5 -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details - -tail -f log/script/* - -# with no command, just spawn a running container suitable for exec's -if [ $# = 0 ]; then - tail -f /dev/null -else - # execute the command passed through docker - "$@" - - # if this command was a server start cmd - # to get around LinuxGSM running everything in - # tmux; - # we attempt to attach to tmux to track the server - # this keeps the container running - # when invoked via docker run - # but requires -it or at least -t - tmux set -g status off && tmux attach 2> /dev/null -fi - -exec "$@" +#!/bin/bash + +exit_handler () { + # Execute the shutdown commands + [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop + exit 0 +} + +# Exit trap +echo "loading exit trap" +trap exit_handler SIGTERM + +echo -e "Welcome to the LinuxGSM Docker" +echo -e "================================================================================" +echo -e "GAMESERVER: ${GAMESERVER}" +[ -n "${GAMESERVER_INSTANCE}" ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" +echo -e "UID: $UID" +echo -e "" +echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" +echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" +echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" + +echo -e "" +echo -e "Initalising" +echo -e "================================================================================" +# Correct permissions in home dir +echo "update permissions for linuxgsm" +sudo chown -R linuxgsm:linuxgsm /home/linuxgsm + +# Copy linuxgsm.sh into homedir +if [ ! -e ~/linuxgsm.sh ]; then + echo "copying linuxgsm.sh to /home/linuxgsm" + cp /linuxgsm.sh ~/linuxgsm.sh +fi + +# Setup game server +if [ ! -f "${GAMESERVER}" ]; then + echo "creating ./${GAMESERVER}" + ./linuxgsm.sh ${GAMESERVER} +fi + +# Create game server instance + +if [ -n "${GAMESERVER_INSTANCE}" ]; then + echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" + mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} +fi + +# Install game server +if [ -z "$(ls -A -- "serverfiles")" ]; then + [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install +fi + +echo "starting cron" +sudo cron + +# Update game server +echo "" +[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update + +echo "" +[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start +sleep 5 +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details + +tail -f log/script/* + +# with no command, just spawn a running container suitable for exec's +if [ $# = 0 ]; then + tail -f /dev/null +else + # execute the command passed through docker + "$@" + + # if this command was a server start cmd + # to get around LinuxGSM running everything in + # tmux; + # we attempt to attach to tmux to track the server + # this keeps the container running + # when invoked via docker run + # but requires -it or at least -t + tmux set -g status off && tmux attach 2> /dev/null +fi + +exec "$@" From 9c1ed6cf74b2919a3d5ea615df8cadec25bda7fb Mon Sep 17 00:00:00 2001 From: rasmuskoit Date: Thu, 14 Sep 2023 22:08:52 +0300 Subject: [PATCH 15/16] Change line endings --- entrypoint.sh | 178 +++++++++++++++++++++++++------------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2abce7c..f14a41a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,89 +1,89 @@ -#!/bin/bash - -exit_handler () { - # Execute the shutdown commands - [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop - exit 0 -} - -# Exit trap -echo "loading exit trap" -trap exit_handler SIGTERM - -echo -e "Welcome to the LinuxGSM Docker" -echo -e "================================================================================" -echo -e "GAMESERVER: ${GAMESERVER}" -[ -n "${GAMESERVER_INSTANCE}" ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" -echo -e "UID: $UID" -echo -e "" -echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" -echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" -echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" - -echo -e "" -echo -e "Initalising" -echo -e "================================================================================" -# Correct permissions in home dir -echo "update permissions for linuxgsm" -sudo chown -R linuxgsm:linuxgsm /home/linuxgsm - -# Copy linuxgsm.sh into homedir -if [ ! -e ~/linuxgsm.sh ]; then - echo "copying linuxgsm.sh to /home/linuxgsm" - cp /linuxgsm.sh ~/linuxgsm.sh -fi - -# Setup game server -if [ ! -f "${GAMESERVER}" ]; then - echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${GAMESERVER} -fi - -# Create game server instance - -if [ -n "${GAMESERVER_INSTANCE}" ]; then - echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" - mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} -fi - -# Install game server -if [ -z "$(ls -A -- "serverfiles")" ]; then - [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" - [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install -fi - -echo "starting cron" -sudo cron - -# Update game server -echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update - -echo "" -[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start -sleep 5 -[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details - -tail -f log/script/* - -# with no command, just spawn a running container suitable for exec's -if [ $# = 0 ]; then - tail -f /dev/null -else - # execute the command passed through docker - "$@" - - # if this command was a server start cmd - # to get around LinuxGSM running everything in - # tmux; - # we attempt to attach to tmux to track the server - # this keeps the container running - # when invoked via docker run - # but requires -it or at least -t - tmux set -g status off && tmux attach 2> /dev/null -fi - -exec "$@" +#!/bin/bash + +exit_handler () { + # Execute the shutdown commands + [ -z "${GAMESERVER_INSTANCE}" ] && echo "recieved SIGTERM stopping ${GAMESERVER}" || echo "recieved SIGTERM stopping ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} stop || ./${GAMESERVER}${GAMESERVER_INSTANCE} stop + exit 0 +} + +# Exit trap +echo "loading exit trap" +trap exit_handler SIGTERM + +echo -e "Welcome to the LinuxGSM Docker" +echo -e "================================================================================" +echo -e "GAMESERVER: ${GAMESERVER}" +[ -n "${GAMESERVER_INSTANCE}" ] && echo -e "GAMESERVER INSTANCE: ${GAMESERVER_INSTANCE}" +echo -e "UID: $UID" +echo -e "" +echo -e "LGSM_GITHUBUSER: ${LGSM_GITHUBUSER}" +echo -e "LGSM_GITHUBREPO: ${LGSM_GITHUBREPO}" +echo -e "LGSM_GITHUBBRANCH: ${LGSM_GITHUBBRANCH}" + +echo -e "" +echo -e "Initalising" +echo -e "================================================================================" +# Correct permissions in home dir +echo "update permissions for linuxgsm" +sudo chown -R linuxgsm:linuxgsm /home/linuxgsm + +# Copy linuxgsm.sh into homedir +if [ ! -e ~/linuxgsm.sh ]; then + echo "copying linuxgsm.sh to /home/linuxgsm" + cp /linuxgsm.sh ~/linuxgsm.sh +fi + +# Setup game server +if [ ! -f "${GAMESERVER}" ]; then + echo "creating ./${GAMESERVER}" + ./linuxgsm.sh ${GAMESERVER} +fi + +# Create game server instance + +if [ -n "${GAMESERVER_INSTANCE}" ]; then + echo "renaming ${GAMESERVER} to ${GAMESERVER}${GAMESERVER_INSTANCE}" + mv ${GAMESERVER} ${GAMESERVER}${GAMESERVER_INSTANCE} +fi + +# Install game server +if [ -z "$(ls -A -- "serverfiles")" ]; then + [ -z "${GAMESERVER_INSTANCE}" ] && echo "installing ${GAMESERVER}" || echo "installing ${GAMESERVER}${GAMESERVER_INSTANCE}" + [ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} auto-install || ./${GAMESERVER}${GAMESERVER_INSTANCE} auto-install +fi + +echo "starting cron" +sudo cron + +# Update game server +echo "" +[ -z "${GAMESERVER_INSTANCE}" ] && echo "update ${GAMESERVER}" || echo "update ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} update || ./${GAMESERVER}${GAMESERVER_INSTANCE} update + +echo "" +[ -z "${GAMESERVER_INSTANCE}" ] && echo "start ${GAMESERVER}" || echo "start ${GAMESERVER}${GAMESERVER_INSTANCE}" +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} start || ./${GAMESERVER}${GAMESERVER_INSTANCE} start +sleep 5 +[ -z "${GAMESERVER_INSTANCE}" ] && ./${GAMESERVER} details || ./${GAMESERVER}${GAMESERVER_INSTANCE} details + +tail -f log/script/* + +# with no command, just spawn a running container suitable for exec's +if [ $# = 0 ]; then + tail -f /dev/null +else + # execute the command passed through docker + "$@" + + # if this command was a server start cmd + # to get around LinuxGSM running everything in + # tmux; + # we attempt to attach to tmux to track the server + # this keeps the container running + # when invoked via docker run + # but requires -it or at least -t + tmux set -g status off && tmux attach 2> /dev/null +fi + +exec "$@" From fb102b0b6dfaf99b14a2a835185627e92e998a6e Mon Sep 17 00:00:00 2001 From: Rasmus Koit Date: Sun, 5 Nov 2023 10:56:13 +0200 Subject: [PATCH 16/16] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ee8fae0..bae8a0a 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,15 @@ Dockerhub https://hub.docker.com/r/gameservermanagers/linuxgsm-docker/ # Usage ## docker-compose -Below is an example `docker-compose` for csgoserver. Ports will vary depending upon server. +Below is an example `docker-compose` for cs2. Ports will vary depending upon server. ``` version: '3.4' services: linuxgsm: image: "raks321/linuxgsm-docker:latest" - container_name: csgoserver + container_name: cs2 environment: - - GAMESERVER=csgoserver + - GAMESERVER=cs2 - GAMESERVER_INSTANCE=01 - LGSM_GITHUBUSER=GameServerManagers - LGSM_GITHUBREPO=LinuxGSM @@ -44,14 +44,14 @@ On first run linuxgsm will install your selected server and will start running. ## Game Server Ports Each game server has its own port requirements. Becuase of this you will need to configure the correct ports in your `docker-compose` after first run. The required ports are output once installation is completed and everytime the docker container is started. ## Volumes -volumes are required to save persistant data for your game server. The example above covers a basic csgoserver however some game servers save files in other places. Please check all the correct locations are mounted to remove the risk of loosing save data. +volumes are required to save persistant data for your game server. The example above covers a basic cs2 however some game servers save files in other places. Please check all the correct locations are mounted to remove the risk of loosing save data. # Run LinuxGSM commands Commands can be run just like standard LinuxGSM using the docker exec command. ``` -docker exec -it csgoserver ./csgoserver details +docker exec -it cs2 ./cs2 details ``` #