2015-01-01 15:10:41 +00:00
|
|
|
#!/bin/bash
|
2014-11-01 20:20:52 +00:00
|
|
|
|
2016-04-16 16:26:13 +00:00
|
|
|
#umask 002
|
|
|
|
export HOME=/data
|
2016-01-29 19:50:53 +00:00
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ ! -e /data/eula.txt ]; then
|
|
|
|
if [ "$EULA" != "" ]; then
|
|
|
|
echo "# Generated via Docker on $(date)" > eula.txt
|
|
|
|
echo "eula=$EULA" >> eula.txt
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
echo "Please accept the Minecraft EULA at"
|
|
|
|
echo " https://account.mojang.com/documents/minecraft_eula"
|
|
|
|
echo "by adding the following immediately after 'docker run':"
|
|
|
|
echo " -e EULA=TRUE"
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-06-11 23:42:33 +00:00
|
|
|
VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
|
|
|
|
|
2015-03-05 01:15:36 +00:00
|
|
|
echo "Checking version information."
|
2015-12-22 06:47:42 +00:00
|
|
|
case "X$VERSION" in
|
|
|
|
X|XLATEST|Xlatest)
|
2017-04-08 12:20:04 +00:00
|
|
|
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
2015-03-05 00:47:54 +00:00
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
XSNAPSHOT|Xsnapshot)
|
2017-04-08 12:20:04 +00:00
|
|
|
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot'`
|
2015-03-05 04:21:52 +00:00
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
X[1-9]*)
|
2015-03-05 04:21:52 +00:00
|
|
|
VANILLA_VERSION=$VERSION
|
2015-03-05 00:47:54 +00:00
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
*)
|
2017-04-08 12:20:04 +00:00
|
|
|
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
2015-12-22 06:47:42 +00:00
|
|
|
;;
|
2015-03-05 00:47:54 +00:00
|
|
|
esac
|
|
|
|
|
2015-03-05 01:17:20 +00:00
|
|
|
cd /data
|
2014-11-01 20:20:52 +00:00
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
function buildSpigotFromSource {
|
|
|
|
echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
|
|
|
mkdir /data/temp
|
|
|
|
cd /data/temp
|
|
|
|
wget -q -P /data/temp https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
|
|
|
|
java -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done"
|
|
|
|
mv spigot-*.jar /data/spigot_server.jar
|
|
|
|
mv craftbukkit-*.jar /data/craftbukkit_server.jar
|
|
|
|
echo "Cleaning up"
|
|
|
|
rm -rf /data/temp
|
|
|
|
cd /data
|
|
|
|
}
|
2015-03-04 23:55:57 +00:00
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
function downloadSpigot {
|
2016-05-10 00:28:25 +00:00
|
|
|
local match
|
2016-04-24 12:26:26 +00:00
|
|
|
case "$TYPE" in
|
|
|
|
*BUKKIT|*bukkit)
|
2016-05-10 00:28:25 +00:00
|
|
|
match="Craftbukkit"
|
2017-04-08 12:20:04 +00:00
|
|
|
downloadUrl=${BUKKIT_DOWNLOAD_URL}
|
2016-04-24 12:26:26 +00:00
|
|
|
;;
|
|
|
|
*)
|
2016-05-10 00:28:25 +00:00
|
|
|
match="Spigot"
|
2017-04-08 12:20:04 +00:00
|
|
|
downloadUrl=${SPIGOT_DOWNLOAD_URL}
|
2016-04-24 12:26:26 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-04-08 12:20:04 +00:00
|
|
|
if [[ -z $downloadUrl ]]; then
|
|
|
|
downloadUrl=$(restify --class=jar-div https://mcadmin.net/ | \
|
|
|
|
jq --arg version "$match $VANILLA_VERSION" -r -f /usr/share/mcadmin.jq)
|
|
|
|
if [[ -z $downloadUrl ]]; then
|
|
|
|
echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE"
|
|
|
|
echo " Refer to https://mcadmin.net/ for supported versions"
|
|
|
|
exit 2
|
2016-04-24 15:50:48 +00:00
|
|
|
fi
|
2016-04-24 12:26:26 +00:00
|
|
|
fi
|
2017-04-08 12:20:04 +00:00
|
|
|
|
|
|
|
echo "Downloading $match"
|
|
|
|
curl -fsSL -o $SERVER "$downloadUrl"
|
|
|
|
status=$?
|
|
|
|
if [ ! -f $SERVER ]; then
|
|
|
|
echo "ERROR: failed to download from $downloadUrl (status=$status)"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:32:45 +00:00
|
|
|
function downloadPaper {
|
|
|
|
local build
|
|
|
|
case "$VERSION" in
|
|
|
|
latest|LATEST|1.10)
|
|
|
|
build="lastSuccessfulBuild";;
|
|
|
|
1.9.4)
|
|
|
|
build="773";;
|
|
|
|
1.9.2)
|
|
|
|
build="727";;
|
|
|
|
1.9)
|
|
|
|
build="612";;
|
|
|
|
1.8.8)
|
|
|
|
build="443";;
|
|
|
|
*)
|
|
|
|
build="nosupp";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ $build != "nosupp" ]; then
|
2017-04-08 12:20:04 +00:00
|
|
|
rm $SERVER
|
|
|
|
downloadUrl=${PAPER_DOWNLOAD_URL:-https://ci.destroystokyo.com/job/PaperSpigot/$build/artifact/paperclip.jar}
|
|
|
|
curl -fsSL -o $SERVER "$downloadUrl"
|
|
|
|
if [ ! -f $SERVER ]; then
|
|
|
|
echo "ERROR: failed to download from $downloadUrl (status=$?)"
|
2016-07-21 16:32:45 +00:00
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ERROR: Version $VERSION is not supported for $TYPE"
|
|
|
|
echo " Refer to https://ci.destroystokyo.com/job/PaperSpigot/"
|
|
|
|
echo " for supported versions"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
function installForge {
|
|
|
|
TYPE=FORGE
|
|
|
|
norm=$VANILLA_VERSION
|
|
|
|
|
|
|
|
echo "Checking Forge version information."
|
|
|
|
case $FORGEVERSION in
|
|
|
|
RECOMMENDED)
|
2017-04-08 12:20:04 +00:00
|
|
|
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
|
2016-04-24 12:26:26 +00:00
|
|
|
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-recommended\"]")
|
|
|
|
if [ $FORGE_VERSION = null ]; then
|
|
|
|
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-latest\"]")
|
2016-04-24 03:23:55 +00:00
|
|
|
if [ $FORGE_VERSION = null ]; then
|
2016-04-24 12:26:26 +00:00
|
|
|
echo "ERROR: Version $FORGE_VERSION is not supported by Forge"
|
|
|
|
echo " Refer to http://files.minecraftforge.net/ for supported versions"
|
|
|
|
exit 2
|
2016-04-24 03:23:55 +00:00
|
|
|
fi
|
2016-04-24 12:26:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
FORGE_VERSION=$FORGEVERSION
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# URL format changed for 1.7.10 from 10.13.2.1300
|
2017-03-01 00:32:15 +00:00
|
|
|
sorted=$( (echo $FORGE_VERSION; echo 10.13.2.1300) | sort | head -1)
|
2016-04-24 12:26:26 +00:00
|
|
|
if [[ $norm == '1.7.10' && $sorted == '10.13.2.1300' ]]; then
|
|
|
|
# if $FORGEVERSION >= 10.13.2.1300
|
|
|
|
normForgeVersion="$norm-$FORGE_VERSION-$norm"
|
|
|
|
else
|
|
|
|
normForgeVersion="$norm-$FORGE_VERSION"
|
|
|
|
fi
|
|
|
|
|
|
|
|
FORGE_INSTALLER="forge-$normForgeVersion-installer.jar"
|
|
|
|
SERVER="forge-$normForgeVersion-universal.jar"
|
|
|
|
|
2017-04-08 12:20:04 +00:00
|
|
|
downloadUrl="http://files.minecraftforge.net/maven/net/minecraftforge/forge/$normForgeVersion/$FORGE_INSTALLER"
|
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
if [ ! -e "$SERVER" ]; then
|
|
|
|
echo "Downloading $FORGE_INSTALLER ..."
|
2017-04-08 12:20:04 +00:00
|
|
|
wget -q $downloadUrl
|
2016-04-24 12:26:26 +00:00
|
|
|
echo "Installing $SERVER"
|
|
|
|
java -jar $FORGE_INSTALLER --installServer
|
|
|
|
fi
|
|
|
|
}
|
2015-11-29 04:11:01 +00:00
|
|
|
|
2017-02-13 00:02:56 +00:00
|
|
|
function installFTB {
|
|
|
|
TYPE=FEED-THE-BEAST
|
|
|
|
|
|
|
|
echo "Looking for Feed-The-Beast server modpack."
|
|
|
|
if [[ -z $FTB_SERVER_MOD ]]; then
|
|
|
|
echo "Environment variable FTB_SERVER_MOD not set."
|
|
|
|
echo "Set FTB_SERVER_MOD to the file name of the FTB server modpack."
|
|
|
|
echo "(And place the modpack in the /data directory.)"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
local srv_modpack=${FTB_SERVER_MOD}
|
|
|
|
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
|
|
|
# Prepend with "/"
|
|
|
|
srv_modpack=/${srv_modpack}
|
|
|
|
fi
|
|
|
|
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
|
|
|
# If not an absolute path, assume file is in "/data"
|
|
|
|
srv_modpack=/data/${srv_modpack}
|
|
|
|
fi
|
|
|
|
if [[ ! -f ${srv_modpack} ]]; then
|
|
|
|
echo "FTB server modpack ${srv_modpack} not found."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
|
|
|
echo "FTB server modpack ${srv_modpack} is not a zip archive."
|
|
|
|
echo "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Unpacking FTB server modpack ${srv_modpack} ..."
|
|
|
|
local ftb_dir=/data/FeedTheBeast
|
|
|
|
mkdir -p ${ftb_dir}
|
2017-03-10 00:56:19 +00:00
|
|
|
unzip -o ${srv_modpack} -d ${ftb_dir}
|
2017-02-13 00:02:56 +00:00
|
|
|
cp -f /data/eula.txt ${ftb_dir}/eula.txt
|
|
|
|
FTB_SERVER_START=${ftb_dir}/ServerStart.sh
|
|
|
|
chmod a+x ${FTB_SERVER_START}
|
|
|
|
}
|
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
function installVanilla {
|
|
|
|
SERVER="minecraft_server.$VANILLA_VERSION.jar"
|
|
|
|
|
|
|
|
if [ ! -e $SERVER ]; then
|
|
|
|
echo "Downloading $SERVER ..."
|
|
|
|
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Checking type information."
|
|
|
|
case "$TYPE" in
|
|
|
|
*BUKKIT|*bukkit|SPIGOT|spigot)
|
|
|
|
case "$TYPE" in
|
|
|
|
*BUKKIT|*bukkit)
|
|
|
|
SERVER=craftbukkit_server.jar
|
|
|
|
;;
|
2016-04-24 03:23:55 +00:00
|
|
|
*)
|
2016-04-24 12:26:26 +00:00
|
|
|
SERVER=spigot_server.jar
|
2016-01-01 22:33:05 +00:00
|
|
|
;;
|
|
|
|
esac
|
2015-03-05 04:21:52 +00:00
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
if [ ! -f $SERVER ]; then
|
|
|
|
if [[ "$BUILD_SPIGOT_FROM_SOURCE" = TRUE || "$BUILD_SPIGOT_FROM_SOURCE" = true || "$BUILD_FROM_SOURCE" = TRUE || "$BUILD_FROM_SOURCE" = true ]]; then
|
|
|
|
buildSpigotFromSource
|
|
|
|
else
|
|
|
|
downloadSpigot
|
|
|
|
fi
|
2015-06-13 06:51:07 +00:00
|
|
|
fi
|
2016-04-24 15:32:59 +00:00
|
|
|
# normalize on Spigot for operations below
|
|
|
|
TYPE=SPIGOT
|
2016-04-24 12:26:26 +00:00
|
|
|
;;
|
2015-06-13 06:51:07 +00:00
|
|
|
|
2016-07-21 16:32:45 +00:00
|
|
|
PAPER|paper)
|
|
|
|
SERVER=paper_server.jar
|
|
|
|
if [ ! -f $SERVER ]; then
|
|
|
|
downloadPaper
|
|
|
|
fi
|
|
|
|
# normalize on Spigot for operations below
|
|
|
|
TYPE=SPIGOT
|
|
|
|
;;
|
2016-10-02 12:50:19 +00:00
|
|
|
|
2016-04-24 12:26:26 +00:00
|
|
|
FORGE|forge)
|
2016-04-24 15:32:59 +00:00
|
|
|
TYPE=FORGE
|
2016-04-24 12:26:26 +00:00
|
|
|
installForge
|
2015-03-04 23:55:57 +00:00
|
|
|
;;
|
2015-03-05 04:21:52 +00:00
|
|
|
|
2017-02-13 00:02:56 +00:00
|
|
|
FTB|ftb)
|
|
|
|
TYPE=FEED-THE-BEAST
|
|
|
|
installFTB
|
|
|
|
;;
|
|
|
|
|
2016-01-01 23:20:39 +00:00
|
|
|
VANILLA|vanilla)
|
2016-04-24 12:26:26 +00:00
|
|
|
installVanilla
|
2016-01-01 22:33:05 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Invalid type: '$TYPE'"
|
|
|
|
echo "Must be: VANILLA, FORGE, SPIGOT"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
2015-03-04 23:55:57 +00:00
|
|
|
esac
|
2014-11-01 20:20:52 +00:00
|
|
|
|
2016-04-16 16:26:13 +00:00
|
|
|
|
2015-12-19 02:32:29 +00:00
|
|
|
# If supplied with a URL for a world, download it and unpack
|
2016-01-01 18:39:43 +00:00
|
|
|
if [[ "$WORLD" ]]; then
|
2015-12-19 02:32:29 +00:00
|
|
|
case "X$WORLD" in
|
2016-01-01 22:33:05 +00:00
|
|
|
X[Hh][Tt][Tt][Pp]*)
|
2015-12-19 08:48:09 +00:00
|
|
|
echo "Downloading world via HTTP"
|
2015-12-22 07:39:53 +00:00
|
|
|
echo "$WORLD"
|
2015-12-19 08:50:44 +00:00
|
|
|
wget -q -O - "$WORLD" > /data/world.zip
|
2015-12-19 08:48:09 +00:00
|
|
|
echo "Unzipping word"
|
|
|
|
unzip -q /data/world.zip
|
|
|
|
rm -f /data/world.zip
|
|
|
|
if [ ! -d /data/world ]; then
|
2015-12-22 07:39:53 +00:00
|
|
|
echo World directory not found
|
2015-12-19 08:48:09 +00:00
|
|
|
for i in /data/*/level.dat; do
|
2016-03-05 04:13:02 +00:00
|
|
|
if [ -f "$i" ]; then
|
2015-12-19 08:50:44 +00:00
|
|
|
d=`dirname "$i"`
|
2015-12-22 07:39:53 +00:00
|
|
|
echo Renaming world directory from $d
|
2015-12-19 08:50:44 +00:00
|
|
|
mv -f "$d" /data/world
|
2015-12-19 08:48:09 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2016-01-01 22:33:05 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
# Reorganise if a Spigot server
|
|
|
|
echo "Moving End and Nether maps to Spigot location"
|
|
|
|
[ -d "/data/world/DIM1" ] && mv -f "/data/world/DIM1" "/data/world_the_end"
|
|
|
|
[ -d "/data/world/DIM-1" ] && mv -f "/data/world/DIM-1" "/data/world_nether"
|
|
|
|
fi
|
2015-12-19 02:32:29 +00:00
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
*)
|
|
|
|
echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
|
|
|
|
;;
|
2015-12-19 02:32:29 +00:00
|
|
|
esac
|
2016-01-01 18:39:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
|
|
|
if [[ "$MODPACK" ]]; then
|
|
|
|
case "X$MODPACK" in
|
|
|
|
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
|
2016-01-03 15:37:27 +00:00
|
|
|
echo "Downloading mod/plugin pack via HTTP"
|
2016-01-01 18:39:43 +00:00
|
|
|
echo "$MODPACK"
|
|
|
|
wget -q -O /tmp/modpack.zip "$MODPACK"
|
2016-01-03 15:37:27 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
mkdir -p /data/plugins
|
2016-07-07 14:17:13 +00:00
|
|
|
unzip -o -d /data/plugins /tmp/modpack.zip
|
2016-01-03 15:37:27 +00:00
|
|
|
else
|
|
|
|
mkdir -p /data/mods
|
2016-07-07 14:17:13 +00:00
|
|
|
unzip -o -d /data/mods /tmp/modpack.zip
|
2016-01-03 15:37:27 +00:00
|
|
|
fi
|
2016-01-01 18:39:43 +00:00
|
|
|
rm -f /tmp/modpack.zip
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2015-12-19 02:32:29 +00:00
|
|
|
|
2016-04-24 03:23:55 +00:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-01 20:20:52 +00:00
|
|
|
if [ ! -e server.properties ]; then
|
2016-04-16 16:26:13 +00:00
|
|
|
echo "Creating server.properties"
|
2014-11-01 20:20:52 +00:00
|
|
|
cp /tmp/server.properties .
|
|
|
|
|
2015-11-29 04:11:01 +00:00
|
|
|
if [ -n "$WHITELIST" ]; then
|
2016-04-16 16:26:13 +00:00
|
|
|
echo "Creating whitelist"
|
2015-11-29 04:11:01 +00:00
|
|
|
sed -i "/whitelist\s*=/ c whitelist=true" /data/server.properties
|
2015-11-29 05:02:43 +00:00
|
|
|
sed -i "/white-list\s*=/ c white-list=true" /data/server.properties
|
2015-11-29 04:11:01 +00:00
|
|
|
fi
|
|
|
|
|
2016-04-24 03:23:55 +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_ANIMAILS"
|
|
|
|
setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
|
|
|
|
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
|
|
|
setServerProp "generate-structures" "$GENERATE_STRUCTURES"
|
|
|
|
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
|
|
|
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"
|
2016-08-02 02:09:30 +00:00
|
|
|
setServerProp "online-mode" "$ONLINE_MODE"
|
2015-03-29 18:39:25 +00:00
|
|
|
|
2015-10-03 12:05:01 +00:00
|
|
|
if [ -n "$LEVEL_TYPE" ]; then
|
|
|
|
# normalize to uppercase
|
2016-12-06 22:31:06 +00:00
|
|
|
LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
|
2016-04-24 12:26:26 +00:00
|
|
|
echo "Setting level type to $LEVEL_TYPE"
|
2015-10-03 12:05:01 +00:00
|
|
|
# check for valid values and only then set
|
|
|
|
case $LEVEL_TYPE in
|
|
|
|
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED)
|
|
|
|
sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid LEVEL_TYPE: $LEVEL_TYPE"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-06-10 18:13:36 +00:00
|
|
|
if [ -n "$DIFFICULTY" ]; then
|
|
|
|
case $DIFFICULTY in
|
2015-12-22 06:47:42 +00:00
|
|
|
peaceful|0)
|
2015-06-10 18:13:36 +00:00
|
|
|
DIFFICULTY=0
|
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
easy|1)
|
2015-06-10 18:13:36 +00:00
|
|
|
DIFFICULTY=1
|
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
normal|2)
|
2015-06-10 18:13:36 +00:00
|
|
|
DIFFICULTY=2
|
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
hard|3)
|
2015-06-10 18:13:36 +00:00
|
|
|
DIFFICULTY=3
|
|
|
|
;;
|
|
|
|
*)
|
2015-06-10 18:14:31 +00:00
|
|
|
echo "DIFFICULTY must be peaceful, easy, normal, or hard."
|
2015-06-10 18:13:36 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2016-04-24 12:26:26 +00:00
|
|
|
echo "Setting difficulty to $DIFFICULTY"
|
2015-06-10 18:13:36 +00:00
|
|
|
sed -i "/difficulty\s*=/ c difficulty=$DIFFICULTY" /data/server.properties
|
|
|
|
fi
|
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$MODE" ]; then
|
2016-04-16 16:26:13 +00:00
|
|
|
echo "Setting mode"
|
2016-12-06 22:31:06 +00:00
|
|
|
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
|
|
|
case $MODE_LC in
|
2015-01-01 16:01:15 +00:00
|
|
|
0|1|2|3)
|
|
|
|
;;
|
2016-10-02 12:50:19 +00:00
|
|
|
su*)
|
2015-01-01 16:01:15 +00:00
|
|
|
MODE=0
|
|
|
|
;;
|
|
|
|
c*)
|
|
|
|
MODE=1
|
|
|
|
;;
|
2015-12-22 06:47:42 +00:00
|
|
|
a*)
|
|
|
|
MODE=2
|
|
|
|
;;
|
2016-10-02 12:50:19 +00:00
|
|
|
sp*)
|
2015-12-22 06:47:42 +00:00
|
|
|
MODE=3
|
|
|
|
;;
|
2015-01-01 16:01:15 +00:00
|
|
|
*)
|
|
|
|
echo "ERROR: Invalid game mode: $MODE"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2015-03-04 23:55:57 +00:00
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
sed -i "/gamemode\s*=/ c gamemode=$MODE" /data/server.properties
|
|
|
|
fi
|
2015-01-01 15:10:41 +00:00
|
|
|
fi
|
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
|
|
|
|
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
|
2016-04-16 16:26:13 +00:00
|
|
|
echo "Setting ops"
|
2014-11-01 20:20:52 +00:00
|
|
|
echo $OPS | awk -v RS=, '{print}' >> ops.txt
|
|
|
|
fi
|
2015-01-01 16:01:15 +00:00
|
|
|
|
2015-11-29 04:11:01 +00:00
|
|
|
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
|
2016-04-16 16:26:13 +00:00
|
|
|
echo "Setting whitelist"
|
2015-11-29 04:11:01 +00:00
|
|
|
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
|
|
|
|
fi
|
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
2014-11-09 16:27:05 +00:00
|
|
|
echo "Using server icon from $ICON..."
|
|
|
|
# Not sure what it is yet...call it "img"
|
|
|
|
wget -q -O /tmp/icon.img $ICON
|
|
|
|
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
|
|
|
|
if [ "$specs" = "PNG 64x64" ]; then
|
|
|
|
mv /tmp/icon.img /data/server-icon.png
|
|
|
|
else
|
|
|
|
echo "Converting image to 64x64 PNG..."
|
|
|
|
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
|
|
|
fi
|
|
|
|
fi
|
2014-11-01 20:20:52 +00:00
|
|
|
|
2015-12-19 08:48:09 +00:00
|
|
|
# Make sure files exist to avoid errors
|
|
|
|
if [ ! -e banned-players.json ]; then
|
|
|
|
echo '' > banned-players.json
|
|
|
|
fi
|
2015-12-22 07:39:53 +00:00
|
|
|
if [ ! -e banned-ips.json ]; then
|
|
|
|
echo '' > banned-ips.json
|
2015-12-19 08:48:09 +00:00
|
|
|
fi
|
|
|
|
|
2015-12-19 02:32:29 +00:00
|
|
|
# If any modules have been provided, copy them over
|
|
|
|
[ -d /data/mods ] || mkdir /data/mods
|
|
|
|
for m in /mods/*.jar
|
|
|
|
do
|
|
|
|
if [ -f "$m" ]; then
|
2015-12-19 08:50:44 +00:00
|
|
|
echo Copying mod `basename "$m"`
|
|
|
|
cp -f "$m" /data/mods
|
2015-12-19 02:32:29 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
[ -d /data/config ] || mkdir /data/config
|
|
|
|
for c in /config/*
|
|
|
|
do
|
|
|
|
if [ -f "$c" ]; then
|
2015-12-19 08:50:44 +00:00
|
|
|
echo Copying configuration `basename "$c"`
|
|
|
|
cp -rf "$c" /data/config
|
2015-12-19 02:32:29 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-01-02 00:11:07 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
if [ -d /plugins ]; then
|
2016-04-24 15:32:59 +00:00
|
|
|
echo Copying any Bukkit plugins over
|
2016-01-02 00:11:07 +00:00
|
|
|
cp -r /plugins /data
|
|
|
|
fi
|
|
|
|
fi
|
2015-12-19 02:32:29 +00:00
|
|
|
|
2016-09-22 13:56:29 +00:00
|
|
|
if [[ $CONSOLE = false ]]; then
|
|
|
|
EXTRA_ARGS=--noconsole
|
|
|
|
else
|
|
|
|
EXTRA_ARGS=""
|
|
|
|
fi
|
|
|
|
|
2017-03-19 14:35:58 +00:00
|
|
|
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
|
|
|
|
echo "Setting initial memory to ${INIT_MEMORY:-${MEMORY}} and max to ${MAX_MEMORY:-${MEMORY}}"
|
|
|
|
JVM_OPTS="-Xms${INIT_MEMORY:-${MEMORY}} -Xmx${MAX_MEMORY:-${MEMORY}} ${JVM_OPTS}"
|
|
|
|
|
2017-02-15 04:15:36 +00:00
|
|
|
set -x
|
2017-02-13 00:02:56 +00:00
|
|
|
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
|
|
|
echo "Running FTB server modpack start ..."
|
|
|
|
exec sh ${FTB_SERVER_START}
|
2016-01-01 22:03:04 +00:00
|
|
|
else
|
2017-02-13 00:02:56 +00:00
|
|
|
# If we have a bootstrap.txt file... feed that in to the server stdin
|
|
|
|
if [ -f /data/bootstrap.txt ];
|
|
|
|
then
|
2017-02-15 04:15:36 +00:00
|
|
|
exec java $JVM_XX_OPTS $JVM_OPTS -jar $SERVER "$@" $EXTRA_ARGS < /data/bootstrap.txt
|
2017-02-13 00:02:56 +00:00
|
|
|
else
|
2017-02-15 04:15:36 +00:00
|
|
|
exec java $JVM_XX_OPTS $JVM_OPTS -jar $SERVER "$@" $EXTRA_ARGS
|
2017-02-13 00:02:56 +00:00
|
|
|
fi
|
2016-01-01 22:03:04 +00:00
|
|
|
fi
|