2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-02-08 13:11:01 +00:00
|
|
|
# CURSE_URL_BASE used in manifest downloads below
|
|
|
|
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
|
|
|
|
|
2018-10-12 22:11:57 +00:00
|
|
|
# Remove old mods/plugins
|
|
|
|
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
|
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
rm -rf /data/plugins/*
|
|
|
|
else
|
|
|
|
rm -rf /data/mods/*
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
|
|
|
if [[ "$MODPACK" ]]; then
|
|
|
|
case "X$MODPACK" in
|
|
|
|
X[Hh][Tt][Tt][Pp]*.zip)
|
|
|
|
echo "Downloading mod/plugin pack via HTTP"
|
|
|
|
echo " from $MODPACK ..."
|
|
|
|
if ! curl -sSL -o /tmp/modpack.zip "$MODPACK"; then
|
|
|
|
echo "ERROR: failed to download from $MODPACK"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
mkdir -p /data/plugins
|
|
|
|
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
|
|
|
echo "ERROR: failed to unzip the modpack from $MODPACK"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
mkdir -p /data/mods
|
|
|
|
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
|
|
|
echo "ERROR: failed to unzip the modpack from $MODPACK"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rm -f /tmp/modpack.zip
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2018-10-12 22:11:57 +00:00
|
|
|
# If supplied with a URL for a plugin download it.
|
|
|
|
if [[ "$MODS" ]]; then
|
|
|
|
for i in ${MODS//,/ }
|
|
|
|
do
|
|
|
|
case "X$i" in
|
|
|
|
X[Hh][Tt][Tt][Pp]*.jar)
|
|
|
|
echo "Downloading mod/plugin via HTTP"
|
|
|
|
echo " from $i ..."
|
|
|
|
if ! curl -sSL -o /tmp/${i##*/} $i; then
|
|
|
|
echo "ERROR: failed to download from $i to /tmp/${i##*/}"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
mkdir -p /data/plugins
|
|
|
|
mv /tmp/${i##*/} /data/plugins/${i##*/}
|
|
|
|
else
|
|
|
|
mkdir -p /data/mods
|
|
|
|
mv /tmp/${i##*/} /data/mods/${i##*/}
|
|
|
|
fi
|
|
|
|
rm -f /tmp/${i##*/}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a JAR file"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2019-02-08 13:11:01 +00:00
|
|
|
if [[ "$MANIFEST" ]]; then
|
|
|
|
case "X$MANIFEST" in
|
|
|
|
X*.json)
|
|
|
|
if [ -f "${MANIFEST}" ]; then
|
2019-02-08 16:31:40 +00:00
|
|
|
MOD_DIR=${FTB_BASE_DIR:-/data/mods}
|
|
|
|
echo "Starting manifest download..."
|
|
|
|
cat "${MANIFEST}" | jq -r '$.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f
|
2019-02-08 13:11:01 +00:00
|
|
|
do
|
2019-02-08 16:31:40 +00:00
|
|
|
if [ ! -f $MOD_DIR/${p}_${f}.jar ]
|
|
|
|
then
|
|
|
|
url="${CURSE_URL_BASE}/${p}/files/${f}/download"
|
|
|
|
echo Downloading curseforge mod $url
|
|
|
|
# Manifest usually doesn't have mod names. Using id should be fine, tho
|
|
|
|
curl -sSL "${url}" -o $MOD_DIR/${p}_${f}.jar
|
|
|
|
fi
|
2019-02-08 13:11:01 +00:00
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "Could not find manifest file, unsufficient privs, or malformed path."
|
|
|
|
fi
|
2019-02-08 13:18:18 +00:00
|
|
|
;;
|
2019-02-08 13:11:01 +00:00
|
|
|
*)
|
|
|
|
echo "Invalid manifest file for modpack. Please make sure it is a .json file."
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
exec /start-finalSetup03Modconfig $@
|