ATM10
I recently set up an ATM10 server for my friends and I to play on. I am using this as a place to document some of my set up.
This page assumes you have set up a minecraft user and moved over the ATM10 server files to your server.
Running ATM10 as a Service
Standing up my own ATM10 server was pretty straight forward. Once I got the server moved over to the server all I had to do was run the startserver.sh right?
This option works great when I don't mind having to leave the terminal session open, but what about keeping this server running between reboots?
First I needed to create a service file.
sudo touch /etc/systemd/system/atm.service
Once the file is created adding the correct info to it helps it handle restarts, shutdowns, etc.
sudo vim /etc/systemd/system/atm.service
Add this to the file ensure.
Update paths as needed.
[Unit]
Description=Run ATM server
After=network.target
[Service]
User=minecraft
Group=minecraft
Restart=always
ExecStart=/usr/bin/screen -DmS mc-atm /opt/minecraft/startserver.sh
ExecStop=/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "say SERVER SHUTTING DOWN IN 5 SECONDS. SAVING AL MAPS..."\015'
ExecStop=/bin/sleep 5
ExecStop=/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "save-all"\015'
ExecStop=/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "stop"\015'
[Install]
WantedBy=multi-user.target
What does this do?
This makes it that when your service is stopping it notifies the server that it is shutting down, and then saves the world.
I added this so that outside of an unexpected shutdown the server should maintain its save.
Backing Up the Server
After setting up my server I needed a way to make sure my stuff was backed up.
I followed some scripts I found online and pieced together one that worked for my set up.
This accesses the same screen session created by my service defined above, and allows me to back up the entire server installation.
#!/bin/bash
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "say Server backup process will begin in 5 minutes"\015'
sleep 5m
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "say Server backup process is starting NOW."\015'
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "save-off"\015'
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "save-all"\015'
tar -cvpzf /opt/minecraft/backups/server-$(date +%F_%R).tar.gz /opt/minecraft/atm
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "save-on"\015'
/usr/bin/screen -p 0 -S mc-atm -X eval 'stuff "say Server backup process is complete. Carry on."\015'
## Delete older backups
find /opt/minecraft/backups/ -type f -mtime +7 -name 'server-*.tar.gz' -delete