Created
July 10, 2019 23:13
-
-
Save philiparola/fb1a63aa64c21d86bf67d7e951afe0fd to your computer and use it in GitHub Desktop.
A barebones Minecraft server run as a service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=start and stop the minecraft-server | |
[Service] | |
WorkingDirectory=/srv/minecraft-server | |
User=minecraft | |
Group=minecraft | |
Restart=on-failure | |
RestartSec=20 5 | |
ExecStart=/usr/bin/screen -DmS minecraft /usr/bin/java -jar -Xms8000M -Xmx10000M server.jar nogui | |
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "say SERVER SHUTTING DOWN IN 15 SECONDS..."\015' | |
ExecStop=/bin/sleep 5 | |
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "say SERVER SHUTTING DOWN IN 10 SECONDS..."\015' | |
ExecStop=/bin/sleep 5 | |
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "say SERVER SHUTTING DOWN IN 5 SECONDS..."\015' | |
ExecStop=/bin/sleep 5 | |
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "save-all"\015' | |
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "stop"\015' | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use ctrl-d + a to exit the screen without closing the server | |
su minecraft | |
# enter password; you know the one | |
screen -r | |
# OR, idk if this works, but the previosu one works if there is only one screen | |
screen -R minecraft | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -jar -Xms2048m -Xmx3072m ./server.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Minecraft server properties | |
#Sun Jul 07 21:23:22 PDT 2019 | |
broadcast-rcon-to-ops=true | |
view-distance=15 | |
max-build-height=256 | |
server-ip= | |
level-seed=-350501890505856 | |
rcon.port=25575 | |
server-port=25565 | |
enable-command-block=true | |
gamemode=survival | |
allow-nether=true | |
enable-rcon=false | |
enable-query=false | |
op-permission-level=4 | |
prevent-proxy-connections=false | |
generator-settings= | |
resource-pack= | |
player-idle-timeout=0 | |
level-name=world | |
rcon.password= | |
motd=Freethinkers only | |
query.port=25565 | |
force-gamemode=false | |
debug=false | |
hardcore=false | |
white-list=true | |
broadcast-console-to-ops=true | |
pvp=true | |
spawn-npcs=true | |
spawn-animals=true | |
generate-structures=true | |
snooper-enabled=true | |
difficulty=easy | |
network-compression-threshold=256 | |
level-type=default | |
max-tick-time=60000 | |
spawn-monsters=true | |
enforce-whitelist=true | |
max-players=10 | |
use-native-transport=true | |
resource-pack-sha1= | |
spawn-protection=0 | |
online-mode=true | |
allow-flight=true | |
max-world-size=29999984 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://minecraft.gamepedia.com/Tutorials/Ubuntu_startup_script | |
sudo adduser --system --home /srv/minecraft-server minecraft | |
sudo addgroup --system minecraft | |
sudo adduser minecraft minecraft # this adds user "minecraft" to the group "minecraft" | |
#sudo chown -R minecraft.minecraft /srv/minecraft-server # This was in the original guide | |
sudo chown -R minecraft:minecraft /srv/minecraft-server | |
sudo cp minecraft-server.service /etc/systemd/system/minecraft-server.service | |
sudo systemctl enable minecraft-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment