94 lines
3.3 KiB
Bash
Executable file
94 lines
3.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
## Dependencies (arch/debian package names, may differ elsewhere):
|
|
## bash, coreutils (dirname, mkdir, rm, cp), git, zip, findutils (find), curl, wget, jq
|
|
check_dep() {
|
|
if ! [ -x "$(command -v $1)" ]; then
|
|
echo "You need to install ${2:-$1}"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_dep dirname coreutils
|
|
check_dep git
|
|
check_dep zip
|
|
check_dep find findutils
|
|
check_dep curl
|
|
check_dep wget
|
|
check_dep jq
|
|
|
|
# Navigate to main modpack project directory
|
|
cd "$(dirname "$0")"
|
|
basedir="$PWD"
|
|
|
|
# Location for downloading/updating the mc_rebalance mod
|
|
if [ ! -d deps ]; then
|
|
mkdir deps
|
|
fi
|
|
|
|
# Location for saving the mc_rebalance mod
|
|
if [ ! -d overrides/mods ]; then
|
|
mkdir -p overrides/mods
|
|
fi
|
|
|
|
# Location for saving all other mods
|
|
rm -rf deps/mods
|
|
mkdir -p deps/mods
|
|
|
|
# Clone the mod repo, if it already exists then update it
|
|
echo "# Cloning/updating MC Rebalance mod"
|
|
git clone --single-branch --branch 1.21 "https://patience.nearmisses.xyz/patience/mc_rebalance.git" "${basedir}/deps/mc_rebalance" 2> /dev/null || \
|
|
(cd "${basedir}/deps/mc_rebalance"; git pull > /dev/null)
|
|
|
|
# Compile the mod
|
|
echo "# Compiling MC Rebalance mod"
|
|
rm -f "${basedir}/deps/mc_rebalance/build/libs/mc_rebalance-"*".jar"
|
|
(cd "${basedir}/deps/mc_rebalance/" && ./gradlew build > /dev/null)
|
|
|
|
# Clean up old mod files
|
|
rm -f "${basedir}/overrides/mods/mc_rebalance-"*".jar"
|
|
cp "$(find "${basedir}/deps/mc_rebalance/build/libs" -regex "${basedir}/deps\/mc_rebalance\/build\/libs\/mc_rebalance-[0-9\.]+\.jar")" "${basedir}/overrides/mods"
|
|
|
|
# Generate language files
|
|
(cd "$basedir/overrides/resources/common/required/mc_rebalance_datapack/assets/minecraft/lang/" && ./gen-langs.sh)
|
|
|
|
# Final path for the modpack
|
|
if [ ! -d release ]; then
|
|
mkdir release
|
|
fi
|
|
|
|
# Get version from the mrpack file
|
|
version="$(jq -r ".versionId" modrinth.index.json)"
|
|
version="${version:-dev}"
|
|
|
|
# Download fabric server
|
|
if [ ! -e "${basedir}/deps/fabric-server.jar" ]; then
|
|
echo "# Downloading fabric server"
|
|
(cd deps && curl --silent --output fabric-server.jar https://meta.fabricmc.net/v2/versions/loader/1.21.1/0.19.2/1.1.1/server/jar)
|
|
fi
|
|
|
|
# Download all mods
|
|
echo "# Downloading mods from modrinth.index.json for modpack"
|
|
(cd deps/mods && wget --quiet --input-file <(jq -r '.files[] | select(.env.server=="required") | .downloads[]' ../../modrinth.index.json))
|
|
|
|
# Export client release to file
|
|
echo "# Zipping client modpack"
|
|
zip --filesync --recurse-paths --quiet "${basedir}/release/MC_Rebalance_${version}.mrpack" overrides modrinth.index.json -x "*.git*" -x "*.sh"
|
|
|
|
# Export server release to file
|
|
echo "# Zipping server modpack"
|
|
if [ -e "${basedir}/release/MC_Rebalance_${version}_server.zip" ]; then
|
|
rm -rf "${basedir}/release/MC_Rebalance_${version}_server.zip"
|
|
fi
|
|
(cd deps && zip --recurse-paths --quiet "${basedir}/release/MC_Rebalance_${version}_server.zip" mods fabric-server.jar)
|
|
(cd server-files && zip --recurse-paths --quiet "${basedir}/release/MC_Rebalance_${version}_server.zip" .)
|
|
(cd overrides && zip --recurse-paths --quiet "${basedir}/release/MC_Rebalance_${version}_server.zip" . -x "*.git*" -x "*.sh")
|
|
|
|
echo
|
|
if [ $? -eq 0 ]; then
|
|
echo "Successfully exported the server modpack to ${basedir}/release/MC_Rebalance_${version}_server.zip"
|
|
echo "Successfully exported the client modpack to ${basedir}/release/MC_Rebalance_${version}.mrpack"
|
|
else
|
|
echo "An unknown error occured while zipping the pack"
|
|
fi
|