2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# FUNCTIONS
|
|
|
|
function setServerProp {
|
|
|
|
local prop=$1
|
|
|
|
local var=$2
|
|
|
|
if [ -n "$var" ]; then
|
2018-01-28 13:45:25 +00:00
|
|
|
echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
|
|
|
|
sed -i "/^${prop}\s*=/ c ${prop}=${var}" $SERVER_PROPERTIES
|
2018-01-28 12:16:45 +00:00
|
|
|
else
|
|
|
|
echo "Skip setting ${prop}"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Deploy server.properties file
|
2018-01-28 13:48:50 +00:00
|
|
|
if [ ! -e $SERVER_PROPERTIES ]; then
|
2018-01-28 13:45:25 +00:00
|
|
|
echo "Creating server.properties in ${SERVER_PROPERTIES}"
|
|
|
|
cp /tmp/server.properties $SERVER_PROPERTIES
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2018-01-28 13:45:25 +00:00
|
|
|
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
|
2018-01-28 12:16:45 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
if [ -n "$WHITELIST" ]; then
|
|
|
|
echo "Creating whitelist"
|
2018-01-28 12:16:45 +00:00
|
|
|
setServerProp "whitelist" "true"
|
|
|
|
setServerProp "white-list" "true"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-12 16:26:44 +00:00
|
|
|
setServerProp "server-port" "$SERVER_PORT"
|
2017-11-01 05:42:44 +00:00
|
|
|
setServerProp "motd" "$MOTD"
|
|
|
|
setServerProp "allow-nether" "$ALLOW_NETHER"
|
|
|
|
setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS"
|
|
|
|
setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK"
|
|
|
|
setServerProp "spawn-animals" "$SPAWN_ANIMALS"
|
|
|
|
setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
|
|
|
|
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
|
|
|
setServerProp "generate-structures" "$GENERATE_STRUCTURES"
|
|
|
|
setServerProp "view-distance" "$VIEW_DISTANCE"
|
|
|
|
setServerProp "hardcore" "$HARDCORE"
|
|
|
|
setServerProp "max-build-height" "$MAX_BUILD_HEIGHT"
|
|
|
|
setServerProp "force-gamemode" "$FORCE_GAMEMODE"
|
|
|
|
setServerProp "hardmax-tick-timecore" "$MAX_TICK_TIME"
|
|
|
|
setServerProp "enable-query" "$ENABLE_QUERY"
|
|
|
|
setServerProp "query.port" "$QUERY_PORT"
|
|
|
|
setServerProp "enable-rcon" "$ENABLE_RCON"
|
|
|
|
setServerProp "rcon.password" "$RCON_PASSWORD"
|
|
|
|
setServerProp "rcon.port" "$RCON_PORT"
|
|
|
|
setServerProp "max-players" "$MAX_PLAYERS"
|
|
|
|
setServerProp "max-world-size" "$MAX_WORLD_SIZE"
|
|
|
|
setServerProp "level-name" "$LEVEL"
|
|
|
|
setServerProp "level-seed" "$SEED"
|
|
|
|
setServerProp "pvp" "$PVP"
|
|
|
|
setServerProp "generator-settings" "$GENERATOR_SETTINGS"
|
|
|
|
setServerProp "online-mode" "$ONLINE_MODE"
|
|
|
|
|
|
|
|
if [ -n "$LEVEL_TYPE" ]; then
|
|
|
|
# normalize to uppercase
|
|
|
|
LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
|
|
|
|
echo "Setting level type to $LEVEL_TYPE"
|
|
|
|
# check for valid values and only then set
|
|
|
|
case $LEVEL_TYPE in
|
|
|
|
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED|BIOMESOP|RTG)
|
2018-01-28 12:16:45 +00:00
|
|
|
setServerProp "level-type" "$LEVEL_TYPE"
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid LEVEL_TYPE: $LEVEL_TYPE"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$DIFFICULTY" ]; then
|
|
|
|
case $DIFFICULTY in
|
|
|
|
peaceful|0)
|
|
|
|
DIFFICULTY=0
|
|
|
|
;;
|
|
|
|
easy|1)
|
|
|
|
DIFFICULTY=1
|
|
|
|
;;
|
|
|
|
normal|2)
|
|
|
|
DIFFICULTY=2
|
|
|
|
;;
|
|
|
|
hard|3)
|
|
|
|
DIFFICULTY=3
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "DIFFICULTY must be peaceful, easy, normal, or hard."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2018-01-28 12:16:45 +00:00
|
|
|
setServerProp "difficulty" "$DIFFICULTY"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$MODE" ]; then
|
|
|
|
echo "Setting mode"
|
|
|
|
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
|
|
|
case $MODE_LC in
|
|
|
|
0|1|2|3)
|
|
|
|
;;
|
|
|
|
su*)
|
|
|
|
MODE=0
|
|
|
|
;;
|
|
|
|
c*)
|
|
|
|
MODE=1
|
|
|
|
;;
|
|
|
|
a*)
|
|
|
|
MODE=2
|
|
|
|
;;
|
|
|
|
sp*)
|
|
|
|
MODE=3
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: Invalid game mode: $MODE"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2018-01-28 13:45:25 +00:00
|
|
|
setServerProp "gamemode" "$MODE"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
2018-01-28 13:45:25 +00:00
|
|
|
else
|
|
|
|
echo "server.properties already created, skipping"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec /start-minecraftFinalSetup $@
|