Only create /home/minecraft if absent

* only download/build Spigot/Bukkit when absent
* refactored download ops into functions
#72
This commit is contained in:
Geoff Bourne 2016-04-24 07:26:26 -05:00
parent cf5d194b14
commit 46c865a123
2 changed files with 106 additions and 91 deletions

View File

@ -36,11 +36,7 @@ esac
cd /data
echo "Checking type information."
case "$TYPE" in
*BUKKIT|*bukkit|SPIGOT|spigot)
if [[ "$BUILD_SPIGOT_FROM_SOURCE" = TRUE || "$BUILD_SPIGOT_FROM_SOURCE" = true || "$BUILD_FROM_SOURCE" = TRUE || "$BUILD_FROM_SOURCE" = true ]]; then
if [ ! -f /data/spigot_server.jar ]; then
function buildSpigotFromSource {
echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
mkdir /data/temp
cd /data/temp
@ -51,24 +47,15 @@ case "$TYPE" in
echo "Cleaning up"
rm -rf /data/temp
cd /data
fi
case "$TYPE" in
*BUKKIT|*bukkit)
SERVER=craftbukkit_server.jar
;;
*)
SERVER=spigot_server.jar
;;
esac
else
}
function downloadSpigot {
case "$TYPE" in
*BUKKIT|*bukkit)
match="Craftbukkit $VANILLA_VERSION"
SERVER=craftbukkit.jar
;;
*)
match="Spigot $VANILLA_VERSION"
SERVER=spigot.jar
;;
esac
@ -82,10 +69,9 @@ case "$TYPE" in
echo " Refer to http://getspigot.org for supported versions"
exit 2
fi
fi
;;
}
FORGE|forge)
function installForge {
TYPE=FORGE
norm=$VANILLA_VERSION
@ -127,15 +113,44 @@ case "$TYPE" in
echo "Installing $SERVER"
java -jar $FORGE_INSTALLER --installServer
fi
;;
}
VANILLA|vanilla)
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
;;
*)
SERVER=spigot_server.jar
;;
esac
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
fi
;;
FORGE|forge)
installForge
;;
VANILLA|vanilla)
installVanilla
;;
*)
@ -250,8 +265,8 @@ if [ ! -e server.properties ]; then
if [ -n "$LEVEL_TYPE" ]; then
# normalize to uppercase
echo "Setting level type"
LEVEL_TYPE=${LEVEL_TYPE^^}
echo "Setting level type to $LEVEL_TYPE"
# check for valid values and only then set
case $LEVEL_TYPE in
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED)
@ -265,7 +280,6 @@ if [ ! -e server.properties ]; then
fi
if [ -n "$DIFFICULTY" ]; then
echo "Setting difficulty"
case $DIFFICULTY in
peaceful|0)
DIFFICULTY=0
@ -284,6 +298,7 @@ if [ ! -e server.properties ]; then
exit 1
;;
esac
echo "Setting difficulty to $DIFFICULTY"
sed -i "/difficulty\s*=/ c difficulty=$DIFFICULTY" /data/server.properties
fi

View File

@ -12,7 +12,7 @@ while lsof -- /start-minecraft; do
sleep 1
done
mkdir /home/minecraft
mkdir -p /home/minecraft
chown minecraft: /home/minecraft
echo "Switching to user 'minecraft'"