Disable Factorio recycler on vanilla server
Validate, publish and promote Factorio chart / chart (push) Successful in 18s
Validate, publish and promote Factorio chart / chart (push) Successful in 18s
This commit is contained in:
1 parent
b21b78a287
commit
df6af9d0d1
5 files changed
+65
-1
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ spec:
|
||||
metadata:
|
||||
labels: *id001
|
||||
annotations:
|
||||
factorio.brunner.ninja/config-revision: {{ printf "%s%s%s%s%s%s" (.Files.Get "scripts/start.sh") (.Files.Get "scripts/health.sh") (.Files.Get "scripts/collect.sh") (.Files.Get "scripts/collector-health.sh") (.Files.Get "server-settings.json") (.Files.Get "server-adminlist.json") | sha256sum }}
|
||||
factorio.brunner.ninja/config-revision: {{ printf "%s%s%s%s%s%s%s" (.Files.Get "scripts/start.sh") (.Files.Get "scripts/disable-recycler.sh") (.Files.Get "scripts/health.sh") (.Files.Get "scripts/collect.sh") (.Files.Get "scripts/collector-health.sh") (.Files.Get "server-settings.json") (.Files.Get "server-adminlist.json") | sha256sum }}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 180
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
mod_list=${1:-/factorio/mods/mod-list.json}
|
||||
mkdir -p "$(dirname "$mod_list")"
|
||||
|
||||
if [[ ! -s "$mod_list" ]]; then
|
||||
printf '{"mods":[{"name":"base","enabled":true}]}\n' > "$mod_list"
|
||||
fi
|
||||
|
||||
tmp_file="${mod_list}.tmp"
|
||||
jq '
|
||||
if (.mods | map(.name) | index("recycler")) then
|
||||
.mods |= map(if .name == "recycler" then .enabled = false else . end)
|
||||
else
|
||||
.mods += [{"name":"recycler","enabled":false}]
|
||||
end
|
||||
' "$mod_list" > "$tmp_file"
|
||||
mv "$tmp_file" "$mod_list"
|
||||
@@ -13,6 +13,9 @@ cp /settings/server-settings.json /factorio/config/server-settings.json
|
||||
cp /settings/server-adminlist.json /factorio/config/server-adminlist.json
|
||||
cp /credentials/rcon-password /factorio/config/rconpw
|
||||
chmod 600 /factorio/config/rconpw
|
||||
# Recycler is shipped with Factorio 2.1 and is auto-enabled if omitted from
|
||||
# mod-list.json. This vanilla server does not use the Space Age expansion.
|
||||
/scripts/disable-recycler.sh /factorio/mods/mod-list.json
|
||||
# Upstream uses bash xtrace, which would otherwise log the RCON password.
|
||||
exec 3>/dev/null
|
||||
export BASH_XTRACEFD=3
|
||||
|
||||
@@ -8,6 +8,8 @@ metadata:
|
||||
data:
|
||||
start.sh: |
|
||||
{{ .Files.Get "scripts/start.sh" | indent 4 }}
|
||||
disable-recycler.sh: |
|
||||
{{ .Files.Get "scripts/disable-recycler.sh" | indent 4 }}
|
||||
health.sh: |
|
||||
{{ .Files.Get "scripts/health.sh" | indent 4 }}
|
||||
collect.sh: |
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import json
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SCRIPT = Path(__file__).resolve().parents[1] / "scripts/disable-recycler.sh"
|
||||
|
||||
|
||||
class ModListTests(unittest.TestCase):
|
||||
def test_disables_recycler_without_changing_other_mods(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "mod-list.json"
|
||||
path.write_text(json.dumps({"mods": [
|
||||
{"name": "base", "enabled": True},
|
||||
{"name": "recycler", "enabled": True},
|
||||
{"name": "my-mod", "enabled": True},
|
||||
]}))
|
||||
|
||||
subprocess.run(["bash", str(SCRIPT), str(path)], check=True)
|
||||
mods = {mod["name"]: mod["enabled"] for mod in json.loads(path.read_text())["mods"]}
|
||||
|
||||
self.assertFalse(mods["recycler"])
|
||||
self.assertTrue(mods["base"])
|
||||
self.assertTrue(mods["my-mod"])
|
||||
|
||||
def test_adds_recycler_disabled_to_new_mod_list(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / "mods" / "mod-list.json"
|
||||
|
||||
subprocess.run(["bash", str(SCRIPT), str(path)], check=True)
|
||||
mods = {mod["name"]: mod["enabled"] for mod in json.loads(path.read_text())["mods"]}
|
||||
|
||||
self.assertTrue(mods["base"])
|
||||
self.assertFalse(mods["recycler"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user