From 5f1d851b312ddd67b8b84c27c40b516cf70e0952 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Mon, 10 Jul 2023 16:30:41 -0400 Subject: [PATCH] BREAKING CHANGES - Radical Reconfiguration (TM) --- .dockerignore | 2 +- .gitea/workflows/build.yaml | 54 ++-- Dockerfile | 32 +-- README.md | 172 ++++++++---- docker-compose.yml | 13 + override/etc/nginx/nginx.d/default.conf | 5 - .../etc/s6-overlay/s6-rc.d/q2ded-watcher/down | 2 +- override/etc/s6-overlay/s6-rc.d/q2ded/run | 101 ++++--- .../etc/s6-overlay/s6-rc.d/quake2_data/up | 2 +- override/usr/local/bin/quake2-install | 257 ++++++++++-------- override/usr/local/bin/quake2-mirror | 100 ++++--- override/usr/local/bin/quake2-shutdown | 27 +- 12 files changed, 449 insertions(+), 318 deletions(-) create mode 100644 docker-compose.yml delete mode 100644 override/etc/nginx/nginx.d/default.conf diff --git a/.dockerignore b/.dockerignore index d236b92..07d3ff5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ -.drone.yml .git .gitea .gitignore LICENSE.md README.md +docker-compose.yml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 4760bc7..c24430b 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -11,8 +11,7 @@ jobs: - name: Docker Build run: | docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-cached --target builder ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-amd64 --target dedicated ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-amd64 ${{ gitea.workspace }} + docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-amd64 ${{ gitea.workspace }} - name: Docker Login uses: actions/docker-login@v2 with: @@ -20,9 +19,7 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.PACKAGER_TOKEN }} - name: Docker Push - run: | - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-amd64 - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-amd64 + run: docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-amd64 - name: Notify Discord uses: actions/discord-status@v1 if: always() @@ -38,8 +35,7 @@ jobs: - name: Docker Build run: | docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-cached --target builder ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-arm64v8 --target dedicated ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-arm64v8 ${{ gitea.workspace }} + docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-arm64v8 ${{ gitea.workspace }} - name: Docker Login uses: actions/docker-login@v2 with: @@ -47,9 +43,7 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.PACKAGER_TOKEN }} - name: Docker Push - run: | - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-arm64v8 - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-arm64v8 + run: docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-arm64v8 - name: Notify Discord uses: actions/discord-status@v1 if: always() @@ -65,8 +59,7 @@ jobs: - name: Docker Build run: | docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-cached --target builder ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-armv7 --target dedicated ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-armv7 ${{ gitea.workspace }} + docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-armv7 ${{ gitea.workspace }} - name: Docker Login uses: actions/docker-login@v2 with: @@ -74,9 +67,7 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.PACKAGER_TOKEN }} - name: Docker Push - run: | - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-armv7 - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-armv7 + run: docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-armv7 - name: Notify Discord uses: actions/discord-status@v1 if: always() @@ -92,8 +83,7 @@ jobs: - name: Docker Build run: | docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-cached --target builder ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-riscv64 --target dedicated ${{ gitea.workspace }} - docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-riscv64 ${{ gitea.workspace }} + docker build --pull -t code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-riscv64 ${{ gitea.workspace }} - name: Docker Login uses: actions/docker-login@v2 with: @@ -101,9 +91,7 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.PACKAGER_TOKEN }} - name: Docker Push - run: | - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-riscv64 - docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-riscv64 + run: docker push code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-riscv64 - name: Notify Discord uses: actions/discord-status@v1 if: always() @@ -123,9 +111,7 @@ jobs: - name: Docker Manifest run: | docker manifest create code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }} --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-amd64 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-arm64v8 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-armv7 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-riscv64 - docker manifest create code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-amd64 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-arm64v8 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-armv7 --amend code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx-riscv64 docker manifest push --purge code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }} - docker manifest push --purge code.nephatrine.net/nephnet/quake2-yamagi:${{ gitea.ref_name }}-nginx publish_amd64: if: gitea.ref_name == 'master' needs: [build_amd64] @@ -136,8 +122,8 @@ jobs: uses: actions/docker-base-image-check@v1.2.1 id: checkbase with: - base-image: nephatrine/nginx-ssl:latest-amd64 - image: nephatrine/quake2-server:yamagi-nginx-amd64 + base-image: nephatrine/alpine-s6:latest-amd64 + image: nephatrine/quake2-server:yamagi-amd64 - name: Docker Login uses: actions/docker-login@v2 with: @@ -146,9 +132,7 @@ jobs: - name: Docker Push run: | docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-amd64 nephatrine/quake2-server:yamagi-amd64 - docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-nginx-amd64 nephatrine/quake2-server:yamagi-nginx-amd64 docker push nephatrine/quake2-server:yamagi-amd64 - docker push nephatrine/quake2-server:yamagi-nginx-amd64 - name: Notify Discord if: github.event_name == 'push' || steps.checkbase.outputs.needs-updating == 'true' uses: actions/discord-status@v1 @@ -170,9 +154,7 @@ jobs: - name: Docker Push run: | docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-arm64v8 nephatrine/quake2-server:yamagi-arm64v8 - docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-nginx-arm64v8 nephatrine/quake2-server:yamagi-nginx-arm64v8 docker push nephatrine/quake2-server:yamagi-arm64v8 - docker push nephatrine/quake2-server:yamagi-nginx-arm64v8 publish_armhf: if: gitea.ref_name == 'master' needs: [build_armhf] @@ -186,9 +168,7 @@ jobs: - name: Docker Push run: | docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-armv7 nephatrine/quake2-server:yamagi-armv7 - docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-nginx-armv7 nephatrine/quake2-server:yamagi-nginx-armv7 docker push nephatrine/quake2-server:yamagi-armv7 - docker push nephatrine/quake2-server:yamagi-nginx-armv7 publish_riscv64: if: gitea.ref_name == 'master' needs: [build_riscv64] @@ -202,9 +182,7 @@ jobs: - name: Docker Push run: | docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-riscv64 nephatrine/quake2-server:yamagi-riscv64 - docker tag code.nephatrine.net/nephnet/quake2-yamagi:master-nginx-riscv64 nephatrine/quake2-server:yamagi-nginx-riscv64 docker push nephatrine/quake2-server:yamagi-riscv64 - docker push nephatrine/quake2-server:yamagi-nginx-riscv64 publish_manifest: needs: [publish_amd64, publish_arm64, publish_armhf, publish_riscv64] runs-on: nephnet @@ -216,14 +194,14 @@ jobs: password: ${{ secrets.DOCKER_PASS }} - name: Docker Manifest run: | - docker manifest create nephatrine/quake2-server:yamagi --amend nephatrine/quake2-server:yamagi-amd64 --amend nephatrine/quake2-server:yamagi-arm64v8 --amend nephatrine/quake2-server:yamagi-armv7 --amend nephatrine/quake2-server:yamagi-riscv64 - docker manifest create nephatrine/quake2-server:yamagi-nginx --amend nephatrine/quake2-server:yamagi-nginx-amd64 --amend nephatrine/quake2-server:yamagi-nginx-arm64v8 --amend nephatrine/quake2-server:yamagi-nginx-armv7 --amend nephatrine/quake2-server:yamagi-nginx-riscv64 + docker manifest create nephatrine/quake2-server:yamagi-8.20 --amend nephatrine/quake2-server:yamagi-amd64 --amend nephatrine/quake2-server:yamagi-arm64v8 --amend nephatrine/quake2-server:yamagi-armv7 --amend nephatrine/quake2-server:yamagi-riscv64 + docker manifest create nephatrine/quake2-server:yamagi-8 --amend nephatrine/quake2-server:yamagi-amd64 --amend nephatrine/quake2-server:yamagi-arm64v8 --amend nephatrine/quake2-server:yamagi-armv7 --amend nephatrine/quake2-server:yamagi-riscv64 + docker manifest create nephatrine/quake2-server:yamagi-latest --amend nephatrine/quake2-server:yamagi-amd64 --amend nephatrine/quake2-server:yamagi-arm64v8 --amend nephatrine/quake2-server:yamagi-armv7 --amend nephatrine/quake2-server:yamagi-riscv64 docker manifest create nephatrine/quake2-server:latest --amend nephatrine/quake2-server:yamagi-amd64 --amend nephatrine/quake2-server:yamagi-arm64v8 --amend nephatrine/quake2-server:yamagi-armv7 --amend nephatrine/quake2-server:yamagi-riscv64 - docker manifest create nephatrine/quake2-server:latest-nginx --amend nephatrine/quake2-server:yamagi-nginx-amd64 --amend nephatrine/quake2-server:yamagi-nginx-arm64v8 --amend nephatrine/quake2-server:yamagi-nginx-armv7 --amend nephatrine/quake2-server:yamagi-nginx-riscv64 - docker manifest push --purge nephatrine/quake2-server:yamagi - docker manifest push --purge nephatrine/quake2-server:yamagi-nginx + docker manifest push --purge nephatrine/quake2-server:yamagi-8.20 + docker manifest push --purge nephatrine/quake2-server:yamagi-8 + docker manifest push --purge nephatrine/quake2-server:yamagi-latest docker manifest push --purge nephatrine/quake2-server:latest - docker manifest push --purge nephatrine/quake2-server:latest-nginx - name: Checkout Repository uses: actions/checkout@v3 - name: Docker Describe diff --git a/Dockerfile b/Dockerfile index 377d1ee..d44adf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,19 @@ FROM nephatrine/nxbuilder:alpine AS builder RUN echo "====== INSTALL LIBRARIES ======" \ && apk add --no-cache mesa-dev sdl2-dev -RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/yquake2.git +ARG YQUAKE2_VERSION=QUAKE2_8_20 +ARG CTF_VERSION=CTF_1_09 +ARG ROGUE_VERSION=ROGUE_2_10 +ARG XATRIX_VERSION=XATRIX_2_11 + +RUN git -C /root clone -b "$YQUAKE2_VERSION" --single-branch --depth=1 https://github.com/yquake2/yquake2.git RUN git -C /root clone --single-branch --depth=1 https://github.com/DirtBagXon/3zb2-zigflag.git RUN git -C /root clone --single-branch --depth=1 https://github.com/packetflinger/lmctf.git RUN git -C /root clone --single-branch --depth=1 https://github.com/packetflinger/openffa.git RUN git -C /root clone --single-branch --depth=1 https://github.com/packetflinger/opentdm.git -RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/ctf.git -RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/rogue.git -RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/xatrix.git +RUN git -C /root clone -b "$CTF_VERSION" --single-branch --depth=1 https://github.com/yquake2/ctf.git +RUN git -C /root clone -b "$ROGUE_VERSION" --single-branch --depth=1 https://github.com/yquake2/rogue.git +RUN git -C /root clone -b "$XATRIX_VERSION" --single-branch --depth=1 https://github.com/yquake2/xatrix.git RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/zaero.git RUN git -C /root clone --single-branch --depth=1 https://github.com/yquake2/pakextract.git @@ -51,12 +56,12 @@ RUN echo "====== COMPILE OPENTDM ======" \ && make -j$(( $(getconf _NPROCESSORS_ONLN) / 2 + 1 )) \ && mv game*.so game.so -FROM nephatrine/alpine-s6:latest AS dedicated +FROM nephatrine/alpine-s6:latest LABEL maintainer="Daniel Wolf " RUN echo "====== INSTALL PACKAGES ======" \ && apk add --no-cache libcurl screen sdl2 \ - && mkdir -p /mnt/shared + && mkdir -p /mnt/shared /mnt/mirror COPY --from=builder /root/pakextract/pakextract /usr/local/bin/ COPY --from=builder /root/yquake2/release/ /opt/quake2/ @@ -89,18 +94,3 @@ RUN echo "====== PREP FOR Q2ADMIN ======" \ && cp /opt/quake2/lmctf/game.so /opt/quake2/lmctf/game.real.so EXPOSE 27910/udp - -FROM nephatrine/nginx-ssl:latest -LABEL maintainer="Daniel Wolf " - -RUN echo "====== INSTALL PACKAGES ======" \ - && apk add --no-cache libcurl screen sdl2 - -ENV QUAKE2_MIRROR=true - -COPY --from=dedicated /usr/local/bin /usr/local/bin -COPY --from=dedicated /opt/quake2 /opt/quake2 -COPY --from=dedicated /opt/quake2-data /opt/quake2-data -COPY override/etc /etc - -EXPOSE 80/tcp 443/tcp 27910/udp diff --git a/README.md b/README.md index dfc1665..d8b6e07 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,141 @@ [Git](https://code.nephatrine.net/NephNET/docker-quake2-yamagi/src/branch/master) | [Docker](https://hub.docker.com/r/nephatrine/quake2-server/) | -[unRAID](https://code.nephatrine.net/nephatrine/unraid-containers) +[unRAID](https://code.nephatrine.net/NephNET/unraid-containers) -# Quake II Server +# Yamagi Quake II Dedicated Server -This docker image contains a Quake II dedicated server. +This docker container manages the Yamagi Quake II dedicated server. -- [Alpine Linux](https://alpinelinux.org/) w/ [S6 Overlay](https://github.com/just-containers/s6-overlay) -- [NGINX](https://www.nginx.com/) w/ [CertBot](https://certbot.eff.org/) (with ``nginx`` tags) -- [Yamagi Quake II](https://yamagi.org/quake2/) +The `yamagi-latest` tag points to version `8.20` and this is the only image +actively being updated. There are tags for older versions, but these may no +longer be using the latest Alpine version and packages. -The ``nginx`` tags will provide an HTTP(S) mirror of the game files for clients -that support HTTP downloads. +## Docker-Compose -You can spin up a quick temporary test container like this: +These are example docker-compose files for various setups. -~~~ -docker run --rm -p 27910:27910 -it nephatrine/quake2-server:latest /bin/bash -~~~ +### Single Server -## Docker Tags +This is just a simple Quake II server. -- **nephatrine/quake2-server:latest**: Yamagi Quake II / Alpine Latest +```yaml +services: + quake2-server: + image: nephatrine/quake2-server:yamagi-latest + container_name: quake2-server + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + ports: + - "27910:27910/udp" + volumes: + - /mnt/containers/quake2-server:/mnt/config +``` -## Configuration Variables +### Single Server w/ HTTP Mirror -You can set these parameters using the syntax ``-e "VARNAME=VALUE"`` on your -``docker run`` command. Some of these may only be used during initial -configuration and further changes may need to be made in the generated -configuration files. +This container is set up to create an HTTP mirror of the game contents so that +players joining can get better download speeds on engines that support it. You +can easily add an NGINX container and map a separate volume that is shared +between the game server and NGINX. Then you can just put that volume in +`QUAKE2_MIRROR` and the `${QUAKE2_MIRROR}/www/quake2` directory will reflect +the installed game data on the server. -- ``GAME_START``: Startup Arguments (*"+exec server.cfg"*) -- ``PUID``: Mount Owner UID (*1000*) -- ``PGID``: Mount Owner GID (*100*) -- ``TZ``: System Timezone (*America/New_York*) +**NB:** You will need to manually configure NGINX's config to share +`/mnt/config/www/quake2`. -If using the ``nginx`` tags, you can use the additional configuration options -documented for the [nginx-ssl](https://code.nephatrine.net/nephatrine/docker-nginx-ssl) -container. +```yaml +services: + quake2-server: + image: nephatrine/quake2-server:yamagi-latest + container_name: quake2-server + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + QUAKE2_MIRROR: /mnt/mirror + ports: + - "27910:27910/udp" + volumes: + - /mnt/containers/quake2-server:/mnt/config + - /mnt/containers/quake2-http:/mnt/mirror + quake2-http: + image: nephatrine/nginx-ssl:latest + container_name: quake2-http + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + ADMINIP: 127.0.0.1 + TRUSTSN: 192.168.0.0/16 + DNSADDR: "8.8.8.8 8.8.4.4" + ports: + - "80:8080/tcp" + volumes: + - /mnt/containers/quake2-http:/mnt/config +``` -## Persistent Mounts +### Multiple Servers -You can provide a persistent mountpoint using the ``-v /host/path:/container/path`` -syntax. These mountpoints are intended to house important configuration files, -logs, and application state (e.g. databases) so they are not lost on image -update. +This is an example where you want to run two servers on the same host. In such +cases, it is possible to have them use a shared game data volume. You just map +a separate volume that is shared by both and put that volume in +`QUAKE2_INSTALL` on one and `QUAKE2_DATA` on the other. Make sure that the +first container starts before the other so that the installation is all set up +for it and you should be good to go. -- ``/mnt/config``: Persistent Data. -- ``/mnt/shared``: Optional - Shared Game Data. +When hosting multiple servers, you *can* use a port setting of +`27911:27910/udp` instead of specifying a different internal listening port in +`GAME_START`, but the port is used for both the port being listened to by the +server as well as what they advertise to the master server. So if you want your +servers to show up properly in the master servers, you'll want to specify the +port each should run on and map those separate ports on both sides. -Do not share ``/mnt/config`` volumes between multiple containers as they may -interfere with the operation of one another. +```yaml +services: + quake2-server-1: + image: nephatrine/quake2-server:yamagi-latest + container_name: quake2-server-1 + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + QUAKE2_INSTALL: /mnt/shared + GAME_START: "+set port 27910 +exec server.cfg" + ports: + - "27910:27910/udp" + volumes: + - /mnt/containers/quake2-server-1:/mnt/config + - /mnt/containers/quake2-data:/mnt/shared + quake2-server-2: + image: nephatrine/quake2-server:yamagi-latest + container_name: quake2-server-2 + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + QUAKE2_DATA: /mnt/shared + GAME_START: "+set port 27911 +game ctf +exec server.cfg" + ports: + - "27911:27911/udp" + depends_on: + - quake2-server-1 + volumes: + - /mnt/containers/quake2-server-2:/mnt/config + - /mnt/containers/quake2-data:/mnt/shared +``` -The ``/mnt/shared`` volume, if mounted, should contain a ``data/quake2`` -directory with the Quake II game data that should be used. This can be shared -between multiple Quake II servers. +## Server Configuration -You can perform some basic configuration of the container using the files and -directories listed below. +These are the configuration and data files you will likely need to be aware of +and potentially customize. -- ``/mnt/config/data/quake2/``: Game Data. [*] -- ``/mnt/config/data/quake2/baseq2/server.cfg``: Default Quake II Configuration. [*] -- ``/mnt/config/etc/crontabs/``: User Crontabs. [*] -- ``/mnt/config/etc/logrotate.conf``: Logrotate Global Configuration. -- ``/mnt/config/etc/logrotate.d/``: Logrotate Additional Configuration. +- `${QUAKE2_DATA}/data/quake2/*` +- `${QUAKE2_DATA}/data/quake2/baseq2/server.cfg` -**[*] Changes to some configuration files may require service restart to take -immediate effect.** +By customizing the `GAME_START` variable, you can run in a different game +directory or exec a different config file, of course. -## Network Services - -This container runs network services that are intended to be exposed outside -the container. You can map these to host ports using the ``-p HOST:CONTAINER`` -or ``-p HOST:CONTAINER/PROTOCOL`` syntax. - -- ``27910/tcp``: Quake II Server. This is the game server. +Modifications to some of these may require a service restart to pull in the +changes made. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5579a7d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + quake2-server: + build: . + container_name: quake2-server + environment: + TZ: America/New_York + PUID: 1000 + PGID: 1000 + QUAKE2_MIRROR: true + ports: + - "27910:27910/udp" + volumes: + - /mnt/containers/quake2-server:/mnt/config diff --git a/override/etc/nginx/nginx.d/default.conf b/override/etc/nginx/nginx.d/default.conf deleted file mode 100644 index f348e64..0000000 --- a/override/etc/nginx/nginx.d/default.conf +++ /dev/null @@ -1,5 +0,0 @@ -server { - server_name _; - include /mnt/config/etc/nginx.d/_server_local.inc; - root /mnt/config/www/quake2; -} diff --git a/override/etc/s6-overlay/s6-rc.d/q2ded-watcher/down b/override/etc/s6-overlay/s6-rc.d/q2ded-watcher/down index c4b150e..bcfdd5e 100755 --- a/override/etc/s6-overlay/s6-rc.d/q2ded-watcher/down +++ b/override/etc/s6-overlay/s6-rc.d/q2ded-watcher/down @@ -1,2 +1,2 @@ #!/command/execlineb -foreground { /bin/bash /usr/local/bin/quake2-shutdown } +foreground { /command/with-contenv /bin/sh /usr/local/bin/quake2-shutdown } diff --git a/override/etc/s6-overlay/s6-rc.d/q2ded/run b/override/etc/s6-overlay/s6-rc.d/q2ded/run index 9d1d8a2..5a591af 100755 --- a/override/etc/s6-overlay/s6-rc.d/q2ded/run +++ b/override/etc/s6-overlay/s6-rc.d/q2ded/run @@ -1,43 +1,76 @@ #!/command/with-contenv /bin/bash -GAME_START=${GAME_START:-"+exec server.cfg"} +export HOME=/mnt/config/home +export GAME_START=${GAME_START:-"+exec server.cfg"} -cd /opt/quake2 - -if ! /usr/bin/pgrep -f quakedock >/dev/null; then - export HOME=/mnt/config/home - - if [[ -f ${HOME}/.yq2/baseq2/qconsole.log ]]; then - /bin/ls -la ${HOME}/.yq2/baseq2/qconsole.log | /command/s6-setuidgid guardian /usr/bin/tee -a /mnt/config/log/qconsole.log - /bin/cat ${HOME}/.yq2/baseq2/qconsole.log | /command/s6-setuidgid guardian /usr/bin/tee -a /mnt/config/log/qconsole.log - /bin/rm -f ${HOME}/.yq2/baseq2/qconsole.log - fi - - if [[ -d /mnt/shared/data/quake2/openffa/highscores ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /opt/quake2/openffa - /command/s6-setuidgid guardian /bin/cp -rvs /mnt/shared/data/quake2/openffa/highscores /opt/quake2/openffa/highscores - fi - if [[ -d /mnt/shared/data/quake2/openffa/mapcfg ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /opt/quake2/openffa - /command/s6-setuidgid guardian /bin/cp -rvs /mnt/shared/data/quake2/openffa/mapcfg /opt/quake2/openffa/mapcfg - fi - if [[ -d /mnt/shared/data/quake2/openffa/motd ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /opt/quake2/openffa - /command/s6-setuidgid guardian /bin/cp -rvs /mnt/shared/data/quake2/openffa/motd /opt/quake2/openffa/motd - fi - - if [[ -d /mnt/shared/data/quake2 ]]; then - /command/s6-setuidgid guardian /usr/bin/screen -dmS quakedock ./q2ded -datadir /mnt/shared/data/quake2 +set basepath /mnt/shared/data/quake2 +set savepath /mnt/config/home/.yq2 ${GAME_START}; +if [[ -z "${QUAKE2_DATA}" ]]; then + if [[ -n "${QUAKE2_INSTALL}" && ! "${QUAKE2_INSTALL}" == "true" && ! "${QUAKE2_INSTALL}" == "false" ]]; then + export QUAKE2_DATA="${QUAKE2_INSTALL}" else - /command/s6-setuidgid guardian /usr/bin/screen -dmS quakedock ./q2ded -datadir /mnt/config/data/quake2 +set basepath /mnt/config/data/quake2 +set savepath /mnt/config/home/.yq2 ${GAME_START}; + export QUAKE2_DATA="/mnt/config" fi - - if [[ -f ${HOME}/.screenrc ]]; then - /bin/chown guardian:users ${HOME} - /bin/chown guardian:users ${HOME}/.screenrc - fi - sleep 10 fi + +if [[ -z "${QUAKE2_DATA_SUBPATH}" ]]; then + export QUAKE2_DATA_SUBPATH=/data/quake2 +fi + +# Transfer Yamagi Log + +if [[ -f "${HOME}/.yq2/baseq2/qconsole.log" ]]; then + /bin/ls -la "${HOME}/.yq2/baseq2/qconsole.log" | /command/s6-setuidgid guardian /usr/bin/tee -a /mnt/config/log/qconsole.log + /bin/cat "${HOME}/.yq2/baseq2/qconsole.log" | /command/s6-setuidgid guardian /usr/bin/tee -a /mnt/config/log/qconsole.log + /bin/rm -f "${HOME}/.yq2/baseq2/qconsole.log" +fi + +# Link OpenFFA Configs + +if [[ ! -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" && -d /opt/quake2/openffa/highscores ]]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" ]]; then + /command/s6-setuidgid guardian /bin/cp -Rv /opt/quake2/openffa/highscores/. "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores/" + /bin/rm -rf /opt/quake2/openffa/highscores + fi +fi +if [[ ! -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg" && -d /opt/quake2/openffa/mapcfg ]]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg" + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg" ]]; then + /command/s6-setuidgid guardian /bin/cp -Rv /opt/quake2/openffa/mapcfg/. "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg/" + /bin/rm -rf /opt/quake2/openffa/mapcfg + fi +fi +if [[ ! -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd" && -d /opt/quake2/openffa/motd ]]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd" + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd" ]]; then + /command/s6-setuidgid guardian /bin/cp -Rv /opt/quake2/openffa/motd/. "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd/" + /bin/rm -rf /opt/quake2/openffa/motd + fi +fi +if [[ -d /opt/quake2/openffa ]]; then + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" && ! -d /opt/quake2/openffa/highscores ]]; then + /bin/cp -Rvsp "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" /opt/quake2/openffa/ + fi + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg" && ! -d /opt/quake2/openffa/mapcfg ]]; then + /bin/cp -Rvsp "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/mapcfg" /opt/quake2/openffa/ + fi + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd" && ! -d /opt/quake2/openffa/motd ]]; then + /bin/cp -Rvsp "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/motd" /opt/quake2/openffa/ + fi +fi + +# Start Yamagi Quake II + +cd /opt/quake2 || exit 1 +/command/s6-setuidgid guardian /usr/bin/screen -dmS quakedock ./q2ded -datadir "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" +set basepath "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" +set savepath /mnt/config/home/.yq2 ${GAME_START}; + +if [[ -f ${HOME}/.screenrc ]]; then + /bin/chown guardian:users ${HOME} + /bin/chown guardian:users ${HOME}/.screenrc +fi +sleep 5 + +# Idle... + while /usr/bin/pgrep -f quakedock >/dev/null; do sleep 60 done diff --git a/override/etc/s6-overlay/s6-rc.d/quake2_data/up b/override/etc/s6-overlay/s6-rc.d/quake2_data/up index 30b5560..d6aa1d9 100755 --- a/override/etc/s6-overlay/s6-rc.d/quake2_data/up +++ b/override/etc/s6-overlay/s6-rc.d/quake2_data/up @@ -1,2 +1,2 @@ #!/command/execlineb -foreground { /command/with-contenv /bin/bash /usr/local/bin/quake2-install } +foreground { /command/with-contenv /bin/sh /usr/local/bin/quake2-install } diff --git a/override/usr/local/bin/quake2-install b/override/usr/local/bin/quake2-install index d9b43d2..31ca7d5 100755 --- a/override/usr/local/bin/quake2-install +++ b/override/usr/local/bin/quake2-install @@ -1,177 +1,196 @@ -#!/command/with-contenv /bin/bash +#!/command/with-contenv /bin/sh if /usr/bin/pgrep -f quakedock >/dev/null; then exit 1 fi -if [[ -d /mnt/shared/data/quake2 ]]; then - cd /mnt/shared/data/quake2 - /usr/bin/find . -type f -name 'game*.so' -exec /bin/cp --parents {} /opt/quake2/ \; - exit 0 -elif [[ -d /mnt/config/data/quake2 ]]; then - cd /mnt/config/data/quake2 +if [ -z "${QUAKE2_DATA}" ]; then + if [ -n "${QUAKE2_INSTALL}" ] && [ ! "${QUAKE2_INSTALL}" = "true" ] && [ ! "${QUAKE2_INSTALL}" = "false" ]; then + export QUAKE2_DATA="${QUAKE2_INSTALL}" + else + export QUAKE2_DATA="/mnt/config" + fi +fi +if [ -z "${QUAKE2_INSTALL}" ] && [ "${QUAKE2_DATA}" = "/mnt/config" ]; then + export QUAKE2_INSTALL="${QUAKE2_DATA}" +elif [ "${QUAKE2_INSTALL}" = "true" ]; then + export QUAKE2_INSTALL="${QUAKE2_DATA}" +elif [ "${QUAKE2_INSTALL}" = "false" ]; then + export QUAKE2_INSTALL= +fi + +if [ -z "${QUAKE2_DATA_SUBPATH}" ]; then + export QUAKE2_DATA_SUBPATH=/data/quake2 +fi + +# Copy Mods Locally + +if [ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" ]; then + cd "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" || exit 1 /usr/bin/find . -type f -name 'game*.so' -exec /bin/cp --parents {} /opt/quake2/ \; fi -# QUAKE II +# Install Quake II -if [[ ! -d /mnt/config/data/quake2/baseq2 ]]; then - if [[ ! -f /tmp/q2-314-demo-x86.exe ]]; then - /usr/bin/wget -qO /tmp/q2-314-demo-x86.exe https://files.nephatrine.net/archives/idstuff/quake2/q2-314-demo-x86.exe +if [ -n "${QUAKE2_INSTALL}" ] && [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2" ]; then + if [ ! -f /tmp/q2-314-demo-x86.exe ]; then + /usr/bin/wget -qO /tmp/q2-314-demo-x86.exe https://nephatrine.net/backup/quake2/q2-314-demo-x86.exe fi - if [[ ! -f /tmp/q2-3.20-x86-full-ctf.exe ]]; then - /usr/bin/wget -qO /tmp/q2-3.20-x86-full-ctf.exe https://files.nephatrine.net/archives/idstuff/quake2/q2-3.20-x86-full-ctf.exe + if [ ! -f /tmp/q2-3.20-x86-full-ctf.exe ]; then + /usr/bin/wget -qO /tmp/q2-3.20-x86-full-ctf.exe https://nephatrine.net/backup/quake2/q2-3.20-x86-full-ctf.exe fi - if [[ ! -f /tmp/match1.tar.gz ]]; then - /usr/bin/wget -qO /tmp/match1.tar.gz https://files.nephatrine.net/archives/idstuff/quake2/maps/match1.tar.gz + if [ ! -f /tmp/match1.tar.gz ]; then + /usr/bin/wget -qO /tmp/match1.tar.gz https://nephatrine.net/backup/quake2/maps/match1.tar.gz fi - if [[ ! -f /tmp/dm_64.tar.gz ]]; then - /usr/bin/wget -qO /tmp/dm_64.tar.gz https://files.nephatrine.net/archives/idstuff/quake2/maps/dm_64.tar.gz + if [ ! -f /tmp/dm_64.tar.gz ]; then + /usr/bin/wget -qO /tmp/dm_64.tar.gz https://nephatrine.net/backup/quake2/maps/dm_64.tar.gz fi - if [[ -f /tmp/q2-314-demo-x86.exe ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/baseq2 - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/baseq2/ /tmp/q2-314-demo-x86.exe \ - Install/Data/baseq2/pak0.pak \ - Install/Data/DOCS/license.txt + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/maps" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/maps" fi - if [[ -f /tmp/q2-3.20-x86-full-ctf.exe ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/baseq2 - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/baseq2/ /tmp/q2-3.20-x86-full-ctf.exe \ - baseq2/maps.lst \ - baseq2/pak1.pak \ - baseq2/pak2.pak + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2" ] && [ -f /tmp/q2-314-demo-x86.exe ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/" /tmp/q2-314-demo-x86.exe \ + Install/Data/baseq2/pak0.pak Install/Data/DOCS/license.txt + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2" ] && [ -f /tmp/q2-3.20-x86-full-ctf.exe ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/" /tmp/q2-3.20-x86-full-ctf.exe \ + baseq2/maps.lst baseq2/pak1.pak baseq2/pak2.pak /command/s6-setuidgid guardian /bin/mkdir /tmp/q2-3.20-x86-full-ctf /command/s6-setuidgid guardian /usr/bin/unzip -d /tmp/q2-3.20-x86-full-ctf/ /tmp/q2-3.20-x86-full-ctf.exe - /command/s6-setuidgid guardian /bin/mv /tmp/q2-3.20-x86-full-ctf/baseq2/players /mnt/config/data/quake2/baseq2/ + /command/s6-setuidgid guardian /bin/mv /tmp/q2-3.20-x86-full-ctf/baseq2/players "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/" /bin/rm -rf /tmp/q2-3.20-x86-full-ctf fi - if [[ -f /tmp/match1.tar.gz ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/baseq2 - /command/s6-setuidgid guardian /bin/tar x -C /mnt/config/data/quake2/baseq2/ -zf /tmp/match1.tar.gz \ + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2" ] &&[ -f /tmp/match1.tar.gz ]; then + /command/s6-setuidgid guardian /bin/tar x -C "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/" -zf /tmp/match1.tar.gz \ pak3.pak fi - if [[ -f /tmp/dm_64.tar.gz ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/baseq2/maps - /command/s6-setuidgid guardian /bin/tar x -C /mnt/config/data/quake2/baseq2/maps/ -zf /tmp/dm_64.tar.gz \ - base64.bsp \ - city64.bsp \ - sewer64.bsp + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/maps" ] && [ -f /tmp/dm_64.tar.gz ]; then + /command/s6-setuidgid guardian /bin/tar x -C "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/maps/" -zf /tmp/dm_64.tar.gz \ + base64.bsp city64.bsp sewer64.bsp fi fi -# CAPTURE THE FLAG +# Install Capture The Flag -if [[ ! -d /mnt/config/data/quake2/ctf ]]; then - if [[ ! -f /tmp/q2-3.20-x86-full-ctf.exe ]]; then - /usr/bin/wget -qO /tmp/q2-3.20-x86-full-ctf.exe https://files.nephatrine.net/archives/idstuff/quake2/q2-3.20-x86-full-ctf.exe +if [ -n "${QUAKE2_INSTALL}" ] && [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf" ]; then + if [ ! -f /tmp/q2-3.20-x86-full-ctf.exe ]; then + /usr/bin/wget -qO /tmp/q2-3.20-x86-full-ctf.exe https://nephatrine.net/backup/quake2/q2-3.20-x86-full-ctf.exe fi - if [[ ! -f /tmp/q2ctf150upgrade.zip ]]; then - /usr/bin/wget -qO /tmp/q2ctf150upgrade.zip https://files.nephatrine.net/archives/idstuff/quake2/ctf/q2ctf150upgrade.zip + if [ ! -f /tmp/q2ctf150upgrade.zip ]; then + /usr/bin/wget -qO /tmp/q2ctf150upgrade.zip https://nephatrine.net/backup/quake2/q2ctf150upgrade.zip fi - if [[ ! -f /tmp/q2ctf4a.tar.gz ]]; then - /usr/bin/wget -qO /tmp/q2ctf4a.tar.gz https://files.nephatrine.net/archives/idstuff/quake2/maps/q2ctf4a.tar.gz + if [ ! -f /tmp/q2ctf4a.tar.gz ]; then + /usr/bin/wget -qO /tmp/q2ctf4a.tar.gz https://nephatrine.net/backup/quake2/maps/q2ctf4a.tar.gz fi - if [[ -f /tmp/q2-3.20-x86-full-ctf.exe ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/ctf - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/ctf/ /tmp/q2-3.20-x86-full-ctf.exe \ - ctf/pak0.pak \ - ctf/server.cfg + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/maps" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/maps" fi - if [[ -f /tmp/q2ctf150upgrade.zip ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/ctf - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/ctf/ /tmp/q2ctf150upgrade.zip \ + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf" ] && [ -f /tmp/q2-3.20-x86-full-ctf.exe ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/" /tmp/q2-3.20-x86-full-ctf.exe \ + ctf/pak0.pak ctf/server.cfg + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf" ] && [ -f /tmp/q2ctf150upgrade.zip ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/" /tmp/q2ctf150upgrade.zip \ pak1.pak fi - if [[ -f /tmp/q2ctf4a.tar.gz ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/ctf/maps - /command/s6-setuidgid guardian /bin/tar x -C /mnt/config/data/quake2/ctf/maps/ -zf /tmp/q2ctf4a.tar.gz \ + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/maps" ] && [ -f /tmp/q2ctf4a.tar.gz ]; then + /command/s6-setuidgid guardian /bin/tar x -C "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/maps/" -zf /tmp/q2ctf4a.tar.gz \ q2ctf4a.bsp fi fi -# ZAERO +# Install Zaero Missionpack -if [[ ! -d /mnt/config/data/quake2/zaero ]]; then - if [[ ! -f /tmp/zaerodemo.zip ]]; then - /usr/bin/wget -qO /tmp/zaerodemo.zip https://files.nephatrine.net/archives/teamevolve/zaerodemo.zip +if [ -n "${QUAKE2_INSTALL}" ] && [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ]; then + if [ ! -f /tmp/zaerodemo.zip ]; then + /usr/bin/wget -qO /tmp/zaerodemo.zip https://nephatrine.net/backup/teamevolve/zaerodemo.zip fi - if [[ ! -f /tmp/zaerodm.zip ]]; then - /usr/bin/wget -qO /tmp/zaerodm.zip https://files.nephatrine.net/archives/teamevolve/zaerodm.zip + if [ ! -f /tmp/zaerodm.zip ]; then + /usr/bin/wget -qO /tmp/zaerodm.zip https://nephatrine.net/backup/teamevolve/zaerodm.zip fi - if [[ ! -f /tmp/zaero-1.1.zip ]]; then - /usr/bin/wget -qO /tmp/zaero-1.1.zip https://files.nephatrine.net/archives/teamevolve/zaero-1.1.zip + if [ ! -f /tmp/zaero-1.1.zip ]; then + /usr/bin/wget -qO /tmp/zaero-1.1.zip https://nephatrine.net/backup/teamevolve/zaero-1.1.zip fi - if [[ -f /tmp/zaerodemo.zip ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/zaero - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/zaero/ /tmp/zaerodemo.zip \ - zdemo/config.cfg \ - zdemo/pak0.pak + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ] && [ -f /tmp/zaerodemo.zip ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero/" /tmp/zaerodemo.zip \ + zdemo/config.cfg zdemo/pak0.pak /command/s6-setuidgid guardian /bin/mkdir /tmp/zaerodemo /command/s6-setuidgid guardian /usr/bin/unzip -d /tmp/zaerodemo/ /tmp/zaerodemo.zip - /command/s6-setuidgid guardian /bin/mv /tmp/zaerodemo/zdemo/sprites /mnt/config/data/quake2/zaero/ + /command/s6-setuidgid guardian /bin/mv /tmp/zaerodemo/zdemo/sprites "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero/" /bin/rm -rf /tmp/zaerodemo fi - if [[ -f /tmp/zaero-1.1.zip ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/zaero - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/zaero/ /tmp/zaero-1.1.zip \ + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ] && [ -f /tmp/zaero-1.1.zip ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero/" /tmp/zaero-1.1.zip \ pak1.pak fi - if [[ -f /tmp/zaerodm.zip ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/zaero - /command/s6-setuidgid guardian /usr/bin/unzip -jq -d /mnt/config/data/quake2/zaero/ /tmp/zaerodm.zip \ + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ] && [ -f /tmp/zaerodm.zip ]; then + /command/s6-setuidgid guardian /usr/bin/unzip -jq -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero/" /tmp/zaerodm.zip \ pak2.pak fi fi -# 3RD ZIGOCK BOT II +# Create Other Mod Directories -if [[ -d /opt/quake2-data/3zb2 ]]; then - if [[ ! -d /mnt/config/data/quake2/3zb2 ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/3zb2 +if [ -n "${QUAKE2_INSTALL}" ]; then + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/3zb2" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/3zb2" fi - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/3zb2/* /mnt/config/data/quake2/3zb2/ -fi - -# DOWNLOAD Q2ADMIN - -if [[ && "$(uname)" == "x86_64" ]]; then - if [[ ! -d /mnt/config/data/quake2/q2admin ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/quake2/q2admin + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/openffa" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/openffa" fi - if [[ ! -e /mnt/config/data/quake2/q2admin/game.so ]]; then - /usr/bin/wget -O /tmp/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz https://files.nephatrine.net/archives/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz \ - && /command/s6-setuidgid guardian /bin/tar -C /mnt/config/data/quake2/q2admin -xvzf /tmp/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz - /usr/bin/wget -O /tmp/q2admin-nxmod_noarch.tar.gz https://files.nephatrine.net/archives/q2admin-nxmod_noarch.tar.gz \ - && /command/s6-setuidgid guardian /bin/tar -C /mnt/config/data/quake2/q2admin -xvzf /tmp/q2admin-nxmod_noarch.tar.gz - fi - if [[ -d /opt/quake2-data/q2admin ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/q2admin/* /mnt/config/data/quake2/q2admin/ + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/opentdm" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/opentdm" fi fi -# COPY YAMAGI FIXES OVER +# Download Q2Admin -if [[ -d /mnt/config/data/quake2/baseq2 && -d /opt/quake2-data/baseq2 ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/baseq2/* /mnt/config/data/quake2/baseq2/ -fi -if [[ -d /mnt/config/data/quake2/jugfull && -d /opt/quake2-data/jugfull ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/jugfull/* /mnt/config/data/quake2/jugfull/ -fi -if [[ -d /mnt/config/data/quake2/xatrix && -d /opt/quake2-data/xatrix ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/xatrix/* /mnt/config/data/quake2/xatrix/ -fi -if [[ -d /mnt/config/data/quake2/rogue && -d /opt/quake2-data/rogue ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/rogue/* /mnt/config/data/quake2/rogue/ -fi -if [[ -d /mnt/config/data/quake2/zaero && -d /opt/quake2-data/zaero ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/zaero/* /mnt/config/data/quake2/zaero/ -fi - -# REGENERATE WWW MIRROR? - -if [[ ! -z "${QUAKE2_MIRROR}" && "${QUAKE2_MIRROR}" == "true" ]]; then - if [[ -d /mnt/config/www/quake2 ]]; then - /bin/rm -rf /mnt/config/www/quake2/* +if [ -n "${QUAKE2_INSTALL}" ] && [ "$(uname)" = "x86_64" ]; then + if [ ! -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin" fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin" ] && [ ! -f "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin/game.so" ]; then + /usr/bin/wget -O /tmp/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz https://nephatrine.net/backup/q2admin/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz \ + && /command/s6-setuidgid guardian /bin/tar -C "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin/" -xvzf /tmp/q2admin-nxmod_x86_64-alpine-linux-musl.tar.gz + /usr/bin/wget -O /tmp/q2admin-nxmod_noarch.tar.gz https://nephatrine.net/backup/q2admin/q2admin-nxmod_noarch.tar.gz \ + && /command/s6-setuidgid guardian /bin/tar -C "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin/" -xvzf /tmp/q2admin-nxmod_noarch.tar.gz + fi +fi + +# Copy Map Fixes + +if [ -n "${QUAKE2_INSTALL}" ]; then + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2" ] && [ -d /opt/quake2-data/baseq2 ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/baseq2/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/baseq2/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/jugfull" ] && [ -d /opt/quake2-data/jugfull ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/jugfull/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/jugfull/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/xatrix" ] && [ -d /opt/quake2-data/xatrix ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/xatrix/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/xatrix/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/rogue" ] && [ -d /opt/quake2-data/rogue ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/rogue/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/rogue/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero" ] && [ -d /opt/quake2-data/zaero ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/zaero/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/zaero/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/3zb2" ] && [ -d /opt/quake2-data/3zb2 ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/3zb2/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/3zb2/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf" ] && [ -d /opt/quake2-data/ctf ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/ctf/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/ctf/" + fi + if [ -d "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin" ] && [ -d /opt/quake2-data/q2admin ]; then + /command/s6-setuidgid guardian /bin/cp -Rn /opt/quake2-data/q2admin/. "${QUAKE2_INSTALL}${QUAKE2_DATA_SUBPATH}/q2admin/" + fi +fi + +# Regenerate HTTP Mirror + +if [ -n "${QUAKE2_MIRROR}" ]; then /usr/local/bin/quake2-mirror fi diff --git a/override/usr/local/bin/quake2-mirror b/override/usr/local/bin/quake2-mirror index cbd99ab..ba91903 100755 --- a/override/usr/local/bin/quake2-mirror +++ b/override/usr/local/bin/quake2-mirror @@ -1,49 +1,73 @@ -#!/usr/bin/with-contenv bash +#!/usr/bin/with-contenv /bin/sh -if [ ! -d /mnt/config/www/quake2 ]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/www/quake2 +if [ -z "${QUAKE2_DATA}" ]; then + if [ -n "${QUAKE2_INSTALL}" ] && [ ! "${QUAKE2_INSTALL}" = "true" ] && [ ! "${QUAKE2_INSTALL}" = "false" ]; then + export QUAKE2_DATA="${QUAKE2_INSTALL}" + else + export QUAKE2_DATA="/mnt/config" + fi fi -if [[ -d /tmp/quake2 ]]; then +if [ -z "${QUAKE2_MIRROR}" ]; then + exit 0 +elif [ "${QUAKE2_MIRROR}" = "true" ]; then + export QUAKE2_MIRROR="${QUAKE2_DATA}" +elif [ "${QUAKE2_MIRROR}" = "false" ]; then + export QUAKE2_MIRROR= +fi + +if [ -z "${QUAKE2_DATA_SUBPATH}" ]; then + export QUAKE2_DATA_SUBPATH=/data/quake2 +fi +if [ -z "${QUAKE2_MIRROR_SUBPATH}" ]; then + export QUAKE2_MIRROR_SUBPATH=/www/quake2 +fi + +# Extract PAKs + +if [ -d /tmp/quake2 ]; then /bin/rm -rf /tmp/quake2 fi - -cd /mnt/config/data/quake2 +cd "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" || exit 1 for dir in */; do - cd /mnt/config/data/quake2/${dir} - /command/s6-setuidgid guardian /bin/mkdir -p /tmp/quake2/${dir} - if [[ "${dir}" == "baseq2/" || "${dir}" == "xatrix/" || "${dir}" == "rogue/" ]]; then - /usr/bin/find . -type f -name 'pak*.pak' ! -name 'pak0.pak' | sort | egrep "pak[0-9].pak" \ - | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o /tmp/quake2/${dir} - else - /usr/bin/find . -type f -name 'pak*.pak' | sort | egrep "pak[0-9].pak" \ - | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o /tmp/quake2/${dir} + /command/s6-setuidgid guardian /bin/mkdir -p "/tmp/quake2/${dir}" + if [ -d "/tmp/quake2/${dir}" ]; then + if [ "${dir}" = "baseq2/" ] || [ "${dir}" = "xatrix/" ] || [ "${dir}" = "rogue/" ]; then + /usr/bin/find "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/${dir}" -type f -name 'pak*.pak' ! -name 'pak0.pak' | sort \ + | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o "/tmp/quake2/${dir}" + else + /usr/bin/find "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/${dir}" -type f -name 'pak*.pak' | sort \ + | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o "/tmp/quake2/${dir}" + fi + /usr/bin/find "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/${dir}" -type f -name '*.pak' ! -name 'pak*.pak' | sort \ + | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o "/tmp/quake2/${dir}" fi - /usr/bin/find . -type f -name '*.pak' | sort | egrep -v "pak[0-9].pak" \ - | /usr/bin/xargs -n1 -r /command/s6-setuidgid guardian /usr/local/bin/pakextract -o /tmp/quake2/${dir} done -if [[ -d /tmp/quake2 ]]; then - cd /tmp/quake2 - /usr/bin/find . -type f -name '*.bsp' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.md2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.pcx' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.png' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.sp2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.tga' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.wal' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; - /usr/bin/find . -type f -name '*.wav' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; +# Mirror Files + +if [ ! -d "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}" ]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}" +fi +if [ ! -d "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}" ]; then + exit 1 fi -cd /mnt/config/data/quake2 -/usr/bin/find . -type f -name '*.bsp' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.md2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.pcx' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.png' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.sp2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.tga' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.wal' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; -/usr/bin/find . -type f -name '*.wav' -exec /command/s6-setuidgid guardian /bin/cp --parents {} /mnt/config/www/quake2/ \; +cd /tmp/quake2 || exit 1 +/usr/bin/find . -type f -name '*.bsp' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.md2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.pcx' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.png' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.sp2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.tga' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.wal' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.wav' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; -if [[ -d /mnt/config/www/default ]]; then - /command/s6-setuidgid guardian /bin/cp -Rn /mnt/config/www/default/* /mnt/config/www/quake2/ -fi +cd "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}" || exit 1 +/usr/bin/find . -type f -name '*.bsp' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.md2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.pcx' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.png' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.sp2' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.tga' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.wal' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; +/usr/bin/find . -type f -name '*.wav' -exec /command/s6-setuidgid guardian /bin/cp --parents {} "${QUAKE2_MIRROR}${QUAKE2_MIRROR_SUBPATH}/" \; diff --git a/override/usr/local/bin/quake2-shutdown b/override/usr/local/bin/quake2-shutdown index 2d35a9d..70e75c2 100755 --- a/override/usr/local/bin/quake2-shutdown +++ b/override/usr/local/bin/quake2-shutdown @@ -1,12 +1,27 @@ -#!/bin/bash +#!/command/with-contenv /bin/sh -if [[ -d /opt/quake2/openffa/highscores ]]; then - /command/s6-setuidgid guardian /bin/mkdir -p /mnt/shared/data/quake2/openffa/highscores - /command/s6-setuidgid guardian /bin/cp -rvs /opt/quake2/openffa/highscores /mnt/shared/data/quake2/openffa/highscores +if [ -d /opt/quake2/openffa/highscores ]; then + if [ -z "${QUAKE2_DATA}" ]; then + if [ -n "${QUAKE2_INSTALL}" ] && [ ! "${QUAKE2_INSTALL}" = "true" ] && [ ! "${QUAKE2_INSTALL}" = "false" ]; then + export QUAKE2_DATA="${QUAKE2_INSTALL}" + else + export QUAKE2_DATA="/mnt/config" + fi + fi + if [ -z "${QUAKE2_DATA_SUBPATH}" ]; then + export QUAKE2_DATA_SUBPATH=/data/quake2 + fi + if [[ ! -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" ]]; then + /command/s6-setuidgid guardian /bin/mkdir -p "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" + if [[ -d "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores" ]]; then + /command/s6-setuidgid guardian /bin/cp -Rv /opt/quake2/openffa/highscores/. "${QUAKE2_DATA}${QUAKE2_DATA_SUBPATH}/openffa/highscores/" + /bin/rm -rf /opt/quake2/openffa/highscores + fi + fi fi if /usr/bin/pgrep -f quakedock >/dev/null; then - /command/s6-setuidgid guardian /usr/bin/screen -S quakedock -X stuff "`echo -ne \"say QUAKE II SERVER SHUTTING DOWN!\r\"`" + /command/s6-setuidgid guardian /usr/bin/screen -S quakedock -X stuff "$(/bin/echo -ne \"say QUAKE II SERVER SHUTTING DOWN!\r\")" sleep 6 - /command/s6-setuidgid guardian /usr/bin/screen -S quakedock -X stuff "`echo -ne \"quit\r\"`" + /command/s6-setuidgid guardian /usr/bin/screen -S quakedock -X stuff "$(/bin/echo -ne \"quit\r\")" sleep 2 fi