#!/bin/bash # Alloc's Minecraft Installer: # feel free to change, update, improve, and release this script # suggestions of feedback? reach me at alloc@dr.com # This script, in no way, is directly distributing any protected minecraft files # all files are downloaded directly from minecraft.net. Don't worry, you won't be # breaking the "one big rule" :) # happy mining! echo "" echo "@-------------------------------------------@" echo "@ Alloc's Bash Minecraft Installer @" echo "@ Verion 1.6.1 @" echo "@ @" echo "@ Please feel free to improve @" echo "@ this script however you desire. @" echo "@ @" echo "@ Alloc@dr.com @" echo "@-------------------------------------------@" counter=1 #----------------------------------# # DOTS FUNCTION # #----------------------------------# function dots { while [ $counter -le 3 ] do echo -ne "." sleep .1 ((counter++)) done let counter=1 echo } ## END DOTS #----------------------------------# # INSTALL FUNCTION # #----------------------------------# function Install { if [ -e /home/$(whoami)/.minecraft ] then echo ".minecraft folder exists" if [ -e /home/$(whoami)/.minecraft/minecraft.jar ] then echo -ne "have you run this before?" dots fi echo "" else echo -ne "creating /home/$(whoami)/.minecraft" dots cd /home/$(whoami) mkdir .minecraft fi #-------------------------------------------- cd /home/$(whoami)/.minecraft #-------------------------------------------- echo -ne "looking for Java" dots if [ -e /usr/lib/jvm/java-6-openjdk/jre/bin/javaws ] then echo "Java is already Installed!" echo "" else echo -ne "you'll need to the correct version of Java" dots echo "this will require root access!" sudo apt-get install openjdk-6-jre echo "" echo "" echo "" echo " JAVA INSTALL SUCCESSFUL!" echo "------------------------------------" echo "" echo "" echo "" fi #-------------------------------------------- echo -ne downloading minecraft.jar dots if [ -e /home/$(whoami)/.minecraft/minecraft.jar ] then echo looks like you already downloaded it! else wget -q www.minecraft.net/download/minecraft.jar echo "downloaded." fi echo"" echo -ne downloading icon dots if [ -e /home/$(whoami)/.minecraft/icon.png ] then echo "you already have the icon!" else wget -q http://www.minecraft.net/favicon.png mv favicon.png icon.png echo saved to /home/$(whoami)/.minecraft fi echo "" #--------------------------------------------- echo -ne writing bin shell dots if [ ! -e /usr/local/bin/minecraft ] then touch minecraft echo java -jar /home/$(whoami)/.minecraft/minecraft.jar >> minecraft echo -ne saving to usr/local/bin dots echo this requires root access: sudo cp minecraft /usr/local/bin/ cd / cd /usr/local/bin sudo chmod +x minecraft echo "done" else echo excecutable already written fi echo "" #-------------------------------------------- echo -ne writing desktop shortcut dots cd /home/$(whoami)/.minecraft/ if [ -e /home/$(whoami)/.minecraft/install_files ] then echo -ne previous version detected, updating dots rm -rf install_files fi mkdir install_files cd install_files touch alloc-installer.desktop echo "[Desktop Entry]" >> alloc-installer.desktop echo "Type=Application" >> alloc-installer.desktop echo "Encoding=UTF-8" >> alloc-installer.desktop echo "Name=Minecraft" >> alloc-installer.desktop echo "Comment=awesome game" >> alloc-installer.desktop echo Exec= java -jar /home/$(whoami)/.minecraft/minecraft.jar >> alloc-installer.desktop echo Icon= /home/$(whoami)/.minecraft/icon.png >> alloc-installer.desktop echo Categories=Game >> alloc-installer.desktop echo "Terminal=false" >> alloc-installer.desktop #---------------------------------------------------- echo -ne granting the shortcut excecution permissions dots echo this requires root access cp alloc-installer.desktop /home/$(whoami)/Desktop sudo chmod +x /home/$(whoami)/Desktop/alloc-installer.desktop echo "done" echo "" #--------------------------------------------- echo -ne writing menu item dots touch alloc-menu.directory echo [Desktop Entry] >> alloc-menu.directory echo Value=1.0 >> alloc-menu.directory echo Type=Directory >> alloc-menu.directory echo Encoding=UTF-8 >> alloc-menu.directory echo "done" echo "" echo -ne installing to Applications menu dots xdg-desktop-menu install alloc-menu.directory alloc-installer.desktop xdg-desktop-menu forceupdate echo installed #-------------------------------------------- echo "" echo "SUCCESS!" echo "" echo -e "Minecraft has been successfull Downloaded and Installed \nCheck your desktop and Applications menu for launchers! \nYou can also run it from terminal with a 'minecraft' command! \ncontact: alloc@dr.com" echo "Happy Mining!" echo"" } ## END INSTALL #----------------------------------# # UNINSTALL FUNCTION # #----------------------------------# function Uninstall { echo -ne "Looking for Minecraft" dots if [ ! -e /home/$(whoami)/.minecraft/minecraft.jar ] then echo -ne " -folder not detected" dots if [ ! -e /usr/local/bin/minecraft ] then echo -ne " -bin launcher not detected" dots echo"" echo "Minecraft doesn't seem to be installed!" Main return fi fi echo "Minecraft found!" echo -ne "Uninstalling Minecraft" dots echo "NOTE: You're save files will be kept" cd /home/$(whoami)/.minecraft echo "" echo -ne "Deleting files and folders" dots rm -rf bin rm -rf texturepacks rm minecraft.jar if [ -e options.txt ] then rm options.txt fi if [ -e lastlogin ] then rm lastlogin fi rm minecraft rm -rf resources rm icon.png cd install_files echo "Removing Application Launcher" xdg-desktop-menu uninstall alloc-menu.directory alloc-installer.desktop echo "Removing Desktop Shortcut" rm /home/$(whoami)/Desktop/alloc-installer.desktop rm -rf /home/$(whoami)/.minecraft/install_files echo "" echo -ne "Removing Binary Launcher" dots echo "this requires root access:" sudo rm /usr/local/bin/minecraft echo "" echo "Minecraft has been uninstalled :(" } ## END UNINSTALL #----------------------------------# # MAIN FUNCTION # #----------------------------------# function Main { echo "" echo "------------------------------------------------------" echo "What would you like to do? (enter number of choice) " INPUT=0 while [ $INPUT != 1 ] && [ $INPUT != 2 ] do echo "1. Install Minecraft" echo "2. Uninstall Minecraft" read INPUT if [ $INPUT -eq 1 ] then Install return else if [ $INPUT -eq 2 ] then Uninstall return else echo "invalid" fi fi done } #----------------------------------# # CALL THE MAIN FUNCTION # #----------------------------------# Main read NOTHING # keeps the window open until # THE END