Skip to content

Instantly share code, notes, and snippets.

@abaez
Last active April 16, 2022 02:48
Show Gist options
  • Save abaez/4480902 to your computer and use it in GitHub Desktop.
Save abaez/4480902 to your computer and use it in GitHub Desktop.
Simple Install script for Minecraft on linux of course ;)
#!/bin/bash
###### NOTE YOU HAVE TO RUN IN root
# cd "$(dirname ${BASH_SOURCE[0]})"
# dir=${PWD##*/}
dir="/opt/minecraft"
#script to make Install of Minecraft
makeInstall() {
curl -O http://media-mcw.cursecdn.com/c/c5/Grass.png
#making the program icon
if [ ! -f "/usr/share/applications/minecraft.desktop" ]; then #failsafe
cat >> /usr/share/applications/minecraft.desktop <<-EOL
[Desktop Entry]
Name=Minecraft
GenericName="Best Game In the World"
Exec=minecraft
Terminal=false
Icon=/opt/minecraft/Grass.png
Type=Application
Categories=Games
EOL
fi
#making the file for minecraft
if [ ! -f "/usr/bin/minecraft" ]; then #failsafe
cat >> /usr/bin/minecraft <<-EOL
#!/bin/bash
cd /opt/minecraft
java -Xmx1G -Xms1G -cp ./minecraft.jar net.minecraft.LauncherFrame
EOL
fi
}
#check if directory of Minecraft exist
if [ ! -d "/opt/minecraft" ]; then
mkdir "$dir"
fi
cd "$dir"
#checking if Minecraft is installed
mine="minecraft.jar"
if [ ! -f "$mine" ]; then
echo "Downloading Minecraft client:"
curl -O https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft.jar
echo "Installing Minecraft to your computer:"
makeInstall #the install magic
fi
echo "So I believe everything is done. Happy gaming :)"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment