-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint
88 lines (74 loc) · 2.58 KB
/
entrypoint
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
#!/bin/sh
# ------------------------------
# PaperMC auto-updater
#
# /runner/entrypoint
# ------------------------------
# default auto-updating JAR path.
JAR_PATH="/home/container/app.jar"
JVM_OPTS="$@ $JVM_OPTS "
echo "entrypoint > In directory: '$(pwd)'"
echo "entrypoint > Found JVM Options: '$JVM_OPTS'"
echo "entrypoint > Found Application Options: '$APP_OPTS'"
if [ -z ${PRODUCT} ];
then
# not set
echo "entrypoint > product not set!"
exit 2
fi
echo "entrypoint > Welcome! using product: $PRODUCT"
if [ ! -z ${SHOULD_CREATE_EULA_TXT} ];
then
echo "Creating eula.txt at $(pwd)/eula.txt"
echo "eula=true" > ./eula.txt
fi
echo "entrypoint > Checking if OVERRIDE_JAR_PATH env variable was set..."
if [ ! -z ${OVERRIDE_JAR_PATH} ];
then
# Variable was set, skip the download and pass the variable to the runner.
echo "entrypoint > OVERRIDE_JAR_PATH found! ('${OVERRIDE_JAR_PATH}') Starting... (in directory '$(pwd)')"
JAR_PATH=$OVERRIDE_JAR_PATH
# source runner to pass through env vars
. /runner/runner
else
echo "entrypoint > Checking if the OVERRIDE_VERSION env variable was set..."
if [ -z ${OVERRIDE_VERSION} ];
then
# Variable is not set.
echo "entrypoint > Variable not set, querying for latest supported minecraft version..."
LATEST_MC=$(dltool latestmc $PRODUCT)
echo "entrypoint > Found version $LATEST_MC! Downloading latest build..."
else
# Variable is set.
echo "entrypoint > Override Variable set! Using overridden version $OVERRIDE_VERSION"
LATEST_MC=$OVERRIDE_VERSION
fi
echo "entrypoint > Checking if the OVERRIDE_JAR_DL_PATH env variable was set..."
if [ -z ${OVERRIDE_JAR_DL_PATH} ];
then
# Variable is not set
echo "entrypoint > Variable not set, using default ($JAR_PATH)..."
else
# Variable is set.
echo "entrypoint > Override Variable set! Using overriden JAR download path '$OVERRIDE_JAR_DL_PATH'"
JAR_PATH=$OVERRIDE_JAR_DL_PATH
fi
# Flag breakdown
# ----------
# --timeout=30 - 30 second timeout
# --tries=5 - retry up to 5 times after timeout
# --retry-connrefused - Attempt to retry even if connection was refused (eg. webserver restarting)
# --show-progress - always show progress bar (even with -q)
# -q - quiet (no output)
# -O - output to file $JAR_PATH
wget --timeout=30 --tries=5 --retry-connrefused --show-progress -q -O $JAR_PATH $(dltool download $PRODUCT $LATEST_MC)
if [ $? -eq 0 ]; then
echo "entrypoint > Successfully downloaded! Starting... (in directory '$(pwd)')"
echo ""
# source runner to pass through env vars
. /runner/runner
else
echo "entrypoint > Failed to download $PRODUCT. Exiting..."
exit 1
fi
fi