Minecraft Java Edition and Bedrock Dedicated Server (BDS for short) systemd units, bash scripts, and IRC bot for backups, automatic updates, installation, and shutdown warnings
@@@ Compatible with Ubuntu @@@
Ubuntu on Windows 10 does not support systemd (Try my Ubuntu Server 18.04 Setup). You can run the scripts without enabling the systemd units, except for MCBEautoUpdate.sh. No automatic update scripts or IRC bot for Java Edition.
How to attach to the systemd service's tmux session (server console):
sudo su mc -s /bin/bash
# Example: systemctl status mc@$instance
tmux -S "/tmp/tmux-mc/$instance" a
Press Ctrl-B then D to detach from a tmux session. exit
to switch back to previous user.
How to control systemd services:
# Backup Minecraft Java Edition server
sudo systemctl start mc-backup@MC
# Stop Minecraft Java Edition server
sudo systemctl stop mc@MC
Backups are in ~mc by default. systemctl status mc-backup@MC mcbe-backup@MCBE
says the last backup's location. Outdated bedrock-server ZIPs in ~mc will be removed by MCBEgetZIP.sh. MCBEupdate.sh only keeps packs, worlds, JSON files, and PROPERTIES files. Other files will be removed. You cannot enable instances of Java Edition and Bedrock Edition with the same name (mc@example and mcbe@example).
PS4 and Xbox One can only connect on LAN, Nintendo Switch cannot connect at all. Try jhead/phantom to work around this on PS4 and Xbox One. Try ProfessorValko's Bedrock Dedicated Server Tutorial.
Open Terminal:
sudo apt install git tmux wget zip
git clone https://github.com/TapeWerm/MCscripts.git
cd MCscripts
sudo adduser --home /opt/MC --system mc
# I recommend replacing the 1st argument to ln with an external drive to dump backups on
# Example: sudo ln -s $ext_drive ~mc/backup_dir
sudo ln -s ~mc ~mc/backup_dir
Copy and paste this block:
echo set -g default-shell /bin/bash | sudo tee ~mc/.tmux.conf
for file in $(ls *.sh); do sudo cp "$file" ~mc/; done
sudo chown -h mc:nogroup ~mc/*
for file in $(ls systemd); do sudo cp "systemd/$file" /etc/systemd/system/; done
Stop the Minecraft server.
# Move server directory
sudo mv "$server_dir" ~mc/MC
# Open server.jar with no GUI and 1024-2048 MB of RAM
echo java -Xms1024M -Xmx2048M -jar server.jar nogui | sudo tee ~mc/MC/start.bat
Copy and paste this block:
sudo chmod 700 ~mc/MC/start.bat
sudo chown -R mc:nogroup ~mc/MC
sudo systemctl enable [email protected] [email protected] --now
If you want to automatically remove backups more than 2-weeks-old to save storage:
sudo systemctl enable [email protected] --now
Stop the Minecraft server.
# Move server directory or
sudo mv "$server_dir" ~mc/MCBE
# Make new server directory
sudo su mc -s /bin/bash
~/MCBEgetZIP.sh
exit
sudo ~mc/MCBEautoUpdate.sh ~mc/MCBE
Copy and paste this block:
sudo chown -R mc:nogroup ~mc/MCBE
sudo systemctl enable [email protected] [email protected] mcbe-getzip.timer [email protected] --now
If you want to automatically remove backups more than 2-weeks-old to save storage:
sudo systemctl enable [email protected] --now
If you want to post connect/disconnect messages to IRC:
sudo su mc -s /bin/bash
mkdir ~/.MCBE_Bot
Enter nano ~/.MCBE_Bot/MCBE_BotJoin.txt
, fill this in, and write out (^G = Ctrl-G):
JOIN #chan $key
irc.domain.tld:$port
Copy and paste this block:
exit
sudo systemctl enable [email protected] [email protected] --now