Skip to content

admsteck/MCscripts

 
 

Repository files navigation

Description

Minecraft Java Edition and Bedrock Dedicated Server (BDS for short) systemd units, bash scripts, and chat bots 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 MCgetJAR.sh, MCBEgetZIP.sh, and MCBEupdate.sh without enabling the systemd units, but no others. No automatic update scripts or chat bots for Java Edition.

Notes

How to send input to and read output from the server console:

# Send input to server console
sudo su mc -s /bin/bash -c "echo $input > /run/$service"
# Read output from server console
systemctl status $service
# Bedrock Dedicated Server example
sudo su mc -s /bin/bash -c "echo save query > /run/mcbe@MCBE"
systemctl status mcbe@MCBE

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.

Setup

Open Terminal:

sudo apt install git 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:

sudo cp -v *.sh ~mc/
sudo chown -h mc:nogroup ~mc/*
sudo cp -v systemd/* /etc/systemd/system/

Java Edition setup

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

Bedrock Edition setup

Stop the Minecraft server.

# Move server directory or
sudo mv "$server_dir" ~mc/MCBE
# Make new server directory
sudo su mc -s /bin/bash -c '~/MCBEgetZIP.sh'
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

Bedrock Edition IRC bot setup

If you want to post connect/disconnect messages to IRC:

sudo su mc -s /bin/bash
mkdir -p ~/.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

Bedrock Edition webhook bots setup

If you want to post connect/disconnect messages to webhooks (Discord and Rocket Chat):

sudo su mc -s /bin/bash
mkdir -p ~/.MCBE_Bot

Enter nano ~/.MCBE_Bot/MCBE_BotWebhook.txt, fill this in, and write out (^G = Ctrl-G):

$url
$url
...

Copy and paste this block:

exit
sudo systemctl enable [email protected] --now

About

Minecraft Java Edition and Bedrock Dedicated Server systemd units, bash scripts, and chat bots for backups, automatic updates, installation, and shutdown warnings

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%