diff options
-rwxr-xr-x | get_version.sh | 52 | ||||
-rwxr-xr-x | launch.sh | 10 | ||||
-rw-r--r-- | profiles/1.0 | 2 | ||||
-rw-r--r-- | profiles/1.1 | 2 | ||||
-rw-r--r-- | profiles/1.2.5 | 2 | ||||
-rw-r--r-- | profiles/1.3.2 | 2 | ||||
-rw-r--r-- | profiles/1.4.7 | 2 | ||||
-rw-r--r-- | profiles/1.5.2 | 2 | ||||
-rw-r--r-- | profiles/a1.1.2_01 | 2 | ||||
-rw-r--r-- | profiles/a1.2.6 | 2 | ||||
-rw-r--r-- | profiles/b1.3_01 | 2 | ||||
-rw-r--r-- | profiles/b1.4 | 2 | ||||
-rw-r--r-- | profiles/b1.4_01 | 2 | ||||
-rw-r--r-- | profiles/b1.5_01 | 2 | ||||
-rw-r--r-- | profiles/b1.6.6 | 2 | ||||
-rw-r--r-- | profiles/b1.7.3 | 2 | ||||
-rw-r--r-- | profiles/b1.8.1 | 2 |
17 files changed, 47 insertions, 45 deletions
diff --git a/get_version.sh b/get_version.sh index c413459..1bcb2a4 100755 --- a/get_version.sh +++ b/get_version.sh @@ -1,8 +1,10 @@ #!/usr/bin/env sh +JQ=${JQ:=jq} + # Check for packages -JQ_VERSION=$(jq --version 2>/dev/null) -if [[ ${JQ_VERSION} == 'jq-1.3' || ${JQ_VERSION} == 'jq-1.4' || ${JQ_VERSION} == 'jq-1.5' || ${JQ_VERSION} == 'jq-1.6' ]]; then +JQ_VERSION=$("${JQ}" --version 2>/dev/null) +if [ "${JQ_VERSION}" = 'jq-1.3' ] || [ "${JQ_VERSION}" = 'jq-1.4' ] || [ "${JQ_VERSION}" = 'jq-1.5' ] || [ "${JQ_VERSION}" = 'jq-1.6' ]; then echo 'ERROR: installed jq version is too old; must be at least 1.7' exit 1 elif [ -z ${JQ_VERSION} ]; then @@ -39,7 +41,7 @@ MANIFEST_LIST_URL='https://launchermeta.mojang.com/mc/game/version_manifest.json mkdir -p assets/indexes echo 'Retrieving version manifest...' -VERSION_MANIFEST_URL=$(curl "${MANIFEST_LIST_URL}" 2>/dev/null | jq -r "(.versions.[] | select(.id==\"${LOOKING_FOR}\")).url") +VERSION_MANIFEST_URL=$(curl "${MANIFEST_LIST_URL}" 2>/dev/null | "${JQ}" -r "(.versions.[] | select(.id==\"${LOOKING_FOR}\")).url") if [ -z "${VERSION_MANIFEST_URL}" ]; then echo "ERROR: Unable to find requested version" @@ -47,56 +49,56 @@ if [ -z "${VERSION_MANIFEST_URL}" ]; then fi mkdir -p manifests -VERSION_MANIFEST=$(curl ${VERSION_MANIFEST_URL} 2>/dev/null | sed -e 's/\\/\\\\/g' | tee "manifests/${LOOKING_FOR}.json") # Some versions contain illegal escape sequences which will crash some shells such as Ksh; double-escape it just to be safe +VERSION_MANIFEST=$(curl ${VERSION_MANIFEST_URL} 2>/dev/null | sed -e 's/\\//g' | tee "manifests/${LOOKING_FOR}.json") # Some versions contain illegal escape sequences which will crash some shells such as Ksh; double-escape it just to be safe # 1.12 and earlier, natives and regular libraries are contained in different elements. For 1.13 and later, an element may contain both. echo 'Downloading libraries...' -for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do - if [[ $(echo "${I}" | jq .downloads.artifact) != 'null' ]]; then - echo "Library '$(echo ${I} | jq -r .name )' found - downloading..." - mkdir -p libraries/$(dirname $(echo ${I} | jq -r .downloads.artifact.path)) - curl $(echo ${I} | jq -r .downloads.artifact.url) > libraries/$(echo "${I}" | jq -r .downloads.artifact.path) 2>/dev/null +for I in $(echo "${VERSION_MANIFEST}" | "${JQ}" -c .libraries.[]); do + if [ "$(echo "${I}" | "${JQ}" .downloads.artifact)" != 'null' ]; then + echo "Library '$(echo ${I} | "${JQ}" -r .name )' found - downloading..." + mkdir -p libraries/$(dirname $(echo ${I} | "${JQ}" -r .downloads.artifact.path)) + curl $(echo ${I} | "${JQ}" -r .downloads.artifact.url) > libraries/$(echo "${I}" | "${JQ}" -r .downloads.artifact.path) 2>/dev/null fi - if [[ $(echo "${I}" | jq .natives) != 'null' ]]; then + if [ "$(echo "${I}" | "${JQ}" .natives)" != 'null' ]; then echo "Downloading native for platform '${PLATFORM}'..." - if [[ $(echo ${I} | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\"") == 'null' ]]; then - echo "WARNING: Mojang does not distribute a '$(echo ${I} | jq -r .name)' native for this platform. This is probably not an issue unless you are using an obscure platform." + if [ "$(echo ${I} | "${JQ}" -r ".downloads.classifiers.\"natives-${PLATFORM}\"")" = 'null' ]; then + echo "WARNING: Mojang does not distribute a '$(echo ${I} | "${JQ}" -r .name)' native for this platform. This is probably not an issue unless you are using an obscure platform." else - mkdir -p libraries/$(dirname $(echo ${I} | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\".path")) - curl $(echo ${I} | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\".url") > libraries/$(echo "${I}" | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\".path") 2>/dev/null + mkdir -p libraries/$(dirname $(echo ${I} | "${JQ}" -r ".downloads.classifiers.\"natives-${PLATFORM}\".path")) + curl $(echo ${I} | "${JQ}" -r ".downloads.classifiers.\"natives-${PLATFORM}\".url") > libraries/$(echo "${I}" | "${JQ}" -r ".downloads.classifiers.\"natives-${PLATFORM}\".path") 2>/dev/null fi fi done echo 'Retrieving asset index...' -ASSET_INDEX=$(echo "${VERSION_MANIFEST}" | jq .assetIndex) +ASSET_INDEX=$(echo "${VERSION_MANIFEST}" | "${JQ}" .assetIndex) echo 'Retrieving object list...' -OBJECT_LIST=$(curl $(echo ${ASSET_INDEX} | jq -r .url) 2>/dev/null | tee assets/indexes/$(echo ${ASSET_INDEX} | jq -r .id).json) +OBJECT_LIST=$(curl $(echo ${ASSET_INDEX} | "${JQ}" -r .url) 2>/dev/null | tee assets/indexes/$(echo ${ASSET_INDEX} | "${JQ}" -r .id).json) -HASH_COUNT=$(echo ${OBJECT_LIST} | jq '.objects | length') +HASH_COUNT=$(echo ${OBJECT_LIST} | "${JQ}" '.objects | length') echo 'Downloading required assets. This may take a few minutes.' MCRESOURCES='https://resources.download.minecraft.net/' -if [[ "$(echo "${ASSET_INDEX}" | jq -r .id)" == 'pre-1.6' || "$(echo "${ASSET_INDEX}" | jq -r .id)" == 'legacy' ]]; then # Release 1.6 and prior use a different asset layout - while read -r LINE; do - H=$(echo ${OBJECT_LIST} | jq -r ".objects.[\"${LINE}\"].hash") - DIR="${H[0]}${H[1]}/" +if [ "$(echo "${ASSET_INDEX}" | "${JQ}" -r .id)" = 'pre-1.6' ] || [ "$(echo "${ASSET_INDEX}" | "${JQ}" -r .id)" = 'legacy' ]; then # Release 1.6 and prior use a different asset layout + echo "${OBJECT_LIST}" | "${JQ}" -r '.objects | keys[]' | while read -r LINE; do + H=$(echo ${OBJECT_LIST} | "${JQ}" -r ".objects.[\"${LINE}\"].hash") + DIR="$(echo "${H}" | cut -c1-2)/" mkdir -p "$(dirname "assets/virtual/legacy/${LINE}")" curl "${MCRESOURCES}${DIR}${H}" > "assets/virtual/legacy/${LINE}" 2>/dev/null echo "Downloaded: assets/virtual/legacy/${LINE}" - done <<< "$(echo "${OBJECT_LIST}" | jq -r '.objects | keys[]')" + done else IND=0 - for I in $(echo "${OBJECT_LIST}" | jq -r .objects.[].hash); do + for I in $(echo "${OBJECT_LIST}" | "${JQ}" -r .objects.[].hash); do IND=$(echo "${IND}" + 1 | nickle) DIR="$(echo "${I}" | cut -c1-2)/" mkdir -p "assets/objects/${DIR}" # If file exists, check its integrity with hash and skip if it's good - if [[ -f assets/objects/${DIR}${I} && $(cat "assets/objects/${DIR}${I}" | sha1sum | sed -e 's/ (stdin)//') == "${I}" ]]; then # Removing (stdin) is not needed for most sha1sum implementations + if [ -f assets/objects/${DIR}${I} ] && [ "$(cat "assets/objects/${DIR}${I}" | sha1sum | sed -e 's/ (stdin)//')" = "${I}" ]; then # Removing (stdin) is not needed for most sha1sum implementations echo "${IND}/${HASH_COUNT} (${DIR}${I}) is already downloaded; skipping. ($(echo "printf(\"%5l\", ${IND} / ${HASH_COUNT} * 100)" | nickle)%)" continue; fi @@ -107,7 +109,7 @@ else fi echo 'Downloading minecraft jar...' -CLIENT_URL=$(echo "${VERSION_MANIFEST}" | jq -r .downloads.client.url) +CLIENT_URL=$(echo "${VERSION_MANIFEST}" | "${JQ}" -r .downloads.client.url) mkdir -p "libraries/com/mojang/minecraft/${LOOKING_FOR}" curl "${CLIENT_URL}" > "libraries/com/mojang/minecraft/${LOOKING_FOR}/minecraft-${LOOKING_FOR}-client.jar" 2>/dev/null @@ -56,13 +56,13 @@ VERSION_MANIFEST=$(cat "manifests/${VERSION}.json") # 1.12 and earlier, natives and regular libraries are contained in different elements. For 1.13 and later, an element may contain both. CLASSPATH= for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do - if [[ $(echo "${I}" | jq .downloads.artifact) != 'null' ]]; then + if [ "$(echo "${I}" | jq .downloads.artifact)" != 'null' ]; then for J in ${BLACKLISTED_LIBRARIES}; do if [ ${J} == $(basename $(echo ${I} | jq -r .downloads.artifact.path)) ]; then SKIP=1 fi done - if [[ ${SKIP} -eq 1 ]]; then + if [ "${SKIP}" = '1' ]; then SKIP= continue fi @@ -71,13 +71,13 @@ for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do CLASSPATH="${PWD}/libraries/${JAR}:${CLASSPATH}" fi fi - if [[ $(echo "${I}" | jq .natives) != 'null' ]]; then + if [ "$(echo "${I}" | jq .natives)" != 'null' ]; then for J in ${BLACKLISTED_NATIVES}; do if [ ${J} == $(basename $(echo ${I} | jq ".downloads.classifiers.\"natives-${PLATFORM}\".path")) ]; then SKIP=1 fi done - if [[ ${SKIP} -eq 1 ]]; then + if [ "${SKIP}" = '1' ]; then SKIP= continue fi @@ -94,7 +94,7 @@ done CLASSPATH="${CLASSPATH}:${PWD}/${MINECRAFT_JAR}" -if [[ $(echo "${VERSION_MANIFEST}" | jq -r .minecraftArguments) != 'null' ]]; then +if [ "$(echo "${VERSION_MANIFEST}" | jq -r .minecraftArguments)" != 'null' ]; then ARGUMENT_LIST=$(echo ${VERSION_MANIFEST} | jq -r .minecraftArguments) else for I in $(echo ${VERSION_MANIFEST} | jq -r '.arguments.game[] | select(type=="string")'); do diff --git a/profiles/1.0 b/profiles/1.0 index 2eb5453..e607c71 100644 --- a/profiles/1.0 +++ b/profiles/1.0 @@ -1,5 +1,5 @@ VERSION=1.0 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/1.1 b/profiles/1.1 index be6bf66..7431175 100644 --- a/profiles/1.1 +++ b/profiles/1.1 @@ -1,5 +1,5 @@ VERSION=1.1 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/1.2.5 b/profiles/1.2.5 index 9305282..c9c64af 100644 --- a/profiles/1.2.5 +++ b/profiles/1.2.5 @@ -1,5 +1,5 @@ VERSION=1.2.5 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/1.3.2 b/profiles/1.3.2 index 69c3dfb..22874eb 100644 --- a/profiles/1.3.2 +++ b/profiles/1.3.2 @@ -1,5 +1,5 @@ VERSION=1.3.2 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/1.4.7 b/profiles/1.4.7 index de61f75..59ba9ee 100644 --- a/profiles/1.4.7 +++ b/profiles/1.4.7 @@ -1,5 +1,5 @@ VERSION=1.4.7 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/1.5.2 b/profiles/1.5.2 index b51df4f..8c39699 100644 --- a/profiles/1.5.2 +++ b/profiles/1.5.2 @@ -1,5 +1,5 @@ VERSION=1.5.2 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/a1.1.2_01 b/profiles/a1.1.2_01 index 29fc500..a83bb36 100644 --- a/profiles/a1.1.2_01 +++ b/profiles/a1.1.2_01 @@ -1,5 +1,5 @@ VERSION=a1.1.2_01 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/a1.2.6 b/profiles/a1.2.6 index 65ab2c6..87a18b9 100644 --- a/profiles/a1.2.6 +++ b/profiles/a1.2.6 @@ -1,5 +1,5 @@ VERSION=a1.2.6 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.3_01 b/profiles/b1.3_01 index f27593e..8f3bc7c 100644 --- a/profiles/b1.3_01 +++ b/profiles/b1.3_01 @@ -1,5 +1,5 @@ VERSION=b1.3_01 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.4 b/profiles/b1.4 index a900d9d..84e9d91 100644 --- a/profiles/b1.4 +++ b/profiles/b1.4 @@ -1,5 +1,5 @@ VERSION=b1.4 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.4_01 b/profiles/b1.4_01 index 8fbf29e..1787f9b 100644 --- a/profiles/b1.4_01 +++ b/profiles/b1.4_01 @@ -1,5 +1,5 @@ VERSION=b1.4_01 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.5_01 b/profiles/b1.5_01 index a041de0..f0055b6 100644 --- a/profiles/b1.5_01 +++ b/profiles/b1.5_01 @@ -1,5 +1,5 @@ VERSION=b1.5_01 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.6.6 b/profiles/b1.6.6 index 15f66eb..321b104 100644 --- a/profiles/b1.6.6 +++ b/profiles/b1.6.6 @@ -1,5 +1,5 @@ VERSION=b1.6.6 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.7.3 b/profiles/b1.7.3 index b05257d..56a5fb8 100644 --- a/profiles/b1.7.3 +++ b/profiles/b1.7.3 @@ -1,5 +1,5 @@ VERSION=b1.7.3 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" diff --git a/profiles/b1.8.1 b/profiles/b1.8.1 index 5e8060b..fd60816 100644 --- a/profiles/b1.8.1 +++ b/profiles/b1.8.1 @@ -1,5 +1,5 @@ VERSION=b1.8.1 mkdir -p instances/${INAME} -[[ ! -L "instances/${INAME}/resources" ]] && rmdir "instances/${INAME}/resources" 2>/dev/null +[ ! -L "instances/${INAME}/resources" ] && rmdir "instances/${INAME}/resources" 2>/dev/null ln -sf ../../assets/virtual/legacy "instances/${INAME}/resources" |