From 86169c9dad174319f003f4a04132d7299aeaf3f4 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Tue, 26 Feb 2019 11:11:21 -0800 Subject: [PATCH] add files to 0.17 --- 0.17/docker-compose.yml | 9 +++++++ 0.17/files/docker-entrypoint.sh | 48 +++++++++++++++++++++++++++++++++ 0.17/files/scenario.sh | 44 ++++++++++++++++++++++++++++++ 0.17/files/scenario2map.sh | 30 +++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 0.17/docker-compose.yml create mode 100644 0.17/files/docker-entrypoint.sh create mode 100644 0.17/files/scenario.sh create mode 100644 0.17/files/scenario2map.sh diff --git a/0.17/docker-compose.yml b/0.17/docker-compose.yml new file mode 100644 index 0000000..1cfb5ff --- /dev/null +++ b/0.17/docker-compose.yml @@ -0,0 +1,9 @@ +version: '2' +services: + factorio: + build: . + ports: + - "34197:34197/udp" + - "27015:27015/tcp" + volumes: + - /opt/factorio:/factorio diff --git a/0.17/files/docker-entrypoint.sh b/0.17/files/docker-entrypoint.sh new file mode 100644 index 0000000..3aee1b8 --- /dev/null +++ b/0.17/files/docker-entrypoint.sh @@ -0,0 +1,48 @@ +#!/bin/sh -x +set -e + +id + +mkdir -p $SAVES +mkdir -p $CONFIG +mkdir -p $MODS +mkdir -p $SCENARIOS +mkdir -p $SCRIPTOUTPUT + +if [ ! -f $CONFIG/rconpw ]; then + echo $(pwgen 15 1) > $CONFIG/rconpw +fi + +if [ ! -f $CONFIG/server-settings.json ]; then + cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json +fi + +if [ ! -f $CONFIG/map-gen-settings.json ]; then + cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json +fi + +if [ ! -f $CONFIG/map-settings.json ]; then + cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json +fi + +if find -L $SAVES -iname \*.tmp.zip -mindepth 1 -print | grep -q .; then + rm -f $SAVES/*.tmp.zip +fi + +if ! find -L $SAVES -iname \*.zip -mindepth 1 -print | grep -q .; then + /opt/factorio/bin/x64/factorio \ + --create $SAVES/_autosave1.zip \ + --map-gen-settings $CONFIG/map-gen-settings.json \ + --map-settings $CONFIG/map-settings.json +fi + +exec /opt/factorio/bin/x64/factorio \ + --port $PORT \ + --start-server-load-latest \ + --server-settings $CONFIG/server-settings.json \ + --server-whitelist $CONFIG/server-whitelist.json \ + --server-banlist $CONFIG/server-banlist.json \ + --rcon-port $RCON_PORT \ + --rcon-password "$(cat $CONFIG/rconpw)" \ + --server-id /factorio/config/server-id.json \ + $@ diff --git a/0.17/files/scenario.sh b/0.17/files/scenario.sh new file mode 100644 index 0000000..588e51c --- /dev/null +++ b/0.17/files/scenario.sh @@ -0,0 +1,44 @@ +#!/bin/sh -x +if [ -z "$1" ] + then + echo "No argument supplied" +fi +SCENARIO=$1 + +set -e + +id + +mkdir -p $SAVES +mkdir -p $CONFIG +mkdir -p $MODS +mkdir -p $SCENARIOS + +#chown -R factorio /factorio + +if [ ! -f $CONFIG/rconpw ]; then + echo $(pwgen 15 1) > $CONFIG/rconpw +fi + +if [ ! -f $CONFIG/server-settings.json ]; then + cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json +fi + +if [ ! -f $CONFIG/map-gen-settings.json ]; then + cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json +fi + +if [ ! -f $CONFIG/map-settings.json ]; then + cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json +fi + + +exec /opt/factorio/bin/x64/factorio \ + --port $PORT \ + --start-server-load-scenario $SCENARIO \ + --server-settings $CONFIG/server-settings.json \ + --server-whitelist $CONFIG/server-whitelist.json \ + --server-banlist $CONFIG/server-banlist.json \ + --rcon-port $RCON_PORT \ + --rcon-password "$(cat $CONFIG/rconpw)" \ + --server-id /factorio/config/server-id.json diff --git a/0.17/files/scenario2map.sh b/0.17/files/scenario2map.sh new file mode 100644 index 0000000..f95d08d --- /dev/null +++ b/0.17/files/scenario2map.sh @@ -0,0 +1,30 @@ +#!/bin/sh -x +if [ -z "$1" ] + then + echo "No argument supplied" +fi +SCENARIO=$1 + +set -e + +id + +mkdir -p $SAVES +mkdir -p $CONFIG +mkdir -p $MODS +mkdir -p $SCENARIOS + +if [ ! -f $CONFIG/server-settings.json ]; then + cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json +fi + +if [ ! -f $CONFIG/map-gen-settings.json ]; then + cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json +fi + +if [ ! -f $CONFIG/map-settings.json ]; then + cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json +fi + +exec /opt/factorio/bin/x64/factorio \ + --scenario2map $SCENARIO