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/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 new file mode 100644 index 0000000..5f7241b --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +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 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 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 9db44da..bae8a0a 100644 --- a/README.md +++ b/README.md @@ -1,56 +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: "ghcr.io/gameservermanagers/linuxgsm-docker:latest" - container_name: csgoserver - environment: - - GAMESERVER=csgoserver - - 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. -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 cs2. Ports will vary depending upon server. + ``` +version: '3.4' +services: + linuxgsm: + image: "raks321/linuxgsm-docker:latest" + container_name: cs2 + environment: + - GAMESERVER=cs2 + - 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 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 cs2 ./cs2 details + +``` +# diff --git a/docker-compose.yml b/docker-compose.yml index 9a7c258..e0bbc26 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,21 @@ -version: '3.4' -services: - linuxgsm: - image: "ghcr.io/gameservermanagers/linuxgsm-docker:latest" - container_name: csgoserver - environment: - - GAMESERVER=csgoserver - - 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 edf7c52..f14a41a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/bash exit_handler () { - # Execute the shutdown commands - echo "recieved SIGTERM stopping ${GAMESERVER}" - ./${GAMESERVER} stop - exit 0 + # 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 @@ -14,6 +14,7 @@ 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}" @@ -36,13 +37,20 @@ fi # Setup game server if [ ! -f "${GAMESERVER}" ]; then echo "creating ./${GAMESERVER}" - ./linuxgsm.sh ${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 - 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 +58,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/* @@ -67,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;