Skip to content

Commit 6dc9ff1

Browse files
committed
maint: Debian 13 support, English docs, checksum enforcement, systemd hardening
1 parent e3ea5c2 commit 6dc9ff1

7 files changed

Lines changed: 230 additions & 85 deletions

File tree

README.md

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🟩 Minecraft Server on Proxmox – Version 2.0 (updated 2025-10-07)
1+
# Minecraft Server on Proxmox – Version 2.0 (updated 2025-10-07)
22

33
<img title="" src="assets/banner.png" alt="Banner" width="326" data-align="center">
44

@@ -14,30 +14,36 @@
1414

1515
---
1616

17-
## 🔗 Quick Links
18-
- 📜 **Server Commands**: [SERVER_COMMANDS.md](SERVER_COMMANDS.md)
19-
- 🧪 **Simulation guide**: [SIMULATION.md](SIMULATION.md)
20-
- 🌐 **Bedrock Networking**: [docs/BEDROCK_NETWORKING.md](docs/BEDROCK_NETWORKING.md)
21-
- 🤖 **Copilot Workflow**: [.github/copilot-instructions.md](.github/copilot-instructions.md)
22-
- 🐞 **Issues & Feedback**: [Open an issue](../../issues)
17+
## Quick Links
18+
19+
- Server Commands: [SERVER_COMMANDS.md](SERVER_COMMANDS.md)
20+
- Simulation Guide: [SIMULATION.md](SIMULATION.md)
21+
- Bedrock Networking: [docs/BEDROCK_NETWORKING.md](docs/BEDROCK_NETWORKING.md)
22+
- Copilot Workflow: [.github/copilot-instructions.md](.github/copilot-instructions.md)
23+
- Issues & Feedback: [Open an issue](../../issues)
2324

2425
---
2526

26-
## ✅ Requirements
27+
## Requirements
28+
2729
- Proxmox VE: 7.4+ / 8.x / 9.x
28-
- Gast-OS: Debian 12/13 oder Ubuntu 24.04
30+
- Guest OS: Debian 11/12/13 or Ubuntu 24.04
2931
- CPU/RAM: ≥2 vCPU, ≥2–4 GB RAM (Java), ≥1–2 GB (Bedrock)
3032
- Storage: ≥10 GB SSD
31-
- Netzwerk: Bridged NIC (vmbr0), Ports 25565/TCP, 19132/UDP
33+
- Network: Bridged NIC (vmbr0), ports 25565/TCP and 19132/UDP
34+
35+
Java 21 is required. If OpenJDK 21 is missing in your repositories, the installers automatically fall back to Amazon Corretto 21 (APT with signed-by keyring).
3236

3337
---
3438

35-
## 📝 Introduction
36-
Dieses Repo stellt in Minuten einen performanten Minecraft-Server (Java & Bedrock) auf Proxmox bereit. VM und LXC werden unterstützt. CLI-First Setup, Update-Skript, Backup-Beispiele.
39+
## Introduction
40+
41+
This repository provisions a performant Minecraft server (Java & Bedrock) on Proxmox in minutes. VM and LXC are supported. CLI-first setup, updater, and backup examples are provided.
42+
43+
> Simulation only: Do not execute commands in this workspace. See SIMULATION.md.
3744
38-
> Simulation only: Keine Ausführung hier. Siehe **SIMULATION.md**.
45+
## Technologies & Dependencies
3946

40-
## 🧩 Technologies & Dependencies
4147
![Proxmox](https://img.shields.io/badge/Proxmox-VE-EE7F2D?logo=proxmox&logoColor=white)
4248
![Debian](https://img.shields.io/badge/Debian-11%20%2F%2012%20%2F%2013-A81D33?logo=debian&logoColor=white)
4349
![Ubuntu](https://img.shields.io/badge/Ubuntu-24.04-E95420?logo=ubuntu&logoColor=white)
@@ -47,20 +53,22 @@ Dieses Repo stellt in Minuten einen performanten Minecraft-Server (Java & Bedroc
4753
![Systemd](https://img.shields.io/badge/systemd-%E2%9C%94-FFDD00?logo=linux&logoColor=black)
4854
![Screen](https://img.shields.io/badge/screen-%E2%9C%94-0077C2?logo=gnu&logoColor=white)
4955

50-
## 📊 Status
51-
Stabil. LXC/VM getestet. Bedrock Update manuell.
56+
## Status
5257

53-
## 🚀 Quickstart
58+
Stable. VM and LXC tested. Bedrock updates remain manual.
59+
60+
## Quickstart
5461

5562
### VM (DHCP)
63+
5664
```bash
5765
wget https://raw.githubusercontent.com/TimInTech/minecraft-server-Proxmox/main/setup_minecraft.sh
5866
chmod +x setup_minecraft.sh
5967
./setup_minecraft.sh
6068
sudo -u minecraft screen -r minecraft
61-
````
69+
```
6270

63-
> Debian 12/13: `/run/screen` mit `root:utmp` und `0775` (siehe unten).
71+
> Debian 11/12/13: Ensure `/run/screen` exists with `root:utmp` and mode `0775` (see below).
6472
6573
### VM (Static IP)
6674

@@ -95,7 +103,7 @@ chmod +x setup_bedrock.sh
95103
sudo -u minecraft screen -r bedrock
96104
```
97105

98-
## 🗃️ Backups
106+
## Backups
99107

100108
### Option A: systemd
101109

@@ -141,34 +149,35 @@ crontab -e
141149
45 3 * * * tar -czf /var/backups/minecraft/bedrock-$(date +\%F).tar.gz /opt/minecraft-bedrock
142150
```
143151

144-
## ♻️ Auto-Update
152+
## Auto-Update (Java)
145153

146154
```bash
147155
cd /opt/minecraft && ./update.sh
148156
crontab -e
149157
0 4 * * 0 /opt/minecraft/update.sh >> /var/log/minecraft-update.log 2>&1
150158
```
151159

152-
> Bedrock erfordert manuellen Download. `setup_bedrock.sh` erzwingt SHA256 (siehe unten).
160+
> Bedrock requires a manual download. `setup_bedrock.sh` enforces SHA256 by default (see below).
153161
154-
## ⚙️ Configuration
162+
## Configuration
155163

156164
### JVM memory (Java)
157165

158-
Installer setzt `Xms ≈ RAM/4`, `Xmx ≈ RAM/2` mit Floors `256M/448M`. Override in `/opt/minecraft/start.sh`.
166+
The installer sets `Xms ≈ RAM/4` and `Xmx ≈ RAM/2` with floors `256M/448M` and an `Xmx` cap of `≤16G`. Override in `/opt/minecraft/start.sh`.
159167

160-
## 🧾 Integrity & Firewall
168+
## Integrity & Firewall
161169

162170
**Java (PaperMC):**
163171

164-
* Paper-Download mit **SHA256-Verifikation** im Installer/Updater.
165-
* Mindestgröße `server.jar > 5 MB` als HTML-Fehlschutz.
172+
- Paper download is verified via **SHA256** in installer/updater.
173+
- Minimum size `server.jar > 5 MB` to avoid saving HTML error pages.
166174

167175
**Bedrock:**
168176

169-
* Standard: `REQUIRE_BEDROCK_SHA=1`. Setze `REQUIRED_BEDROCK_SHA256=<sha>`. Override möglich mit `REQUIRE_BEDROCK_SHA=0`.
177+
- Default: `REQUIRE_BEDROCK_SHA=1`. Set `REQUIRED_BEDROCK_SHA256=<sha>`. Override with `REQUIRE_BEDROCK_SHA=0`.
178+
- The installer validates MIME type via HTTP HEAD (application/zip|octet-stream), checks size, and tests the ZIP via `unzip -tq` before extracting.
170179

171-
**screen Socket (Debian 12/13):**
180+
**screen socket (Debian 11/12/13):**
172181

173182
```bash
174183
sudo install -d -m 0775 -o root -g utmp /run/screen
@@ -185,25 +194,27 @@ sudo ufw allow 19132/udp
185194
sudo ufw enable
186195
```
187196

188-
## 🕹️ Admin/Commands
197+
## Admin/Commands
198+
199+
See **[SERVER_COMMANDS.md](SERVER_COMMANDS.md)**.
189200

190-
Siehe **[SERVER_COMMANDS.md](SERVER_COMMANDS.md)**.
201+
## Troubleshooting
191202

192-
## 🔧 Troubleshooting
203+
- Not enough RAM in LXC → reduce values in `start.sh`.
204+
- Missing `/run/screen` → follow the "screen socket" section above.
205+
- Bedrock ZIP MIME-Type issue → revisit the Mojang download page.
193206

194-
* Zu wenig RAM in LXC → `start.sh` Werte reduzieren.
195-
* Kein `/run/screen` → Abschnitt „screen Socket“ ausführen.
196-
* Bedrock-ZIP MIME-Type Fehler → Mojang-Seite erneut prüfen.
207+
## Contributing
197208

198-
## 🤝 Contributing
209+
Use the PR template. Do not execute anything in this workspace. See **[.github/copilot-instructions.md](.github/copilot-instructions.md)**.
199210

200-
PR-Vorlage nutzen. Keine Ausführung in diesem Workspace. Siehe **[.github/copilot-instructions.md](.github/copilot-instructions.md)**.
211+
For safe simulation workflow details, see **[SIMULATION.md](SIMULATION.md)**.
201212

202-
## 📚 References
213+
## References
203214

204-
* PaperMC: [https://papermc.io/](https://papermc.io/)
205-
* Proxmox Wiki: [https://pve.proxmox.com/wiki/Main_Page](https://pve.proxmox.com/wiki/Main_Page)
206-
* Mojang Bedrock Server: [https://www.minecraft.net/en-us/download/server/bedrock](https://www.minecraft.net/en-us/download/server/bedrock)
215+
- PaperMC: [https://papermc.io/](https://papermc.io/)
216+
- Proxmox Wiki: [https://pve.proxmox.com/wiki/Main_Page](https://pve.proxmox.com/wiki/Main_Page)
217+
- Mojang Bedrock Server: [https://www.minecraft.net/en-us/download/server/bedrock](https://www.minecraft.net/en-us/download/server/bedrock)
207218

208219
## License
209220

SIMULATION.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ The descriptions below explain the side effects, created files, and expected out
3535
Installs a PaperMC-based Java server under /opt/minecraft.
3636

3737
- Packages: apt update/upgrade, installs screen, wget, curl, jq, unzip.
38-
- Java: attempts OpenJDK 21; if unavailable, falls back to OpenJDK 17 (headless).
38+
- Java: attempts OpenJDK 21; if unavailable, falls back to Amazon Corretto 21 via APT keyring.
3939
- Filesystem: creates /opt/minecraft owned by the invoking user; changes into that directory.
40-
- Download: queries PaperMC API via curl+jq to get LATEST_VERSION and LATEST_BUILD; downloads server.jar accordingly.
40+
- Download: queries PaperMC API via curl+jq to get LATEST_VERSION and LATEST_BUILD; downloads server.jar accordingly with SHA256 verification and minimum size >5MB.
4141
- EULA: writes eula.txt with eula=true.
42-
- Start script: creates start.sh (java -Xms2G -Xmx4G -jar server.jar nogui) and marks it executable.
42+
- Start script: creates start.sh with auto-sized memory (Xms≈RAM/4, Xmx≈RAM/2; floors 256M/448M; cap ≤16G) and marks it executable.
4343
- Update script: writes update.sh to refresh server.jar to latest build; marks it executable.
4444
- Runtime: starts the server in a detached GNU screen session named minecraft.
4545

@@ -64,8 +64,8 @@ Idempotency:
6464
Similar to the VM installer but uses apt without sudo (typical for privileged containers) and does not write an update.sh. It:
6565

6666
- Updates packages, installs screen, wget, curl, jq, unzip.
67-
- Installs OpenJDK 21 or falls back to 17.
68-
- Sets up /opt/minecraft, downloads latest PaperMC server.jar.
67+
- Installs OpenJDK 21 or falls back to Amazon Corretto 21 via APT keyring.
68+
- Sets up /opt/minecraft, downloads latest PaperMC server.jar with SHA256 verification and minimum size >5MB.
6969
- Accepts EULA and creates start.sh.
7070
- Starts screen session minecraft.
7171

@@ -84,8 +84,8 @@ Installs a Bedrock server under /opt/minecraft-bedrock.
8484

8585
- Packages: installs unzip, wget, screen, curl (with sudo).
8686
- Filesystem: creates /opt/minecraft-bedrock and assigns to invoking user.
87-
- Download: parses Mojang download page for the latest linux ZIP (azureedge) and downloads it.
88-
- Validation: tests the ZIP with unzip -tq before extracting; extracts contents and removes ZIP.
87+
- Download: parses Mojang download page for the latest linux ZIP and downloads it after validating Content-Type via HTTP HEAD.
88+
- Validation: prints archive SHA256, enforces REQUIRED_BEDROCK_SHA256 by default (override with REQUIRE_BEDROCK_SHA=0), tests the ZIP with unzip -tq before extracting; extracts contents and removes ZIP.
8989
- Start script: creates start.sh to run LD_LIBRARY_PATH=. ./bedrock_server.
9090
- Runtime: starts a screen session bedrock running start.sh.
9191

@@ -104,22 +104,22 @@ Failure points:
104104
Updates PaperMC server.jar to the latest available build.
105105

106106
- Assumes /opt/minecraft as working dir.
107-
- Uses curl+jq to resolve latest version/build; downloads new server.jar.
107+
- Uses curl+jq to resolve latest version/build; downloads new server.jar with SHA256 verification and minimum size >5MB.
108108
- Does not stop the server; best practice is to stop the server, back up, then update.
109109

110110
Safe update flow (suggested): stop server (screen -S minecraft -X stuff 'stop\n'), back up /opt/minecraft, run update.sh, then start start.sh again.
111111

112112
### minecraft.service (Optional systemd unit – Java)
113113

114-
Defines a simple systemd service to run /opt/minecraft/start.sh as root at boot.
114+
Defines a hardened systemd service to run /opt/minecraft/start.sh as the minecraft user at boot.
115115

116-
- User=root, WorkingDirectory=/opt/minecraft, ExecStart=/opt/minecraft/start.sh.
116+
- User=minecraft, Group=minecraft, WorkingDirectory=/opt/minecraft, ExecStart=/opt/minecraft/start.sh.
117117
- Installation (example, do not execute here):
118118
- sudo cp minecraft.service /etc/systemd/system/minecraft.service
119119
- sudo systemctl daemon-reload
120120
- sudo systemctl enable --now minecraft
121121

122-
Consider customizing User to a non-root service account and hardening with systemd options (ProtectSystem, PrivateTmp, etc.).
122+
Includes hardening (NoNewPrivileges, ProtectSystem=full, PrivateTmp, etc.) and limits writes to /opt/minecraft only.
123123

124124
### bedrock_helper.sh
125125

@@ -152,6 +152,7 @@ In this workspace:
152152

153153
## Integrity & Firewall
154154

155-
> Integrity: Java downloads are SHA256-verified via PaperMC API.
156-
> Bedrock has no official checksum; the installer prints the archive’s SHA256.
157-
> Enforce a known value by exporting `REQUIRED_BEDROCK_SHA256=<sha256>` before running `setup_bedrock.sh`.
155+
> Integrity: Java downloads are SHA256-verified via PaperMC API with a minimum-size safeguard.
156+
> Bedrock checksum is enforced by default. Export `REQUIRED_BEDROCK_SHA256=<sha256>` or set `REQUIRE_BEDROCK_SHA=0` to override.
157+
158+
For Debian 12/13, ensure `/run/screen` exists with `root:utmp` and `0775`. You can persist it via systemd-tmpfiles.

minecraft.service

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ After=network.target
66
User=minecraft
77
Group=minecraft
88
WorkingDirectory=/opt/minecraft
9-
ExecStart=/usr/bin/bash /opt/minecraft/start.sh
9+
ExecStart=/opt/minecraft/start.sh
1010
Restart=on-failure
1111
UMask=0027
1212

13+
# NOTE: Systemd hardening options to reduce attack surface
1314
NoNewPrivileges=true
1415
ProtectSystem=full
1516
ProtectHome=true
@@ -23,5 +24,8 @@ CapabilityBoundingSet=
2324
AmbientCapabilities=
2425
ReadWritePaths=/opt/minecraft
2526

27+
# Optional: set RETAIN_DAYS via Environment or drop-in. Example cleanup after start:
28+
#ExecStartPost=/bin/bash -lc 'BACKUP_DIR=${BACKUP_DIR:-/var/backups/minecraft}; mkdir -p "$BACKUP_DIR"; find "$BACKUP_DIR" -type f -name "*.tar.gz" -mtime +"${RETAIN_DAYS:-7}" -delete'
29+
2630
[Install]
2731
WantedBy=multi-user.target

setup_bedrock.sh

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,75 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3+
34
apt update
45
apt install -y unzip wget screen curl ca-certificates
6+
57
if ! id -u minecraft >/dev/null 2>&1; then useradd -r -m -s /bin/bash minecraft; fi
68
mkdir -p /opt/minecraft-bedrock
79
chown -R minecraft:minecraft /opt/minecraft-bedrock
810
cd /opt/minecraft-bedrock
9-
HTML="$(curl -fsSL https://www.minecraft.net/en-us/download/server/bedrock)"
10-
LATEST_URL="$(printf '%s' "$HTML" | grep -Eo 'https://www\.minecraft\.net/bedrockdedicatedserver/bin-linux/bedrock-server-[0-9.]+\.zip' | head -1)"
11-
if [[ -z "${LATEST_URL:-}" ]]; then echo "ERROR: Could not find Bedrock server URL"; exit 1; fi
12-
curl -fsSI "$LATEST_URL" | grep -iqE '^content-type:\s*application/zip' || { echo "ERROR: unexpected content-type"; exit 1; }
11+
12+
# Scrape Mojang page for the latest Linux ZIP link
13+
HTML=$(curl -fsSL "https://www.minecraft.net/en-us/download/server/bedrock")
14+
LATEST_URL=$(printf '%s' "$HTML" | grep -Eo 'https://www\.minecraft\.net/bedrockdedicatedserver/bin-linux/bedrock-server-[0-9.]+\.zip' | head -1)
15+
if [[ -z "${LATEST_URL:-}" ]]; then
16+
echo "ERROR: Could not find Bedrock server URL on Mojang page" >&2
17+
exit 1
18+
fi
19+
20+
# HEAD check for MIME type and optional size
21+
if ! curl -fsSI "$LATEST_URL" | grep -iqE '^content-type:\s*(application/zip|application/octet-stream)'; then
22+
echo "ERROR: Unexpected Content-Type for Bedrock ZIP (must be application/zip or octet-stream)" >&2
23+
exit 1
24+
fi
1325
echo "Downloading: $LATEST_URL"
14-
wget -O bedrock-server.zip "$LATEST_URL"
15-
ACTUAL_SHA="$(sha256sum bedrock-server.zip | awk '{print $1}')"
26+
curl -fL --retry 3 --retry-delay 2 -o bedrock-server.zip "$LATEST_URL"
27+
zip_size=$(stat -c '%s' bedrock-server.zip)
28+
if (( zip_size < 1048576 )); then # 1MB sanity check
29+
echo "ERROR: Downloaded bedrock-server.zip is too small (${zip_size} bytes)." >&2
30+
exit 1
31+
fi
32+
33+
ACTUAL_SHA=$(sha256sum bedrock-server.zip | awk '{print $1}')
1634
echo "bedrock-server.zip sha256: ${ACTUAL_SHA}"
35+
36+
# NOTE: Enforce checksum by default; require REQUIRED_BEDROCK_SHA256 when REQUIRE_BEDROCK_SHA=1
1737
if [[ "${REQUIRE_BEDROCK_SHA:=1}" = "1" ]]; then
1838
if [[ -z "${REQUIRED_BEDROCK_SHA256:-}" ]]; then
19-
echo "ERROR: Set REQUIRED_BEDROCK_SHA256 to a known-good value (export REQUIRED_BEDROCK_SHA256=<sha>)"
39+
echo "ERROR: Set REQUIRED_BEDROCK_SHA256 to a known-good value (export REQUIRED_BEDROCK_SHA256=<sha>)" >&2
2040
exit 1
2141
fi
2242
if [[ "${ACTUAL_SHA}" != "${REQUIRED_BEDROCK_SHA256}" ]]; then
23-
echo "ERROR: SHA256 mismatch (expected ${REQUIRED_BEDROCK_SHA256}, got ${ACTUAL_SHA})"
43+
echo "ERROR: SHA256 mismatch (expected ${REQUIRED_BEDROCK_SHA256}, got ${ACTUAL_SHA})" >&2
2444
exit 1
2545
fi
2646
fi
47+
48+
# Test and extract the archive
2749
unzip -tq bedrock-server.zip >/dev/null
2850
unzip -o bedrock-server.zip && rm -f bedrock-server.zip
29-
[[ -x bedrock_server || -f bedrock_server ]] || { echo "ERROR: bedrock_server missing"; exit 1; }
51+
52+
if [[ ! -f bedrock_server ]]; then
53+
echo "ERROR: bedrock_server binary missing after extraction" >&2
54+
exit 1
55+
fi
56+
3057
cat > start.sh <<'E2'
3158
#!/usr/bin/env bash
3259
exec env LD_LIBRARY_PATH=. ./bedrock_server
3360
E2
3461
chmod +x start.sh
62+
3563
chown -R minecraft:minecraft /opt/minecraft-bedrock
36-
install -d -m 775 -o root -g utmp /run/screen || true
64+
65+
# Ensure screen runtime directory exists with correct ownership and mode
66+
# NOTE: Required on Debian 12/13 so screen can create sockets.
67+
install -d -m 0775 -o root -g utmp /run/screen || true
68+
3769
if command -v runuser >/dev/null 2>&1; then
3870
runuser -u minecraft -- bash -lc 'cd /opt/minecraft-bedrock && screen -dmS bedrock ./start.sh'
3971
else
4072
su -s /bin/bash -c 'cd /opt/minecraft-bedrock && screen -dmS bedrock ./start.sh' minecraft
4173
fi
74+
4275
echo "✅ Setup complete. Attach: screen -r bedrock"

0 commit comments

Comments
 (0)