Skip to content

Commit bb2848e

Browse files
authored
Merge pull request #70 from SQLJames/bug/modencoding
Bug/mod encoding
2 parents 78cf1bd + faf6032 commit bb2848e

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22

3+
### V2.4.1
4+
5+
#### Non-Breaking Changes
6+
- Fixing mod download script to encode spaces properly, fixes [Issue 42](https://github.com/SQLJames/factorio-server-charts/issues/42)
7+
- Adding update mod check on mod script to avoid it always updating mods, fixes part of[Issue 45](https://github.com/SQLJames/factorio-server-charts/issues/45)
8+
39
### V2.4.0
410

511
#### Potentially Breaking Changes

charts/factorio-server-charts/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sources:
2020
# This is the chart version. This version number should be incremented each time you make changes
2121
# to the chart and its templates, including the app version.
2222
# Versions are expected to follow Semantic Versioning (https://semver.org/)
23-
version: 2.4.0
23+
version: 2.4.1
2424

2525
# This is the version number of the application being deployed. This version number should be
2626
# incremented each time you make changes to the application. Versions are not expected to

charts/factorio-server-charts/templates/deployment.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ spec:
8686
imagePullPolicy: {{ .Values.image.pullPolicy }}
8787
command:
8888
- /bin/bash
89-
- -ec
89+
- -ecx
9090
- |
9191
mkdir -p /factorio/mods
92+
ls -alth /scripts
93+
echo "Running mod-downloader.sh script..."
9294
bash /scripts/mod-downloader.sh
95+
echo "Finished mod-downloader.sh script"
96+
ls -althR /factorio/mods
9397
{{- with .Values.podSecurityContext }}
9498
securityContext:
9599
{{- toYaml . | nindent 12 }}
96100
{{- end }}
101+
env:
102+
- name: UPDATE_MODS_ON_START
103+
value: {{ .Values.factorioServer.update_mods_on_start | quote }}
97104
volumeMounts:
98105
- name: datadir
99106
mountPath: /factorio

charts/factorio-server-charts/templates/mod-downloader-configmap.yaml

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ data:
1111
# credit to the factoriotools/factorio-docker team, most of this logic came from them
1212
# https://github.com/factoriotools/factorio-docker/blob/master/docker/files/update-mods.sh
1313
mod-downloader.sh: |
14+
FLAG_FILE="/factorio/mods/.mod_update_complete"
15+
16+
# Check if flag file exists and UPDATE_MODS_ON_START is not true
17+
if [[ -f "$FLAG_FILE" && "${UPDATE_MODS_ON_START}" != "true" ]]; then
18+
echo "Mod update already completed previously. Skipping."
19+
exit 0
20+
fi
1421
modDir=/factorio/mods
1522
MOD_BASE_URL="https://mods.factorio.com"
1623
declare -a officialMods
@@ -39,6 +46,8 @@ data:
3946
cd $modDir;curl -L -o $2 $1
4047
}
4148
function downloadofficial() {
49+
MOD_NAME="$1"
50+
MOD_NAME_ENCODED="${1// /%20}"
4251
if [[ -z ${USERNAME:-} ]]; then
4352
USERNAME="$(cat /account/username)"
4453
fi
@@ -54,7 +63,7 @@ data:
5463
if [[ -z ${TOKEN:-} ]]; then
5564
echo "You need to provide your Factorio token to update mods."
5665
fi
57-
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$1"
66+
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME_ENCODED"
5867
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL")
5968
# echo "$MOD_INFO_URL $MOD_INFO_JSON"
6069
if ! echo "$MOD_INFO_JSON" | jq -e .name >/dev/null; then
@@ -107,7 +116,9 @@ data:
107116
done
108117
fi
109118
fi
110-
119+
# Mark the update as complete by creating the flag file
120+
touch "$FLAG_FILE"
121+
echo "Mod update completed."
111122
112123
113124

0 commit comments

Comments
 (0)