games-server/minecraft-server: New package

Package-Manager: Portage-2.3.103, Repoman-2.3.23
Signed-off-by: Alarig Le Lay <alarig@swordarmor.fr
This commit is contained in:
Alarig Le Lay 2020-08-21 13:59:48 +02:00
parent 9abcd8562f
commit da96bf46b3
Signed by: alarig
GPG Key ID: 7AFE62C6DF8BCDEC
6 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1 @@
DIST minecraft-server-1.16.2.jar 37968964 BLAKE2B 08c9f3f5b7c5618fd55b40e77a3ab92ed2d8cdf64771fe171292045ee611b6c549f0e732ed3dec2553f2219c219ff8f9b2187563717be14edbffa68ceb05b555 SHA512 8fa8bf001cb50e59351f58598fdbd4b7b13cee8d5a6ae7d4486f6259d419c8101123cb18efc96cac7c796ca98483d6d1e9ac3888d6b364d81b86927aee3f350d

View File

@ -0,0 +1,20 @@
This package provides an init script and a conf file.
You don't have to modify those files directly,
but instead you can make a symlink of that init script
and a copy of that conf file.
You would do this for every server, you want to setup.
For example, you wan't to setup an world called 'gentoo',
you would do:
cd /etc/init.d
ln -s minecraft-server minecraft-server.gentoo
cd /etc/conf.d
cp minecraft-server minecraft-server.gentoo
After that, make your settings in
/etc/conf.d/minecraft-server.gentoo.
If you don't make a symlink, but use the default scripts,
your world will be called 'main'.

View File

@ -0,0 +1,7 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Java options for your started server
# You should at least define some memory settings (-Xms, -Xmx),
# for maximum memory, as the java default is far to low for Minecraft
MINECRAFT_OPTS="-Xms1024m -Xmx1024m"

View File

@ -0,0 +1,47 @@
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
if [ "${SVCNAME}" = "minecraft-server" ]; then
instance="main"
else
instance="${SVCNAME#minecraft-server.}"
fi
dtach_tmpfile="$(mktemp -u)"
minecraft_command="/usr/bin/minecraft-server"
minecraft_logs="/var/log/minecraft-server"
minecraft_logs_instance="${minecraft_logs}/${instance}"
minecraft_path="/var/lib/minecraft-server"
minecraft_path_instance="${minecraft_path}/${instance}"
name="Minecraft Server (World: ${instance})"
pidfile="/run/minecraft-server.${instance}.pid"
start_stop_daemon_args="--chdir ${minecraft_path_instance} --env JAVA_OPTS='${MINECRAFT_OPTS}'"
command="/usr/bin/dtach"
command_background="true"
command_args="-N ${dtach_tmpfile} ${minecraft_command}"
command_group="minecraft"
command_user="minecraft"
depend() {
use net
}
start_pre() {
checkpath -d -o "${command_user}:${command_group}" -q "${minecraft_path}" "${minecraft_path_instance}"
checkpath -f -o "${command_user}:${command_group}" -q "${minecraft_path_instance}"/eula.txt
echo "eula=true" > "${minecraft_path_instance}"/eula.txt
checkpath -d -o "${command_user}:${command_group}" -q "${minecraft_logs}" "${minecraft_logs_instance}"
if [ ! -L "${minecraft_path_instance}"/logs ]; then
cd "${minecraft_path_instance}" && ln -s ../../../log/minecraft-server/"${instance}" logs
fi
if [ -z "${MINECRAFT_OPTS}" ]; then
eerror "You must define MINECRAFT_OPTS in /etc/conf.d/minecraft.${SVCNAME}!"
return 1
fi
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>conikost@gentoo.org</email>
<name>Conrad Kostecki</name>
</maintainer>
<longdescription>
Minecraft is a sandbox video game created and designed
by Swedish game designer Markus "Notch" Persson,
and later fully developed and published by Mojang.
This is the headless server for Minecraft.
</longdescription>
</pkgmetadata>

View File

@ -0,0 +1,48 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
EGIT_COMMIT="a412fd69db1f81db3f511c1463fd304675244077"
inherit readme.gentoo-r1 java-pkg-2
DESCRIPTION="The official server for the sandbox video game"
HOMEPAGE="https://www.minecraft.net/"
SRC_URI="https://launcher.mojang.com/v1/objects/${EGIT_COMMIT}/server.jar -> ${P}.jar"
LICENSE="Mojang"
SLOT="0"
KEYWORDS="~amd64 ~x86"
RDEPEND="
acct-group/minecraft
acct-user/minecraft
app-misc/dtach
|| (
>=virtual/jre-1.8
>=virtual/jdk-1.8
)
"
RESTRICT="bindist mirror"
S="${WORKDIR}"
src_unpack() {
cp "${DISTDIR}"/${A} "${WORKDIR}" || die
}
src_install() {
java-pkg_newjar minecraft-server-${PV}.jar minecraft-server.jar
java-pkg_dolauncher minecraft-server --jar minecraft-server.jar --java_args "\${JAVA_OPTS}"
newinitd "${FILESDIR}"/minecraft-server.initd-r3 minecraft-server
newconfd "${FILESDIR}"/minecraft-server.confd minecraft-server
readme.gentoo_create_doc
}
pkg_postinst() {
readme.gentoo_print_elog
}