feat(spaceengineers) update the cfg ports automatically (#12755)

**Description**
Auto update the ports for the instance cfg file.
⚒️ Fixes  # <!--(issue)-->

**⚙️ 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?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ 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._
This commit is contained in:
Xstar97TheNoob
2023-09-22 18:43:57 -04:00
committed by GitHub
parent 0ba8e8b590
commit 7027255a00
3 changed files with 59 additions and 3 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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/<SteamPort>[0-9]*<\/SteamPort>/<SteamPort>$SteamPort<\/SteamPort>/" "$CONFIG_PATH"
sed -i "s/<ServerPort>[0-9]*<\/ServerPort>/<ServerPort>$ServerPort<\/ServerPort>/" "$CONFIG_PATH"
sed -i "s/<RemoteApiPort>[0-9]*<\/RemoteApiPort>/<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