Created
November 12, 2016 19:57
-
-
Save kalisjoshua/c89c60cb093cfb07af2320599f2a7c53 to your computer and use it in GitHub Desktop.
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
#! /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