
Not too long ago I bought a Raspberry Pi 4B 8Gb and successfully set up PLEX Media Server, using a SATA expansion board.. In an effort to expand my own knowledge, I decided to see if I could add a private Minecraft server for the fun of it, and because my niece and nephew will think I'm a cool uncle.
Steps I've Completed
- Swapped Raspberry PiOS for Ubuntu Server 21.04 so Java can take advantage of the entire bus width(64-bit versus 32-bit).
- Installed Liberica's Java 16 JDK in preparation for Minecraft.
- Set up a LEMP server(replaced Apache with NGINX) to make sure the LAN was properly set up.
- Found the PineCraft Installer, so I could automate the steps.
- The installer script completed successfully, with the following Caveats.
Caveats
- The installer creates init files. Ubuntu uses systemd
- The server is run as
$user
which requires a$password
, or the use ofsudo
, which I don't want to have to do every time
I Need Help Here
I've taken the .service
file from Setting up a Minecraft server using Systemd, and turned it into this:
[Unit]
Description=Minecraft Server Pinecraft SysV init script conversion attempt
Documentation=https://github.com/Cat5TV/pinecraft
Wants=network.target
After=network.target
[Service]
User=minecraft
Group=minecraft
Nice=5
KillMode=none
SuccessExitStatus=0 1
#ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
InaccessiblePaths=/root /sys /srv -/opt /media -/lost+found
ReadWritePaths=/home/minecraft
WorkingDirectory=/home/minecraft
ExecStartPre=/usr/bin/screen -dmS PineCraft
ExecStart=/bin/bash /home/minecraft/server.sh
ExecStop=/bin/bash /home/minecraft/stop.sh
Restart=/bin/bash /home/minecraft/reboot.sh
[Install]
WantedBy=multi-user.target
- Ich kann nicht herausfinden, wie ich das Skriptergebnis an den Bildschirm „übergebe“.
- Der Bildschirm ist möglicherweise immer leer, da der Dienststatus „Aktiv geladen/beenden“ anzeigt. Ich gehe davon aus, dass das
server.sh
Skript abgeschlossen ist, aber nicht geladen/ausgeführt bleibt - Wenn ich die Java-Zeile mit Aiker-Argumenten außerhalb des Skripts ausführe, startet der Server ohne Fehler
Siehe den Create the Scripts
Abschnitt, etwa 3/4 des Weges nach untenInstallationsskript. Ich habe immer nur eine .service
Datei aus einem Paket/Paketmanager installiert. Ich musste nie eine schreiben.
Aktualisieren
Teilweise gelöst: Dieses Setup verwendet den folgenden Cron-Job:
crontab -u ubuntu -l
@reboot /usr/bin/screen -dmS Pinecraft /home/ubuntu/minecraft/server > /dev/null 2>&1
server
ist der Name des Shell-Skripts, bevor ich es für meinen Testdienst umbenannt habe. Offenbar wird Cron bei einer Neuinstallation standardmäßig nicht ausgeführt und systemctl | grep cron
hat nichts zurückgegeben. sudo systemctl enable cron && sudo systemctl start cron
Das Problem wurde einfach behoben.
Ich lasse das noch offen, da ich dies in einen nativen systemd-Dienst umwandeln möchte