Hi everyone!
Just having bought a Raspberry Pi to use as a small Minecraft Forge Server, I am delighted to say DietPi has so far worked really well. I use it in its “headless” configuration, i.e. without a screen and keyboard. Using these instructions to get the Minecraft server up and running, I’ve so far managed to get everything working - mostly. As Linux newbie one thing has alluded me altogether; I can’t get the server script to autostart when rebooting the server. If anyone can point me in the right direction, I’d be most grateful.
Here are the details:
- Trying to keep things as simple as possible, I’m using the dietpi-config tool to setup the autostart using the menu item “9. Autostart Option → 17. Custom script (foreground, with autologin”).
- When editing the autostart-script (stored as the default file name, i.e. “/var/lib/dietpi/dietpi-autostart/custom.sh”), I’m asking dietpi-config to run it as root.
- Here are the contents of the custom.sh script:
cd /opt/minecraft/
screen -dmS Minecraft ./run.sh
Unfortunately, when starting the server the script doesn’t launch. A “screen -ls” check reveals no deattched screen has been started, and running “ps -all” or “htop” shows no Java process (i.e. the Minecraft server) is running.
When launching the script “manually” using sudo in a ssh window (i.e. by changing directory to “/var/lib/dietpi/dietpi-autostart/”, and then typing “sudo ./custom.sh”), the script doesn’t seem to be executed at all; sudo never asks me for my password, and the bash prompt immediately re-appears. No error message is given, like the following output shows:
@foobar:~$ cd /var/lib/dietpi/dietpi-autostart/
8bitkid@foobar:/var/lib/dietpi/dietpi-autostart$ sudo ./custom.sh
8bitkid@foobar:/var/lib/dietpi/dietpi-autostart$
For anyone interested, here are the permissions for custom.sh and /opt/minecraft/run.sh:
-rwxr-xr-x 1 root root 159 1 jan 20.54 /var/lib/dietpi/dietpi-autostart/custom.sh
-rwxr-xr-x 1 root root 365 1 jan 16.00 /opt/minecraft/run.sh
Finally, this is what the Minecraft Forge server script (“run.sh”) looks like:
#!/usr/bin/env sh
# Forge requires a configured set of both JVM and program arguments.
# Add custom JVM arguments to the user_jvm_args.txt
# Add custom program arguments {such as nogui} to this file in the next line before the "$@" or
# pass them to this script directly
java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.18.1-39.0.9/unix_args.txt "$@"
If someone here would be kind enough to review this post and tell me in what way I’ve managed to screw up, I’d very much appreciate it . Thank you very much in advance!