factorio-docker/smart_launch.sh

38 lines
865 B
Bash
Raw Normal View History

#!/bin/bash
if [ -f /opt/factorio/saves/save.zip ]
then
echo "###"
echo "# Using existing map [save.zip]"
echo "###"
2016-03-24 09:43:21 +01:00
echo "###"
echo "# Finding latest map"
echo "###"
2016-03-24 10:00:34 +01:00
last_save=$(ls /opt/factorio/saves -lt | grep save |head -1 |awk '{print $(NF)}')
else
echo "###"
echo "# Creating a new map [save.zip]"
echo "###"
2016-02-26 15:03:32 +01:00
/opt/factorio/bin/x64/factorio --create save.zip
2016-03-26 10:49:27 +01:00
last_save="save.zip"
echo "###"
echo "# New map created [save.zip]"
echo "###"
fi
2016-03-27 18:39:55 +02:00
# Checking options
2016-03-27 18:55:08 +02:00
if [ "$FACTORIO_DISSALOW_COMMANDS" == false ]; then
2016-03-27 18:39:55 +02:00
disallow_commands=""
else
disallow_commands="--disallow-commands"
fi
echo "###"
echo "# Launching Game"
echo "###"
2016-03-26 10:49:27 +01:00
exec /opt/factorio/bin/x64/factorio \
2016-03-27 18:39:55 +02:00
$disallow_commands \
2016-03-26 10:49:27 +01:00
--autosave-interval ${FACTORIO_AUTOSAVE_INTERVAL} \
2016-03-26 15:25:32 +01:00
--autosave-slots ${FACTORIO_AUTOSAVE_SLOTS} \
2016-03-26 18:04:55 +01:00
--start-server \
2016-03-26 15:25:32 +01:00
$last_save