minecraft.sh - kjør en oppgitt minecraft-versjon
[einar-bin] / minecraft.sh
1 #!/bin/bash
2 # This script assumes that you have prepared various versions of
3 # Minecraft bin folders in your $MC_HOME like this:
4 # ${MC_HOME}/bin-version (example: ${MC_HOME}/bin-1.2.5)
5 #
6 # The script tries to preserve the various versions of the bin folder
7 # by copying the selected bin folder to a "working folder", to prevent
8 # accidental updates on launch.
9 #
10 # Use at your own risk, changing minecraft versions around may result in
11 # unexpected and undesirable behaviour. You may lose your saves.
12 # This script does not handle backups of the world data, I suggest using
13 # deja-dup or similar backup software. It's good for you.
14
15 # Written by Einar Jørgen Haraldseid <einar@haraldseid.net>
16 # inspired by a similar idea by Lars Erik Pedersen
17
18 # Released to the public under the WTFPL: http://sam.zoy.org/wtfpl/COPYING
19
20 # CONFIG STUFF - change these to suit your system
21 MC_HOME="${HOME}/.minecraft"
22 MC_LAUNCHER="${HOME}/bin/minecraft.jar"
23 MC_COMMAND="java -Xmx2048M -Xms1024M -cp ${MC_LAUNCHER} net.minecraft.LauncherFrame"
24
25 # This might be needed to fix 64bit java on Linux (path to your 64bit java libs)
26 # Uncomment this if not suitable.
27 export LD_LIBRARY_PATH="/usr/lib/jvm/jre/lib/amd64/"
28
29
30 # Here comes the code
31
32 if [ ${#} -ne 1 ]; then
33 echo "Usage: 'minecraft <version>'"
34 exit 1
35 fi
36
37 MC_VERSION_FOLDER="${MC_HOME}/bin-${1}"
38 MC_WORKING_FOLDER="${MC_HOME}/bin"
39
40 if [ ! -d "${MC_VERSION_FOLDER}" ]; then
41 echo "Could not find that version folder."
42 exit 1
43 fi
44
45 if [ -d "${MC_WORKING_FOLDER}" ]; then
46 rm -rf ${MC_WORKING_FOLDER}
47 elif [ ! -d "${MC_WORKING_FOLDER}" ]; then
48 echo "Minecraft bin folder is not a directory, bailing out."
49 exit 1
50 fi
51
52 if [ ! -e "${MC_WORKING_FOLDER}" ]; then
53 cp -r ${MC_VERSION_FOLDER} ${MC_WORKING_FOLDER}
54 ${MC_COMMAND}
55 fi