diff --git a/CHANGELOG.md b/CHANGELOG.md index c79b4de..e2ad489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog +### V2.4.1 + +#### Non-Breaking Changes +- Fixing mod download script to encode spaces properly, fixes [Issue 42](https://github.com/SQLJames/factorio-server-charts/issues/42) +- 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) + ### V2.4.0 #### Potentially Breaking Changes diff --git a/charts/factorio-server-charts/Chart.yaml b/charts/factorio-server-charts/Chart.yaml index 49d253b..9e94ad1 100644 --- a/charts/factorio-server-charts/Chart.yaml +++ b/charts/factorio-server-charts/Chart.yaml @@ -20,7 +20,7 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.4.0 +version: 2.4.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/factorio-server-charts/templates/deployment.yaml b/charts/factorio-server-charts/templates/deployment.yaml index 364e009..f4cc415 100644 --- a/charts/factorio-server-charts/templates/deployment.yaml +++ b/charts/factorio-server-charts/templates/deployment.yaml @@ -86,14 +86,21 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} command: - /bin/bash - - -ec + - -ecx - | mkdir -p /factorio/mods + ls -alth /scripts + echo "Running mod-downloader.sh script..." bash /scripts/mod-downloader.sh + echo "Finished mod-downloader.sh script" + ls -althR /factorio/mods {{- with .Values.podSecurityContext }} securityContext: {{- toYaml . | nindent 12 }} {{- end }} + env: + - name: UPDATE_MODS_ON_START + value: {{ .Values.factorioServer.update_mods_on_start | quote }} volumeMounts: - name: datadir mountPath: /factorio diff --git a/charts/factorio-server-charts/templates/mod-downloader-configmap.yaml b/charts/factorio-server-charts/templates/mod-downloader-configmap.yaml index 57a3d96..3efe95f 100644 --- a/charts/factorio-server-charts/templates/mod-downloader-configmap.yaml +++ b/charts/factorio-server-charts/templates/mod-downloader-configmap.yaml @@ -11,6 +11,13 @@ data: # credit to the factoriotools/factorio-docker team, most of this logic came from them # https://github.com/factoriotools/factorio-docker/blob/master/docker/files/update-mods.sh mod-downloader.sh: | + FLAG_FILE="/factorio/mods/.mod_update_complete" + + # Check if flag file exists and UPDATE_MODS_ON_START is not true + if [[ -f "$FLAG_FILE" && "${UPDATE_MODS_ON_START}" != "true" ]]; then + echo "Mod update already completed previously. Skipping." + exit 0 + fi modDir=/factorio/mods MOD_BASE_URL="https://mods.factorio.com" declare -a officialMods @@ -39,6 +46,8 @@ data: cd $modDir;curl -L -o $2 $1 } function downloadofficial() { + MOD_NAME="$1" + MOD_NAME_ENCODED="${1// /%20}" if [[ -z ${USERNAME:-} ]]; then USERNAME="$(cat /account/username)" fi @@ -54,7 +63,7 @@ data: if [[ -z ${TOKEN:-} ]]; then echo "You need to provide your Factorio token to update mods." fi - MOD_INFO_URL="$MOD_BASE_URL/api/mods/$1" + MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME_ENCODED" MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL") # echo "$MOD_INFO_URL $MOD_INFO_JSON" if ! echo "$MOD_INFO_JSON" | jq -e .name >/dev/null; then @@ -107,7 +116,9 @@ data: done fi fi - + # Mark the update as complete by creating the flag file + touch "$FLAG_FILE" + echo "Mod update completed."