-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathstart-configuration
executable file
·279 lines (225 loc) · 6.16 KB
/
start-configuration
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
: "${EULA:=}"
: "${PROXY:=}"
: "${ENABLE_AUTOPAUSE:=false}"
: "${ENABLE_AUTOSTOP:=false}"
: "${RCON_CMDS_STARTUP:=}"
: "${RCON_CMDS_ON_CONNECT:=}"
: "${RCON_CMDS_ON_DISCONNECT:=}"
: "${RCON_CMDS_FIRST_CONNECT:=}"
: "${RCON_CMDS_LAST_DISCONNECT:=}"
: "${RCON_CMDS_PERIOD:=10}"
: "${ENABLE_RCON:=true}"
: "${RCON_PORT:=25575}"
export ENABLE_RCON RCON_PORT
: "${MEMORY=1G}"
: "${INIT_MEMORY=${MEMORY}}"
: "${MAX_MEMORY=${MEMORY}}"
export MEMORY INIT_MEMORY MAX_MEMORY
shopt -s nullglob
isDebugging && set -x
#umask 002
export HOME=/data
log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
if [ ! -e /data/eula.txt ]; then
if ! isTrue "$EULA"; then
log ""
log "Please accept the Minecraft EULA at"
log " https://account.mojang.com/documents/minecraft_eula"
log "by adding the following immediately after 'docker run':"
log " -e EULA=TRUE"
log ""
exit 1
fi
writeEula
fi
if isTrue "${DEBUG_MEMORY:-false}"; then
log "Memory usage and availability (in MB)"
uname -a
free -m
fi
##########################################
# Setup RCON password
if isTrue "${ENABLE_RCON:-true}"; then
if [[ -v RCON_PASSWORD_FILE ]]; then
if [ ! -e "${RCON_PASSWORD_FILE}" ]; then
log ""
log "Initial RCON password file ${RCON_PASSWORD_FILE} does not seems to exist."
log "Please ensure your configuration."
log "If you are using Docker Secrets feature, please check this for further information: "
log " https://docs.docker.com/engine/swarm/secrets"
log ""
exit 1
else
RCON_PASSWORD=$(cat "${RCON_PASSWORD_FILE}")
export RCON_PASSWORD
fi
elif ! [[ -v RCON_PASSWORD ]]; then
RCON_PASSWORD=$(openssl rand -hex 12)
export RCON_PASSWORD
fi
# For rcon-cli access running via exec, which by default is running as root
echo "password=${RCON_PASSWORD}" > "$HOME/.rcon-cli.env"
echo "password: \"${RCON_PASSWORD}\"" > "$HOME/.rcon-cli.yaml"
else
rm -f "$HOME/.rcon-cli.env" "$HOME/.rcon-cli.yaml"
fi
##########################################
# Auto-pause/stop
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${EXEC_DIRECTLY:-false}"; then
log "EXEC_DIRECTLY=true is incompatible with ENABLE_AUTOPAUSE=true"
exit 1
fi
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${ENABLE_AUTOSTOP}"; then
log "ENABLE_AUTOPAUSE=true is incompatible with ENABLE_AUTOSTOP=true"
exit 1
fi
if [[ $PROXY ]]; then
export http_proxy="$PROXY"
export https_proxy="$PROXY"
export JAVA_TOOL_OPTIONS+="-Djava.net.useSystemProxies=true"
log "INFO: Giving proxy time to startup..."
sleep 5
fi
function fixJavaPath() {
# Some Docker management UIs grab all the image declared variables and present them for configuration.
# When upgrading images across Java versions, that creates a mismatch in PATH's expected by base image.
if ! which java > /dev/null; then
log "ERROR: your Docker provider has an annoying flaw where it"
log " tries to set PATH even though the container establishes"
log " a very specific value."
sleep 2
# now find where java might be
for d in /opt/java/openjdk/bin /usr/bin; do
if [ -x "${d}/java" ]; then
PATH="${PATH}:${d}"
return 0
fi
done
return 1
fi
}
if ! fixJavaPath; then
log "ERROR: could not locate path that contains java"
exit 1
fi
cd /data || exit 1
export DECLARED_TYPE=${TYPE^^}
export DECLARED_VERSION="$VERSION"
if isTrue "${ENABLE_AUTOPAUSE}"; then
"${SCRIPTS:-/}start-autopause"
fi
if isTrue "${ENABLE_AUTOSTOP}"; then
"${SCRIPTS:-/}start-autostop"
fi
if
[[ "$RCON_CMDS_STARTUP" ]] ||
[[ "$RCON_CMDS_ON_CONNECT" ]] ||
[[ "$RCON_CMDS_ON_DISCONNECT" ]] ||
[[ "$RCON_CMDS_FIRST_CONNECT" ]] ||
[[ "$RCON_CMDS_LAST_DISCONNECT" ]]
then
log "Starting RCON commands"
# shellcheck source=start-rconcmds
"${SCRIPTS:-/}start-rconcmds"
fi
: "${MOD_PLATFORM:=}"
case "${TYPE^^}" in
AUTO_CURSEFORGE|MODRINTH|CURSEFORGE|FTB|FTBA)
MOD_PLATFORM="$TYPE"
;;
esac
if [[ $MOD_PLATFORM ]]; then
case "${MOD_PLATFORM^^}" in
FTB|CURSEFORGE)
exec "${SCRIPTS:-/}start-deployCF" "$@"
;;
FTBA)
exec "${SCRIPTS:-/}start-deployFTBA" "$@"
;;
AUTO_CURSEFORGE)
exec "${SCRIPTS:-/}start-deployAutoCF" "$@"
;;
MODRINTH)
exec "${SCRIPTS:-/}start-deployModrinth" "$@"
;;
*)
log "ERROR; Invalid MOD_PLATFORM: '$MOD_PLATFORM'"
exit 1
;;
esac
fi
log "Resolving type given ${TYPE}"
case "${TYPE^^}" in
*BUKKIT|SPIGOT)
exec "${SCRIPTS:-/}start-deployBukkitSpigot" "$@"
;;
PAPER)
exec "${SCRIPTS:-/}start-deployPaper" "$@"
;;
FOLIA)
exec "${SCRIPTS:-/}start-deployFolia" "$@"
;;
FORGE)
exec "${SCRIPTS:-/}start-deployForge" "$@"
;;
NEOFORGE|NEOFORGED)
exec "${SCRIPTS:-/}start-deployNeoForge" "$@"
;;
FABRIC)
exec "${SCRIPTS:-/}start-deployFabric" "$@"
;;
QUILT)
exec "${SCRIPTS:-/}start-deployQuilt" "$@"
;;
VANILLA)
exec "${SCRIPTS:-/}start-deployVanilla" "$@"
;;
SPONGEVANILLA)
exec "${SCRIPTS:-/}start-deploySpongeVanilla" "$@"
;;
CUSTOM)
exec "${SCRIPTS:-/}start-deployCustom" "$@"
;;
MAGMA)
exec "${SCRIPTS:-/}start-deployMagma" "$@"
;;
MAGMA_MAINTAINED)
exec "${SCRIPTS:-/}start-deployMagmaMaintained" "$@"
;;
KETTING)
exec "${SCRIPTS:-/}start-deployKetting" "$@"
;;
MOHIST)
exec "${SCRIPTS:-/}start-deployMohist" "$@"
;;
CATSERVER)
exec "${SCRIPTS:-/}start-deployCatserver" "$@"
;;
PURPUR)
exec "${SCRIPTS:-/}start-deployPurpur" "$@"
;;
PUFFERFISH)
exec "${SCRIPTS:-/}start-deployPufferfish" "$@"
;;
CANYON)
exec "${SCRIPTS:-/}start-deployCanyon" "$@"
;;
LIMBO)
exec "${SCRIPTS:-/}start-deployLimbo" "$@"
;;
CRUCIBLE)
exec "${SCRIPTS:-/}start-deployCrucible" "$@"
;;
*)
log "ERROR: Invalid TYPE: '$TYPE'"
log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FOLIA, PURPUR, FABRIC, QUILT,"
log " SPONGEVANILLA, CUSTOM, MAGMA, MOHIST, CATSERVER, AIRPLANE, PUFFERFISH,"
log " CANYON, LIMBO, CRUCIBLE"
exit 1
;;
esac