Skip to content

Instantly share code, notes, and snippets.

@ronoaldo
Last active March 9, 2022 00:54
Show Gist options
  • Save ronoaldo/1b77c452e7ded870d4b82ae5209673dc to your computer and use it in GitHub Desktop.
Save ronoaldo/1b77c452e7ded870d4b82ae5209673dc to your computer and use it in GitHub Desktop.
Using minetest with tmux and systemd
#!/bin/sh
while true ; do
echo "Starting server ..."
minetestserver --terminal
echo "Server crashed/terminated. Restarting ..."
sleep 3
done
[Unit]
Description=Start mercurio Minetest server
After=network.service
[Service]
Type=forking
User=ronoaldo
ExecStart=/usr/bin/tmux new-session -d -s mercurio /home/user/bin/minetest-run.sh
ExecStop=/usr/bin/tmux kill-session -t mercurio
MemoryAccounting=true
MemoryMax=1G
[Install]
WantedBy=multi-user.target
@ronoaldo
Copy link
Author

ronoaldo commented Apr 2, 2021

Add minetest.service do /lib/systemd/system and enable with systemctl enable minetest.

During boot, it will launch the server inside a tmux session and you can attach to it to diagnose or issue server commands from the terminal.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment