La til noen sikkerhetsrelaterte sjekker i minecraft.sh
[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 # Minecraft home folder, where the binaries and saves and stuff are stored:
22 MC_HOME="${HOME}/.minecraft"
23 # Location and filename for the Minecraft launcher jar:
24 MC_LAUNCHER="${HOME}/bin/minecraft.jar"
25 # Command line to run to start Minecraft:
26 MC_COMMAND="java -Xmx2048M -Xms1024M -cp ${MC_LAUNCHER} net.minecraft.LauncherFrame"
27
28 # This might be needed to fix 64bit java on Linux (path to your 64bit java libs)
29 # Uncomment this if not suitable.
30 export LD_LIBRARY_PATH="/usr/lib/jvm/jre/lib/amd64/"
31
32
33 # Here comes the code
34
35 if [ ${#} -ne 1 ]; then
36 echo "Usage: 'minecraft <version>'"
37 exit 1
38 fi
39
40 if [ -z ${MC_HOME} ]; then
41 echo "Minecraft home folder not set! Baaaad idea!"
42 exit 1
43 fi
44
45 if [ ! -d ${MC_HOME} ]; then
46 echo "Minecraft home folder (${MC_HOME}) not found!"
47 exit 1
48 fi
49
50 MC_VERSION_FOLDER="${MC_HOME}/bin-${1}"
51 MC_WORKING_FOLDER="${MC_HOME}/bin"
52
53 if [ ! -d "${MC_VERSION_FOLDER}" ]; then
54 echo "Could not find that version folder (${MC_WORKING_FOLDER})."
55 exit 1
56 fi
57
58 if [ -d "${MC_WORKING_FOLDER}" ]; then
59 rm -rf ${MC_WORKING_FOLDER}
60 elif [ ! -d "${MC_WORKING_FOLDER}" ]; then
61 echo "Minecraft bin folder (${MC_WORKING_FOLDER}) is not a directory, bailing out."
62 exit 1
63 fi
64
65 if [ ! -e "${MC_WORKING_FOLDER}" ]; then
66 cp -r ${MC_VERSION_FOLDER} ${MC_WORKING_FOLDER}
67 ${MC_COMMAND}
68 fi