Light python script to create a Java Edition Minecraft Server
I have been using How to Make Minecraft Server on Ubuntu 20.04 to make a solid Minecraft server. This also works for Ubuntu 22.04. I am essentially breaking up this instructions into a python script to automate the process. I will then test it out in an Ubuntu 22.04 VM to ensure it works properly.
I initially crated bash scripts to automate the process. minecraft-install.sh is the script that can also be run to automate the process as well.
- git
- build-essentials
- openjdk-21(or latest version)
- mcrcon repository:
https://github.com/Tiiffi/mcrcon.git
- Optional: UFW Firewall to set firewall rules
- Ensure
sed
is installed - Inquirer and subprocess for the python script
- Run the script with
sudo python3 mc-installer.py
- Enter the password for mcrcon when prompted
- Paste in the link to the Minecraft Jar file.
- When installation is complete, run the following to verify that everything worked:
sudo systemctl status minecraft
- Run the script with
sudo python3 mc-installer.py
- Select
Uninstall
- Enter the name of the minecraft server. If the default was left during installation, leave the default name during this process.
- Set
minecraft-install.sh
to an executable. It will set all necessary files as executable:chmod +x File-Name
- Run
./minecraft-install.sh
- The
minecraft-install.sh
will perform the following:- Edit the eula.txt file:
eula=true
- Update the
server.properties
rcon.port=25575
- Prompt you to set the
rcon.password
enable-rcon=true
- Add the minecraft.service file to the directory:
/etc/systemd/system
- Reload the daemon:
daemon-reload
- Start the service:
sudo systemctl start minecraft
- Enable service to start after rebooting:
sudo systemctl enable minecraft
- Create script to backup the server file
- Edit the eula.txt file:
- Accessing the console
/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p strong-password -t