diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1ec72b..b23d086 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,6 @@ on: jobs: build: - if: github.repository_owner == 'itzg' runs-on: ubuntu-20.04 strategy: matrix: @@ -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 }} diff --git a/Dockerfile b/Dockerfile index a1c7970..0df240b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index f543f0e..b7c559c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/run-bungeecord.sh b/run-bungeecord.sh index dbc5c4c..70909e6 100755 --- a/run-bungeecord.sh +++ b/run-bungeecord.sh @@ -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}" @@ -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,,} @@ -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?} @@ -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 } @@ -191,6 +255,10 @@ function getFromPaperMc() { handleDebugMode +if [[ ${GENERIC_PACKS} ]]; then + genericPacks +fi + log "Resolving type given ${TYPE}" case "${TYPE^^}" in BUNGEECORD)