mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
Add option for Vanilla or Forge server
This commit is contained in:
parent
14a1e5fb2a
commit
87140179f2
@ -26,4 +26,5 @@ ENV UID 1000
|
||||
ENV MOTD A Minecraft Server Powered by Docker
|
||||
ENV LEVEL world
|
||||
ENV JVM_OPTS -Xmx1024M -Xms1024M
|
||||
ENV TYPE VANILLA
|
||||
ENV VERSION LATEST
|
||||
|
@ -1,68 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import scrapy
|
||||
from scrapy.contrib.spiders import CrawlSpider, Rule
|
||||
from scrapy.contrib.linkextractors import LinkExtractor
|
||||
from scrapy.selector import Selector
|
||||
|
||||
import re
|
||||
|
||||
class Forge(scrapy.Item):
|
||||
versions = scrapy.Field()
|
||||
latest = scrapy.Field()
|
||||
|
||||
class ForgeVersions(scrapy.Item):
|
||||
id = scrapy.Field()
|
||||
minecraft = scrapy.Field()
|
||||
type = scrapy.Field()
|
||||
time = scrapy.Field()
|
||||
url = scrapy.Field()
|
||||
|
||||
class ForgeLatest(scrapy.Item):
|
||||
forge_latest = scrapy.Field()
|
||||
forge_recommended = scrapy.Field()
|
||||
|
||||
class ForgeSpider(CrawlSpider):
|
||||
name = "ForgeSpider"
|
||||
allowed_domains = ["minecraftforge.net"]
|
||||
start_urls = ['http://files.minecraftforge.net']
|
||||
|
||||
def parse(self, response):
|
||||
forge = Forge()
|
||||
forge['versions'] = []
|
||||
forge['latest'] = ForgeLatest()
|
||||
|
||||
selector = Selector(response)
|
||||
rows = selector.xpath('//table[@id="promotions_table"]//tr')
|
||||
header = rows.pop(0)
|
||||
for row in rows:
|
||||
cells = row.xpath('td')
|
||||
|
||||
id = cells[1].xpath('text()').extract()
|
||||
minecraft = cells[2].xpath('text()').extract()
|
||||
type = cells[0].xpath('text()')
|
||||
time = cells[3].xpath('text()')
|
||||
url = cells[4].xpath('a[text()="Installer"]/@href')
|
||||
|
||||
#if has version
|
||||
has_version = re.match('(.+)\-.+', ''.join(type.extract()))
|
||||
if has_version:
|
||||
download = ForgeVersions()
|
||||
download['id'] = id
|
||||
download['minecraft'] = minecraft
|
||||
download['type'] = 'forge_' + ''.join(type.re('([a-zA-Z]+)')).lower()
|
||||
download['time'] = time.extract()
|
||||
download['url'] = url.re('http://adf.ly/\d+/(.+)')
|
||||
|
||||
forge['versions'].append(download)
|
||||
else:
|
||||
is_recommended = re.match('Recommended', ''.join(type.extract()))
|
||||
if is_recommended:
|
||||
download = ForgeLatest()
|
||||
forge['latest']['forge_recommended'] = id
|
||||
else:
|
||||
download = ForgeLatest()
|
||||
forge['latest']['forge_latest'] = id
|
||||
|
||||
|
||||
return forge
|
||||
|
@ -15,22 +15,49 @@ if [ ! -e /data/eula.txt ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
case $VERSION in
|
||||
LATEST)
|
||||
export VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.release)'`
|
||||
;;
|
||||
|
||||
SNAPSHOT)
|
||||
export VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.snapshot)'`
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /data
|
||||
|
||||
if [ ! -e minecraft_server.$VERSION.jar ]; then
|
||||
echo "Downloading minecraft_server.$VERSION.jar ..."
|
||||
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VERSION/minecraft_server.$VERSION.jar
|
||||
fi
|
||||
case $TYPE in
|
||||
VANILLA)
|
||||
case $VERSION in
|
||||
LATEST)
|
||||
export VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.release)'`
|
||||
;;
|
||||
SNAPSHOT)
|
||||
export VANILLA_VERSION=`wget -O - https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | jsawk -n 'out(this.latest.snapshot)'`
|
||||
;;
|
||||
esac
|
||||
export SERVER="minecraft_server.$VANILLA_VERSION"
|
||||
|
||||
if [ ! -e $SERVER ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER
|
||||
fi
|
||||
;;
|
||||
|
||||
FORGE)
|
||||
case $VERSION in
|
||||
LATEST)
|
||||
export FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json \
|
||||
| jsawk -n 'out(this.promos.recommended)'`
|
||||
;;
|
||||
SNAPSHOT)
|
||||
export FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json \
|
||||
| jsawk -n 'out(this.promos.latest)'`
|
||||
;;
|
||||
esac
|
||||
export FORGE_INSTALLER="forge-$VERSION-$FORGE_VERSION-installer.jar"
|
||||
export SERVER="forge-$VERSION-$FORGE_VERSION-universal.jar"
|
||||
|
||||
if [ ! -e $SERVER ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
wget -q http://files.minecraftforge.net/maven/net/minecraftforge/forge/$VERSION-$FORGE_VERSION/$FORGE_INSTALLER
|
||||
fi
|
||||
|
||||
echo "Installing $SERVER"
|
||||
exec java -jar $FORGE_INSTALLER --installServer
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -e server.properties ]; then
|
||||
cp /tmp/server.properties .
|
||||
@ -62,7 +89,7 @@ if [ ! -e server.properties ]; then
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
sed -i "/gamemode\s*=/ c gamemode=$MODE" /data/server.properties
|
||||
fi
|
||||
fi
|
||||
@ -85,5 +112,5 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
exec java $JVM_OPTS -jar minecraft_server.$VERSION.jar
|
||||
exec java $JVM_OPTS -jar $SERVER
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user