Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:

jobs:
build:
if: github.repository_owner == 'itzg'
runs-on: ubuntu-20.04
strategy:
matrix:
Expand All @@ -37,7 +36,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
itzg/bungeecord
${{ secrets.DOCKER_USER }}/bungeecord
tags: |
type=ref,event=branch,prefix=${{ matrix.tagPrefix }}
type=ref,event=tag,prefix=${{ matrix.tagPrefix }}
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ RUN apt-get update \
tzdata \
nano \
unzip \
ttf-dejavu \
&& apt-get clean
&& apt-get clean

RUN addgroup --gid 1000 bungeecord \
&& adduser --system --shell /bin/false --uid 1000 --ingroup bungeecord --home /server bungeecord
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ Unless you're on a home/private LAN, you should [enable TLS access](https://docs

[BungeeCord Configuration Guide](https://www.spigotmc.org/wiki/bungeecord-configuration-guide/)

### Generic pack files

To install all the server content (jars, mods, plugins, configs, etc.) from a zip or tgz file, then set `GENERIC_PACK` to the container path or URL of the archive file.

If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of archive file paths and/or URLs to files.

To avoid repetition, each entry will be prefixed by the value of `GENERIC_PACKS_PREFIX` and suffixed by the value of `GENERIC_PACKS_SUFFIX`, both of which are optional. For example, the following variables

```
GENERIC_PACKS=configs-v9.0.1,mods-v4.3.6
GENERIC_PACKS_PREFIX=https://cdn.example.org/
GENERIC_PACKS_SUFFIX=.zip
```

would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.org/mods-v4.3.6.zip`.

### Replacing variables inside configs

Sometimes you have mods or plugins that require configuration information that is only available at runtime.
Expand Down
70 changes: 69 additions & 1 deletion run-bungeecord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
: "${INIT_MEMORY:=${MEMORY}}"
: "${MAX_MEMORY:=${MEMORY}}"
: "${SYNC_SKIP_NEWER_IN_DESTINATION:=true}"
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
: "${GENERIC_PACKS_PREFIX:=}"
: "${GENERIC_PACKS_SUFFIX:=}"
: "${REPLACE_ENV_DURING_SYNC:=true}"
: "${REPLACE_ENV_VARIABLES:=false}"
: "${REPLACE_ENV_SUFFIXES:=yml,yaml,txt,cfg,conf,properties,hjson,json,tml,toml}"
Expand All @@ -21,6 +24,8 @@ RCON_JAR_URL=https://github.com/orblazer/bungee-rcon/releases/download/v${RCON_J
RCON_VELOCITY_JAR_URL=https://github.com/UnioDex/VelocityRcon/releases/download/v${RCON_VELOCITY_JAR_VERSION}/VelocityRcon.jar
download_required=true

set -eo pipefail

function isTrue() {
local value=${1,,}

Expand Down Expand Up @@ -79,6 +84,65 @@ function containsJars() {
return 1
}

function isURL() {
local value=$1

if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" || ${value:0:6} == "ftp://" ]]; then
return 0
else
return 1
fi
}

function genericPacks() {
IFS=',' read -ra packs <<< "${GENERIC_PACKS}"

packFiles=()
for packEntry in "${packs[@]}"; do
pack="${GENERIC_PACKS_PREFIX}${packEntry}${GENERIC_PACKS_SUFFIX}"
if isURL "${pack}"; then
mkdir -p "${BUNGEE_HOME}/packs"
log "Downloading generic pack from $pack"
if ! outfile=$(mc-image-helper -o "${BUNGEE_HOME}/packs" --output-filename --skip-up-to-date "$pack"); then
log "ERROR: failed to download $pack"
exit 2
fi
packFiles+=("$outfile")
else
packFiles+=("$pack")
fi
done

log "Applying generic pack(s)..."
original_base_dir="${BUNGEE_HOME}/.tmp/generic_pack_base"
base_dir=$original_base_dir
rm -rf "${base_dir}"
mkdir -p "${base_dir}"
for pack in "${packFiles[@]}"; do
unzip -o -q -d "${base_dir}" "${pack}"
done

if [ -f "${BUNGEE_HOME}/manifest.txt" ]; then
log "Manifest exists from older generic pack, cleaning up ..."
while read -r f; do
rm -rf "${BUNGEE_HOME}/${f}"
done < "${BUNGEE_HOME}/packs/manifest.txt"
find "${BUNGEE_HOME}" -mindepth 1 -depth -type d -empty -delete
rm -f "${BUNGEE_HOME}/manifest.txt"
fi

log "Writing generic pack manifest ... "
find "${base_dir}" -type f -printf "%P\n" > "${BUNGEE_HOME}/manifest.txt"

log "Applying generic pack ..."
cp -R -f "${base_dir}"/* "${BUNGEE_HOME}"
rm -rf $original_base_dir

if [ $UID == 0 ]; then
chown -R bungeecord:bungeecord "${BUNGEE_HOME}"
fi
}

function getResourceFromSpiget() {
resource=${1?}
dest=${2?}
Expand Down Expand Up @@ -145,7 +209,7 @@ function processConfigs {
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
--replace-env-prefix="${REPLACE_ENV_VARIABLE_PREFIX}" \
/server
"${BUNGEE_HOME}"

fi
}
Expand Down Expand Up @@ -191,6 +255,10 @@ function getFromPaperMc() {

handleDebugMode

if [[ ${GENERIC_PACKS} ]]; then
genericPacks
fi

log "Resolving type given ${TYPE}"
case "${TYPE^^}" in
BUNGEECORD)
Expand Down