Skip to content

Instantly share code, notes, and snippets.

@cdgriffith
Created June 12, 2016 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdgriffith/6a6037e13690b1d6bf95f95514be5b81 to your computer and use it in GitHub Desktop.
Save cdgriffith/6a6037e13690b1d6bf95f95514be5b81 to your computer and use it in GitHub Desktop.
Factorio setup
cd /opt
sudo wget https://www.factorio.com/get-download/0.12.35/headless/linux64
sudo tar xzf linux64
sudo groupadd factorio
sudo useradd -g factorio factorio
sudo passwd factorio
sudo chown -R factorio:factorio factorio/
sudo mkdir factorio_data
sudo git clone https://github.com/Bisa/factorio-init.git
sudo chown -R factorio:factorio factorio-init/
sudo ln -s /opt/factorio-init/factorio /etc/init.d/factorio
sudo chmod +x /opt/factorio-init/factorio
sudo git clone https://github.com/narc0tiq/factorio-updater
echo "Update factorio-init config"
echo "#!/bin/bash
# Enable debugging, useful when you want to figure out why
# this script is not behaving the way you expect it to do
DEBUG=0
# What do you want to call this service?
SERVICE_NAME=\"Factorio\"
# Which user/group is running factorio?
# Running any public service as root is generally not recommended
USERNAME=factorio
USERGROUP=factorio
# The absolute path to the factorio directory
FACTORIO_PATH=/opt/factorio
# The absolute path to the factorio binary
BINARY=${FACTORIO_PATH}/bin/x64/factorio
# Absolute path to factorios config.ini
FCONF=${FACTORIO_PATH}/config/config.ini
# Port on which you want to run the server
PORT=6789
# The latency expected between peers (milliseconds)
# Try to set this to the highest latency + 30
# If Peer A and B have a latency of 100 between each other
# set this to 130
LATENCY=250
# The number of minutes between each autosave
AUTOSAVE_INTERVAL=10
# The number of autosaves to use for rotation
AUTOSAVE_SLOTS=3
# Factorio comes packaged in a tarball containing the directory named factorio
# when using this scripts update/install command we expect to see this very
# directory. If you want to supply your own update/install tar other than what you can download
# from factorio.com/downloads you can use this option to tell the script this is ok.
#
# If you place your factorio install within a directory named "factorio" and you update/install
# with the official tarball you can safely ignore this option.
PACKAGE_DIR_NAME=factorio
#
# narcotiq made a sweet update script for factorio and by cloning into this
# you can simply run "factorio update" provided you configure the below arguments
# To install the updater:
#
# git clone https://github.com/narc0tiq/factorio-updater
#
# absolute path to the factorio-updater script
UPDATE_SCRIPT=/opt/factorio-updater/update_factorio.py
# Note that if you set HEADLESS=1 the username/token will not be used as the headless
# download is provided free of charge
HEADLESS=1
UPDATE_EXPERIMENTAL=0
UPDATE_TMPDIR=/tmp
# Extras
# Additional binary arguments, these will be sent to the binary when issuing the start command
EXTRA_BINARGS=\"--disallow-commands\"
#
# Refrain from changing the variables below, they are used internally by the script and should
# not be altered unless you know what you are doing
#
SAVE_NAME=factorio-init-save
INVOCATION=\"${BINARY} --config ${FCONF} --port ${PORT} --start-server ${SAVE_NAME} --autosave-interval ${AUTOSAVE_INTERVAL} --autosave-slots ${AUTOSAVE_SLOTS} --latency-ms ${LATENCY} ${EXTRA_BINARGS}\"
" > factorio-init/config
sudo -u factorio /opt/factorio/bin/x64/factorio --create factorio-init-save
# sudo -u factorio /opt/factorio/bin/x64/factorio --start-server factorio-init-save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment