From 2f3e93c6192e646f6b561eadd09e76709f595ef7 Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 13:15:41 +0100 Subject: [PATCH 1/5] fix_properly_set_ftb_properties - revert disfunctional change --- minecraft-server/start-deployFTB | 1 - 1 file changed, 1 deletion(-) diff --git a/minecraft-server/start-deployFTB b/minecraft-server/start-deployFTB index 00fb5e82..1ce4cbd6 100755 --- a/minecraft-server/start-deployFTB +++ b/minecraft-server/start-deployFTB @@ -53,7 +53,6 @@ if [ ! -d ${FTB_DIR} ]; then mkdir -p ${FTB_DIR} unzip -o ${srv_modpack} -d ${FTB_DIR} | awk '{printf "."} END {print ""}' cp -f /data/eula.txt ${FTB_DIR}/eula.txt - ln -snf /data/server.properties ${FTB_DIR}/server.properties fi export FTB_SERVER_START=${FTB_DIR}/ServerStart.sh chmod a+x ${FTB_SERVER_START} From 230b57598304d3c9662f4214c637320b44e361f0 Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 13:16:45 +0100 Subject: [PATCH 2/5] 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 From 7afa00b72c01c93b373e10742c66257f2084287d Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 14:45:25 +0100 Subject: [PATCH 3/5] fix_properly_set_ftb_properties - use existing variables thus preventing override --- .../start-finalSetup04ServerProperties | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/minecraft-server/start-finalSetup04ServerProperties b/minecraft-server/start-finalSetup04ServerProperties index b19320a2..a75d9a0a 100755 --- a/minecraft-server/start-finalSetup04ServerProperties +++ b/minecraft-server/start-finalSetup04ServerProperties @@ -1,14 +1,12 @@ #!/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}' in ${PROPERTIES_PATH}" - sed -i "/^$prop\s*=/ c $prop=$var" $PROPERTIES_PATH + echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" + sed -i "/^${prop}\s*=/ c ${prop}=${var}" $SERVER_PROPERTIES else echo "Skip setting ${prop}" fi @@ -16,12 +14,15 @@ function setServerProp { # Deploy server.properties file if [ ! -e $PROPERTIES_PATH ]; then - echo "Creating server.properties" - cp /tmp/server.properties . + echo "Creating server.properties in ${SERVER_PROPERTIES}" + cp /tmp/server.properties $SERVER_PROPERTIES - if [[ ! -z ${FTB_DIR} ]]; then - PROPERTIES_PATH=${FTB_DIR}/server.properties - cp /tmp/server.properties $PROPERTIES_PATH + if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then + export SERVER_PROPERTIES=${FTB_DIR}/server.properties + echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}" + cp /tmp/server.properties $SERVER_PROPERTIES + else + echo "TYPE=${TYPE}" fi if [ -n "$WHITELIST" ]; then @@ -117,9 +118,10 @@ if [ ! -e $PROPERTIES_PATH ]; then exit 1 ;; esac - - sed -i "/^gamemode\s*=/ c gamemode=$MODE" $SERVER_PROPERTIES + setServerProp "gamemode" "$MODE" fi +else + echo "server.properties already created, skipping" fi exec /start-minecraftFinalSetup $@ From ce4b4ad2088e479633a324c150b94fcacf7e9675 Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 14:48:50 +0100 Subject: [PATCH 4/5] fix_properly_set_ftb_properties - use correct variable --- minecraft-server/start-finalSetup04ServerProperties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minecraft-server/start-finalSetup04ServerProperties b/minecraft-server/start-finalSetup04ServerProperties index a75d9a0a..b1f83539 100755 --- a/minecraft-server/start-finalSetup04ServerProperties +++ b/minecraft-server/start-finalSetup04ServerProperties @@ -13,7 +13,7 @@ function setServerProp { } # Deploy server.properties file -if [ ! -e $PROPERTIES_PATH ]; then +if [ ! -e $SERVER_PROPERTIES ]; then echo "Creating server.properties in ${SERVER_PROPERTIES}" cp /tmp/server.properties $SERVER_PROPERTIES From dc3c93becf04a7063289a4f2ef3409a3d8ac67c7 Mon Sep 17 00:00:00 2001 From: Dirk Gustke Date: Sun, 28 Jan 2018 14:50:08 +0100 Subject: [PATCH 5/5] fix_properly_set_ftb_properties - remove debugging information --- minecraft-server/start-finalSetup04ServerProperties | 2 -- 1 file changed, 2 deletions(-) diff --git a/minecraft-server/start-finalSetup04ServerProperties b/minecraft-server/start-finalSetup04ServerProperties index b1f83539..613a753f 100755 --- a/minecraft-server/start-finalSetup04ServerProperties +++ b/minecraft-server/start-finalSetup04ServerProperties @@ -21,8 +21,6 @@ if [ ! -e $SERVER_PROPERTIES ]; then export SERVER_PROPERTIES=${FTB_DIR}/server.properties echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}" cp /tmp/server.properties $SERVER_PROPERTIES - else - echo "TYPE=${TYPE}" fi if [ -n "$WHITELIST" ]; then