-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-deployForge
131 lines (115 loc) · 3.76 KB
/
start-deployForge
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
export TYPE=FORGE
if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
norm=$VANILLA_VERSION
case $VANILLA_VERSION in
*.*.*)
norm=$VANILLA_VERSION ;;
*.*)
norm=${VANILLA_VERSION}.0 ;;
esac
echo "Checking Forge version information."
case $FORGEVERSION in
RECOMMENDED)
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-recommended\"]")
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
if [ $FORGE_VERSION = null ]; then
echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
echo " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
fi
fi
;;
LATEST)
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-recommended\"]")
if [ $FORGE_VERSION = null ]; then
echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
echo " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
fi
fi
;;
*)
FORGE_VERSION=$FORGEVERSION
;;
esac
normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm
shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION
FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
elif [[ -z $FORGE_INSTALLER ]]; then
FORGE_INSTALLER="/tmp/forge-installer.jar"
elif [[ ! -e $FORGE_INSTALLER ]]; then
echo "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
exit 2
fi
installMarker=".forge-installed-$shortForgeVersion"
if [ ! -e $installMarker ]; then
if [ ! -e $FORGE_INSTALLER ]; then
if [[ -z $FORGE_INSTALLER_URL ]]; then
echo "Downloading $normForgeVersion"
forgeFileNames="
$normForgeVersion/forge-$normForgeVersion-installer.jar
$shortForgeVersion/forge-$shortForgeVersion-installer.jar
END
"
for fn in $forgeFileNames; do
if [ $fn == END ]; then
echo "Unable to compute URL for $normForgeVersion"
exit 2
fi
downloadUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/$fn
echo "...trying $downloadUrl"
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
break
fi
done
else
echo "Downloading $FORGE_INSTALLER_URL ..."
if ! curl -o $FORGE_INSTALLER -fsSL $FORGE_INSTALLER_URL; then
echo "Failed to download from given location $FORGE_INSTALLER_URL"
exit 2
fi
fi
fi
echo "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
mkdir -p mods
tries=3
while ((--tries >= 0)); do
java -jar $FORGE_INSTALLER --installServer
if [ $? == 0 ]; then
break
fi
done
if (($tries < 0)); then
echo "Forge failed to install after several tries." >&2
exit 10
fi
# NOTE $shortForgeVersion will be empty if installer location was given to us
echo "Finding installed server jar..."
for j in *forge*.jar; do
echo "...$j"
case $j in
*installer*)
;;
*)
export SERVER=$j
break
;;
esac
done
if [[ -z $SERVER ]]; then
echo "Unable to derive server jar for Forge"
exit 2
fi
echo "Using server $SERVER"
echo $SERVER > $installMarker
else
export SERVER=$(cat $installMarker)
fi
# Continue to Final Setup
exec start-finalSetup01World $@