Skip to content

Instantly share code, notes, and snippets.

@eliask
Created April 10, 2019 08:39
Show Gist options
  • Save eliask/2b283144263b21d2e1c4b725599e686c to your computer and use it in GitHub Desktop.
Save eliask/2b283144263b21d2e1c4b725599e686c to your computer and use it in GitHub Desktop.
Simple updater for a headless Factorio server
#!/usr/bin/env bash
set -Eeuo pipefail
new_version=$(
curl -fsL https://updater.factorio.com/get-available-versions |
jq -r '."core-linux_headless64"[].to|select(.)' |
python -c'import sys;v=max(sys.stdin,key=lambda x:tuple(map(int,x.split("."))));print(v.strip())'
)
cur_version=$(cat $HOME/factorio/.cur-version || true)
if [[ $cur_version != $new_version ]]; then
cd
curl -fL "https://www.factorio.com/get-download/${new_version}/headless/linux64" | tar xpJv
echo "$new_version" > $HOME/factorio/.cur-version
kill -1 $(pgrep factorio) # Assuming the server is set up to start again after shutdown
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment