Created
April 10, 2019 08:39
-
-
Save eliask/2b283144263b21d2e1c4b725599e686c to your computer and use it in GitHub Desktop.
Simple updater for a headless Factorio server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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