Build spigot using buildtools (#67)

* Download buildtools

* Download buildtools

* Not a good idea to chmod /root

* Remove bukkit code

* fix jar not found

* Run start-minecraft as root (temp)

* Working buildtools

* Remove echo line

* Added more server properties, not working yet

* Show what server properties are being added

* Show what server properties are being added

* Add rcon.password

* Add max-world-size

* Added alot of server settings

* Expose rcon port

* Export home per itzg suggestion

* Update readme and server properties

* Env for building spigot from source

* Update readme
This commit is contained in:
Sander
2016-04-16 18:26:13 +02:00
committed by Geoff Bourne
parent 21c9be4ec1
commit a4835ec331
5 changed files with 287 additions and 32 deletions
+172 -30
View File
@@ -1,6 +1,7 @@
#!/bin/bash
umask 002
#umask 002
export HOME=/data
if [ ! -e /data/eula.txt ]; then
if [ "$EULA" != "" ]; then
@@ -39,35 +40,62 @@ echo "Checking type information."
case "$TYPE" in
*BUKKIT|*bukkit|SPIGOT|spigot)
TYPE=SPIGOT
case "$TYPE" in
*BUKKIT|*bukkit)
echo "Downloading latest CraftBukkit $VANILLA_VERSION server ..."
SERVER=craftbukkit_server.jar
;;
*)
echo "Downloading latest Spigot $VANILLA_VERSION server ..."
SERVER=spigot_server.jar
;;
esac
case $VANILLA_VERSION in
1.8*)
URL=/spigot18/$SERVER
;;
1.9*)
URL=/spigot19/$SERVER
;;
*)
echo "That version of $SERVER is not available."
exit 1
;;
esac
#attempt https, and if it fails, fallback to http and download that way. Display error if neither works.
wget -q -N $SERVER https://getspigot.org$URL || \
(echo "Falling back to http, unable to contact server using https..." && \
wget -q -N $SERVER http://getspigot.org$URL) || \
echo "Unable to download new copy of spigot server"
if [ -z "$BUILD_SPIGOT_FROM_SOURCE" ]; then
case "$TYPE" in
*BUKKIT|*bukkit)
echo "Downloading latest CraftBukkit $VANILLA_VERSION server ..."
SERVER=craftbukkit_server.jar
;;
*)
echo "Downloading latest Spigot $VANILLA_VERSION server ..."
SERVER=spigot_server.jar
;;
esac
case $VANILLA_VERSION in
1.8*)
URL=/spigot18/$SERVER
;;
1.9*)
URL=/spigot19/$SERVER
;;
*)
echo "That version of $SERVER is not available."
exit 1
;;
esac
#attempt https, and if it fails, fallback to http and download that way. Display error if neither works.
wget -q -N $SERVER https://getspigot.org$URL || \
(echo "Falling back to http, unable to contact server using https..." && \
wget -q -N $SERVER http://getspigot.org$URL) || \
echo "Unable to download new copy of spigot server"
fi
if [ "$BUILD_SPIGOT_FROM_SOURCE" = true ]; then
echo "Building spigot from source, might take a while, get some coffee"
if [ ! -f /data/spigot_server.jar ]; then
echo "Downloading and building buildtools for version $VANILLA_VERSION"
mkdir /data/temp
cd /data/temp
wget -P /data/temp https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
java -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION && \
find * -maxdepth 0 ! -name '*.jar' -exec rm -rf {} \; && \
chown minecraft:minecraft spigot-*.jar && \
chown minecraft:minecraft craftbukkit-*.jar && \
mv spigot-*.jar /data/spigot_server.jar && \
mv craftbukkit-*.jar /data/craftbukkit_server.jar
echo "Cleaning up"
rm -rf /data/temp
cd /data
fi
case "$TYPE" in
*BUKKIT|*bukkit)
SERVER=craftbukkit_server.jar
;;
*)
SERVER=spigot_server.jar
;;
esac
fi
;;
FORGE|forge)
@@ -122,6 +150,11 @@ case "$TYPE" in
esac
#Switch to minecraft user
echo "...switching to user 'minecraft'"
su - minecraft
# If supplied with a URL for a world, download it and unpack
if [[ "$WORLD" ]]; then
case "X$WORLD" in
@@ -178,31 +211,135 @@ esac
fi
if [ ! -e server.properties ]; then
echo "Creating server.properties"
cp /tmp/server.properties .
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
fi
if [ -n "$MOTD" ]; then
echo "Setting motd"
sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties
fi
if [ -n "$ALLOW_NETHER" ]; then
echo "Setting allow-nether"
sed -i "/allow-nether\s*=/ c allow-nether=$ALLOW_NETHER" /data/server.properties
fi
if [ -n "$ANNOUNCE_PLAYER_ACHIEVEMENTS" ]; then
echo "Setting announce-player-achievements"
sed -i "/announce-player-achievements\s*=/ c announce-player-achievements=$ANNOUNCE_PLAYER_ACHIEVEMENTS" /data/server.properties
fi
if [ -n "$ENABLE_COMMAND_BLOCK" ]; then
echo "Setting enable-command-block"
sed -i "/enable-command-block\s*=/ c enable-command-block=$ENABLE_COMMAND_BLOCK" /data/server.properties
fi
if [ -n "$SPAWN_ANIMAILS" ]; then
echo "Setting spawn-animals"
sed -i "/spawn-animals\s*=/ c spawn-animals=$SPAWN_ANIMAILS" /data/server.properties
fi
if [ -n "$SPAWN_MONSTERS" ]; then
echo "Setting spawn-monsters"
sed -i "/spawn-monsters\s*=/ c spawn-monsters=$SPAWN_MONSTERS" /data/server.properties
fi
if [ -n "$SPAWN_NPCS" ]; then
echo "Setting spawn-npcs"
sed -i "/spawn-npcs\s*=/ c spawn-npcs=$SPAWN_NPCS" /data/server.properties
fi
if [ -n "$GENERATE_STRUCTURES" ]; then
echo "Setting generate-structures"
sed -i "/generate-structures\s*=/ c generate-structures=$GENERATE_STRUCTURES" /data/server.properties
fi
if [ -n "$VIEW_DISTANCE" ]; then
echo "Setting view-distance"
sed -i "/view-distance\s*=/ c view-distance=$VIEW_DISTANCE" /data/server.properties
fi
if [ -n "$HARDCORE" ]; then
echo "Setting hardcore"
sed -i "/hardcore\s*=/ c hardcore=$HARDCORE" /data/server.properties
fi
if [ -n "$MAX_BUILD_HEIGHT" ]; then
echo "Setting max-build-height"
sed -i "/max-build-height\s*=/ c max-build-height=$MAX_BUILD_HEIGHT" /data/server.properties
fi
if [ -n "$FORCE_GAMEMODE" ]; then
echo "Setting force-gamemode"
sed -i "/force-gamemode\s*=/ c force-gamemode=$FORCE_GAMEMODE" /data/server.properties
fi
if [ -n "$MAX_TICK_TIME" ]; then
echo "Setting max-tick-time"
sed -i "/max-tick-time\s*=/ c max-tick-time=$MAX_TICK_TIME" /data/server.properties
fi
if [ -n "$ENABLE_QUERY" ]; then
echo "Enabling query"
sed -i "/enable-query\s*=/ c enable-query=$ENABLE_QUERY" /data/server.properties
fi
if [ -n "$QUERY_PORT" ]; then
echo "Setting query port"
sed -i "/query.port\s*=/ c query.port=$QUERY_PORT" /data/server.properties
fi
if [ -n "$ENABLE_RCON" ]; then
echo "Enabling rcon"
sed -i "/enable-rcon\s*=/ c enable-rcon=$ENABLE_RCON" /data/server.properties
fi
if [ -n "$RCON_PASSWORD" ]; then
echo "Setting rcon password to $RCON_PASSWORD"
sed -i "/rcon.password\s*=/ c rcon.password=$RCON_PASSWORD" /data/server.properties
fi
if [ -n "$RCON_PORT" ]; then
echo "Setting rcon port"
sed -i "/rcon.port\s*=/ c rcon.port=$RCON_PORT" /data/server.properties
fi
if [ -n "$MAX_PLAYERS" ]; then
echo "Setting max players"
sed -i "/max-players\s*=/ c max-players=$MAX_PLAYERS" /data/server.properties
fi
if [ -n "$MAX_WORLD_SIZE" ]; then
echo "Setting max world size"
sed -i "/max-world-size\s*=/ c max-world-size=$MAX_WORLD_SIZE" /data/server.properties
fi
if [ -n "$LEVEL" ]; then
echo "Setting level name"
sed -i "/level-name\s*=/ c level-name=$LEVEL" /data/server.properties
fi
if [ -n "$SEED" ]; then
echo "Setting seed"
sed -i "/level-seed\s*=/ c level-seed=$SEED" /data/server.properties
fi
if [ -n "$PVP" ]; then
echo "Setting PVP"
sed -i "/pvp\s*=/ c pvp=$PVP" /data/server.properties
fi
if [ -n "$LEVEL_TYPE" ]; then
# normalize to uppercase
echo "Setting level type"
LEVEL_TYPE=${LEVEL_TYPE^^}
# check for valid values and only then set
case $LEVEL_TYPE in
@@ -217,10 +354,12 @@ if [ ! -e server.properties ]; then
fi
if [ -n "$GENERATOR_SETTINGS" ]; then
echo "Setting generator settings"
sed -i "/generator-settings\s*=/ c generator-settings=$GENERATOR_SETTINGS" /data/server.properties
fi
if [ -n "$DIFFICULTY" ]; then
echo "Setting difficulty"
case $DIFFICULTY in
peaceful|0)
DIFFICULTY=0
@@ -243,6 +382,7 @@ if [ ! -e server.properties ]; then
fi
if [ -n "$MODE" ]; then
echo "Setting mode"
case ${MODE,,?} in
0|1|2|3)
;;
@@ -270,10 +410,12 @@ fi
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
echo "Setting ops"
echo $OPS | awk -v RS=, '{print}' >> ops.txt
fi
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
echo "Setting whitelist"
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
fi