Skip to content

Commit

Permalink
misc: replaced use of jq and main download with mc-image-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg committed Nov 23, 2021
1 parent 373d81b commit 8e094db
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 71 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ RUN apt-get update \
sudo \
net-tools \
curl \
jq \
tzdata \
nano \
unzip \
Expand Down Expand Up @@ -42,7 +41,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
COPY rcon-config.yml /templates/rcon-config.yml
COPY rcon-velocity-config.toml /templates/rcon-velocity-config.toml

ARG MC_HELPER_VERSION=1.9.10
ARG MC_HELPER_VERSION=1.9.13
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
| tar -C /usr/share -zxf - \
Expand Down
48 changes: 24 additions & 24 deletions docs/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
connection_throttle: 4000
prevent_proxy_connections: false
remote_ping_timeout: 5000
groups:
md_5:
- admin
servers:
lobby:
address: mc:25565
restricted: false
motd: '${CFG_MOTD}'
remote_ping_cache: -1
connection_throttle_limit: 3
online_mode: true
ip_forward: false
forge_support: false
player_limit: -1
disabled_commands:
- disabledcommandhere
log_pings: true
log_commands: false
stats: 19659f49-ed6b-47e3-8b81-63bd14ade63a
server_connect_timeout: 5000
listeners:
- motd: '${CFG_MOTD}'
- motd: ${CFG_MOTD}
priorities:
- lobby
host: 0.0.0.0:25577
Expand All @@ -36,6 +15,7 @@ listeners:
query_enabled: false
query_port: 25577
proxy_protocol: false
remote_ping_cache: -1
network_compression_threshold: 256
permissions:
default:
Expand All @@ -46,5 +26,25 @@ permissions:
- bungeecord.command.end
- bungeecord.command.ip
- bungeecord.command.reload
log_pings: true
connection_throttle_limit: 3
prevent_proxy_connections: false
timeout: 30000
server_connect_timeout: 5000
player_limit: -1
ip_forward: false
groups:
md_5:
- admin
remote_ping_timeout: 5000
connection_throttle: 4000
log_commands: false
stats: 19659f49-ed6b-47e3-8b81-63bd14ade63a
online_mode: true
forge_support: false
disabled_commands:
- disabledcommandhere
servers:
lobby:
address: mc:25565
restricted: false
motd: ${CFG_MOTD}
22 changes: 22 additions & 0 deletions docs/docker-compose-velocity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.5'

services:
mc:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
ONLINE_MODE: "FALSE"
proxy:
image: itzg/bungeecord
environment:
TYPE: VELOCITY
DEBUG: "false"
ENABLE_RCON: "true"
ports:
- "25565:25577"
volumes:
- ./config.yml:/config/config.yml
- proxy:/server

volumes:
proxy: {}
3 changes: 2 additions & 1 deletion docs/docker-compose-waterfall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ services:
image: itzg/bungeecord
environment:
TYPE: WATERFALL
DEBUG: "false"
ports:
- 25565:25577
volumes:
- ./config.yml:/server/config.yml
- ./config.yml:/config/config.yml
71 changes: 27 additions & 44 deletions run-bungeecord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ function log() {
echo "[init] $*"
}

function get() {
local flags=()
if isTrue "${DEBUG_GET:-false}"; then
flags+=("--debug")
fi
mc-image-helper "${flags[@]}" get "$@"
}

