2015-01-01 15:10:41 +00:00
|
|
|
#!/bin/bash
|
2014-11-01 20:20:52 +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
|
|
|
|
|
2015-03-05 01:15:36 +00:00
|
|
|
echo "Checking version information."
|
2015-03-05 00:47:54 +00:00
|
|
|
case $VERSION in
|
|
|
|
LATEST)
|
|
|
|
VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.release)'`
|
2015-03-05 01:15:36 +00:00
|
|
|
FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json | jsawk -n 'out(this.promos.recommended)'`
|
2015-03-05 00:47:54 +00:00
|
|
|
;;
|
|
|
|
SNAPSHOT)
|
|
|
|
VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.snapshot)'`
|
2015-03-05 01:15:36 +00:00
|
|
|
FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json | jsawk -n 'out(this.promos.latest)'`
|
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
|
|
|
|
2015-03-05 01:15:36 +00:00
|
|
|
echo "Checking minecraft / forge type information."
|
2015-03-04 23:55:57 +00:00
|
|
|
case $TYPE in
|
|
|
|
VANILLA)
|
2015-03-05 00:47:54 +00:00
|
|
|
SERVER="minecraft_server.$VANILLA_VERSION.jar"
|
2015-03-04 23:55:57 +00:00
|
|
|
|
|
|
|
if [ ! -e $SERVER ]; then
|
|
|
|
echo "Downloading $SERVER ..."
|
|
|
|
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
FORGE)
|
2015-03-05 01:15:36 +00:00
|
|
|
FORGE_INSTALLER="forge-$VANILLA_VERSION-$FORGE_VERSION-installer.jar"
|
|
|
|
SERVER="forge-$VANILLA_VERSION-$FORGE_VERSION-universal.jar"
|
2015-03-04 23:55:57 +00:00
|
|
|
|
|
|
|
if [ ! -e $SERVER ]; then
|
2015-03-05 01:15:36 +00:00
|
|
|
echo "Downloading $FORGE_INSTALLER ..."
|
|
|
|
wget -q http://files.minecraftforge.net/maven/net/minecraftforge/forge/$VANILLA_VERSION-$FORGE_VERSION/$FORGE_INSTALLER
|
|
|
|
echo "Installing $SERVER"
|
|
|
|
exec java -jar $FORGE_INSTALLER --installServer
|
2015-03-04 23:55:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
2014-11-01 20:20:52 +00:00
|
|
|
|
|
|
|
if [ ! -e server.properties ]; then
|
|
|
|
cp /tmp/server.properties .
|
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$MOTD" ]; then
|
|
|
|
sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties
|
|
|
|
fi
|
2015-01-01 15:10:41 +00:00
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$LEVEL" ]; then
|
|
|
|
sed -i "/level-name\s*=/ c level-name=$LEVEL" /data/server.properties
|
|
|
|
fi
|
2015-01-01 15:10:41 +00:00
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$SEED" ]; then
|
|
|
|
sed -i "/level-seed\s*=/ c level-seed=$SEED" /data/server.properties
|
|
|
|
fi
|
2015-01-01 15:10:41 +00:00
|
|
|
|
2015-01-01 16:01:15 +00:00
|
|
|
if [ -n "$MODE" ]; then
|
|
|
|
case ${MODE,,?} in
|
|
|
|
0|1|2|3)
|
|
|
|
;;
|
|
|
|
s*)
|
|
|
|
MODE=0
|
|
|
|
;;
|
|
|
|
c*)
|
|
|
|
MODE=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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
|
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
|
|
|
|
|
|
|
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-03-04 23:55:57 +00:00
|
|
|
exec java $JVM_OPTS -jar $SERVER
|