Simple Instructions: 1.3 Setup (MC 1.16.5 or older, Linux, Start Script) - GeheimagentNr1/AutoRestart GitHub Wiki
In this example, we suppose, that you installed the Minecraft server in the directory "/opt/minecraft/servers/Minecraft Server/" and use the Minecraft version 1.16.5 and the Forge version 36.2.23.
First, you create a file named start.sh in the "/opt/minecraft/servers/Minecraft Server/" directory.
Next, you insert the start script into the start.sh file:
#!/bin/bash
cd "<Path of your Minecraft server>" || exit 1
screen -d -m -S <Name of your Screen, i.e. your directory name without spaces> java -Xmx<Amount of RAM in gigabytes you want to allocate to Minecraft>G -jar forge-<Minecraft version>-<Forge version>.jar
In our example we give the Minecraft server 6 GB RAM to use, with the directory "/opt/minecraft/servers/Minecraft Server/", Minecraft version 1.16.5 and Forge version 36.2.23 it would look like this:
#!/bin/bash
cd "/opt/minecraft/servers/Minecraft Server" || exit 1
screen -d -m -S MinecraftServer java -Xmx6G -jar forge-1.16.5-36.2.23.jar
Then you make the script executable, so the server can start it: chmod +x start.sh
If you created the script on Windows, convert it to Linux line endings first: sed -i 's/\r$//' start.sh (see Troubleshooting).
Last, we have to feed the configuration file named auto_restart-server.toml. It is located in the world/serverconfig directory in the installation directory of your server. In our example, is in the directory "/opt/minecraft/servers/Minecraft Server/world/serverconfig".
In the config file, we have to set use_external_restart_script to false and restart_command to "<Path of your Minecraft server>/start.sh".
#Options for restarting:
[restart]
#Is the server started by an external restart script?
use_external_restart_script = false
#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
restart_command = "<Path of your Minecraft server>/start.sh"
In our example, it would look like this:
#Options for restarting:
[restart]
#Is the server started by an external restart script?
use_external_restart_script = false
#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
restart_command = "/opt/minecraft/servers/Minecraft Server/start.sh"
"restart_command" must only contain the path of the script, without any other commands or arguments (i.e. not "bash start.sh" or "start.sh nogui"), because the whole value is used as the name of the program to start.
Now we can start the Minecraft server and the Minecraft server restarts, if you use the /restart command.
After testing that the Minecraft server can restart, we continue configuring the features of the Auto Restart mod, starting with the mod naming Auto Restart feature.
Auto Restart Feature