diff --git a/setupMC.sh b/setupMC.sh index 58346f2..a696450 100755 --- a/setupMC.sh +++ b/setupMC.sh @@ -2,95 +2,60 @@ #determine if host system is 64 bit arm64 or 32 bit armhf if [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 64)" ];then - MACHINE='aarch64' + BITS=64 elif [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 32)" ];then - MACHINE='armv7l' + BITS=32 else - echo "Failed to detect OS CPU architecture! Something is very wrong." + echo "Failed to detect or unsupported CPU architecture! Something is very wrong." fi DIR=~/Minecraft +LWJGL3_DIR=~/lwjgl3arm$BITS +LWJGL2_DIR=~/lwjgl2arm32 # create folders echo Setup 1/9 -if [ ! -d "$DIR" ]; then - mkdir "$DIR" -fi +mkdir -p "$DIR" cd "$DIR" -pwd echo Setup 2/9 -if [ "$MACHINE" = "aarch64" ]; then - echo "Raspberry Pi OS (64 bit)" - if [ ! -d ~/lwjgl3arm64 ]; then - mkdir ~/lwjgl3arm64 - fi -else - echo "Raspberry Pi OS (32 bit)" - if [ ! -d ~/lwjgl3arm32 ]; then - mkdir ~/lwjgl3arm32 - fi - if [ ! -d ~/lwjgl2arm32 ]; then - mkdir ~/lwjgl2arm32 - fi + mkdir -p "$LWJGL3_DIR" +if [ $BITS == 32 ]; then + mkdir -p "$LWJGL2_DIR" fi # download minecraft launcher echo Setup 3/9 -if [ ! -f launcher.jar ]; then - wget https://launcher.mojang.com/v1/objects/eabbff5ff8e21250e33670924a0c5e38f47c840b/launcher.jar -fi +wget -nc https://launcher.mojang.com/v1/objects/eabbff5ff8e21250e33670924a0c5e38f47c840b/launcher.jar # download java echo Setup 4/9 -if [ "$MACHINE" = "aarch64" ]; then - if [ ! -f jdk-8u251-linux-arm64-vfp-hflt.tar.gz ]; then - wget https://github.com/mikehooper/Minecraft/raw/main/jdk-8u251-linux-arm64-vfp-hflt.tar.gz - fi -else - if [ ! -f jdk-8u251-linux-arm32-vfp-hflt.tar.gz ]; then - wget https://github.com/mikehooper/Minecraft/raw/main/jdk-8u251-linux-arm32-vfp-hflt.tar.gz - fi -fi +wget -nc https://github.com/mikehooper/Minecraft/raw/main/jdk-8u251-linux-arm${BITS}-vfp-hflt.tar.gz # download lwjgl3arm* echo Setup 5/9 -if [ "$MACHINE" = "aarch64" ]; then - if [ ! -f lwjgl3arm64.tar.gz ]; then - wget https://github.com/mikehooper/Minecraft/raw/main/lwjgl3arm64.tar.gz - fi -else - if [ ! -f lwjgl3arm32.tar.gz ]; then - wget https://github.com/mikehooper/Minecraft/raw/main/lwjgl3arm32.tar.gz - fi - if [ ! -f lwjgl2arm32.tar.gz ]; then - wget https://github.com/mikehooper/Minecraft/raw/main/lwjgl2arm32.tar.gz - fi +wget -nc https://github.com/mikehooper/Minecraft/raw/main/lwjgl3arm${BITS}.tar.gz +if [ $BITS == 32 ]; then + wget -nc https://github.com/mikehooper/Minecraft/raw/main/lwjgl2arm32.tar.gz fi echo Setup 6/9 -if [ ! -d /opt/jdk ]; then - sudo mkdir /opt/jdk -fi +sudo mkdir -p /opt/jdk # extract oracle java 8 echo Setup 7/9 echo Extracting java ... -if [ "$MACHINE" = "aarch64" ]; then - sudo tar -zxf jdk-8u251-linux-arm64-vfp-hflt.tar.gz -C /opt/jdk +sudo tar -zxf jdk-8u251-linux-arm${BITS}-vfp-hflt.tar.gz -C /opt/jdk +if [ $BITS == 64 ]; then # install opnjdk for launcher.jar and optifine install sudo apt install openjdk-11-jdk -y -else - sudo tar -zxf jdk-8u251-linux-arm32-vfp-hflt.tar.gz -C /opt/jdk fi # extract lwjgl* echo Setup 8/9 echo Extracting lwjgl... -if [ "$MACHINE" = "aarch64" ]; then - tar -zxf lwjgl3arm64.tar.gz -C ~/lwjgl3arm64 -else - tar -zxf lwjgl3arm32.tar.gz -C ~/lwjgl3arm32 - tar -zxf lwjgl2arm32.tar.gz -C ~/lwjgl2arm32 +tar -zxf lwjgl3arm${BITS}.tar.gz -C $LWJGL3_PATH +if [ $BITS == 32 ]; then + tar -zxf lwjgl2arm32.tar.gz -C $LWJGL2_PATH fi echo Setup 9/9