Skip to content

Latest commit

 

History

History
159 lines (129 loc) · 7.52 KB

README.md

File metadata and controls

159 lines (129 loc) · 7.52 KB

This is an aid for Factorio headless server owners. It fetches update packages from factorio.com for you, so that you can then apply the update with minimal downtime.

Usage

This is a Python 3 script using minimal requirements:

To install the required dependencies, you should need do no more than run pip install -r requirements.txt. If this does not work, you are encouraged to read the linked documentation and try to figure out what's gone wrong.


From there, it's really simple: open a shell on the machine running your headless server, fetch the updater script, and run it (try it with --help first!). Here's an example session:

[narc@odin ~/src/factorio-updater]% python update_factorio.py --help
usage: update_factorio.py [-h] [-d] [-v] [-l] [-u USER] [-t TOKEN]
                          [-p PACKAGE] [-f FOR_VERSION] [-O OUTPUT_PATH]
                          [-a APPLY_TO] [-D] [-x]

Fetches Factorio update packages (e.g., for headless servers)

optional arguments:
  -h, --help            show this help message and exit
  -d, --dry-run         Don't download files, just state which updates would
                        be downloaded.
  -v, --verbose         Print URLs and stuff as they happen.
  -l, --list-packages   Print a list of valid packages (e.g., 'core-
                        linux_headless64', etc.).
  -c CREDENTIALS_FILE, --credentials-file CREDENTIALS_FILE
                        Path to server-settings.json or player-data.json, for
                        loading credentials.
  -u USER, --user USER  Your Factorio service username, from
                        server-settings.json or player-data.json.
  -t TOKEN, --token TOKEN
                        Your Factorio service token, also from
                        server-settings.json or player-data.json.
  -p PACKAGE, --package PACKAGE
                        Which Factorio package to look for updates for, e.g.,
                        'core-linux_headless64' for a 64-bit Linux headless
                        Factorio. Use '--list-packages' to fetch an updated
                        list.
  -f FOR_VERSION, --for-version FOR_VERSION
                        Which Factorio version you currently have, e.g.,
                        '0.12.2'. If empty, query the Factorio binary given in
                        '--apply-to' for its version.
  -O OUTPUT_PATH, --output-path OUTPUT_PATH
                        Where to put downloaded files.
  -a APPLY_TO, --apply-to APPLY_TO
                        Apply the updates using the chosen binary.
  -D, --delete-after-applying
                        Delete update archives after successfully applying
                        their contents. Ignored if '--apply-to' was not
                        provided.
  -x, --experimental    Download experimental versions, too (otherwise only
                        stable updates are considered).
[narc@odin ~/src/factorio-updater]% python3 update_factorio.py -xDa ~/srv/factorio/bin/x64/factorio
Auto-detected starting version as 0.15.10 from binary.
Applying update with `/home/narc/srv/factorio/bin/x64/factorio --apply-update /tmp/core-linux_headless64-0.15.10-0.15.11-update.zip`.
Update applied, deleting temporary file /tmp/core-linux_headless64-0.15.10-0.15.11-update.zip.
Applying update with `/home/narc/srv/factorio/bin/x64/factorio --apply-update /tmp/core-linux_headless64-0.15.11-0.15.12-update.zip`.
Update applied, deleting temporary file /tmp/core-linux_headless64-0.15.11-0.15.12-update.zip.
Applying update with `/home/narc/srv/factorio/bin/x64/factorio --apply-update /tmp/core-linux_headless64-0.15.12-0.15.13-update.zip`.
Update applied, deleting temporary file /tmp/core-linux_headless64-0.15.12-0.15.13-update.zip.
[narc@odin ~/src/factorio-updater]% ls /tmp/core-linux_headless64*
zsh: no matches found: /tmp/core-linux_headless64*

Service username and token

The keen-eyed will have noticed the options for --user and --token. These allow you to supply a username and token normally used by the Factorio services (like the in-game updater and authenticated multiplayer). Having them will allow you to download (and potentially apply) more updates than unauthenticated checks.

Where are they?

The username and token may be present in your server-settings.json or in a Factorio client's player-data.json. As the server owner, you would have put them into the server-settings.json in the first place, so we'll document where they live on the client:

  • The Factorio client must have been used to login to the Factorio API (e.g., to allow use of the mod portal, multiplayer, or in-game updates). The game normally asks you to do so on the first install, otherwise you may find the option in Settings -> Other.
  • You will need to find your Factorio user data directory. There are two options for this (unless you've made changes explicitly):
    • If you have the standalone download, the working directory is the same as your Factorio data. It might be something like C:\Games\Factorio, or maybe ~/Desktop/Factorio.
    • If you have the version with an installer, or the Steam version, the working directory will be in your user profile's application data area:
      • On Windows, %APPDATA%\Factorio
      • On Linux, ~/.factorio
      • On OSX, ~/Library/Application Support/factorio
  • From your user data directory, you will need the file named player-data.json. Open it with any editor capable of showing plain text files (e.g., Notepad).

You are looking for lines like these:

    "service-username": "Narc",
    "service-token": "xyz123abc456def789ghijklmnopqr"

These are the username and token you can provide.

Why provide username and token?

If you happen to have some desire to download updates for a non-headless version (not normally recommended, but sometimes needs must), you must authenticate to be able to see these updates. Here's an example session:

[narc@odin ~/src/factorio-updater]% python update_factorio.py -u Narc -t xyz123abc456def789ghijklmnopqr --list-packages
Available packages:
         core-win64
         core-mac
         core-linux_headless64
         core-win32
         core-linux32
         core-linux64
[narc@odin ~/src/factorio-updater]% mkdir update-packages
[narc@odin ~/src/factorio-updater]% python update_factorio.py -u Narc -t xyz123abc456def789ghijklmnopqr -O update-packages -p core-win64 -f 0.14.23 -x
Wrote update-packages/core-win64-0.14.23-0.15.1-update.zip, apply with `factorio --apply-update update-packages/core-win64-0.14.23-0.15.1-update.zip`
Wrote update-packages/core-win64-0.15.1-0.15.2-update.zip, apply with `factorio --apply-update update-packages/core-win64-0.15.1-0.15.2-update.zip`
[...]
Wrote update-packages/core-win64-0.15.12-0.15.13-update.zip, apply with `factorio --apply-update update-packages/core-win64-0.15.12-0.15.13-update.zip`

You can now take any Factorio Windows 64-bit, version 0.14.23 and up, and apply the updates from the update-packages directory just like the in-game updater would.

License

The source of Factorio Update Helper is Copyright 2015-2024 Octav "narc" Sandulescu. It is licensed under the MIT license, available in this package in the file LICENSE.md.

Statistics

1 API key was invalidated during the development of this script.