initial setup
This commit is contained in:
parent
a4ec091a8e
commit
0b3e71028b
|
@ -0,0 +1,2 @@
|
||||||
|
mc_server_version: 15c777e2cfe0556eef19aab534b186c0c6f277e1
|
||||||
|
mc_server_memory: 1G
|
|
@ -0,0 +1 @@
|
||||||
|
eula=true
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Minecraft Server
|
||||||
|
Documentation=https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=minecraft
|
||||||
|
Group=minecraft
|
||||||
|
WorkingDirectory=/srv/minecraft-server
|
||||||
|
ExecStart=/bin/bash /srv/minecraft-server/minecraft-server.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,49 @@
|
||||||
|
# based on https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_server#Debian,_Ubuntu,_Raspbian
|
||||||
|
|
||||||
|
- name: Install required packages
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
name:
|
||||||
|
- openjdk-18-jre-headless
|
||||||
|
|
||||||
|
- name: Add user "minecraft"
|
||||||
|
user:
|
||||||
|
name: minecraft
|
||||||
|
create_home: false
|
||||||
|
shell: /bin/false
|
||||||
|
system: true
|
||||||
|
|
||||||
|
- name: Create install directory
|
||||||
|
file:
|
||||||
|
path: /srv/minecraft-server
|
||||||
|
owner: minecraft
|
||||||
|
group: minecraft
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Download server jar
|
||||||
|
get_url:
|
||||||
|
url: https://piston-data.mojang.com/v1/objects/{{ mc_server_version }}/server.jar
|
||||||
|
dest: /srv/minecraft-server
|
||||||
|
|
||||||
|
- name: Accept EULA
|
||||||
|
copy:
|
||||||
|
src: eula.txt
|
||||||
|
dest: /srv/minecraft-server/eula.txt
|
||||||
|
|
||||||
|
- name: Install server script
|
||||||
|
template:
|
||||||
|
src: minecraft-server.sh
|
||||||
|
dest: /srv/minecraft-server/minecraft-server.sh
|
||||||
|
|
||||||
|
- name: Install minecraft-server systemd unit
|
||||||
|
copy:
|
||||||
|
src: minecraft-server.service
|
||||||
|
dest: /etc/systemd/system/minecraft-server.service
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Enable minecraft-server service
|
||||||
|
systemd:
|
||||||
|
name: minecraft-server
|
||||||
|
daemon_reload: yes
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec /usr/bin/java -Xmn{{ mc_server_memory }} -Xmx{{ mc_server_memory }} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar /srv/minecraft-server/server.jar
|
Loading…
Reference in New Issue