From 25ba946216807cb79b90a0bd202e0c8d4ed18f39 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Mon, 13 Sep 2021 10:38:02 +0200 Subject: [PATCH] minecraft --- bundles/java/metadata.py | 16 ++++++++++++++++ bundles/minecraft/items.py | 31 +++++++++++++++++++++++++++++++ bundles/minecraft/metadata.py | 20 ++++++++++++++++++++ nodes/htz.games.py | 27 +++++++++++++++++++++++---- 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 bundles/java/metadata.py create mode 100644 bundles/minecraft/items.py create mode 100644 bundles/minecraft/metadata.py diff --git a/bundles/java/metadata.py b/bundles/java/metadata.py new file mode 100644 index 0000000..f561c9a --- /dev/null +++ b/bundles/java/metadata.py @@ -0,0 +1,16 @@ +assert node.os == 'debian' + +if node.os_version == (10,): + version = 11 +elif node.os_version == (11,): + version = 17 +else: + raise Exception('java bundle doesnt support this os and version') + +defaults = { + 'apt': { + 'packages': { + f'openjdk-{version}-jre': {}, + } + } +} diff --git a/bundles/minecraft/items.py b/bundles/minecraft/items.py new file mode 100644 index 0000000..4c113b8 --- /dev/null +++ b/bundles/minecraft/items.py @@ -0,0 +1,31 @@ +users = { + 'minecraft': {}, +} + +directories = { + '/opt/minecraft': { + 'owner': 'minecraft', + }, +} + +downloads = { + '/opt/minecraft/server.jar': { + 'url': node.metadata.get('minecraft/download'), + 'sha256': node.metadata.get('minecraft/sha256'), + } +} + +files = { + '/opt/minecraft/eula.txt': { + 'content': 'eula=true', + } +} + +svc_systemd = { + 'minecraft': { + 'needs': { + 'file:/opt/minecraft/eula.txt', + 'download:/opt/minecraft/server.jar', + }, + }, +} diff --git a/bundles/minecraft/metadata.py b/bundles/minecraft/metadata.py new file mode 100644 index 0000000..727d077 --- /dev/null +++ b/bundles/minecraft/metadata.py @@ -0,0 +1,20 @@ +assert node.has_bundle('java') + +defaults = { + 'systemd': { + 'units': { + 'minecraft.service': { + 'Unit': { + 'Description': 'minecraft', + 'After': 'network.target', + }, + 'Service': { + 'User': 'minecraft', + 'WorkingDirectory': '/opt/minecraft', + 'ExecStart': '/usr/bin/java -Xms1024M -Xmx2560M -jar /opt/minecraft/server.jar nogui', + 'Restart': 'always', + }, + }, + }, + }, +} diff --git a/nodes/htz.games.py b/nodes/htz.games.py index ad7c720..3226cbe 100644 --- a/nodes/htz.games.py +++ b/nodes/htz.games.py @@ -1,14 +1,33 @@ { - 'dummy': True, + 'hostname': '159.69.93.165', 'groups': [ 'backup', - 'debian-10', + 'debian-11', ], 'bundles': [ - 'steam', - 'l4d2', +# 'steam', +# 'l4d2', + 'java', + 'minecraft', ], 'metadata': { 'id': '353bb086-f3ce-4f36-8533-e91786c91ed9', + 'network': { + 'internal': { + 'interface': 'ens10', + 'ipv4': '10.0.10.3/24', + }, + 'external': { + 'interface': 'eth0', + 'ipv4': '159.69.93.165/32', + 'ipv6': '2a01:4f8:c2c:867::2/64', + 'gateway4': '172.31.1.1', + 'gateway6': 'fe80::1', + } + }, + 'minecraft': { + 'download': 'https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar', + 'sha256': 'e8c211b41317a9f5a780c98a89592ecb72eb39a6e475d4ac9657e5bc9ffaf55f', + }, }, }