fix_properly_set_ftb_properties - use existing variables thus preventing override

This commit is contained in:
Dirk Gustke 2018-01-28 14:45:25 +01:00
parent 230b575983
commit 7afa00b72c

View File

@ -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 $@