From 1b6c8adf28c87efefdfd713e2c081526f2eb29ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 6 Jul 2019 16:37:13 +0200 Subject: [PATCH] Switch to test, cleanupm, formatting --- 0.17/files/docker-entrypoint.sh | 16 ++++++++-------- 0.17/files/scenario.sh | 15 +++++++-------- 0.17/files/scenario2map.sh | 14 ++++++-------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/0.17/files/docker-entrypoint.sh b/0.17/files/docker-entrypoint.sh index 6cc30a6..b69db27 100755 --- a/0.17/files/docker-entrypoint.sh +++ b/0.17/files/docker-entrypoint.sh @@ -9,26 +9,26 @@ mkdir -p "$MODS" mkdir -p "$SCENARIOS" mkdir -p "$SCRIPTOUTPUT" -if [ ! -f "$CONFIG/rconpw" ]; then +if [[ ! -f $CONFIG/rconpw ]]; then # Generate a new RCON password if none exists pwgen 15 1 >"$CONFIG/rconpw" fi -if [ ! -f "$CONFIG/server-settings.json" ]; then +if [[ ! -f $CONFIG/server-settings.json ]]; then # Copy default settings if server-settings.json doesn't exist cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" fi -if [ ! -f "$CONFIG/map-gen-settings.json" ]; then +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 +if [[ ! -f $CONFIG/map-settings.json ]]; then cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" fi NRTMPSAVES=$( find -L "$SAVES" -iname \*.tmp.zip -mindepth 1 | wc -l ) -if [ "$NRTMPSAVES" -gt 0 ]; then +if [[ $NRTMPSAVES -gt 0 ]]; then # Delete incomplete saves (such as after a forced exit) rm -f "$SAVES"/*.tmp.zip fi @@ -37,7 +37,7 @@ if [[ ${UPDATE_MODS_ON_START:-} ]]; then ./docker-update-mods.sh fi -if [ "$(id -u)" = '0' ]; then +if [[ $(id -u) = 0 ]]; then # Update the User and Group ID based on the PUID/PGID variables usermod -o -u "$PUID" factorio groupmod -o -g "$PGID" factorio @@ -49,8 +49,8 @@ else SU_EXEC="" fi -NRSAVES=$( find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l ) -if [ "$NRSAVES" -eq 0 ]; then +NRSAVES=$(find -L "$SAVES" -iname \*.zip -mindepth 1 | wc -l) +if [[ $NRSAVES -eq 0 ]]; then # Generate a new map if no save ZIPs exist $SU_EXEC /opt/factorio/bin/x64/factorio \ --create "$SAVES/_autosave1.zip" \ diff --git a/0.17/files/scenario.sh b/0.17/files/scenario.sh index b2f2abd..4ce9088 100755 --- a/0.17/files/scenario.sh +++ b/0.17/files/scenario.sh @@ -1,12 +1,11 @@ #!/bin/bash set -eoux pipefail + +if [[ -z ${1:-} ]]; then echo "No argument supplied" fi + SERVER_SCENARIO="$1" - - -id - mkdir -p "$SAVES" mkdir -p "$CONFIG" mkdir -p "$MODS" @@ -14,19 +13,19 @@ mkdir -p "$SCENARIOS" #chown -R factorio /factorio -if [ ! -f "$CONFIG/rconpw" ]; then +if [[ ! -f $CONFIG/rconpw ]]; then pwgen 15 1 >"$CONFIG/rconpw" fi -if [ ! -f "$CONFIG/server-settings.json" ]; then +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 +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 +if [[ ! -f $CONFIG/map-settings.json ]]; then cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" fi diff --git a/0.17/files/scenario2map.sh b/0.17/files/scenario2map.sh index 31d7cd4..94c4dd2 100755 --- a/0.17/files/scenario2map.sh +++ b/0.17/files/scenario2map.sh @@ -1,27 +1,25 @@ #!/bin/bash set -eoux pipefail + +if [[ -z ${1:-} ]]; then echo "No argument supplied" fi + SERVER_SCENARIO="$1" - -set -euo pipefail - -id - mkdir -p "$SAVES" mkdir -p "$CONFIG" mkdir -p "$MODS" mkdir -p "$SCENARIOS" -if [ ! -f "$CONFIG/server-settings.json" ]; then +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 +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 +if [[ ! -f $CONFIG/map-settings.json ]]; then cp /opt/factorio/data/map-settings.example.json "$CONFIG/map-settings.json" fi