Skip to content

Bug/mod encoding #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading