factorio-docker/0.14/docker-entrypoint.sh

36 lines
873 B
Bash
Raw Normal View History

2016-11-01 20:31:24 +00:00
#!/bin/sh -x
2016-10-26 23:15:09 +00:00
set -e
2016-11-01 20:31:24 +00:00
SAVES=/factorio/saves
CONFIG=/factorio/config
2016-10-25 16:49:23 +00:00
2016-11-01 20:31:24 +00:00
mkdir -p $SAVES
2016-10-26 23:15:09 +00:00
mkdir -p /factorio/mods
2016-11-01 20:31:24 +00:00
mkdir -p $CONFIG
2016-10-26 23:15:09 +00:00
2016-11-01 20:31:24 +00:00
if [ ! -f $CONFIG/rconpw ]; then
echo $(pwgen 15 1) > $CONFIG/rconpw
2016-10-31 19:59:57 +00:00
fi
2016-11-01 20:31:24 +00:00
if [ ! -f $CONFIG/server-settings.json ]; then
cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json
2016-10-26 23:15:09 +00:00
fi
2016-11-01 20:31:24 +00:00
if [ ! -f $CONFIG/map-gen-settings.json ]; then
cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json
2016-10-26 23:15:09 +00:00
fi
2016-10-27 00:08:21 +00:00
if ! find -L $SAVES -iname \*.zip -mindepth 1 -print | grep -q .; then
2016-10-25 21:57:49 -07:00
/opt/factorio/bin/x64/factorio \
2016-10-31 20:27:11 +00:00
--create $SAVES/_autosave1.zip \
2016-11-01 20:31:24 +00:00
--map-gen-settings $CONFIG/map-gen-settings.json
fi
2016-10-25 21:57:49 -07:00
exec /opt/factorio/bin/x64/factorio \
2016-10-26 17:46:34 +00:00
--port 34197 \
2016-10-25 21:57:49 -07:00
--start-server-load-latest \
2016-11-01 20:31:24 +00:00
--server-settings $CONFIG/server-settings.json \
2016-10-31 19:59:57 +00:00
--rcon-port 27015 \
2016-11-01 20:31:24 +00:00
--rcon-password "$(cat $CONFIG/rconpw)"