Skip to content

Commit

Permalink
Merge pull request #70 from SQLJames/bug/modencoding
Browse files Browse the repository at this point in the history
Bug/mod encoding
  • Loading branch information
SQLJames authored Nov 8, 2024
2 parents 78cf1bd + faf6032 commit bb2848e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/factorio-server-charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion charts/factorio-server-charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit bb2848e

Please sign in to comment.