2018-07-31 02:49:43 +00:00
|
|
|
#!/bin/bash
|
2021-02-07 23:58:50 +00:00
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
2018-07-31 02:49:43 +00:00
|
|
|
|
2021-10-10 17:05:37 +00:00
|
|
|
# shellcheck source=start-utils
|
2022-01-27 02:25:52 +00:00
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2021-10-10 17:05:37 +00:00
|
|
|
: "${EULA:=}"
|
|
|
|
: "${PROXY:=}"
|
2022-04-10 15:58:18 +00:00
|
|
|
: "${ENABLE_AUTOPAUSE:=false}"
|
|
|
|
: "${ENABLE_AUTOSTOP:=false}"
|
2022-03-02 17:29:12 +00:00
|
|
|
: "${RCON_CMDS_STARTUP:=}"
|
|
|
|
: "${RCON_CMDS_ON_CONNECT:=}"
|
|
|
|
: "${RCON_CMDS_ON_DISCONNECT:=}"
|
2022-03-04 02:47:30 +00:00
|
|
|
: "${RCON_CMDS_FIRST_CONNECT:=}"
|
|
|
|
: "${RCON_CMDS_LAST_DISCONNECT:=}"
|
2022-03-02 17:29:12 +00:00
|
|
|
: "${RCON_CMDS_PERIOD:=10}"
|
2022-10-13 03:09:56 +00:00
|
|
|
: "${ENABLE_RCON:=true}"
|
2022-04-10 15:58:18 +00:00
|
|
|
: "${RCON_PORT:=25575}"
|
2023-11-26 00:30:18 +00:00
|
|
|
export ENABLE_RCON RCON_PORT
|
2021-02-07 23:58:50 +00:00
|
|
|
|
2022-10-13 00:23:01 +00:00
|
|
|
: "${MEMORY=1G}"
|
|
|
|
: "${INIT_MEMORY=${MEMORY}}"
|
|
|
|
: "${MAX_MEMORY=${MEMORY}}"
|
|
|
|
export MEMORY INIT_MEMORY MAX_MEMORY
|
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
shopt -s nullglob
|
|
|
|
|
2021-10-10 17:05:37 +00:00
|
|
|
isDebugging && set -x
|
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
#umask 002
|
|
|
|
export HOME=/data
|
|
|
|
|
2020-05-11 23:49:52 +00:00
|
|
|
log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
if [ ! -e /data/eula.txt ]; then
|
2020-07-26 18:19:45 +00:00
|
|
|
if ! isTrue "$EULA"; then
|
2020-03-06 15:52:17 +00:00
|
|
|
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 ""
|
2018-07-31 02:49:43 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-09-15 22:15:33 +00:00
|
|
|
|
2020-07-26 18:19:45 +00:00
|
|
|
writeEula
|
2018-07-31 02:49:43 +00:00
|
|
|
fi
|
|
|
|
|
2023-11-30 23:00:09 +00:00
|
|
|
if isTrue "${DEBUG_MEMORY:-false}"; then
|
|
|
|
log "Memory usage and availability (in MB)"
|
|
|
|
uname -a
|
|
|
|
free -m
|
|
|
|
fi
|
|
|
|
|
2023-11-26 00:30:18 +00:00
|
|
|
##########################################
|
|
|
|
# Setup RCON password
|
|
|
|
|
2023-11-26 14:34:49 +00:00
|
|
|
if isTrue "${ENABLE_RCON:-true}"; then
|
|
|
|
if [[ -v RCON_PASSWORD_FILE ]]; then
|
2023-11-26 00:30:18 +00:00
|
|
|
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
|
2023-11-26 14:34:49 +00:00
|
|
|
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"
|
2023-11-26 00:30:18 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
##########################################
|
|
|
|
# Auto-pause/stop
|
|
|
|
|
2021-12-11 19:01:30 +00:00
|
|
|
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${EXEC_DIRECTLY:-false}"; then
|
|
|
|
log "EXEC_DIRECTLY=true is incompatible with ENABLE_AUTOPAUSE=true"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-09-15 22:15:33 +00:00
|
|
|
|
2021-12-21 00:27:27 +00:00
|
|
|
if isTrue "${ENABLE_AUTOPAUSE}" && isTrue "${ENABLE_AUTOSTOP}"; then
|
|
|
|
log "ENABLE_AUTOPAUSE=true is incompatible with ENABLE_AUTOSTOP=true"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
if [[ $PROXY ]]; then
|
|
|
|
export http_proxy="$PROXY"
|
|
|
|
export https_proxy="$PROXY"
|
2020-06-19 20:33:33 +00:00
|
|
|
export JAVA_TOOL_OPTIONS+="-Djava.net.useSystemProxies=true"
|
2020-03-06 15:52:17 +00:00
|
|
|
log "INFO: Giving proxy time to startup..."
|
2018-07-31 02:49:43 +00:00
|
|
|
sleep 5
|
|
|
|
fi
|
|
|
|
|
2022-02-19 17:34:13 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-06-08 13:52:08 +00:00
|
|
|
|
2022-02-19 17:34:13 +00:00
|
|
|
if ! fixJavaPath; then
|
|
|
|
log "ERROR: could not locate path that contains java"
|
2022-01-29 20:53:34 +00:00
|
|
|
exit 1
|
2021-03-06 22:05:01 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-12 19:31:19 +00:00
|
|
|
cd /data || exit 1
|
2018-07-31 02:49:43 +00:00
|
|
|
|
2023-11-12 22:10:03 +00:00
|
|
|
export DECLARED_TYPE=${TYPE^^}
|
|
|
|
export DECLARED_VERSION="$VERSION"
|
2018-07-31 02:49:43 +00:00
|
|
|
|
2020-05-20 13:17:58 +00:00
|
|
|
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
2023-01-09 01:15:24 +00:00
|
|
|
"${SCRIPTS:-/}start-autopause"
|
2020-05-20 13:17:58 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-21 00:27:27 +00:00
|
|
|
if isTrue "${ENABLE_AUTOSTOP}"; then
|
2023-01-09 01:15:24 +00:00
|
|
|
"${SCRIPTS:-/}start-autostop"
|
2021-12-21 00:27:27 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-04 02:47:30 +00:00
|
|
|
if
|
|
|
|
[[ "$RCON_CMDS_STARTUP" ]] ||
|
|
|
|
[[ "$RCON_CMDS_ON_CONNECT" ]] ||
|
|
|
|
[[ "$RCON_CMDS_ON_DISCONNECT" ]] ||
|
|
|
|
[[ "$RCON_CMDS_FIRST_CONNECT" ]] ||
|
|
|
|
[[ "$RCON_CMDS_LAST_DISCONNECT" ]]
|
|
|
|
then
|
2022-03-02 17:29:12 +00:00
|
|
|
log "Starting RCON commands"
|
|
|
|
# shellcheck source=start-rconcmds
|
2023-01-09 01:15:24 +00:00
|
|
|
"${SCRIPTS:-/}start-rconcmds"
|
2022-03-02 17:29:12 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-06 14:11:12 +00:00
|
|
|
: "${MOD_PLATFORM:=}"
|
2023-06-08 13:52:08 +00:00
|
|
|
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" "$@"
|
|
|
|
;;
|
2023-07-06 14:11:12 +00:00
|
|
|
|
|
|
|
*)
|
|
|
|
log "ERROR; Invalid MOD_PLATFORM: '$MOD_PLATFORM'"
|
|
|
|
exit 1
|
|
|
|
;;
|
2023-06-08 13:52:08 +00:00
|
|
|
esac
|
2021-11-24 20:30:20 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-28 18:56:48 +00:00
|
|
|
log "Resolving type given ${TYPE}"
|
2018-08-12 22:25:16 +00:00
|
|
|
case "${TYPE^^}" in
|
|
|
|
*BUKKIT|SPIGOT)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployBukkitSpigot" "$@"
|
2018-07-31 02:49:43 +00:00
|
|
|
;;
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
PAPER)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployPaper" "$@"
|
2018-07-31 02:49:43 +00:00
|
|
|
;;
|
|
|
|
|
2023-04-14 02:55:58 +00:00
|
|
|
FOLIA)
|
|
|
|
exec "${SCRIPTS:-/}start-deployFolia" "$@"
|
|
|
|
;;
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
FORGE)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployForge" "$@"
|
2018-07-31 02:49:43 +00:00
|
|
|
;;
|
|
|
|
|
2023-10-03 23:00:24 +00:00
|
|
|
NEOFORGE|NEOFORGED)
|
|
|
|
exec "${SCRIPTS:-/}start-deployNeoForge" "$@"
|
|
|
|
;;
|
|
|
|
|
2019-07-10 03:19:59 +00:00
|
|
|
FABRIC)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployFabric" "$@"
|
2019-07-10 03:19:59 +00:00
|
|
|
;;
|
|
|
|
|
2022-05-13 12:31:36 +00:00
|
|
|
QUILT)
|
|
|
|
exec "${SCRIPTS:-/}start-deployQuilt" "$@"
|
|
|
|
;;
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
VANILLA)
|
2021-10-10 17:05:37 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployVanilla" "$@"
|
2018-07-31 02:49:43 +00:00
|
|
|
;;
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
SPONGEVANILLA)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deploySpongeVanilla" "$@"
|
2018-07-31 02:49:43 +00:00
|
|
|
;;
|
|
|
|
|
2019-01-14 01:00:34 +00:00
|
|
|
CUSTOM)
|
2022-01-29 20:53:34 +00:00
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployCustom" "$@"
|
2020-04-12 19:31:19 +00:00
|
|
|
;;
|
|
|
|
|
2020-04-21 23:30:48 +00:00
|
|
|
MAGMA)
|
2022-01-29 20:53:34 +00:00
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployMagma" "$@"
|
2020-04-21 23:30:48 +00:00
|
|
|
;;
|
|
|
|
|
2023-12-19 14:14:56 +00:00
|
|
|
MAGMA_MAINTAINED)
|
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployMagmaMaintained" "$@"
|
|
|
|
;;
|
|
|
|
|
2023-12-11 13:19:25 +00:00
|
|
|
KETTING)
|
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployKetting" "$@"
|
|
|
|
;;
|
|
|
|
|
2020-06-19 16:31:56 +00:00
|
|
|
MOHIST)
|
2022-01-29 20:53:34 +00:00
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployMohist" "$@"
|
2020-06-19 16:31:56 +00:00
|
|
|
;;
|
|
|
|
|
2020-06-20 20:28:21 +00:00
|
|
|
CATSERVER)
|
2022-01-29 20:53:34 +00:00
|
|
|
evaluateJavaCompatibilityForForge
|
|
|
|
exec "${SCRIPTS:-/}start-deployCatserver" "$@"
|
2020-04-21 23:30:48 +00:00
|
|
|
;;
|
|
|
|
|
2021-02-07 17:22:08 +00:00
|
|
|
PURPUR)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployPurpur" "$@"
|
2021-02-07 17:22:08 +00:00
|
|
|
;;
|
|
|
|
|
2022-01-06 12:49:46 +00:00
|
|
|
PUFFERFISH)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployPufferfish" "$@"
|
2022-01-06 12:49:46 +00:00
|
|
|
;;
|
|
|
|
|
2021-05-20 01:16:57 +00:00
|
|
|
CANYON)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployCanyon" "$@"
|
2021-05-20 01:16:57 +00:00
|
|
|
;;
|
|
|
|
|
2021-08-15 17:44:31 +00:00
|
|
|
LIMBO)
|
2022-01-29 20:53:34 +00:00
|
|
|
exec "${SCRIPTS:-/}start-deployLimbo" "$@"
|
2021-08-15 17:44:31 +00:00
|
|
|
;;
|
|
|
|
|
2021-10-19 02:58:53 +00:00
|
|
|
CRUCIBLE)
|
|
|
|
exec "${SCRIPTS:-/}start-deployCrucible" "$@"
|
|
|
|
;;
|
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
*)
|
2023-07-06 14:11:12 +00:00
|
|
|
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"
|
2018-07-31 02:49:43 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|