function containsJars() {
file=${1?}

Expand Down Expand Up @@ -161,26 +169,22 @@ case "${TYPE^^}" in

# Retrieve waterfall version
if [[ ${WATERFALL_VERSION^^} = LATEST ]]; then
WATERFALL_VERSION=$(curl -fsSL "https://papermc.io/api/v2/projects/waterfall" -H "accept: application/json" | jq -r '.versions[-1]')
if [ -z "$WATERFALL_VERSION" ]; then
if ! WATERFALL_VERSION=$(get --json-path=".versions[-1]" "https://papermc.io/api/v2/projects/waterfall"); then
echo "ERROR: failed to lookup PaperMC versions"
exit 1
fi
fi

# Retrieve waterfall build
if [[ ${WATERFALL_BUILD_ID^^} = LATEST ]]; then
WATERFALL_BUILD_ID=$(curl -fsSL "https://papermc.io/api/v2/projects/waterfall/versions/${WATERFALL_VERSION}" -H "accept: application/json" \
| jq '.builds[-1]')
if [ -z $WATERFALL_BUILD_ID ]; then
if ! WATERFALL_BUILD_ID=$(get --json-path=".builds[-1]" "https://papermc.io/api/v2/projects/waterfall/versions/${WATERFALL_VERSION}"); then
echo "ERROR: failed to lookup PaperMC build from version ${WATERFALL_VERSION}"
exit 1
fi
fi

WATERFALL_JAR=$(curl -fsSL "https://papermc.io/api/v2/projects/waterfall/versions/${WATERFALL_VERSION}/builds/${WATERFALL_BUILD_ID}" \
-H "accept: application/json" | jq -r '.downloads.application.name')
if [ -z $WATERFALL_JAR ]; then

if ! WATERFALL_JAR=$(get --json-path=".downloads.application.name" "https://papermc.io/api/v2/projects/waterfall/versions/${WATERFALL_VERSION}/builds/${WATERFALL_BUILD_ID}"); then
echo "ERROR: failed to lookup PaperMC download file from version=${WATERFALL_VERSION} build=${WATERFALL_BUILD_ID}"
exit 1
fi
Expand Down Expand Up @@ -216,11 +220,8 @@ case "${TYPE^^}" in
esac

if isTrue "$download_required"; then
if [ -f "$BUNGEE_JAR" ]; then
zarg=(-z "$BUNGEE_JAR")
fi
log "Downloading ${BUNGEE_JAR_URL}"
if ! curl -o "$BUNGEE_JAR" "${zarg[@]}" -fsSL "$BUNGEE_JAR_URL"; then
if ! get -o "$BUNGEE_JAR" --skip-up-to-date --log-progress-each "$BUNGEE_JAR_URL"; then
echo "ERROR: failed to download" >&2
exit 2
fi
Expand All @@ -233,31 +234,15 @@ fi

# If supplied with a URL for a plugin download it.
if [[ "$PLUGINS" ]]; then
for i in ${PLUGINS//,/ }
do
EFFECTIVE_PLUGIN_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i)
case "X$EFFECTIVE_PLUGIN_URL" in
X[Hh][Tt][Tt][Pp]*.jar)
log "Downloading plugin via HTTP"
log " from $EFFECTIVE_PLUGIN_URL ..."
if ! curl -sSL -o /tmp/${EFFECTIVE_PLUGIN_URL##*/} $EFFECTIVE_PLUGIN_URL; then
echo "ERROR: failed to download from $EFFECTIVE_PLUGIN_URL to /tmp/${EFFECTIVE_PLUGIN_URL##*/}"
exit 2
fi

mkdir -p $BUNGEE_HOME/plugins
mv /tmp/${EFFECTIVE_PLUGIN_URL##*/} "$BUNGEE_HOME/plugins/${EFFECTIVE_PLUGIN_URL##*/}"
rm -f /tmp/${EFFECTIVE_PLUGIN_URL##*/}
;;
*)
echo "ERROR: Invalid URL given for plugin list: Must be HTTP or HTTPS and a JAR file"
;;
esac
done
mkdir -p "$BUNGEE_HOME/plugins"
if ! get --skip-existing -o "$BUNGEE_HOME/plugins" "$PLUGINS"; then
echo "ERROR: failed to download plugin(s)"
exit 1
fi
fi

if [[ ${SPIGET_PLUGINS} ]]; then
if isTrue ${REMOVE_OLD_PLUGINS:-false}; then
if isTrue "${REMOVE_OLD_PLUGINS:-false}"; then
removeOldMods $BUNGEE_HOME/plugins
REMOVE_OLD_PLUGINS=false
fi
Expand All @@ -271,21 +256,19 @@ fi

# Download rcon plugin
if [ "${TYPE^^}" = "VELOCITY" ]; then # Download UnioDex/VelocityRcon plugin
if isTrue "${ENABLE_RCON}" && [[ ! -e $BUNGEE_HOME/plugins/${RCON_VELOCITY_JAR_URL##*/} ]]; then
if isTrue "${ENABLE_RCON}"; then
log "Downloading Velocity rcon plugin"
mkdir -p $BUNGEE_HOME/plugins/velocityrcon

if ! curl -sSL -o "$BUNGEE_HOME/plugins/${RCON_VELOCITY_JAR_URL##*/}" $RCON_VELOCITY_JAR_URL; then
echo "ERROR: failed to download from $RCON_VELOCITY_JAR_URL to /tmp/${RCON_VELOCITY_JAR_URL##*/}"
exit 2
mkdir -p "$BUNGEE_HOME/plugins"
if ! get -o "$BUNGEE_HOME/plugins" --skip-up-to-date --log-progress-each "$RCON_VELOCITY_JAR_URL"; then
echo "ERROR: failed to download from $RCON_VELOCITY_JAR_URL"
exit 1
fi

log "Copy Velocity rcon configuration"
sed -i 's#${PORT}#'"$RCON_PORT"'#g' /templates/rcon-velocity-config.toml
sed -i 's#${PASSWORD}#'"$RCON_PASSWORD"'#g' /templates/rcon-velocity-config.toml

mv /templates/rcon-velocity-config.toml "$BUNGEE_HOME/plugins/velocityrcon/rcon.toml"
rm -f /templates/rcon-velocity-config.toml
mkdir -p $BUNGEE_HOME/plugins/velocityrcon
sed -e 's#${PORT}#'"$RCON_PORT"'#g' -e 's#${PASSWORD}#'"$RCON_PASSWORD"'#g' \
/templates/rcon-velocity-config.toml > "$BUNGEE_HOME/plugins/velocityrcon/rcon.toml"
fi
else # Download orblazer/bungee-rcon plugin
if isTrue "${ENABLE_RCON}" && [[ ! -e $BUNGEE_HOME/plugins/${RCON_JAR_URL##*/} ]]; then
Expand Down

0 comments on commit 8e094db

Please sign in to comment.