From 7027255a0058203ac172bebbd0cd83c4198d798a Mon Sep 17 00:00:00 2001 From: Xstar97TheNoob <9399967+xstar97@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:43:57 -0400 Subject: [PATCH] feat(spaceengineers) update the cfg ports automatically (#12755) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** Auto update the ports for the instance cfg file. ⚒️ Fixes # **⚙️ Type of change** - [X] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [X] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [X] ⚖️ My code follows the style guidelines of this project - [X] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [X] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- charts/incubator/spaceengineers/Chart.yaml | 2 +- .../incubator/spaceengineers/questions.yaml | 22 +++++++++++ charts/incubator/spaceengineers/values.yaml | 38 ++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/charts/incubator/spaceengineers/Chart.yaml b/charts/incubator/spaceengineers/Chart.yaml index 74c2a0cd706..42f4dd109ef 100644 --- a/charts/incubator/spaceengineers/Chart.yaml +++ b/charts/incubator/spaceengineers/Chart.yaml @@ -21,7 +21,7 @@ sources: - https://github.com/truecharts/charts/tree/master/charts/incubator/spaceengineers - https://github.com/Devidian/docker-spaceengineers type: application -version: 3.0.0 +version: 3.0.1 annotations: truecharts.org/catagories: | - GameServers diff --git a/charts/incubator/spaceengineers/questions.yaml b/charts/incubator/spaceengineers/questions.yaml index 697a378427e..bb41173a0d6 100644 --- a/charts/incubator/spaceengineers/questions.yaml +++ b/charts/incubator/spaceengineers/questions.yaml @@ -55,6 +55,28 @@ questions: type: int default: 27017 required: true + - variable: steam + label: Steam Service + description: The Steam service. + schema: + additional_attrs: true + type: dict + attrs: +# Include{serviceSelectorLoadBalancer} +# Include{serviceSelectorExtras} + - variable: steam + label: Steam Service Port Configuration + schema: + additional_attrs: true + type: dict + attrs: + - variable: port + label: Port + description: This port exposes the container port on the service + schema: + type: int + default: 27018 + required: true - variable: api label: API Service description: The API service. diff --git a/charts/incubator/spaceengineers/values.yaml b/charts/incubator/spaceengineers/values.yaml index ed709dd79dd..e7ca60f4503 100644 --- a/charts/incubator/spaceengineers/values.yaml +++ b/charts/incubator/spaceengineers/values.yaml @@ -15,15 +15,20 @@ service: ports: main: protocol: udp - targetPort: 27016 port: 27017 + steam: + enabled: true + ports: + steam: + protocol: udp + enabled: true + port: 27018 api: enabled: true ports: api: protocol: http enabled: true - targetPort: 8080 port: 18080 spaceengineers: @@ -35,6 +40,35 @@ workload: podSpec: containers: main: + lifecycle: + postStart: + type: exec + command: + - /bin/sh + - -c + - | + INSTANCE_NAME="{{ .Values.spaceengineers.instance_name }}" + CONFIG_PATH="{{ .Values.persistence.instances.mountPath }}/$INSTANCE_NAME/SpaceEngineers-Dedicated.cfg" + + # Define the new values for the port-related options + ServerPort="{{ .Values.service.main.ports.main.port }}" + SteamPort="{{ .Values.service.steam.ports.steam.port }}" + RemoteApiPort="{{ .Values.service.api.ports.api.port }}" + + # Check if the configuration file exists + if [ -f "$CONFIG_PATH" ]; then + # Update the XML file with the new values using sed + sed -i "s/[0-9]*<\/SteamPort>/$SteamPort<\/SteamPort>/" "$CONFIG_PATH" + sed -i "s/[0-9]*<\/ServerPort>/$ServerPort<\/ServerPort>/" "$CONFIG_PATH" + sed -i "s/[0-9]*<\/RemoteApiPort>/$RemoteApiPort<\/RemoteApiPort>/" "$CONFIG_PATH" + + echo "Port-related options updated for instance $INSTANCE_NAME:" + echo "SteamPort: $SteamPort" + echo "ServerPort: $ServerPort" + echo "RemoteApiPort: $RemoteApiPort" + else + echo "Configuration file not found. Please create it manually or check the path: $CONFIG_PATH" + fi probes: liveness: enabled: false