Skip to content

Instantly share code, notes, and snippets.

@siasur
Last active August 22, 2019 18:57
Show Gist options
  • Save siasur/5df4c4722b79bf5249c468caba256bb3 to your computer and use it in GitHub Desktop.
Save siasur/5df4c4722b79bf5249c468caba256bb3 to your computer and use it in GitHub Desktop.
Factorio Server stuff
#!/bin/bash
if [ -f .factorio-lock ]; then
echo "Factorio Server is already running."
exit 1
else
touch .factorio-lock
fi
screen -Dm -S factorio ./watchdog & echo $! > .factorio-lock
echo "Starting the server."
#!/bin/bash
if [ ! -f .factorio-lock ]; then
echo "Factorio Server is not running."
exit 0
fi
pid=$(cat .factorio-lock)
rm .factorio-lock
screen -S factorio -p 0 -X stuff "^C"
while (screen -ls | grep $pid > /dev/null); do : ; done;
echo "Factorio Server stopped."
#!/bin/bash
python update_factorio.py --apply-to factorio/bin/x64/factorio -x -D
chmod +x factorio/bin/x64/factorio
echo "Update finished."
#!/bin/bash
while [ -f .factorio-lock ]; do
cd factorio
./bin/x64/factorio --start-server-load-latest --server-settings ./data/server-settings.json
cd ..
# Uncomment when using a telegram bot for crash notification
# if [ -f .factorio-lock ]; then
# curl --header "Content-Type: application/json" --request POST --data '{"chat_id":"<INSERT CHAT ID>","text":"<INSERT MESSAGE TEXT>"}' https://api.telegram.org/bot<INSERT BOT TOKEN>/sendMessage
# fi
done
@siasur
Copy link
Author

siasur commented Aug 22, 2019

I just added the missing update.sh file. This script just calls narc0tiqs factorio-updater and sets the perms on the factorio executable again after the finished update

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