From b4665a0b4809c5016ffe9ed965578c3945099abe Mon Sep 17 00:00:00 2001 From: The_Spider Date: Fri, 28 Jan 2022 10:08:16 -0600 Subject: [PATCH] script needs to use variables --- build-factario-container.jenkins | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build-factario-container.jenkins b/build-factario-container.jenkins index 933e16c..2197371 100644 --- a/build-factario-container.jenkins +++ b/build-factario-container.jenkins @@ -8,37 +8,37 @@ def factorioScript = """#!/bin/sh set -e id -[ ! -d "/data/saves" ] && mkdir -p /data/saves -[ ! -d "/data/config" ] && mkdir -p /data/config -[ ! -d "/data/mods" ] && mkdir -p /data/mods -[ ! -d "/data/scenarios" ] && mkdir -p /data/scenarios -[ ! -d "/data/script-output" ] && mkdir -p /data/script-output -[ ! -f "/data/config/rconpw" ] && printf '%s' "\$(pwgen 15 1)" > /data/config/rconpw -[ ! -f "/data/config/server-settings.json" ] && cp /opt/factorio/data/server-settings.example.json /data/config/server-settings.json -[ ! -f "/data/config/map-gen-settings.json" ] && cp /opt/factorio/data/map-gen-settings.example.json /data/config/map-gen-settings.json -[ ! -f "/data/config/map-settings.json" ] && cp /opt/factorio/data/map-settings.example.json /data/config/map-settings.json +[ ! -d "\${SAVES}" ] && mkdir -p "\${SAVES}" +[ ! -d "\${CONFIG}" ] && mkdir -p "\${CONFIG}" +[ ! -d "\${MODS}" ] && mkdir -p "\${MODS}" +[ ! -d "\${SCENARIOS}" ] && mkdir -p "\${SCENARIOS}" +[ ! -d "\${SCRIPT_OUTPUT}" ] && mkdir -p "\${SCRIPT_OUTPUT}" +[ ! -f "\${CONFIG}/rconpw" ] && printf '%s' "\$(pwgen 15 1)" > "\${CONFIG}/rconpw" +[ ! -f "\${CONFIG}/server-settings.json" ] && cp /opt/factorio/data/server-settings.example.json "\${CONFIG}/server-settings.json" +[ ! -f "\${CONFIG}/map-gen-settings.json" ] && cp /opt/factorio/data/map-gen-settings.example.json "\${CONFIG}/map-gen-settings.json" +[ ! -f "\${CONFIG}/map-settings.json" ] && cp /opt/factorio/data/map-settings.example.json "\${CONFIG}/map-settings.json" -if find -L /data/saves -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then - rm -f /data/saves/*.tmp.zip +if find -L "\${SAVES}" -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then + rm -f \${SAVES}/*.tmp.zip fi -if ! find -L /data/saves -iname \\*.zip -mindepth 1 -print | grep -q .; then +if ! find -L "\${SAVES}" -iname \\*.zip -mindepth 1 -print | grep -q .; then /opt/factorio/bin/x64/factorio \\ - --create /data/saves/_autosave1.zip \\ - --map-gen-settings /data/config/map-gen-settings.json \\ - --map-settings /data/config/map-settings.json + --create "\${SAVES}/_autosave1.zip" \\ + --map-gen-settings "\${CONFIG}/map-gen-settings.json" \\ + --map-settings "\${CONFIG}/map-settings.json" fi /opt/factorio/bin/x64/factorio \\ --port \${PORT} \\ --start-server-load-latest \\ - --server-settings /data/config/server-settings.json \\ - --server-banlist /data/config/server-banlist.json \\ + --server-settings "\${CONFIG}/server-settings.json" \\ + --server-banlist "\${CONFIG}/server-banlist.json" \\ --rcon-port \${RCON_PORT} \\ - --server-whitelist /data/config/server-whitelist.json \\ + --server-whitelist "\${CONFIG}/server-whitelist.json" \\ --use-server-whitelist \\ - --server-adminlist /data/config/server-adminlist.json \\ - --rcon-password "\$(cat /data/config/rconpw)" \\ + --server-adminlist "\${CONFIG}/server-adminlist.json" \\ + --rcon-password "\$(cat "\${CONFIG}/rconpw")" \\ --server-id /factorio/config/server-id.json \\ \${@} """