forked from dirien/pulumi-python-minecraft
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloud-init.yaml
45 lines (40 loc) · 1.28 KB
/
cloud-init.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#cloud-config
users:
- default
package_update: true
packages:
- apt-transport-https
- ca-certificates
- curl
- openjdk-17-jre-headless
write_files:
- path: /etc/sysctl.d/enabled_ipv4_forwarding.conf
content: |
net.ipv4.conf.all.forwarding=1
- path: /etc/systemd/system/minecraft.service
content: |
[Unit]
Description=Minecraft Server
Documentation=https://www.minecraft.net/en-us/download/server
[Service]
WorkingDirectory=/minecraft
Type=simple
ExecStart=/usr/bin/java -Xmx2G -Xms2G -jar server.jar nogui
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
runcmd:
- mkdir -p /minecraft
- URL=$(curl -s https://java-version.minectl.ediri.online/latest)
- curl -sLSf $URL > /minecraft/server.jar
- systemctl enable minecraft.service
- systemctl start minecraft.service
- sleep 1m
- echo "eula=true" > /minecraft/eula.txt
- sed -ir "s/^[#]*\s*max-players=.*/max-players=100/" /minecraft/server.properties
- sed -ir "s/^[#]*\s*motd=.*/motd=Pulumi Minecraft/" /minecraft/server.properties
- sed -ir "s/^[#]*\s*difficulty=.*/difficulty=normal:q/" /minecraft/server.properties
- sed -ir "s/^[#]*\s*level-seed=.*/level-seed=pulumi/" /minecraft/server.properties
- systemctl restart minecraft.service
- systemctl enable minecraft.service