Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Created November 12, 2016 19:57
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 kalisjoshua/c89c60cb093cfb07af2320599f2a7c53 to your computer and use it in GitHub Desktop.
Save kalisjoshua/c89c60cb093cfb07af2320599f2a7c53 to your computer and use it in GitHub Desktop.
#! /bin/bash
ROOT=/opt/fact
FACTORIO="$ROOT/factorio/bin/x64/factorio"
VERSION=$($FACTORIO --version | xargs echo | cut -d ' ' -f 2)
if [ "$1" = "start" ]; then
echo 'starting server'
# echo $$ > $ROOT/factorio.pid
# exec $ROOT/factorio/bin/x64/factorio \
# --start-server $ROOT/saves/megabase.zip \
# --server-settings $ROOT/factorio/config/server-settings.json
elif [ "$1" = "stop" ]; then
echo 'stopping server'
# kill -s INT $(cat $ROOT/factorio.pid)
# rm -f $ROOT/factorio.pid
elif [ "$1" = "update" ]; then
if [ -n "$2" ]; then
echo 'updating server'
cp $ROOT/saves/megabase.zip $ROOT/saves/megabase-$VERSION.zip
URL="https://www.factorio.com/get-download/$2/headless/linux64"
# get the desired version
cd $ROOT/releases
wget --content-disposition $URL
# unpack tarball
cd $ROOT
tar -zxvf releases/factorio_headless_x64_$2.tar.gz
else
echo 'no version provided to upgrade to'
fi
else
echo 'no admin action provided'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment