Skip to content

Instantly share code, notes, and snippets.

@artheus
Created January 30, 2021 09:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save artheus/170964ea374490e6c5b9ab33c2455f52 to your computer and use it in GitHub Desktop.
Save artheus/170964ea374490e6c5b9ab33c2455f52 to your computer and use it in GitHub Desktop.
Shell script for downloading mods for Curseforge Modpack on Linux clients (using Vanilla Minecraft Launcher)
#!/bin/bash
## Usage:
## 1. Download the modpack zip from CurseForge
## 2. Extract zip to where you want your modpacks game directory to be (e.g. ~/minecraft/modpack/gamedir)
## 3. In terminal, run this script in your chosen game directory
## If successful, it should print out which mods its downloading, until it is done
## 4. Create an "Installation" in the Vanilla Minecraft Launcher
## * Version should be set to the correct modded minecraf version installed (eg. 1.16.4-forge-35.1.13)
## * Make sure you are running the correct java version, and are giving an appropriate amount of RAM
## Check if manifest.json exists, exit if it does not exist
if [ ! -f "manifest.json" ]; then
echo "## No manifest.json found, probably no files to download.."
exit 0
fi
OVERRIDES_DIR=$(cat manifest.json | jq -r .overrides)
if [ ! -z "${OVERRIDES_DIR}" ] && [ "${OVERRIDES_DIR}" != "null" ] && [ -d "./${OVERRIDES_DIR}" ]; then
mv "./${OVERRIDES_DIR}/"* ./
rm -r "./${OVERRIDES_DIR}"
fi
## Function to download mod files from manifest.json
function downloadFile {
if [[ $# != 2 ]]; then
echo "Not enough arguments to download file"
return
fi
## Change to mods directory
cd mods
## Get download url for mod file
MOD_FILE_URL=$(curl -sL "https://addons-ecs.forgesvc.net/api/v2/addon/${1}/file/${2}/download-url")
echo "# Downloading mods/$(basename "$MOD_FILE_URL")"
curl -sSLOJ "$MOD_FILE_URL"
}
## Make downloadFile function accessible for xargs call
export -f downloadFile
# Create mods directory if it does not exist
[ ! -d "mods" ] && mkdir "mods"
# Download all mod files to mods directory
cat manifest.json | \
jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)' | \
xargs -n 1 -P 10 -I {} bash -c 'downloadFile $@' _ {}
@kaptenol
Copy link

kaptenol commented Aug 2, 2022

``

@kaptenol
Copy link

kaptenol commented Aug 2, 2022

Ukir Jepara com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment