-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-minecraft-java
More file actions
53 lines (28 loc) · 1.39 KB
/
setup-minecraft-java
File metadata and controls
53 lines (28 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Credit for a portion of the script goes to [Mincraft-Server-Tutorial](https://www.cherryservers.com/blog/minecraft-server-ubuntu) with some adjustments made by myself
# Prepare system for minecraft server
# Temporarily switch to root
# Create Java Server Home Folder
sudo su << 'EOF'
apt install openjdk-21-jre-headless curl wget grep
# Create a minecraft user
useradd -r -U -d /usr/local/games/minecraft_server/ -s /usr/sbin/nologin minecraft;
# Create Minecraft Java Server Folder
mkdir -p /usr/local/games/minecraft_server/java;
# Set permissions
chown -R minecraft: /usr/local/games/minecraft_server/;
firewall-cmd --permanent --zone=public --add-port 25565/tcp;
firewall-cmd --permanent --zone=public --add-port 25565/udp;
firewall-cmd --reload;
exit
EOF
# Switch to minecraft user and begin installation
sudo su - minecraft -s /bin/bash << 'FOE'
DOWNLOAD_URL=$(curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -s -L -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; JAVA-UPDATER)" https://www.minecraft.net/en-us/download/server | grep -o 'https.*server\.jar');
# Download Minecraft Java
cd /usr/local/games/minecraft_server/java;
wget -U "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; JAVA-UPDATER)" $DOWNLOAD_URL -O ./server.jar;
# Init Java
java -Xmx1024M -Xms1024M -jar ./server.jar nogui &
sed -i 's/\bfalse\b/TRUE/' ./eula.txt;
FOE