Skip to content
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

Creation of Server Settings Based On Environment Variables #304

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

deefdragon
Copy link

See pull #300 for context. Created new PR to account for new branch name on my end.

@SuperSandro2000
Copy link
Member

Next time please don't merge master and rather rebase on master.

@deefdragon
Copy link
Author

I have done what testing I can at this point. Did find a few things. Unfortunately, I cant seem to get my router to stop randomizing the ports, so I cant test that you can still actually connect to a net game(though it DOES show up on the public games server). Will take a look at it again later, but I suspect that I wont be able to get very far.

@deefdragon
Copy link
Author

Did some more testing. still having issues with my firewall. I can host with the client, but not over docker. The base factorio-tools one or my changes.

I can connect to both of them over lan however, and it does work as expected. The only thing that I had to add was the new setting that they added in .18. If someone could grab it and test that they can access a public game for me that would be great. I have an 18.9 testing version pushed to my dockerhub

docker run \
--env GENERATE_SETTINGS_FILES=true \
--env GENERATE_SETTINGS_FILES_DEBUG=true \
--env FORCE_GENERATE_SETTINGS_FILES=true \
--env TEMPLATE_SERVER_NAME=testing \
--env TEMPLATE_SERVER_USERNAME=$FACTORIO_USERNAME \
--env TEMPLATE_SERVER_PASSWORD=$FACTORIO_PASSWORD \
--env TEMPLATE_SERVER_GAME_PASSWORD=test deefdragon/factorio:tagname

(ps, sorry about the merge instead of rebase. Work muscle-memory.)

@pasqualet
Copy link

pasqualet commented Feb 29, 2020

@deef0000dragon1 I've started your docker image at the following address: 188.40.151.194:34197

This is the log returned by the container:

  • FACTORIO_VOL=/factorio`
  • LOAD_LATEST_SAVE=true
  • GENERATE_NEW_SAVE=false
  • SAVE_NAME=
  • mkdir -p /factorio
  • mkdir -p /factorio/saves
  • mkdir -p /factorio/config
  • mkdir -p /factorio/mods
  • mkdir -p /factorio/scenarios
  • mkdir -p /factorio/script-output
  • [[ ! -f /factorio/config/rconpw ]]
  • pwgen 15 1
  • [[ -n true ]]
  • ./create-settings.sh
    Creating server settings file
    Setting templateServerName to testing in server-settings-template.json
    Setting templateServerGamePassword to test in server-settings-template.json
    Creating map generation settings file
    Creating map settings file
    ++ ++ wc -l
    find -L /factorio/saves -iname '*.tmp.zip' -mindepth 1
  • NRTMPSAVES=0
  • [[ 0 -gt 0 ]]
  • [[ -n '' ]]
    ++ id -u
  • [[ 0 = 0 ]]
  • usermod -o -u 845 factorio
    usermod: no changes
  • groupmod -o -g 845 factorio
  • chown -R factorio:factorio /factorio
  • SU_EXEC='su-exec factorio'
    ++ find -L /factorio/saves -iname '*.zip' -mindepth 1
    ++ wc -l
  • NRSAVES=0
  • [[ false != true ]]
  • [[ 0 == 0 ]]
  • GENERATE_NEW_SAVE=true
  • SAVE_NAME=_autosave1
  • [[ true == true ]]
  • [[ -z _autosave1 ]]
  • [[ -f /factorio/saves/_autosave1.zip ]]
  • su-exec factorio /opt/factorio/bin/x64/factorio --create /factorio/saves/_autosave1.zip --map-gen-settings /factorio/config/map-gen-settings.json --map-settings /factorio/config/map-settings.json
    0.000 2020-02-29 14:43:43; Factorio 0.18.9 (build 49691, linux64, headless)
    0.000 Operating system: Linux
    0.000 Program arguments: "/opt/factorio/bin/x64/factorio" "--create" "/factorio/saves/_autosave1.zip" "--map-gen-settings" "/factorio/config/map-gen-settings.json" "--map-settings" "/factorio/config/map-settings.json"
    0.000 Read data path: /opt/factorio/data
    0.000 Write data path: /opt/factorio [429810/479063MB]
    0.000 Binaries path: /opt/factorio/bin
    0.012 System info: [CPU: AMD Ryzen 5 3600 6-Core Processor, 2 cores, RAM: 3019 MB]
    0.012 Environment: DISPLAY= WAYLAND_DISPLAY= DESKTOP_SESSION= XDG_SESSION_DESKTOP= XDG_CURRENT_DESKTOP= __GL_FSAA_MODE= __GL_LOG_MAX_ANISO= __GL_SYNC_TO_VBLANK= __GL_SORT_FBCONFIGS= __GL_YIELD=
    0.012 Running in headless mode
    0.025 Loading mod core 0.0.0 (data.lua)
    0.108 Loading mod base 0.18.9 (data.lua)
    0.539 Loading mod base 0.18.9 (data-updates.lua)
    0.740 Checksum for core: 3416661365
    0.740 Checksum of base: 3591523921
    1.051 Prototype list checksum: 1010569779
    1.143 Info PlayerData.cpp:70: Local player-data.json unavailable
    1.143 Info PlayerData.cpp:75: Cloud player-data.json unavailable
    1.172 Factorio initialised
    1.173 Info Main.cpp:683: Creating new map /factorio/saves/_autosave1.zip

then
mv "$CONFIG/map-gen-settings.json" "$CONFIG/map-gen-settings.json.$(date +%Y.%m.%d.%H.%M.%S)"
fi

if [[ ! -f $CONFIG/map-settings.json ]]
if [[ -f $CONFIG/map-settings.json ]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those changes are a mistake.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basing off of https://linuxize.com/post/bash-check-if-file-exists/ and that i was getting errors when I had it the other way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it should error but right now it checks if the file does exist and then copies the default file but we want to do it when the file does not exist.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the section that backs up an existing settings file (if you force the update of the settings via FORCE_GENERATE_SETTINGS_FILES). As such, if the file exists, we want to back it up. Lines 278-295 are the ones that you might be confusing these with. those are the ones that only move the generated settings file in if a file does not already exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants