From 230b57598304d3c9662f4214c637320b44e361f0 Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 13:16:45 +0100 Subject: [PATCH] fix_properly_set_ftb_properties - use a unified setter, set the correct file --- .../start-finalSetup04ServerProperties | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/minecraft-server/start-finalSetup04ServerProperties b/minecraft-server/start-finalSetup04ServerProperties index bd946e2f..b19320a2 100755 --- a/minecraft-server/start-finalSetup04ServerProperties +++ b/minecraft-server/start-finalSetup04ServerProperties @@ -1,24 +1,33 @@ #!/bin/bash +PROPERTIES_PATH=/data/server.properties + # FUNCTIONS function setServerProp { local prop=$1 local var=$2 if [ -n "$var" ]; then - echo "Setting $prop to $var" - sed -i "/$prop\s*=/ c $prop=$var" /data/server.properties + echo "Setting ${prop} to '${var}' in ${PROPERTIES_PATH}" + sed -i "/^$prop\s*=/ c $prop=$var" $PROPERTIES_PATH + else + echo "Skip setting ${prop}" fi } # Deploy server.properties file -if [ ! -e server.properties ]; then +if [ ! -e $PROPERTIES_PATH ]; then echo "Creating server.properties" cp /tmp/server.properties . + if [[ ! -z ${FTB_DIR} ]]; then + PROPERTIES_PATH=${FTB_DIR}/server.properties + cp /tmp/server.properties $PROPERTIES_PATH + fi + if [ -n "$WHITELIST" ]; then echo "Creating whitelist" - sed -i "/whitelist\s*=/ c whitelist=true" /data/server.properties - sed -i "/white-list\s*=/ c white-list=true" /data/server.properties + setServerProp "whitelist" "true" + setServerProp "white-list" "true" fi setServerProp "motd" "$MOTD" @@ -54,7 +63,7 @@ if [ ! -e server.properties ]; then # check for valid values and only then set case $LEVEL_TYPE in DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED|BIOMESOP|RTG) - sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties + setServerProp "level-type" "$LEVEL_TYPE" ;; *) echo "Invalid LEVEL_TYPE: $LEVEL_TYPE" @@ -82,8 +91,7 @@ if [ ! -e server.properties ]; then exit 1 ;; esac - echo "Setting difficulty to $DIFFICULTY" - sed -i "/difficulty\s*=/ c difficulty=$DIFFICULTY" /data/server.properties + setServerProp "difficulty" "$DIFFICULTY" fi if [ -n "$MODE" ]; then