-
-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
I have noticed that it sometimes takes a while for you to get back to the script to update it for the new server jar file download, and i wanted to contribute in a small way to help with that. here is a script you are welcome to pull from to auto detect (i think it should work for all future versions) and download the minecraft_server.jar file from the mincraft webiste. I just want to help however I can, so let me know how I can do so.
#!/bin/bash
# Move to user's minecraft installation directory
cd ~/minecraft
# Fetch the webpage content with a user-agent string
page_content=$(curl -s -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" https://www.minecraft.net/en-us/download/server)
# Extract the download link (searching for the specific structure in the <a> tag)
download_link=$(echo "$page_content" | grep -oP '(?<=href=")https://piston-data\.mojang\.com/v1/objects/[a-f0-9]+/server\.jar')
# Extract the version number from the page content (only the first match)
version=$(echo "$page_content" | grep -oP 'minecraft_server\.\K[0-9]+\.[0-9]+\.[0-9]+' | head -1)
# Print the version number and download the .jar file to a directory named after the version number
if [ -n "$download_link" ] && [ -n "$version" ]; then
echo "Minecraft Server Version: $version"
# Create a directory named after the version number
mkdir -p "$version"
# Download the .jar file into the directory
wget -O "$version/minecraft.jar" "$download_link"
#success or failure messages
echo "Downloaded minecraft.jar to $(pwd)/$version/"
else
echo "Download link or version number not found"
fi
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels