forked from neckro/rotato-mindcrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmindcrack.sh
executable file
·55 lines (52 loc) · 1.56 KB
/
mindcrack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
REPO="http://www.boylecraft.net/mindcrack"
export PATH=./util:$PATH
uname=$( uname )
if test "$uname" = "Windows_NT"; then
# Windows
FTB_CFG="$APPDATA/ftblauncher/ftblaunch.cfg"
elif test "$uname" = "Darwin"; then
# Mac
FTB_CFG="$HOME/Library/Application Support/ftblauncher/ftblaunch.cfg"
elif test "$uname" = "Linux"; then
# Linux
FTB_CFG="$HOME/.ftblauncher/ftblaunch.cfg"
else
echo "I don't know what the hell OS you're using." && exit
fi
# this is such a hack but it works
MC_BASE=$( sed -n 's/^installPath=\(.*\)$/\1/p' "$FTB_CFG" | sed 's/\\\([^\\]\)/\1/g' )
MC_JARS="$MC_BASE/MindCrack/instMods"
MC_MODS="$MC_BASE/MindCrack/minecraft/mods"
test "$MC_BASE" = "" && echo "There was a problem finding/parsing your ftblaunch.cfg." && exit
function get_list() {
curl -f -s $REPO/$1
if test $? != 0; then
echo "Error retrieving file $1" 1>&2
return 1
fi
}
function process_list() {
DESTDIR="$1"
mkdir -p "$DESTDIR" 2>/dev/null
while read FILE; do
DEST="$DESTDIR/$( basename "$FILE" )"
get_file "$FILE" "$DEST"
done
}
function get_file() {
FILE="$1"
DEST="$2"
echo "Downloading $FILE"
curl -f -k -# "$FILE" -o ./tempfile &&\
mv -f ./tempfile "$DEST" &&\
echo "Saved to $DEST" && echo && return 0
echo
return 1
}
REMOVE_LIST=$( get_list mods_deprecated.txt )
for FILE in $REMOVE_LIST; do rm -f "$MC_MODS/$FILE" 2>/dev/null; done
get_list mods_forge.txt | process_list "$MC_MODS"
get_list mods_jar.txt | process_list "$MC_JARS"
echo "$REPO/Recipes.cfg" | process_list "$MC_BASE/MindCrack/minecraft/config/GregTech"
echo "All done! Press a key." && read