Skip to content

Instantly share code, notes, and snippets.

@JemiloII
Last active April 13, 2026 12:15
Show Gist options
  • Select an option

  • Save JemiloII/2dc85f31888df9290328c08471c6607e to your computer and use it in GitHub Desktop.

Select an option

Save JemiloII/2dc85f31888df9290328c08471c6607e to your computer and use it in GitHub Desktop.
Minecraft Linux Start Up

To Run

chmod +x start-minecraft.sh
./start-minecraft.sh
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "================================"
echo "Minecraft Server Setup"
echo "================================"
echo
if ! command -v java >/dev/null 2>&1; then
echo "Java is not installed or not in PATH."
echo "Install Java 21 or later, then run this again."
exit 1
fi
if ! command -v curl >/dev/null 2>&1; then
echo "curl is not installed."
echo "Install curl, then run this again."
exit 1
fi
if ! command -v python3 >/dev/null 2>&1; then
echo "python3 is not installed."
echo "Install python3, then run this again."
exit 1
fi
echo "Downloading latest Minecraft server..."
MANIFEST_URL="https://launchermeta.mojang.com/mc/game/version_manifest.json"
MANIFEST_JSON="$(curl -fsSL "$MANIFEST_URL")"
LATEST_VERSION="$(
printf '%s' "$MANIFEST_JSON" | python3 -c '
import sys, json
data = json.load(sys.stdin)
print(data["latest"]["release"])
'
)"
VERSION_URL="$(
printf '%s' "$MANIFEST_JSON" | python3 -c "
import sys, json
data = json.load(sys.stdin)
target = \"$LATEST_VERSION\"
for version in data[\"versions\"]:
if version[\"id\"] == target:
print(version[\"url\"])
break
"
)"
VERSION_JSON="$(curl -fsSL "$VERSION_URL")"
SERVER_URL="$(
printf '%s' "$VERSION_JSON" | python3 -c '
import sys, json
data = json.load(sys.stdin)
print(data["downloads"]["server"]["url"])
'
)"
curl -fL "$SERVER_URL" -o server.jar
echo "Download complete!"
echo
if [ ! -f "server.properties" ]; then
echo "Creating server.properties..."
cat > server.properties <<'EOF'
server-ip=0.0.0.0
server-port=25565
online-mode=true
max-players=25
level-name=white
gamemode=survival
difficulty=normal
spawn-protection=16
enable-command-block=false
EOF
else
echo "Updating server-ip in existing server.properties..."
if grep -q '^server-ip=' server.properties; then
sed -i 's/^server-ip=.*/server-ip=0.0.0.0/' server.properties
else
printf '\nserver-ip=0.0.0.0\n' >> server.properties
fi
fi
echo
echo "================================"
echo "Starting Minecraft Server"
echo "================================"
echo "Server will be accessible on 0.0.0.0:25565"
echo
cat > eula.txt <<'EOF'
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
eula=true
EOF
if [ ! -s ops.json ]; then
cat > ops.json <<'EOF'
[
{
"uuid": "3936ad41-5295-46f0-8185-0b8a06cffa97",
"name": "ShibikoX",
"level": 4,
"bypassesPlayerLimit": true
}
]
EOF
fi
# 8GB RAM
# java -Xmx8G -Xms4G -jar server.jar nogui
# 12GB RAM
java -Xmx12G -Xms6G -jar server.jar nogui
# 16GB RAM
# java -Xmx16G -Xms8G -jar server.jar nogui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment