Thicket data repository for the EEG
1{
2 "id": "https://www.tunbury.org/2020/04/18/minecraft-java-edition-server-on-ubuntu-18-04",
3 "title": "Minecraft Java Edition Server on Ubuntu 18.04",
4 "link": "https://www.tunbury.org/2020/04/18/minecraft-java-edition-server-on-ubuntu-18-04/",
5 "updated": "2020-04-18T12:41:29",
6 "published": "2020-04-18T12:41:29",
7 "summary": "See How to install a Minecraft Bedrock Server on Ubuntu",
8 "content": "<p>See <a href=\"https://linuxize.com/post/how-to-install-minecraft-server-on-ubuntu-18-04/\">How to install a Minecraft Bedrock Server on Ubuntu</a></p>\n\n<blockquote>\n <p>I’ll note here that this works perfectly, but it doesn’t do what I wanted it to! What I discovered afterwards is that there is Minecraft Java Edition which is the original product but Java Edition only supports cross play with Java Edition endpoints such as a PC or Mac. iPhones/iPad use the newer C++ Edition and there is a new Bedrock Edition server which works across both Java and C++ endpoints.</p>\n</blockquote>\n\n<p>Install Ubuntu 18.04.4 using VMware Fusion. Create a bridged connection to the LAN not the default NAT’ed connection. Allow SSH. Install my SSH key using <code>ssh-copy-id user@192.168.1.127</code></p>\n\n<p>Sign on on the console sudo -Es, then install the essentials</p>\n\n<div><div><pre><code>apt update\napt install git build-essential\napt install openjdk-8-jre-headless\n</code></pre></div></div>\n\n<p>Create, and then switch to a user account</p>\n\n<div><div><pre><code>useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft\nsu - minecraft\n</code></pre></div></div>\n\n<p>Create a folder structure to work with</p>\n\n<div><div><pre><code>mkdir -p ~/{backups,tools,server}\n</code></pre></div></div>\n\n<p>Clone the git repository for the micron tool</p>\n\n<div><div><pre><code>cd ~/tools && git clone https://github.com/Tiiffi/mcrcon.git\n</code></pre></div></div>\n\n<p>Compile it</p>\n\n<div><div><pre><code>cd ~/tools/mcrcon && gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c\n</code></pre></div></div>\n\n<p>Download the JAR file</p>\n\n<div><div><pre><code>wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar -P ~/server\n</code></pre></div></div>\n\n<p>Make an initial run on the server</p>\n\n<div><div><pre><code>cd ~/server\njava -Xmx1024M -Xms512M -jar server.jar nogui\n</code></pre></div></div>\n\n<p>Updated the eula.txt to accept the EULA</p>\n\n<div><div><pre><code>sed -i \"s/false/true/g\" ~/server/eula.txt\n</code></pre></div></div>\n\n<p>Edit <code>server.properties</code> to enable RCON and set the password</p>\n\n<div><div><pre><code>sed -i \"s/enable-rcon=false/enable-rcon=true/g\" ~/server/server.properties\nsed -i \"s/rcon.password=/rcon.password=s3cr3t/g\" ~/server/server.properties\n</code></pre></div></div>\n\n<p>Create a cron job to create backups</p>\n\n<div><div><pre><code>cat > /opt/minecraft/tools/backup.sh <<'EOF'\n#!/bin/bash\n\nfunction rcon {\n/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p s3cr3t \"$1\"\n}\n\nrcon \"save-off\"\nrcon \"save-all\"\ntar -cvpzf /opt/minecraft/backups/server-$(date +%F-%H-%M).tar.gz /opt/minecraft/server\nrcon \"save-on\"\n\n## Delete older backups\nfind /opt/minecraft/backups/ -type f -mtime +7 -name '*.gz' -delete\nEOF\n</code></pre></div></div>\n\n<p>Make it executable</p>\n\n<div><div><pre><code>chmod +x /opt/minecraft/tools/backup.sh\n</code></pre></div></div>\n\n<p>Schedule the backup to run at 3am via CRON using crontab -e</p>\n\n<div><div><pre><code>0 3 * * * /opt/minecraft/tools/backup.sh\n</code></pre></div></div>\n\n<p>As root, create <code>/etc/systemd/system/minecraft.service</code></p>\n\n<div><div><pre><code>cat > /etc/systemd/system/minecraft.service <<'EOF'\n[Unit]\nDescription=Minecraft Server\nAfter=network.target\n\n[Service]\nUser=minecraft\nNice=1\nKillMode=none\nSuccessExitStatus=0 1\nProtectHome=true\nProtectSystem=full\nPrivateDevices=true\nNoNewPrivileges=true\nWorkingDirectory=/opt/minecraft/server\nExecStart=/usr/bin/java -Xmx2048M -Xms1024M -jar server.jar nogui\nExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p s3cr3t stop\n\n[Install]\nWantedBy=multi-user.target\nEOF\n</code></pre></div></div>\n\n<p>Refresh <code>systemd</code>, set the service to start at boot, start the service and check the status:</p>\n\n<div><div><pre><code>sudo systemctl daemon-reload\nsudo systemctl enable minecraft\nsudo systemctl start minecraft\nsudo systemctl status minecraft\n</code></pre></div></div>\n\n<p>Open the firewall port</p>\n\n<div><div><pre><code>sudo ufw allow 25565/tcp\n</code></pre></div></div>\n\n<p>If, down the road, you want to create a new world, just stop the server and delete <code>/opt/minecraft/server/world</code>. Alternatively, edit <code>server.properties</code> and set a new name on <code>level-name=world</code>.</p>",
9 "content_type": "html",
10 "author": {
11 "name": "Mark Elvers",
12 "email": "mark.elvers@tunbury.org",
13 "uri": null
14 },
15 "categories": [
16 "ubuntu",
17 "minecraft"
18 ],
19 "source": "https://www.tunbury.org/atom.xml"
20}